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
,
TargetInvocation
SERVICE_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()
InternalOperationService
getSlowOperationDTOs
in interface InternalOperationService
SlowOperationDTO
instances.public InvocationRegistry getInvocationRegistry()
public InboundResponseHandler getBackupHandler()
public int getPartitionThreadCount()
InternalOperationService
getPartitionThreadCount
in interface InternalOperationService
public int getGenericThreadCount()
InternalOperationService
getGenericThreadCount
in interface InternalOperationService
public int getRunningOperationsCount()
getRunningOperationsCount
in interface InternalOperationService
public long getExecutedOperationCount()
InternalOperationService
getExecutedOperationCount
in interface InternalOperationService
public int getRemoteOperationsCount()
getRemoteOperationsCount
in interface InternalOperationService
public int getOperationExecutorQueueSize()
getOperationExecutorQueueSize
in interface InternalOperationService
public int getPriorityOperationExecutorQueueSize()
getPriorityOperationExecutorQueueSize
in interface InternalOperationService
public OperationExecutor getOperationExecutor()
public int getResponseQueueSize()
InternalOperationService
getResponseQueueSize
in interface InternalOperationService
public void populate(LiveOperations liveOperations)
LiveOperationsTracker
populate
in interface LiveOperationsTracker
liveOperations
- the LiveOperations to populate.public void execute(PartitionSpecificRunnable task)
InternalOperationService
ClientEngine
when it has received a Packet containing a request that needs to be processed.execute
in interface InternalOperationService
task
- the task to executepublic void executeOnPartitions(PartitionTaskFactory taskFactory, BitSet partitions)
InternalOperationService
OperationExecutor.executeOnPartitions(PartitionTaskFactory, BitSet)
executeOnPartitions
in interface InternalOperationService
taskFactory
- 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 OperationService
public InvocationBuilder createInvocationBuilder(String serviceName, Operation op, Address target)
createInvocationBuilder
in interface OperationService
public void run(Operation op)
OperationService
run
in interface OperationService
op
- the operation to execute in the calling threadpublic void execute(Operation op)
OperationService
execute
in interface OperationService
op
- the operation to execute in the operation executor pool.public boolean isRunAllowed(Operation op)
InternalOperationService
OperationService.run(Operation)
method, otherwise
OperationService.execute(Operation)
should be used.isRunAllowed
in interface InternalOperationService
op
- the operation to check.public <E> InternalCompletableFuture<E> invokeOnPartition(String serviceName, Operation op, int partitionId)
invokeOnPartition
in interface OperationService
public <E> InternalCompletableFuture<E> invokeOnPartition(Operation op)
OperationService
invokeOnPartition
in interface OperationService
E
- the return type of the operation responseop
- the operationpublic <E> InternalCompletableFuture<E> invokeOnTarget(String serviceName, Operation op, Address target)
invokeOnTarget
in interface OperationService
public <V> void asyncInvokeOnPartition(String serviceName, Operation op, int partitionId, ExecutionCallback<V> callback)
asyncInvokeOnPartition
in interface InternalOperationService
public void onStartAsyncOperation(Operation op)
InternalOperationService
onStartAsyncOperation
in interface InternalOperationService
public void onCompletionAsyncOperation(Operation op)
InternalOperationService
onCompletionAsyncOperation
in interface InternalOperationService
InternalOperationService.onStartAsyncOperation(Operation)
public boolean isCallTimedOut(Operation op)
InternalOperationService
isCallTimedOut
in interface InternalOperationService
op
- the operation to check.public Map<Integer,Object> invokeOnAllPartitions(String serviceName, OperationFactory operationFactory) throws Exception
OperationService
This 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 OperationService
serviceName
- the name of the service.operationFactory
- the factory responsible for creating operationsException
public <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 OperationService
T
- type of result of operations returned by operationFactory
serviceName
- 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
OperationService
This 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 OperationService
T
- type of result of operations returned by operationFactory
serviceName
- 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 OperationService
T
- type of result of operations returned by operationFactory
serviceName
- 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
OperationService
This 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 OperationService
serviceName
- the name of the serviceoperationFactory
- the factory responsible for creating operationspartitions
- the partitions the operation should be executed on.Exception
public boolean send(Operation op, Address target)
OperationService
send
in interface OperationService
op
- the operation to send and execute.target
- the address of that target member.public void onMemberLeft(MemberImpl member)
public void onEndpointLeft(Address endpoint)
InternalOperationService
onEndpointLeft
in interface InternalOperationService
endpoint
- the endpoint that has leftpublic void reset()
public void provideMetrics(MetricsRegistry registry)
provideMetrics
in interface MetricsProvider
public 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.