public class DistributedApplicationService extends ApplicationService
DelegatedResource
,
GeneratedTextResource
Modifier and Type | Field and Description |
---|---|
static String |
HAZELCAST_DEFAULT_INSTANCE_NAME
Hazelcast default instance name attribute for an
Application . |
static String |
HAZELCAST_DISTRIBUTED_GLOBALS_MAP_NAME
Hazelcast distributed globals name attribute for an
Application . |
static String |
HAZELCAST_DISTRIBUTED_SHARED_GLOBALS_MAP_NAME
Hazelcast shared distributed globals name attribute for an
Application . |
static String |
HAZELCAST_EXECUTOR_SERVICE_NAME
Hazelcast executor service name attribute for an
Application . |
static String |
HAZELCAST_MEMBER_TAGS_ATTRIBUTE
Tags attribute for a Hazelcast
Member . |
static String |
HAZELCAST_TASK_INSTANCE_ATTRIBUTE_NAME
Hazelcast task instance attribute name attribute for an
Application . |
Constructor and Description |
---|
DistributedApplicationService(Application application)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
<T> Object |
distributedCodeTask(String applicationName,
String code,
Object context,
Object where,
boolean multi)
Submits a task on the tasks cluster.
|
<T> Object |
distributedExecuteTask(String applicationName,
String documentName,
String entryPointName,
Object context,
Object where,
boolean multi)
Submits a task on the tasks cluster.
|
Object |
getDistributedGlobal(String name,
Object defaultValue)
Gets a value global to the Prudence cluster, atomically setting it to a
default value if it doesn't exist.
|
ConcurrentMap<String,Object> |
getDistributedGlobals()
A map of all values global to the Prudence cluster for this application.
|
Object |
getDistributedSharedGlobal(String name,
Object defaultValue)
Gets a value global to the Prudence cluster, atomically setting it to a
default value if it doesn't exist.
|
ConcurrentMap<String,Object> |
getDistributedSharedGlobals()
A map of all values global to the Prudence cluster.
|
com.hazelcast.core.ILock |
getDistributedSharedLock(String name)
Gets a cluster-wide lock.
|
com.hazelcast.core.HazelcastInstance |
getHazelcastDefaultInstance()
The Hazelcast default instance.
|
com.hazelcast.core.IExecutorService |
getHazelcastExecutorService()
The Hazelcast executor service.
|
com.hazelcast.core.HazelcastInstance |
getHazelcastTaskInstance()
The Hazelcast task instance.
|
codeTask, create, create, executeTask, getApplication, getComponent, getContainerRoot, getExecutor, getGlobal, getGlobals, getLock, getLocks, getLogger, getMediaTypeByExtension, getMediaTypeByName, getRoot, getScheduler, getSharedGlobal, getSharedGlobals, getSharedLock, getSharedLocks, getSubLogger, getTaskCollector
public static final String HAZELCAST_DEFAULT_INSTANCE_NAME
Application
.public static final String HAZELCAST_TASK_INSTANCE_ATTRIBUTE_NAME
Application
.public static final String HAZELCAST_DISTRIBUTED_GLOBALS_MAP_NAME
Application
.public static final String HAZELCAST_DISTRIBUTED_SHARED_GLOBALS_MAP_NAME
Application
.public static final String HAZELCAST_EXECUTOR_SERVICE_NAME
Application
.public static final String HAZELCAST_MEMBER_TAGS_ATTRIBUTE
Member
.public DistributedApplicationService(Application application)
application
- The applicationpublic com.hazelcast.core.HazelcastInstance getHazelcastDefaultInstance()
The name can be configured via the "com.threecrickets.prudence.hazelcast.defaultInstanceName" application context attribute, and defaults to "com.threecrickets.prudence".
RuntimeException
- If the Hazelcast default instance has not been initializedpublic com.hazelcast.core.HazelcastInstance getHazelcastTaskInstance()
The instance can be set as a component context attribute, which is named according to the application context attribute "com.threecrickets.prudence.hazelcast.taskInstanceAttributeName". This value defaults to "com.threecrickets.prudence.hazelcast.taskInstance".
If the instance has not been explicitly set, will default to the value of
getHazelcastDefaultInstance()
.
RuntimeException
- If the Hazelcast instance has not been initializedpublic com.hazelcast.core.IExecutorService getHazelcastExecutorService()
The name can be configured via the "com.threecrickets.prudence.hazelcast.executorName" application context attribute, and defaults to "default".
RuntimeException
- If the Hazelcast executor service has not been foundgetHazelcastTaskInstance()
public ConcurrentMap<String,Object> getDistributedGlobals()
This is a Hazelcast distributed map, the name of which can be configured via the "com.threecrickets.prudence.hazelcast.distributedGlobalsMapName" application context attribute, and defaults to "com.threecrickets.prudence.distributedGlobals".
public ConcurrentMap<String,Object> getDistributedSharedGlobals()
This is a Hazelcast distributed map, the name of which can be configured via the "com.threecrickets.prudence.hazelcast.distributedSharedGlobalsMapName" application context attribute, and defaults to "com.threecrickets.prudence.distributedGlobals".
public Object getDistributedGlobal(String name, Object defaultValue)
If distributed globals are not set up, does nothing and returns null.
name
- The name of the distributed globaldefaultValue
- The default valuepublic Object getDistributedSharedGlobal(String name, Object defaultValue)
If distributed shared globals are not set up, does nothing and returns null.
name
- The name of the distributed shared globaldefaultValue
- The default valuepublic com.hazelcast.core.ILock getDistributedSharedLock(String name)
These locks are evicted automatically.
name
- The distributed shared lock namepublic <T> Object distributedExecuteTask(String applicationName, String documentName, String entryPointName, Object context, Object where, boolean multi)
T
- The task result classapplicationName
- The application's full name, or null to default to current
application's namedocumentName
- The document nameentryPointName
- The entry point name or nullcontext
- The context made available to the task (must be serializable)where
- A Member
, a collection of Member
, any other object
(the member key), or null to let Hazelcast decide (all members for
multi=true)multi
- Whether the task should be executed on multiple membersHazelcastInstance.getExecutorService(String)
public <T> Object distributedCodeTask(String applicationName, String code, Object context, Object where, boolean multi)
T
- The task result classapplicationName
- The application's full name, or null to default to current
application's namecode
- The code to executecontext
- The context made available to the task (must be serializable)where
- A Member
, a MemberSelector
, an Iterable
of
Member
, a string (comma-separated member tags), or null to
let Hazelcast decide (all members for multi=true)multi
- Whether the task should be executed on multiple membersHazelcastInstance.getExecutorService(String)
Copyright © 2009-2016 Three Crickets LLC.