|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gcube.common.core.contexts.GCUBEContext
org.gcube.common.core.contexts.GHNContext
public class GHNContext
A specialisation of GCUBEContext for gCube Hosting Nodes (gHNs).
(*) it manages the lifetime of the gHN, from its initialisation to its shutdown and failure.
This functionality supports the internal operation of the gHN and remains transparent to most service developers.
(*) it exposes the configuration of the gHN and its hosting environment.
This functionality allows service developers to inspect at runtime the environment in which their code is deployed.
(*) it mediates between RIs of deployed services.
This functionality supports dynamic discovery of RIs and, while it is generically available to all service developers,
it is key for the correct operation of the gHN and distinguished Local Services.
Clients can obtain the single instance of the GHNContext by invoking its static method getContext().
The first invocation of the method triggers the initialisation of the instance.
| Nested Class Summary | |
|---|---|
static class |
GHNContext.Mode
GHN modes |
static class |
GHNContext.Status
Enumerates the possible statuses of the GHN. |
static class |
GHNContext.Type
GHN types |
| Field Summary | |
|---|---|
static String |
ALLOWEDSCOPES_JNDI_NAME
Name of allowedScopes Name JNDI environment. |
static String |
CONFIGDIR_NAME
Configuration directory name. |
static String |
CONTAINER_STATUS_JNDI_NAME
Container status system property. |
static String |
COORDINATES_JNDI_NAME
Name of Coordinates JNDI environment. |
static String |
COUNTRY_JNDI_NAME
Name of Country JNDI environment. |
static String |
CUSTOMLABELS_JNDI_NAME
Name of Custom Labels JNDI environment. |
static int |
DEFAULT_TEST_INTERVAL
Default test interval in seconds |
static long |
DEFAULT_TRUSTEDGHNINTERVAL
Name of the interval for trusted gHNs synchronization |
static long |
DEFAULT_UPDATE_INTERVAL
Default update interval in seconds. |
static String |
GCF_VERSION
current gcf version |
static String |
GHN_CLIENT_JNDI_RESOURCE
The classpath resource which contains the configuration of the GHN for client use. |
static String |
GHN_JNDI_RESOURCE
The classpath resource which contains the configuration of the GHN. |
static String |
GHN_TYPE
Name of GHNType JNDI environment. |
static short |
GHN_UPDATE_ATTEMPTS
Number of attempts for GHN updates. |
protected static Properties |
implementations
Properties set with implementations of the interfaces |
static String |
IMPLEMENTATIONS_RESOURCE
The classpath resource which contains the current implementations of gCF interfaces. |
static String |
INFRASTRUCTURE_NAME
Name of Coordinates JNDI environment. |
static String |
JNDI_SERVICES_BASE_NAME
Name of the jndi root for service configurations. |
static String |
LOCATION_JNDI_NAME
Name of Location JNDI environment. |
static String |
MBEANS_PREFIX
Prefix for mbeans. |
static String |
MODE_JNDI_NAME
Name of the Mode startup JNDI environment |
static String |
MSGBROKER
Name of the MSGBROKER on the ServiceMap. |
protected static GCUBEHostingNode |
node
The GCUBE Hosting Node resource associated with the context. |
static String |
OPEN_PORTS
Name of OpenPorts JNDI environment. |
static String |
OVERRIDE_SERVICE_SECURITY
Name of Override service Security JNDI environment. |
static String |
PROFILE_FILE_NAME
Name of the file in which the GHN is serialised. |
static String |
PUBLISHED_HOST_NAME
The name of the host to publish in the local profiles, if different from the container's one |
static String |
PUBLISHED_PORT_NAME
The name of the port to publish in the local profiles, if different from the container's one |
static String |
SECURITY_JNDI_NAME
Name of Security JNDI environment. |
static int |
SHUTDOWN_DELAY
Delay before gHN shutdown |
protected static GHNContext |
singleton
Singleton context. |
static String |
STARTSCOPES_JNDI_NAME
Name of startScopes Name JNDI environment. |
static String |
STORAGE_ROOT
The absolute path to the storage root on the local file system. |
static String |
TESTINTERVAL_JNDI_NAME
Name of the test interval JNDI environment. |
static String |
TRUSTEDGHNINTERVAL_JNDI_NAME
Name of the interval for trusted gHNs synchronization |
static String |
UPDATEINTERVAL_JNDI_NAME
Name of the update interval JNDI environment. |
| Fields inherited from class org.gcube.common.core.contexts.GCUBEContext |
|---|
logger, timers |
| Constructor Summary | |
|---|---|
protected |
GHNContext()
Creates an instance |
| Method Summary | ||
|---|---|---|
Set<GCUBEScope> |
addScope(GCUBEScope... scopes)
Adds one or more scopes to the GHN. |
|
protected void |
configureGHN(File file)
Used internally to load external configuration. |
|
protected void |
configureGHNResource()
Used internally to configure the GCUBEHostingNode resource that models the local gHN. |
|
void |
delegateCredentials(GCUBEServiceContext context,
GSSCredential credentials)
Delegates credentials to a service. |
|
GCUBEScope[] |
getAllowedScopes()
Returns the allowed scopes of the GHN. |
|
String |
getBaseURL()
Returns the base endpoint of the gHN. |
|
String |
getBaseURLToPublish()
Returns the base endpoint of the gHN. |
|
static GHNContext |
getContext()
Returns a context instance. |
|
ArrayList<HashMap<String,String>> |
getCPUInfo()
Returns information about the processors underlying of the gHN. |
|
List<String> |
getDeployedPortTypes()
Returns the names of the port-types of the gCube services deployed in the GHN. |
|
File |
getFile(String fileName,
boolean... writeMode)
Gives read or write access to a File. |
|
Integer |
getFreePort()
Returns the number of the first free port on the gHN in the range specified in the GHN configuration ( openPorts) or, if no such range exist,
in the range 60000-65000; |
|
long |
getFreeSpace(String localFS)
Returns the amount of free space on a partition of the underlying file system. |
|
GCUBEHostingNode |
getGHN()
Sets the GCUBE Hosting Node resource associated with the context. |
|
String |
getGHNID()
Returns the GHN identifier. |
|
String |
getHostDomain()
Returns the host domain of the gHN. |
|
String |
getHostname()
Returns the hostname of the gHN. |
|
String |
getHostnameAndPort()
Returns the hostname and port of the gHN. |
|
static
|
getImplementation(Class<INTERFACE> interfaceClass)
Returns an implementation for a gCF interface. |
|
String |
getIP()
Returns the IP address. |
|
Map<String,Double> |
getLoadStatistics()
Returns load statistics for the gHN. |
|
LocalInstanceContext |
getLocalInstanceContext()
|
|
String |
getLocation()
Returns the installation folder of the gHN. |
|
GHN |
getManagementBean()
Return the management bean of the GHN. |
|
Map<String,Long> |
getMemoryUsage()
Returns virtual memory statistics. |
|
GHNContext.Mode |
getMode()
Gets the GHN mode. |
|
int |
getPort()
Returns the port of the gHN. |
|
String |
getPublishedHostDomain()
Returns the host domain of the gHN. |
|
String |
getPublishedHostname()
Returns the hostname of the gHN. |
|
String |
getPublishedHostnameAndPort()
Returns the hostname and port of the gHN to publish. |
|
int |
getPublishedPort()
Returns the port of the gHN. |
|
InputStream |
getResource(String resourceName)
Returns a classpath resource given its path. |
|
GCUBEServiceContext |
getServiceContext(String serviceClass,
String serviceName)
Returns the context of a registered service from its class and name. |
|
Set<GCUBEServiceContext> |
getServiceContexts()
Returns all the registered service contexts (no matter about which status they have) |
|
String |
getServiceEndpointPrefix()
Returns the prefix to the relative endpoint of services. |
|
GCUBEScope[] |
getStartScopes()
Returns the start scopes of the GHN. |
|
GHNContext.Status |
getStatus()
Returns the current status of the GHN. |
|
String |
getStatusMessage()
Returns the message associated to the current status of the GHN. |
|
String |
getStorageRoot()
Returns the absolute path to the storage root folder on local the file system. |
|
long |
getTrustedGHNSynchInterval()
Returns the synchronization interval for the local list of trusted gHNs |
|
GHNContext.Type |
getType()
Returns the GHN type. |
|
String |
getUptime()
Returns the length of time since the underlying machine. |
|
String |
getVirtualPlatformsLocation()
Returns the virtual platforms folder of the gHN. |
|
protected void |
initialise()
Used internally to initialise the context at class loading time. |
|
boolean |
isClientMode()
Indicates whether the context is running within a container or else in client mode. |
|
boolean |
isGHNReady()
Checks if the GHN has completed the startup procedure. |
|
boolean |
isSecurityEnabled()
Indicates whether the GHN is operating in a secure infrastructure. |
|
boolean |
overrideServiceSecurity()
Indicates whether the GHN security status must override the security status of the services. |
|
void |
registerService(GCUBEServiceContext context)
Registers a service context in the current node. |
|
Set<GCUBEScope> |
removeScope(GCUBEScope... scopes)
Removes one or more scopes from the GHN. |
|
void |
restart(String... message)
Restarts the gHN. |
|
void |
restartAndClean(String... message)
|
|
void |
setMode(GHNContext.Mode mode)
Sets the GHN mode. |
|
void |
setStatus(GHNContext.Status newStatus,
String... message)
Sets the current status of the GHN. |
|
void |
shutdown(String... message)
Shuts down the gHN. |
|
void |
subscribeForCredential(CredentialConsumer consumer)
Subscribes a consumer to CredentialDelegationEvents. |
|
void |
subscribeForCredentialRequest(CredentialRequestConsumer consumer)
Subscribes a consumer to CredentialRequestEvents. |
|
void |
subscribeGHNEvents(GHNConsumer consumer,
Events.GHNTopic... topics)
Subscribes a consumer to one or more GHNTopics. |
|
void |
unsubscribeGHNEvents(GHNConsumer consumer,
Events.GHNTopic... topics)
Unsubscribe a consumer to one or more GHNTopics. |
|
| Methods inherited from class org.gcube.common.core.contexts.GCUBEContext |
|---|
debugContext, getJNDIContext, getName, getProperty, getTiming, printContext, resetTimer, setJNDIContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String GCF_VERSION
public static final String CUSTOMLABELS_JNDI_NAME
public static final String COORDINATES_JNDI_NAME
public static final String COUNTRY_JNDI_NAME
public static final String LOCATION_JNDI_NAME
public static final String SECURITY_JNDI_NAME
public static final String OVERRIDE_SERVICE_SECURITY
public static final String STARTSCOPES_JNDI_NAME
public static final String ALLOWEDSCOPES_JNDI_NAME
public static final String INFRASTRUCTURE_NAME
public static final String MODE_JNDI_NAME
public static final String PUBLISHED_HOST_NAME
public static final String PUBLISHED_PORT_NAME
public static final String GHN_TYPE
public static final String OPEN_PORTS
public static final String CONTAINER_STATUS_JNDI_NAME
public static final String CONFIGDIR_NAME
public static final String PROFILE_FILE_NAME
public static final String IMPLEMENTATIONS_RESOURCE
public static final String GHN_JNDI_RESOURCE
public static final String GHN_CLIENT_JNDI_RESOURCE
public static final short GHN_UPDATE_ATTEMPTS
public static final String UPDATEINTERVAL_JNDI_NAME
public static final long DEFAULT_UPDATE_INTERVAL
public static final String TRUSTEDGHNINTERVAL_JNDI_NAME
public static final long DEFAULT_TRUSTEDGHNINTERVAL
public static final int SHUTDOWN_DELAY
public static final String STORAGE_ROOT
public static final String MBEANS_PREFIX
public static final int DEFAULT_TEST_INTERVAL
public static final String TESTINTERVAL_JNDI_NAME
public static final String MSGBROKER
public static final String JNDI_SERVICES_BASE_NAME
protected static Properties implementations
protected static GHNContext singleton
protected static GCUBEHostingNode node
| Constructor Detail |
|---|
protected GHNContext()
| Method Detail |
|---|
public static GHNContext getContext()
protected void initialise()
throws Exception
Exception - if the context could not be initialised.public boolean isClientMode()
true if the context is running in client mode, false otherwise
protected void configureGHN(File file)
throws Exception
file - the configuration file.
Exception - if it could not load external configuration
protected void configureGHNResource()
throws Exception
GCUBEHostingNode resource that models the local gHN.
Exception - if the resource could not be configured
public void setStatus(GHNContext.Status newStatus,
String... message)
throws IllegalStateException
newStatus - the status.message - message associated to the status
IllegalStateException - if the transition from the current to the new status is illegal.public GHNContext.Status getStatus()
public String getStatusMessage()
public void restart(String... message)
public void restartAndClean(String... message)
public void shutdown(String... message)
public void registerService(GCUBEServiceContext context)
throws Exception
context - the context.
Exception - if the service is already registered or the registration could not be completed.
IllegalStateException - if the container is down.
public GCUBEServiceContext getServiceContext(String serviceClass,
String serviceName)
throws Exception
serviceClass - the service class.serviceName - the service name.
Exception - if the service is not registered.
IllegalStateException - if the gHN is down.
public Set<GCUBEServiceContext> getServiceContexts()
throws Exception
Exception - if there is no service registered.
IllegalStateException - if the gHN is down.
public void subscribeGHNEvents(GHNConsumer consumer,
Events.GHNTopic... topics)
throws Exception
GHNTopics.
consumer - the consumer.topics - the topics of interest.
Exception - if the subscription could not be completed.
public void unsubscribeGHNEvents(GHNConsumer consumer,
Events.GHNTopic... topics)
GHNTopics.
consumer - the consumer.topics - the topics.public boolean isSecurityEnabled()
true if its is, false otherwise.public boolean overrideServiceSecurity()
true if its is, false otherwise.
public void subscribeForCredentialRequest(CredentialRequestConsumer consumer)
throws Exception
CredentialRequestEvents.
consumer - the consumer.
Exception - if the subscription could not be completed.
public void subscribeForCredential(CredentialConsumer consumer)
throws Exception
CredentialDelegationEvents.
consumer - the consumer.
Exception - if the subscription could not be completed.
public void delegateCredentials(GCUBEServiceContext context,
GSSCredential credentials)
context - the service context.credentials - the credentials.
public Set<GCUBEScope> addScope(GCUBEScope... scopes)
throws GCUBEResource.InvalidScopeException
scopes - the scopes.
GCUBEResource.InvalidScopeExceptionpublic Set<GCUBEScope> removeScope(GCUBEScope... scopes)
public static <INTERFACE> INTERFACE getImplementation(Class<INTERFACE> interfaceClass)
throws Exception
implementations.property
found in the GHN's configuration folder.
INTERFACE - the interface.interfaceClass - the Class of the interface.
null if an implementation could not be found.
Exception - if the implementation is not compatible with the interface or could not be instantiated.
public File getFile(String fileName,
boolean... writeMode)
throws IllegalArgumentException
File.
Write access induces backups and read access relies on backups to recover from failures.
getFile in class GCUBEContextfileName - the file path.writeMode - (optional) the access mode, true for write access and false for read access (default).
IllegalArgumentException - if access is in write mode and the path is to a folder.public InputStream getResource(String resourceName)
getResource in class GCUBEContextnull if the path could not be resolved.public String getGHNID()
public boolean isGHNReady()
true if the GHN is started, false otherwise.public GHN getManagementBean()
public GCUBEHostingNode getGHN()
public GHNContext.Mode getMode()
public GHNContext.Type getType()
public void setMode(GHNContext.Mode mode)
mode - the new mode.
public Integer getFreePort()
throws RuntimeException,
Exception
openPorts) or, if no such range exist,
in the range 60000-65000;
Exception - if no free port could be found.
RuntimeException - if no free port-configuration was found.
public List<String> getDeployedPortTypes()
throws Exception,
IllegalStateException
Exception - if the names could not be returned.
IllegalStateException - if the query failspublic GCUBEScope[] getStartScopes()
public GCUBEScope[] getAllowedScopes()
public long getTrustedGHNSynchInterval()
public String getLocation()
public String getVirtualPlatformsLocation()
public String getBaseURL()
throws IOException
IOException - if the endpoint could not be identified.
public String getBaseURLToPublish()
throws IOException
IOException - if the endpoint could not be identified.public int getPublishedPort()
public int getPort()
public String getPublishedHostname()
IOException - if the hostname could not be returned.public LocalInstanceContext getLocalInstanceContext()
public String getHostname()
IOException - if the hostname could not be returned.public String getServiceEndpointPrefix()
public String getStorageRoot()
public long getFreeSpace(String localFS)
localFS - the partition name.
public String getUptime()
public Map<String,Long> getMemoryUsage()
public ArrayList<HashMap<String,String>> getCPUInfo()
public Map<String,Double> getLoadStatistics()
public String getIP()
public String getHostnameAndPort()
public String getPublishedHostnameAndPort()
public String getHostDomain()
throws IOException
IOException - if the host domain could not identified.
public String getPublishedHostDomain()
throws IOException
IOException - if the host domain could not identified.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||