com.bigdata.jini.start
Class ManageLogicalServiceTask<V extends ServiceConfiguration>

java.lang.Object
  extended by com.bigdata.jini.start.ManageLogicalServiceTask<V>
All Implemented Interfaces:
Callable

public class ManageLogicalServiceTask<V extends ServiceConfiguration>
extends Object
implements Callable

Task makes adjusts an imbalance between the serviceCount and the #of logical services (creating or destroying a logical service) and then exits.

Version:
$Id$
Author:
Bryan Thompson
TODO:
If the task hangs then the ZLock must be broken so that another service can give it a go., No mechanism is currently defined to reduce the #of logical services and there are a variety of issues to be considered.

For example, if the target logical data service count is reduced below the actual #of logical data services then we need to identify a logical data service to shutdown (probably one that is lightly used) and shed all index partitions for that data service before it is shutdown, otherwise the data would be lost.

However, some kinds of services do not pose any such problem. For example, it should be trivial to reduce the #of jini registrars that are running or the #of ClassServers.

In order to destroy a logical service, first set the #of replicas to zero so that the physical instances will be destroyed (using the RemoteDestroyAdmin and any other APIs required to insure that the total system state is preserved). Then delete the logical service node.


Field Summary
protected  List<String> children
           
protected  V config
           
protected  String configZPath
           
protected static boolean DEBUG
           
protected  JiniFederation fed
           
protected static boolean INFO
           
protected  IServiceListener listener
           
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
ManageLogicalServiceTask(JiniFederation fed, IServiceListener listener, String configZPath, List<String> children, V config)
           
 
Method Summary
 Object call()
          Compare serviceCount to #of logical services.
protected  void destroyLogicalService()
          Destroy a logical service (must destroy the physical services first, which is complex for data services since index partitions must be shed).
protected  void newLogicalService()
          Create zpath for the new logical service, create its direct children (the BigdataZooDefs.PHYSICAL_SERVICES_CONTAINER and BigdataZooDefs.MASTER_ELECTION), and create the BigdataZooDefs.LOCKS_CREATE_PHYSICAL_SERVICE znode, whose data contains the zpath of the new logical service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log

INFO

protected static final boolean INFO

DEBUG

protected static final boolean DEBUG

fed

protected final JiniFederation fed

listener

protected final IServiceListener listener

configZPath

protected final String configZPath

children

protected final List<String> children

config

protected final V extends ServiceConfiguration config
Constructor Detail

ManageLogicalServiceTask

public ManageLogicalServiceTask(JiniFederation fed,
                                IServiceListener listener,
                                String configZPath,
                                List<String> children,
                                V config)
Parameters:
fed -
listener -
configZPath -
children -
config -
Method Detail

call

public Object call()
            throws Exception
Compare serviceCount to #of logical services. if too few, then create one (already holding a lock).

Specified by:
call in interface Callable
Throws:
Exception

newLogicalService

protected void newLogicalService()
                          throws org.apache.zookeeper.KeeperException,
                                 InterruptedException
Create zpath for the new logical service, create its direct children (the BigdataZooDefs.PHYSICAL_SERVICES_CONTAINER and BigdataZooDefs.MASTER_ELECTION), and create the BigdataZooDefs.LOCKS_CREATE_PHYSICAL_SERVICE znode, whose data contains the zpath of the new logical service.

The creation of the BigdataZooDefs.LOCKS_CREATE_PHYSICAL_SERVICE child trigger watchers looking for to contend for the right to create a physical service which is an instance of that logical service. All service managers contend for that lock. If the winner can satisify the constraints for that service type (including considering its recent service load, RAM, disk, etc), and is able to successfully create the service, then it destroys the lock node. Otherwise it releases the lock and sleeps a bit. Either it or the other service managers will give it a try. This will continue until the requirements change or the service is successfully created somewhere.

Note that this does not find the "best" host for the new service since there is no global consideration of host scores. However, the load balancer will adjust the load on the IDataServices which are the most heavily loaded part of the system.

Note: The ServicesManagerServer is responsible for watching the BigdataZooDefs.LOCKS_CREATE_PHYSICAL_SERVICE znode. It does that using a MonitorCreatePhysicalServiceLocksTask task.

Throws:
InterruptedException
org.apache.zookeeper.KeeperException
TODO:
To be robust and handle client disconnects within this method we should inspect the hierarchy on a client reconnect for partially created logical services, and create all the znodes each time through ignoring errors if they already exit.

destroyLogicalService

protected void destroyLogicalService()
Destroy a logical service (must destroy the physical services first, which is complex for data services since index partitions must be shed). FIXME destroyLogicalService() not implemented yet.



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