use of com.hazelcast.spi.impl.operationexecutor.OperationHostileThread in project hazelcast by hazelcast.
the class OperationExecutorImpl method isInvocationAllowed.
@Override
public boolean isInvocationAllowed(Operation op, boolean isAsync) {
checkNotNull(op, "op can't be null");
Thread currentThread = Thread.currentThread();
// IO threads are not allowed to run any operation
if (currentThread instanceof OperationHostileThread) {
return false;
}
// if it is async we don't need to check if it is PartitionOperationThread or not
if (isAsync) {
return true;
}
// allowed to invoke non partition specific task
if (op.getPartitionId() < 0) {
return true;
}
// allowed to invoke from non PartitionOperationThreads (including GenericOperationThread)
if (currentThread.getClass() != PartitionOperationThread.class) {
return true;
}
PartitionOperationThread partitionThread = (PartitionOperationThread) currentThread;
OperationRunner runner = partitionThread.currentRunner;
if (runner != null) {
// in this case partitionId of both inner and outer operations have to match
return runner.getPartitionId() == op.getPartitionId();
}
return toPartitionThreadIndex(op.getPartitionId()) == partitionThread.threadId;
}
use of com.hazelcast.spi.impl.operationexecutor.OperationHostileThread in project hazelcast by hazelcast.
the class OperationExecutorImpl method isRunAllowed.
@Override
public boolean isRunAllowed(Operation op) {
checkNotNull(op, "op can't be null");
Thread currentThread = Thread.currentThread();
// IO threads are not allowed to run any operation
if (currentThread instanceof OperationHostileThread) {
return false;
}
int partitionId = op.getPartitionId();
// TODO: do we want to allow non partition specific tasks to be run on a partitionSpecific operation thread?
if (partitionId < 0) {
return true;
}
// we are only allowed to execute partition aware actions on an OperationThread
if (currentThread.getClass() != PartitionOperationThread.class) {
return false;
}
PartitionOperationThread partitionThread = (PartitionOperationThread) currentThread;
// to execute operations for this particular partitionId
return toPartitionThreadIndex(partitionId) == partitionThread.threadId;
}
Aggregations