org.duracloud.duraservice.mgmt
Class ServiceManager

java.lang.Object
  extended by org.duracloud.duraservice.mgmt.ServiceManager
All Implemented Interfaces:
Securable, LocalServicesManager, ServicesManager

public class ServiceManager
extends Object
implements LocalServicesManager

Performs management functions over services.

Author:
Bill Branan

Field Summary
protected static String NEW_HOST_DISPLAY
           
static String NEW_SERVICE_HOST
           
protected static String PRIMARY_HOST_DISPLAY
           
 
Constructor Summary
ServiceManager(ContentStoreManagerUtil contentStoreManagerUtil, ServiceConfigUtil serviceConfigUtil, ServiceComputeInstanceUtil serviceComputeInstanceUtil)
           
 
Method Summary
 void clearCache()
           
 void configure(InputStream configXml)
          Initializes the service manager with the provided XML document so that the service manager is able to connect to all services service compute instances, and user storage.
 String createServiceInstance(String displayName)
          Starts up a new services compute instance.
 int deployService(int serviceId, String serviceHost, String userConfigVersion, List<UserConfigModeSet> userConfigModeSets)
          Attempts to deploy the service with the given ID the the server at the given host.
 List<ServiceInfo> getAvailableServices()
          Retrieves a listing of services which are available for deployment along with the description and user configuration for each service
 ServiceInfo getDeployedService(int serviceId, int deploymentId)
          Gets a service which has been deployed.
 Map<String,String> getDeployedServiceProps(int serviceId, int deploymentId)
          Gets the properties of a service which has been deployed.
 List<ServiceInfo> getDeployedServices()
          Retrieves a listing of services which have been deployed.
 ServiceInfo getService(int serviceId)
          Gets a service.
protected  void initialize()
           
 boolean isConfigured()
          Determines if the service manager has been configured
 void lockServiceComputeInstance(String instanceHost)
          Locks a service compute instance, meaning that no further services should be deployed on this instance until the lock is removed.
 void login(Credential credential)
          This method supplies user credentials to the application.
 void logout()
          This method clears any previously logged-in credentials.
 void undeployAllServices()
          Undeploys all of the deployed services.
 void undeployService(int serviceId, int deploymentId)
          Stops and un-deploys a service
 void unlockServiceComputeInstance(String instanceHost)
          Unlocks a services compute instance, indicating that the instance is available for further service deployments.
 void updateServiceConfig(int serviceId, int deploymentId, String userConfigVersion, List<UserConfigModeSet> userConfigModeSets)
          Updates the configuration of a service which has already been deployed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIMARY_HOST_DISPLAY

protected static final String PRIMARY_HOST_DISPLAY
See Also:
Constant Field Values

NEW_HOST_DISPLAY

protected static final String NEW_HOST_DISPLAY
See Also:
Constant Field Values

NEW_SERVICE_HOST

public static final String NEW_SERVICE_HOST
See Also:
Constant Field Values
Constructor Detail

ServiceManager

public ServiceManager(ContentStoreManagerUtil contentStoreManagerUtil,
                      ServiceConfigUtil serviceConfigUtil,
                      ServiceComputeInstanceUtil serviceComputeInstanceUtil)
Method Detail

configure

public void configure(InputStream configXml)
Initializes the service manager with the provided XML document so that the service manager is able to connect to all services service compute instances, and user storage.

Specified by:
configure in interface LocalServicesManager
Parameters:
configXml - the xml used to initialize the service manager

isConfigured

public boolean isConfigured()
Description copied from interface: LocalServicesManager
Determines if the service manager has been configured

Specified by:
isConfigured in interface LocalServicesManager

initialize

protected void initialize()

getAvailableServices

public List<ServiceInfo> getAvailableServices()
Retrieves a listing of services which are available for deployment along with the description and user configuration for each service

Specified by:
getAvailableServices in interface ServicesManager
Returns:
list of available services

getDeployedServices

public List<ServiceInfo> getDeployedServices()
Retrieves a listing of services which have been deployed. Each service includes the full set of userconfig options as well as the selected options currently in use in order to allow for reconfiguring the service.

Specified by:
getDeployedServices in interface ServicesManager
Returns:
list of deployed services

clearCache

public void clearCache()

deployService

public int deployService(int serviceId,
                         String serviceHost,
                         String userConfigVersion,
                         List<UserConfigModeSet> userConfigModeSets)
                  throws NoSuchServiceException,
                         NoSuchServiceComputeInstanceException
Attempts to deploy the service with the given ID the the server at the given host. The service is configured based on the provided user configuration as well as a set of system configuration values.

Specified by:
deployService in interface ServicesManager
Parameters:
serviceId - the ID of the service to be deployed
serviceHost - the server host on which the service is to be deployed
userConfigVersion - version of the user configuration
userConfigModeSets - user configuration settings for the service
Returns:
the deployment ID of the newly deployed service
Throws:
NoSuchServiceException - if there is no service with ID = serviceId
NoSuchServiceComputeInstanceException - if there is no services compute instance at serviceHost

getDeployedService

public ServiceInfo getDeployedService(int serviceId,
                                      int deploymentId)
                               throws NoSuchDeployedServiceException
Gets a service which has been deployed. This provides the full set of userconfig options as well as the selected options currently in use a particular deployment.

Specified by:
getDeployedService in interface ServicesManager
Parameters:
serviceId - the ID of the service to retrieve
deploymentId - the ID of the service deployment to retrieve
Returns:
the service with a single deployment
Throws:
NoSuchDeployedServiceException - if either service or deployment does not exist

getDeployedServiceProps

public Map<String,String> getDeployedServiceProps(int serviceId,
                                                  int deploymentId)
                                           throws NoSuchDeployedServiceException
Gets the properties of a service which has been deployed.

Specified by:
getDeployedServiceProps in interface ServicesManager
Parameters:
serviceId - the ID of the service to retrieve
deploymentId - the ID of the service deployment to retrieve
Returns:
the properties of the service
Throws:
NoSuchDeployedServiceException - if either service or deployment does not exist

updateServiceConfig

public void updateServiceConfig(int serviceId,
                                int deploymentId,
                                String userConfigVersion,
                                List<UserConfigModeSet> userConfigModeSets)
                         throws NoSuchDeployedServiceException
Updates the configuration of a service which has already been deployed

Specified by:
updateServiceConfig in interface ServicesManager
Parameters:
serviceId - the ID of the service to update
deploymentId - the ID of the service deployment to update
userConfigVersion - version of the user configuration
userConfigModeSets - the updated user configuration for this service deployment
Throws:
NoSuchDeployedServiceException - if either service or deployment does not exist

getService

public ServiceInfo getService(int serviceId)
                       throws NoSuchServiceException
Gets a service. Includes user configuration options, description, etc. as well as all deployments of the service. Does not guarantee that the service is available for deployment.

Specified by:
getService in interface ServicesManager
Parameters:
serviceId - the ID of the service to be retrieved
Returns:
a service
Throws:
NoSuchServiceException - if the service does not exist

undeployAllServices

public void undeployAllServices()
Undeploys all of the deployed services.


login

public void login(Credential credential)
Description copied from interface: Securable
This method supplies user credentials to the application.

Specified by:
login in interface Securable
Parameters:
credential - of user

logout

public void logout()
Description copied from interface: Securable
This method clears any previously logged-in credentials.

Specified by:
logout in interface Securable

undeployService

public void undeployService(int serviceId,
                            int deploymentId)
                     throws NoSuchDeployedServiceException
Stops and un-deploys a service

Specified by:
undeployService in interface ServicesManager
Parameters:
serviceId - the ID of the service to undeploy
deploymentId - the ID of the service deployment to undeploy
Throws:
NoSuchDeployedServiceException - if either service or deployment does not exist

lockServiceComputeInstance

public void lockServiceComputeInstance(String instanceHost)
                                throws NoSuchServiceComputeInstanceException
Locks a service compute instance, meaning that no further services should be deployed on this instance until the lock is removed.

Parameters:
instanceHost - the host name of the compute instance to lock
Throws:
NoSuchServiceComputeInstanceException - if no such compute instance exists

unlockServiceComputeInstance

public void unlockServiceComputeInstance(String instanceHost)
                                  throws NoSuchServiceComputeInstanceException
Unlocks a services compute instance, indicating that the instance is available for further service deployments.

Parameters:
instanceHost - the host name of the compute instance to unlock
Throws:
NoSuchServiceComputeInstanceException - if no such compute instance exists

createServiceInstance

public String createServiceInstance(String displayName)
Starts up a new services compute instance.

Parameters:
displayName - the name to display to indicate the new instance
Returns:
the hostName of the new instance


Copyright © 2009-2012 DuraSpace. All Rights Reserved.