com.sun.faban.harness.services
Class ServiceContext

java.lang.Object
  extended by com.sun.faban.harness.services.ServiceContext
All Implemented Interfaces:
Serializable

public class ServiceContext
extends Object
implements Serializable

This class provides the context for every service. Each service has only one context.

Author:
Sheetal Patil
See Also:
Serialized Form

Field Summary
 ServiceDescription desc
          The service description describing this context.
 
Method Summary
 Object getAttribute(String key)
          Obtains the attribute of a given key.
 List<NameValuePair<Integer>> getHostPorts()
          Obtains a list of host:ports as configured in the configuration file to be used by the role this service is associated.
 String getHostRole()
          Obtains host role.
 String[] getHosts()
          Obtains the list of hosts as configured in the configuration file for the role this service is associated.
 String getName()
          Obtains the name (aka id) of the service.
 String getProperty(String key)
          Obtains the property for a given key.
 String getRunDuration()
          Obtains the run duration.
 List<NameValuePair<Integer>> getUniqueHostPorts()
          Obtains a list of hostports non-duplicate hosts:ports.
 String[] getUniqueHosts()
          Obtains a list of non-duplicate hosts.
 boolean isRestart()
          Check if service restart is enabled
 void setAttribute(String key, Object value)
          Sets an object attribute in the service context.
 void setProperty(String key, String value)
          Sets a property in the service context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

desc

public ServiceDescription desc
The service description describing this context.

Method Detail

getName

public String getName()
Obtains the name (aka id) of the service.

Returns:
The name of the service

getHosts

public String[] getHosts()
Obtains the list of hosts as configured in the configuration file for the role this service is associated.

Returns:
string array of hosts

getUniqueHosts

public String[] getUniqueHosts()
Obtains a list of non-duplicate hosts. If two or more host names refer to the same physical or virtual system (OS instance), only the first of such host names is returned as part of the list. This is used by services to avoid unwanted multiple starts of a service.

Returns:
The unique list of host names

getHostPorts

public List<NameValuePair<Integer>> getHostPorts()
Obtains a list of host:ports as configured in the configuration file to be used by the role this service is associated.

Returns:
List of host:ports

getUniqueHostPorts

public List<NameValuePair<Integer>> getUniqueHostPorts()
Obtains a list of hostports non-duplicate hosts:ports. If two or more host names with the same port refer to the same physical or virtual system (OS instance), only the first of such host:port pairs is returned as part of the list.

Returns:
Unique list of host:port pairs

isRestart

public boolean isRestart()
Check if service restart is enabled

Returns:
true if restart is enabled

getHostRole

public String getHostRole()
Obtains host role.

Returns:
host role

getProperty

public String getProperty(String key)
Obtains the property for a given key.

Parameters:
key - The property key
Returns:
The property value

setProperty

public void setProperty(String key,
                        String value)
Sets a property in the service context. This can then be accessed by tools through the tool context.

Parameters:
key - The property key
value - The property value

getAttribute

public Object getAttribute(String key)
Obtains the attribute of a given key.

Parameters:
key - They attribute key
Returns:
The attribute

setAttribute

public void setAttribute(String key,
                         Object value)
Sets an object attribute in the service context. This can then be accessed by tools through the tool context.

Parameters:
key - The attribute key
value - The attribute

getRunDuration

public String getRunDuration()
Obtains the run duration.

Returns:
duration of steady state as String