com.bigdata.service.jini.master
Class ServiceMap

java.lang.Object
  extended by com.bigdata.service.jini.master.ServiceMap
All Implemented Interfaces:
Serializable

public class ServiceMap
extends Object
implements Serializable

An ordered mapping of indices in [0:N-1] onto the services on which the task with the corresponding index will be executed.

Version:
$Id$
Author:
Bryan Thompson
See Also:
Serialized Form
TODO:
Stable assignments across re-runs are only required if the client will be reading or writing data local to the host on which it is executing. Otherwise we are free to choose new assignments on restart or even to add more clients over time in an m/r model.

If the ServiceItem to client# assignment can change over time then we need to use a lock to make that change atomic with respect to requests for the client's proxy.


Field Summary
 int ntasks
          The #of tasks to be mapped over the services.
 UUID[] serviceUUIDs
          The mapping of tasks onto the IRemoteExecutors on which that task will execute.
 
Constructor Summary
ServiceMap(int ntasks)
           
 
Method Summary
 void assignClientsToServices(net.jini.core.lookup.ServiceItem[] serviceItems)
          Assigns clients to services.
 net.jini.core.lookup.ServiceItem getServiceItem(int clientNum)
          Return the ServiceItem of the service to which the Nth client was assigned.
 UUID getServiceUUID(int clientNum)
          Return the UUID of the service to which the Nth client was assigned.
 void resolveServiceUUIDs(JiniFederation fed)
          Populates the elements of the serviceItems array by resolving the serviceUUIDs to the corresponding ServiceItems.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ntasks

public final int ntasks
The #of tasks to be mapped over the services.


serviceUUIDs

public final UUID[] serviceUUIDs
The mapping of tasks onto the IRemoteExecutors on which that task will execute. The index is the task#. The value is the IRemoteExecutor service UUID.

Constructor Detail

ServiceMap

public ServiceMap(int ntasks)
Parameters:
ntasks - The #of tasks to be mapped over the services.
Method Detail

resolveServiceUUIDs

public void resolveServiceUUIDs(JiniFederation fed)
                         throws RemoteException,
                                InterruptedException
Populates the elements of the serviceItems array by resolving the serviceUUIDs to the corresponding ServiceItems. For each service, this tests the service cache for IClientServices and IDataServices and only then does a lookup with a timeout for the service.

Throws:
InterruptedException - If interrupted during service lookup.
RemoteException - If there is an RMI problem.

assignClientsToServices

public void assignClientsToServices(net.jini.core.lookup.ServiceItem[] serviceItems)
                             throws Exception
Assigns clients to services. The assignments are made in the given order MODULO the #of service items.

Parameters:
serviceItems - The ordered array of services to which each client will be assigned.
Throws:
Exception

getServiceUUID

public UUID getServiceUUID(int clientNum)
Return the UUID of the service to which the Nth client was assigned.

Parameters:
clientNum - The client number in [0:N-1].
Returns:
The UUID of the service on which that client should execute.

getServiceItem

public net.jini.core.lookup.ServiceItem getServiceItem(int clientNum)
Return the ServiceItem of the service to which the Nth client was assigned.

Parameters:
clientNum - The client number in [0:N-1].
Returns:
The ServiceItem of the service on which that client should execute.


Copyright © 2006-2011 SYSTAP, LLC. All Rights Reserved.