org.apache.oozie.service
Class Services

java.lang.Object
  extended by org.apache.oozie.service.Services

public class Services
extends Object

Services is a singleton that manages the lifecycle of all registered Services.

It has 2 built in services: XLogService and ConfigurationService.

The rest of the services are loaded from the CONF_SERVICE_CLASSES configuration property. The services class names must be separated by commas (spaces and enters are allowed).

The CONF_SYSTEM_MODE configuration property is any of NORMAL/SAFEMODE/NOWEBSERVICE.

Services are loaded and initialized in the order they are defined in the in configuration property.

After all services are initialized, if the Instrumentation service is present, all services that implement the Instrumentable are instrumented.

Services are destroyed in reverse order.

If services initialization fail, initialized services are immediatly destroyed.


Field Summary
static String CONF_DELETE_RUNTIME_DIR
           
static String CONF_SERVICE_CLASSES
           
static String CONF_SERVICE_EXT_CLASSES
           
static String CONF_SYSTEM_ID
           
static String CONF_SYSTEM_MODE
           
static String OOZIE_HOME_DIR
          Environment variable that indicates the location of the Oozie home directory.
 
Constructor Summary
Services()
          Create a services.
 
Method Summary
 void destroy()
          Destroy all services.
static Services get()
          Return the services singleton.
<T extends Service>
T
get(Class<T> serviceKlass)
          Return a service by its public interface.
 org.apache.hadoop.conf.Configuration getConf()
          Return the services configuration.
static String getOozieHome()
           
 String getRuntimeDir()
          Return the runtime directory of the Oozie instance.
 String getSystemId()
          Return the system ID, the value defined in the CONF_SYSTEM_ID configuration property.
 org.apache.oozie.client.OozieClient.SYSTEM_MODE getSystemMode()
          Return active system mode.
 void init()
          Initialize all services define in the CONF_SERVICE_CLASSES configuration property.
static void setOozieHome()
           
 void setService(Class<? extends Service> klass)
          Set a service programmatically.
 void setSystemMode(org.apache.oozie.client.OozieClient.SYSTEM_MODE sysMode)
          Set and set system mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OOZIE_HOME_DIR

public static final String OOZIE_HOME_DIR
Environment variable that indicates the location of the Oozie home directory. The Oozie home directory is used to pick up the conf/ directory from

See Also:
Constant Field Values

CONF_SYSTEM_ID

public static final String CONF_SYSTEM_ID
See Also:
Constant Field Values

CONF_SERVICE_CLASSES

public static final String CONF_SERVICE_CLASSES
See Also:
Constant Field Values

CONF_SERVICE_EXT_CLASSES

public static final String CONF_SERVICE_EXT_CLASSES
See Also:
Constant Field Values

CONF_SYSTEM_MODE

public static final String CONF_SYSTEM_MODE
See Also:
Constant Field Values

CONF_DELETE_RUNTIME_DIR

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

Services

public Services()
         throws ServiceException
Create a services.

The built in services are initialized.

Throws:
ServiceException - thrown if any of the built in services could not initialize.
Method Detail

setOozieHome

public static void setOozieHome()
                         throws ServiceException
Throws:
ServiceException

getOozieHome

public static String getOozieHome()
                           throws ServiceException
Throws:
ServiceException

getSystemMode

public org.apache.oozie.client.OozieClient.SYSTEM_MODE getSystemMode()
Return active system mode.

.

Returns:

getRuntimeDir

public String getRuntimeDir()
Return the runtime directory of the Oozie instance.

The directory is created under TMP and it is always a new directory per Services initialization.

Returns:
the runtime directory of the Oozie instance.

getSystemId

public String getSystemId()
Return the system ID, the value defined in the CONF_SYSTEM_ID configuration property.

Returns:
the system ID, the value defined in the CONF_SYSTEM_ID configuration property.

setSystemMode

public void setSystemMode(org.apache.oozie.client.OozieClient.SYSTEM_MODE sysMode)
Set and set system mode.

Parameters:
sysMode - system mode

getConf

public org.apache.hadoop.conf.Configuration getConf()
Return the services configuration.

Returns:
services configuraiton.

init

public void init()
          throws ServiceException
Initialize all services define in the CONF_SERVICE_CLASSES configuration property.

Throws:
ServiceException - thrown if any of the services could not initialize.

destroy

public void destroy()
Destroy all services.


get

public <T extends Service> T get(Class<T> serviceKlass)
Return a service by its public interface.

Parameters:
serviceKlass - service public interface.
Returns:
the associated service, or null if not define.

setService

public void setService(Class<? extends Service> klass)
                throws ServiceException
Set a service programmatically.

The service will be initialized by the services.

If a service is already defined with the same public interface it will be destroyed.

Parameters:
klass - service klass
Throws:
ServiceException - if the service could not be initialized, at this point all services have been destroyed.

get

public static Services get()
Return the services singleton.

Returns:
services singleton, null if not initialized.


Copyright © 2013 Apache Software Foundation. All Rights Reserved.