public final class OperationServiceImpl extends Object implements InternalOperationService, MetricsProvider, LiveOperationsTracker
InternalOperationService.
UrgentSystemOperation is invoked on this OperationService, it will be executed with a
high urgency by making use of a urgent queue. So when the system is under load, and the operation queues are
filled, then system operations are executed before normal operation. The advantage is that when a system is under
pressure, it still is able to do things like recognizing new members in the cluster and moving partitions around.
When a UrgentSystemOperation is send to a remote machine, it is wrapped in a Packet and the packet is marked as a
urgent packet. When this packet is received on the remove OperationService, the urgent flag is checked and if
needed, the operation is set on the urgent queue. So local and remote execution of System operations will obey
the urgency.Invocation,
InvocationBuilderImpl,
PartitionInvocation,
TargetInvocationSERVICE_NAME| Constructor and Description |
|---|
OperationServiceImpl(NodeEngineImpl nodeEngine) |
| Modifier and Type | Method and Description |
|---|---|
<V> void |
asyncInvokeOnPartition(String serviceName,
Operation op,
int partitionId,
ExecutionCallback<V> callback) |
InvocationBuilder |
createInvocationBuilder(String serviceName,
Operation op,
Address target) |
InvocationBuilder |
createInvocationBuilder(String serviceName,
Operation op,
int partitionId) |
void |
execute(Operation op)
Executes an operation in the operation executor pool.
|
void |
execute(PartitionSpecificRunnable task)
Executes a PartitionSpecificRunnable.
|
void |
executeOnPartitions(PartitionTaskFactory taskFactory,
BitSet partitions)
Executes for each of the partitions, a task created by the
taskFactory.
|
InboundResponseHandler |
getBackupHandler() |
long |
getExecutedOperationCount()
Returns the number of executed operations.
|
int |
getGenericThreadCount()
Returns the number of generic threads.
|
InboundResponseHandlerSupplier |
getInboundResponseHandlerSupplier() |
com.hazelcast.spi.impl.operationservice.impl.Invocation.Context |
getInvocationContext() |
InvocationMonitor |
getInvocationMonitor() |
InvocationRegistry |
getInvocationRegistry() |
OperationExecutor |
getOperationExecutor() |
int |
getOperationExecutorQueueSize() |
OutboundResponseHandler |
getOutboundResponseHandler() |
int |
getPartitionThreadCount()
Returns the number of partition threads.
|
int |
getPriorityOperationExecutorQueueSize() |
int |
getRemoteOperationsCount() |
int |
getResponseQueueSize()
Returns the size of the response queue.
|
int |
getRunningOperationsCount() |
List<SlowOperationDTO> |
getSlowOperationDTOs()
Returns information about long running operations.
|
Map<Integer,Object> |
invokeOnAllPartitions(String serviceName,
OperationFactory operationFactory)
Invokes a set of operations on each partition.
|
<T> ICompletableFuture<Map<Integer,T>> |
invokeOnAllPartitionsAsync(String serviceName,
OperationFactory operationFactory)
Invokes a set of operations on selected set of all partitions in an async way.
|
<E> InternalCompletableFuture<E> |
invokeOnPartition(Operation op)
Executes an operation on a partition.
|
<E> InternalCompletableFuture<E> |
invokeOnPartition(String serviceName,
Operation op,
int partitionId) |
<T> Map<Integer,T> |
invokeOnPartitions(String serviceName,
OperationFactory operationFactory,
Collection<Integer> partitions)
Invokes a set of operations on selected set of partitions.
|
Map<Integer,Object> |
invokeOnPartitions(String serviceName,
OperationFactory operationFactory,
int[] partitions)
Invokes a set of operations on selected set of partitions.
|
<T> ICompletableFuture<Map<Integer,T>> |
invokeOnPartitionsAsync(String serviceName,
OperationFactory operationFactory,
Collection<Integer> partitions)
Invokes a set of operations on selected set of partitions in an async way.
|
<E> InternalCompletableFuture<E> |
invokeOnTarget(String serviceName,
Operation op,
Address target) |
boolean |
isCallTimedOut(Operation op)
Checks if this call is timed out.
|
boolean |
isRunAllowed(Operation op)
Returns true if the given operation is allowed to run on the calling
thread, false otherwise.
|
void |
onCompletionAsyncOperation(Operation op)
Should be called when the asynchronous operation has completed.
|
void |
onEndpointLeft(Address endpoint)
Cleans up heartbeats and fails invocations for the given endpoint.
|
void |
onMemberLeft(MemberImpl member) |
void |
onStartAsyncOperation(Operation op)
Should be called when an asynchronous operations not running on a operation thread is running.
|
void |
populate(LiveOperations liveOperations)
Populate the LiveOperations
|
void |
provideMetrics(MetricsRegistry registry) |
void |
reset() |
void |
run(Operation op)
Runs an operation in the calling thread.
|
boolean |
send(Operation op,
Address target)
Executes an operation remotely.
|
void |
shutdownInvocations()
Shuts down invocation infrastructure.
|
void |
shutdownOperationExecutor() |
void |
start() |
public OperationServiceImpl(NodeEngineImpl nodeEngine)
public OutboundResponseHandler getOutboundResponseHandler()
public InboundResponseHandlerSupplier getInboundResponseHandlerSupplier()
public InvocationMonitor getInvocationMonitor()
public List<SlowOperationDTO> getSlowOperationDTOs()
InternalOperationServicegetSlowOperationDTOs in interface InternalOperationServiceSlowOperationDTO instances.public InvocationRegistry getInvocationRegistry()
public InboundResponseHandler getBackupHandler()
public int getPartitionThreadCount()
InternalOperationServicegetPartitionThreadCount in interface InternalOperationServicepublic int getGenericThreadCount()
InternalOperationServicegetGenericThreadCount in interface InternalOperationServicepublic int getRunningOperationsCount()
getRunningOperationsCount in interface InternalOperationServicepublic long getExecutedOperationCount()
InternalOperationServicegetExecutedOperationCount in interface InternalOperationServicepublic int getRemoteOperationsCount()
getRemoteOperationsCount in interface InternalOperationServicepublic int getOperationExecutorQueueSize()
getOperationExecutorQueueSize in interface InternalOperationServicepublic int getPriorityOperationExecutorQueueSize()
getPriorityOperationExecutorQueueSize in interface InternalOperationServicepublic OperationExecutor getOperationExecutor()
public int getResponseQueueSize()
InternalOperationServicegetResponseQueueSize in interface InternalOperationServicepublic void populate(LiveOperations liveOperations)
LiveOperationsTrackerpopulate in interface LiveOperationsTrackerliveOperations - the LiveOperations to populate.public void execute(PartitionSpecificRunnable task)
InternalOperationServiceClientEngine
when it has received a Packet containing a request that needs to be processed.execute in interface InternalOperationServicetask - the task to executepublic void executeOnPartitions(PartitionTaskFactory taskFactory, BitSet partitions)
InternalOperationServiceOperationExecutor.executeOnPartitions(PartitionTaskFactory, BitSet)executeOnPartitions in interface InternalOperationServicetaskFactory - the PartitionTaskFactory used to create
operations.partitions - the partitions to execute an operation on.public InvocationBuilder createInvocationBuilder(String serviceName, Operation op, int partitionId)
createInvocationBuilder in interface OperationServicepublic InvocationBuilder createInvocationBuilder(String serviceName, Operation op, Address target)
createInvocationBuilder in interface OperationServicepublic void run(Operation op)
OperationServicerun in interface OperationServiceop - the operation to execute in the calling threadpublic void execute(Operation op)
OperationServiceexecute in interface OperationServiceop - the operation to execute in the operation executor pool.public boolean isRunAllowed(Operation op)
InternalOperationServiceOperationService.run(Operation) method, otherwise
OperationService.execute(Operation) should be used.isRunAllowed in interface InternalOperationServiceop - the operation to check.public <E> InternalCompletableFuture<E> invokeOnPartition(String serviceName, Operation op, int partitionId)
invokeOnPartition in interface OperationServicepublic <E> InternalCompletableFuture<E> invokeOnPartition(Operation op)
OperationServiceinvokeOnPartition in interface OperationServiceE - the return type of the operation responseop - the operationpublic <E> InternalCompletableFuture<E> invokeOnTarget(String serviceName, Operation op, Address target)
invokeOnTarget in interface OperationServicepublic <V> void asyncInvokeOnPartition(String serviceName, Operation op, int partitionId, ExecutionCallback<V> callback)
asyncInvokeOnPartition in interface InternalOperationServicepublic void onStartAsyncOperation(Operation op)
InternalOperationServiceonStartAsyncOperation in interface InternalOperationServicepublic void onCompletionAsyncOperation(Operation op)
InternalOperationServiceonCompletionAsyncOperation in interface InternalOperationServiceInternalOperationService.onStartAsyncOperation(Operation)public boolean isCallTimedOut(Operation op)
InternalOperationServiceisCallTimedOut in interface InternalOperationServiceop - the operation to check.public Map<Integer,Object> invokeOnAllPartitions(String serviceName, OperationFactory operationFactory) throws Exception
OperationServiceThis method blocks until the operations complete.
If the operations have sync backups, this method will not wait for their completion.
Instead, it will return once the operations are completed on primary replicas of the
given partitions.
invokeOnAllPartitions in interface OperationServiceserviceName - the name of the service.operationFactory - the factory responsible for creating operationsExceptionpublic <T> ICompletableFuture<Map<Integer,T>> invokeOnAllPartitionsAsync(String serviceName, OperationFactory operationFactory)
OperationService
If the operations have sync backups, the returned ICompletableFuture does not
wait for their completion. Instead, the ICompletableFuture is completed once the
operations are completed on primary replicas of the given partitions.
invokeOnAllPartitionsAsync in interface OperationServiceT - type of result of operations returned by operationFactoryserviceName - the name of the serviceoperationFactory - the factory responsible for creating operationspublic <T> Map<Integer,T> invokeOnPartitions(String serviceName, OperationFactory operationFactory, Collection<Integer> partitions) throws Exception
OperationServiceThis method blocks until all operations complete.
If the operations have sync backups, this method will not wait for their completion.
Instead, it will return once the operations are completed on primary replicas of the given partitions.
invokeOnPartitions in interface OperationServiceT - type of result of operations returned by operationFactoryserviceName - the name of the serviceoperationFactory - the factory responsible for creating operationspartitions - the partitions the operation should be executed on.Exception - if there was an exception while waiting for the results
of the partition invocationspublic <T> ICompletableFuture<Map<Integer,T>> invokeOnPartitionsAsync(String serviceName, OperationFactory operationFactory, Collection<Integer> partitions)
OperationService
If the operations have sync backups, the returned ICompletableFuture does not
wait for their completion. Instead, the ICompletableFuture is completed once the
operations are completed on primary replicas of the given partitions.
invokeOnPartitionsAsync in interface OperationServiceT - type of result of operations returned by operationFactoryserviceName - the name of the serviceoperationFactory - the factory responsible for creating operationspartitions - the partitions the operation should be executed on.public Map<Integer,Object> invokeOnPartitions(String serviceName, OperationFactory operationFactory, int[] partitions) throws Exception
OperationServiceThis method blocks until all operations complete.
If the operations have sync backups, this method will not wait for their completion.
Instead, it will return once the operations are completed on primary replicas of the given partitions.
invokeOnPartitions in interface OperationServiceserviceName - the name of the serviceoperationFactory - the factory responsible for creating operationspartitions - the partitions the operation should be executed on.Exceptionpublic boolean send(Operation op, Address target)
OperationServicesend in interface OperationServiceop - the operation to send and execute.target - the address of that target member.public void onMemberLeft(MemberImpl member)
public void onEndpointLeft(Address endpoint)
InternalOperationServiceonEndpointLeft in interface InternalOperationServiceendpoint - the endpoint that has leftpublic void reset()
public void provideMetrics(MetricsRegistry registry)
provideMetrics in interface MetricsProviderpublic void start()
public com.hazelcast.spi.impl.operationservice.impl.Invocation.Context getInvocationContext()
public void shutdownInvocations()
public void shutdownOperationExecutor()
Copyright © 2020 Hazelcast, Inc.. All Rights Reserved.