Class ClusteredExecutorInfo
- java.lang.Object
-
- com.oracle.coherence.concurrent.executor.ClusteredExecutorInfo
-
- All Implemented Interfaces:
ClusterMemberAware,Leased,LiveObject,TaskExecutorService.ExecutorInfo,com.tangosol.io.ExternalizableLite,com.tangosol.io.pof.PortableObject,Serializable
public class ClusteredExecutorInfo extends Object implements TaskExecutorService.ExecutorInfo, LiveObject, Leased, ClusterMemberAware, com.tangosol.io.pof.PortableObject
A Coherence-based implementation of aTaskExecutorService.ExecutorInfo.- Since:
- 21.12
- Author:
- bo
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classClusteredExecutorInfo.CacheAwareContinuationstatic classClusteredExecutorInfo.ClosingContinuationstatic classClusteredExecutorInfo.ClosingGracefullyContinuationAComposableContinuationto gracefully close aClusteredExecutorInfo, allowing already assignedTasks to complete.static classClusteredExecutorInfo.JoiningContinuationstatic classClusteredExecutorInfo.RemoveContinuationAComposableContinuationto remove aClusteredExecutorInfo.static classClusteredExecutorInfo.SetStateProcessorAnInvocableMap.EntryProcessorto compare and set the state of aClusteredExecutorInfo, returning the previous state.static classClusteredExecutorInfo.TouchProcessorAnInvocableMap.EntryProcessorto update the last update timestamp of aClusteredExecutorInfo.static classClusteredExecutorInfo.TouchRunnableARunnableto asynchronously touch.static classClusteredExecutorInfo.UpdateInfoProcessorAnInvocableMap.EntryProcessorto update the state of anTaskExecutorService.ExecutorInfo.static classClusteredExecutorInfo.UpdateInfoRunnableARunnableto asynchronously update the state ofClusteredExecutorInfousing the information based on the currentRuntime.-
Nested classes/interfaces inherited from interface com.oracle.coherence.concurrent.executor.TaskExecutorService.ExecutorInfo
TaskExecutorService.ExecutorInfo.State
-
-
Field Summary
Fields Modifier and Type Field Description static longLEASE_DURATION_MSThe duration of a lease forExecutors.protected longm_cCompletedThe completed tasks count.protected longm_cFreeMemoryThe free memory as reported byRuntime.freeMemory().protected longm_cInProgressThe tasks that are in progress count.protected longm_cMaxMemoryThe maximum memory as reported byRuntime.maxMemory().protected longm_cRejectedThe rejected tasks count.protected longm_cTotalMemoryThe total memory as reported byRuntime.totalMemory().protected longm_ldtUpdateThe cluster time when theTaskExecutorService.ExecutorInfowas last updated.protected OptionsByType<TaskExecutorService.Registration.Option>m_optionsByTypeTheTaskExecutorService.Registration.Options for theExecutor.protected Stringm_sIdentityThe identity of theTaskExecutorService.Registration.protected TaskExecutorService.ExecutorInfo.Statem_stateTheTaskExecutorService.ExecutorInfo.Stateof theExecutor.
-
Constructor Summary
Constructors Constructor Description ClusteredExecutorInfo()Constructs aClusteredExecutorInfo(for serialization support).ClusteredExecutorInfo(String sIdentity, long ldtUpdate, long cMaxMemory, long totalMemory, long freeMemory, OptionsByType<TaskExecutorService.Registration.Option> optionsByType)Constructs aClusteredExecutorInfowith the specified parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetDescription()Return the description of theClusteredExecutorInfo.StringgetExecutorName()Return the logical name of thisClusteredExecutorInfo.longgetFreeMemory()The last reported free memory byRuntime.freeMemory()available to theExecutorService.StringgetId()Obtains the unique identity for theExecutorService.longgetLastUpdateTime()Obtains the time since the epoch when theTaskExecutorService.ExecutorInfowas last updated.longgetLeaseExpiryTime()Obtains the time the lease will expiry (in milliseconds since the epoc).longgetMaxMemory()The last reported maximum memory byRuntime.maxMemory()available to theExecutorService.<T extends TaskExecutorService.Registration.Option>
TgetOption(Class<T> clzOfOption, T defaultIfNotFound)Obtains theTaskExecutorService.Registration.Optionof the specified class when theExecutorServicewas registered, or the default value if not found.TaskExecutorService.ExecutorInfo.StategetState()Obtains the currentTaskExecutorService.ExecutorInfo.Stateof theExecutor.longgetTasksCompletedCount()Return the number of completed tasks.longgetTasksInProgressCount()Return the number of tasks currently in progress.longgetTasksRejectedCount()Return the number rejected tasks.longgetTotalMemory()The last reported total memory byRuntime.totalMemory()available to theExecutorService.com.tangosol.util.UIDgetUid()TheUIDof theMemberfor which this object wishes to receive membership events.ComposableContinuationonDeleted(com.tangosol.net.CacheService service, com.tangosol.util.InvocableMap.Entry entry, Cause cause)TheLiveObjectwas deleted.ComposableContinuationonInserted(com.tangosol.net.CacheService service, com.tangosol.util.InvocableMap.Entry entry, Cause cause)TheLiveObjectwas inserted.booleanonLeaseExpiry()A callback invoked as part of anInvocableMap.EntryProcessorto perform custom lease expiry operations when a lease has expired.booleanonMemberJoined()A callback invoked as part of anInvocableMap.EntryProcessorto perform custom operations when theMemberhas joined the cluster.booleanonMemberLeaving()A callback invoked as part of anInvocableMap.EntryProcessorto perform custom operations when theMemberis leaving the cluster.booleanonMemberLeft()A callback invoked as part of anInvocableMap.EntryProcessorto perform custom operations when theMemberis leaving the cluster.ComposableContinuationonUpdated(com.tangosol.net.CacheService service, com.tangosol.util.InvocableMap.Entry entry, Cause cause)TheLiveObjectwas updated.voidreadExternal(com.tangosol.io.pof.PofReader in)voidreadExternal(DataInput in)voidrenew()Renews the lease for some period of time.voidsetFreeMemory(long cFreeMemory)Sets the free memory as reported byRuntime.freeMemory().voidsetMaxMemory(long cMaxMemory)Sets the maximum memory as reported byRuntime.maxMemory().voidsetState(TaskExecutorService.ExecutorInfo.State state)Sets the currentTaskExecutorService.ExecutorInfo.Stateof theExecutor.voidsetTasksCompletedCount(long cTasksCompleted)Sets the number of completed tasks.voidsetTasksFailedCount(long cTasksFailed)Sets the number of task failures.voidsetTasksInProgressCount(long cTasksInProgress)Sets the number of tasks currently in progress.voidsetTotalMemory(long cTotalMemory)Sets the total memory as reported byRuntime.totalMemory().StringtoString()voidtouch()Touches the last update time for theTaskExecutorService.ExecutorInfo.voidwriteExternal(com.tangosol.io.pof.PofWriter out)voidwriteExternal(DataOutput out)
-
-
-
Field Detail
-
LEASE_DURATION_MS
public static long LEASE_DURATION_MS
The duration of a lease forExecutors.When
TaskExecutorService.ExecutorInfofor anExecutorhas not been updated for the lease duration time, theExecutoris considered to be offline and should automatically be de-registered.
-
m_state
protected TaskExecutorService.ExecutorInfo.State m_state
TheTaskExecutorService.ExecutorInfo.Stateof theExecutor.
-
m_sIdentity
protected String m_sIdentity
The identity of theTaskExecutorService.Registration.
-
m_optionsByType
protected OptionsByType<TaskExecutorService.Registration.Option> m_optionsByType
TheTaskExecutorService.Registration.Options for theExecutor.
-
m_ldtUpdate
protected long m_ldtUpdate
The cluster time when theTaskExecutorService.ExecutorInfowas last updated.
-
m_cMaxMemory
protected long m_cMaxMemory
The maximum memory as reported byRuntime.maxMemory().
-
m_cTotalMemory
protected long m_cTotalMemory
The total memory as reported byRuntime.totalMemory().
-
m_cFreeMemory
protected long m_cFreeMemory
The free memory as reported byRuntime.freeMemory().
-
m_cCompleted
protected long m_cCompleted
The completed tasks count.
-
m_cRejected
protected long m_cRejected
The rejected tasks count.
-
m_cInProgress
protected long m_cInProgress
The tasks that are in progress count.
-
-
Constructor Detail
-
ClusteredExecutorInfo
public ClusteredExecutorInfo()
Constructs aClusteredExecutorInfo(for serialization support).
-
ClusteredExecutorInfo
public ClusteredExecutorInfo(String sIdentity, long ldtUpdate, long cMaxMemory, long totalMemory, long freeMemory, OptionsByType<TaskExecutorService.Registration.Option> optionsByType)
Constructs aClusteredExecutorInfowith the specified parameters.- Parameters:
sIdentity- the identityldtUpdate- the time since the epoc when theTaskExecutorService.ExecutorInfowas last updatedcMaxMemory- the maximum memory as reported byRuntime.maxMemory()totalMemory- the total memory as reported byRuntime.totalMemory()freeMemory- the free memory as reported byRuntime.freeMemory()optionsByType- theTaskExecutorService.Registration.Options for theExecutor
-
-
Method Detail
-
touch
public void touch()
Touches the last update time for theTaskExecutorService.ExecutorInfo.
-
getId
public String getId()
Description copied from interface:TaskExecutorService.ExecutorInfoObtains the unique identity for theExecutorService.- Specified by:
getIdin interfaceTaskExecutorService.ExecutorInfo- Returns:
- the unique identity
-
getState
public TaskExecutorService.ExecutorInfo.State getState()
Obtains the currentTaskExecutorService.ExecutorInfo.Stateof theExecutor.- Specified by:
getStatein interfaceTaskExecutorService.ExecutorInfo- Returns:
- the current
TaskExecutorService.ExecutorInfo.State
-
getLastUpdateTime
public long getLastUpdateTime()
Description copied from interface:TaskExecutorService.ExecutorInfoObtains the time since the epoch when theTaskExecutorService.ExecutorInfowas last updated.- Specified by:
getLastUpdateTimein interfaceTaskExecutorService.ExecutorInfo- Returns:
- the time since the epoch for the last update
-
getMaxMemory
public long getMaxMemory()
Description copied from interface:TaskExecutorService.ExecutorInfoThe last reported maximum memory byRuntime.maxMemory()available to theExecutorService.- Specified by:
getMaxMemoryin interfaceTaskExecutorService.ExecutorInfo- Returns:
- the maximum memory (in bytes)
-
getTotalMemory
public long getTotalMemory()
Description copied from interface:TaskExecutorService.ExecutorInfoThe last reported total memory byRuntime.totalMemory()available to theExecutorService.- Specified by:
getTotalMemoryin interfaceTaskExecutorService.ExecutorInfo- Returns:
- the total memory (in bytes)
-
getFreeMemory
public long getFreeMemory()
Description copied from interface:TaskExecutorService.ExecutorInfoThe last reported free memory byRuntime.freeMemory()available to theExecutorService.- Specified by:
getFreeMemoryin interfaceTaskExecutorService.ExecutorInfo- Returns:
- the free memory (in bytes)
-
getOption
public <T extends TaskExecutorService.Registration.Option> T getOption(Class<T> clzOfOption, T defaultIfNotFound)
Description copied from interface:TaskExecutorService.ExecutorInfoObtains theTaskExecutorService.Registration.Optionof the specified class when theExecutorServicewas registered, or the default value if not found.- Specified by:
getOptionin interfaceTaskExecutorService.ExecutorInfo- Type Parameters:
T- the type of theTaskExecutorService.Registration.Option- Parameters:
clzOfOption- the class ofTaskExecutorService.Registration.OptiondefaultIfNotFound- the value to return if not found- Returns:
- a
TaskExecutorService.Registration.Option
-
setState
public void setState(TaskExecutorService.ExecutorInfo.State state)
Sets the currentTaskExecutorService.ExecutorInfo.Stateof theExecutor.- Parameters:
state- the desiredTaskExecutorService.ExecutorInfo.State
-
getTasksCompletedCount
public long getTasksCompletedCount()
Return the number of completed tasks.- Returns:
- the number of completed tasks
-
getTasksRejectedCount
public long getTasksRejectedCount()
Return the number rejected tasks.- Returns:
- the number rejected tasks
-
getTasksInProgressCount
public long getTasksInProgressCount()
Return the number of tasks currently in progress.- Returns:
- the number of tasks currently in progress
-
setMaxMemory
public void setMaxMemory(long cMaxMemory)
Sets the maximum memory as reported byRuntime.maxMemory().- Parameters:
cMaxMemory- the maximum memory
-
setTotalMemory
public void setTotalMemory(long cTotalMemory)
Sets the total memory as reported byRuntime.totalMemory().- Parameters:
cTotalMemory- the total memory
-
setFreeMemory
public void setFreeMemory(long cFreeMemory)
Sets the free memory as reported byRuntime.freeMemory().- Parameters:
cFreeMemory- the free memory
-
setTasksCompletedCount
public void setTasksCompletedCount(long cTasksCompleted)
Sets the number of completed tasks.- Parameters:
cTasksCompleted- the number of completed tasks
-
setTasksFailedCount
public void setTasksFailedCount(long cTasksFailed)
Sets the number of task failures.- Parameters:
cTasksFailed- the number of failed tasks
-
setTasksInProgressCount
public void setTasksInProgressCount(long cTasksInProgress)
Sets the number of tasks currently in progress.- Parameters:
cTasksInProgress- the number of tasks in progress
-
getExecutorName
public String getExecutorName()
Return the logical name of thisClusteredExecutorInfo.- Returns:
- the logical name of this
ClusteredExecutorInfo
-
getDescription
public String getDescription()
Return the description of theClusteredExecutorInfo.- Returns:
- the description of the
ClusteredExecutorInfo - Since:
- 22.06
-
getLeaseExpiryTime
public long getLeaseExpiryTime()
Description copied from interface:LeasedObtains the time the lease will expiry (in milliseconds since the epoc).- Specified by:
getLeaseExpiryTimein interfaceLeased- Returns:
- the time in milliseconds since the epoc
-
renew
public void renew()
Description copied from interface:LeasedRenews the lease for some period of time.
-
onLeaseExpiry
public boolean onLeaseExpiry()
Description copied from interface:LeasedA callback invoked as part of anInvocableMap.EntryProcessorto perform custom lease expiry operations when a lease has expired.- Specified by:
onLeaseExpiryin interfaceLeased- Returns:
trueif theLeasedstate was mutated and should be saved,falseotherwise
-
onInserted
public ComposableContinuation onInserted(com.tangosol.net.CacheService service, com.tangosol.util.InvocableMap.Entry entry, Cause cause)
Description copied from interface:LiveObjectTheLiveObjectwas inserted.- Specified by:
onInsertedin interfaceLiveObject- Parameters:
service- theCacheServicefor theLiveObjectentry- the entry being insertedcause- theCauseof theEvent- Returns:
- an optional
ComposableContinuationto be performed asynchronously for theLiveObject(may benull)
-
onUpdated
public ComposableContinuation onUpdated(com.tangosol.net.CacheService service, com.tangosol.util.InvocableMap.Entry entry, Cause cause)
Description copied from interface:LiveObjectTheLiveObjectwas updated.This callback is invoked against the updated value, not the original value. The original value is available via the provided
Event.- Specified by:
onUpdatedin interfaceLiveObject- Parameters:
service- theCacheServicefor theLiveObjectentry- the entry being updatedcause- theCauseof theEvent- Returns:
- an optional
ComposableContinuationto be performed asynchronously for theLiveObject(may benull)
-
onDeleted
public ComposableContinuation onDeleted(com.tangosol.net.CacheService service, com.tangosol.util.InvocableMap.Entry entry, Cause cause)
Description copied from interface:LiveObjectTheLiveObjectwas deleted.- Specified by:
onDeletedin interfaceLiveObject- Parameters:
service- theCacheServicefor theLiveObjectentry- the entry being deletedcause- theCauseof theEvent- Returns:
- an optional
ComposableContinuationto be performed asynchronously for theLiveObject(may benull)
-
getUid
public com.tangosol.util.UID getUid()
Description copied from interface:ClusterMemberAwareTheUIDof theMemberfor which this object wishes to receive membership events. May returnnullwhich means do not receive membership events.- Specified by:
getUidin interfaceClusterMemberAware- Returns:
- a
UID
-
onMemberJoined
public boolean onMemberJoined()
Description copied from interface:ClusterMemberAwareA callback invoked as part of anInvocableMap.EntryProcessorto perform custom operations when theMemberhas joined the cluster.- Specified by:
onMemberJoinedin interfaceClusterMemberAware- Returns:
trueif theClusterMemberAwarestate was mutated and should be saved,falseotherwise- See Also:
MemberListener.memberJoined(MemberEvent)
-
onMemberLeaving
public boolean onMemberLeaving()
Description copied from interface:ClusterMemberAwareA callback invoked as part of anInvocableMap.EntryProcessorto perform custom operations when theMemberis leaving the cluster.- Specified by:
onMemberLeavingin interfaceClusterMemberAware- Returns:
trueif theClusterMemberAwarestate was mutated and should be saved,falseotherwise
-
onMemberLeft
public boolean onMemberLeft()
Description copied from interface:ClusterMemberAwareA callback invoked as part of anInvocableMap.EntryProcessorto perform custom operations when theMemberis leaving the cluster.See
MemberListener.memberLeft(MemberEvent).- Specified by:
onMemberLeftin interfaceClusterMemberAware- Returns:
trueif theClusterMemberAwarestate was mutated and should be saved,falseotherwise
-
readExternal
public void readExternal(DataInput in) throws IOException
- Specified by:
readExternalin interfacecom.tangosol.io.ExternalizableLite- Throws:
IOException
-
writeExternal
public void writeExternal(DataOutput out) throws IOException
- Specified by:
writeExternalin interfacecom.tangosol.io.ExternalizableLite- Throws:
IOException
-
readExternal
public void readExternal(com.tangosol.io.pof.PofReader in) throws IOException- Specified by:
readExternalin interfacecom.tangosol.io.pof.PortableObject- Throws:
IOException
-
writeExternal
public void writeExternal(com.tangosol.io.pof.PofWriter out) throws IOException- Specified by:
writeExternalin interfacecom.tangosol.io.pof.PortableObject- Throws:
IOException
-
-