use of com.hazelcast.spi.impl.operationservice.InternalOperationService in project hazelcast by hazelcast.
the class LockAdvancedTest method testLockCleanup_whenInvokingMemberDies.
@Test
public void testLockCleanup_whenInvokingMemberDies() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance hz = factory.newHazelcastInstance();
HazelcastInstance hz2 = factory.newHazelcastInstance();
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz2);
InternalOperationService operationService = getOperationService(hz2);
warmUpPartitions(hz2);
String name = randomNameOwnedBy(hz);
Data key = nodeEngine.toData(name);
int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
operationService.invokeOnPartition(LockService.SERVICE_NAME, new SlowLockOperation(name, key, 2000), partitionId);
sleepMillis(500);
terminateInstance(hz2);
final ILock lock = hz.getLock(name);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertFalse("Lock owned by dead member should have been released!", lock.isLocked());
}
}, 30);
}
use of com.hazelcast.spi.impl.operationservice.InternalOperationService in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method prepareToSafeShutdown.
@Override
public boolean prepareToSafeShutdown(long timeout, TimeUnit unit) {
if (!node.joined()) {
return true;
}
if (node.isLiteMember()) {
return true;
}
CountDownLatch latch = getShutdownLatch();
InternalOperationService operationService = nodeEngine.getOperationService();
long timeoutMillis = unit.toMillis(timeout);
long awaitStep = Math.min(SAFE_SHUTDOWN_MAX_AWAIT_STEP_MILLIS, timeoutMillis);
try {
do {
Address masterAddress = nodeEngine.getMasterAddress();
if (masterAddress == null) {
logger.warning("Safe shutdown failed, master member is not known!");
return false;
}
if (node.getThisAddress().equals(masterAddress)) {
onShutdownRequest(node.getThisAddress());
} else {
operationService.send(new ShutdownRequestOperation(), masterAddress);
}
if (latch.await(awaitStep, TimeUnit.MILLISECONDS)) {
return true;
}
timeoutMillis -= awaitStep;
} while (timeoutMillis > 0);
} catch (InterruptedException e) {
logger.info("Safe shutdown is interrupted!");
}
return false;
}
use of com.hazelcast.spi.impl.operationservice.InternalOperationService in project hazelcast by hazelcast.
the class TransactionLog method invokeAsync.
private void invokeAsync(NodeEngine nodeEngine, ExecutionCallback callback, TransactionLogRecord record, Operation op) {
InternalOperationService operationService = (InternalOperationService) nodeEngine.getOperationService();
if (record instanceof TargetAwareTransactionLogRecord) {
Address target = ((TargetAwareTransactionLogRecord) record).getTarget();
operationService.invokeOnTarget(op.getServiceName(), op, target);
} else {
operationService.asyncInvokeOnPartition(op.getServiceName(), op, op.getPartitionId(), callback);
}
}
use of com.hazelcast.spi.impl.operationservice.InternalOperationService in project hazelcast by hazelcast.
the class LockServiceImpl method destroyDistributedObject.
@Override
public void destroyDistributedObject(String objectId) {
final Data key = nodeEngine.getSerializationService().toData(objectId, StringPartitioningStrategy.INSTANCE);
final int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
final LockStoreImpl lockStore = containers[partitionId].getLockStore(new InternalLockNamespace(objectId));
if (lockStore != null) {
InternalOperationService operationService = (InternalOperationService) nodeEngine.getOperationService();
operationService.execute(new PartitionSpecificRunnable() {
@Override
public void run() {
lockStore.forceUnlock(key);
}
@Override
public int getPartitionId() {
return partitionId;
}
});
}
}
use of com.hazelcast.spi.impl.operationservice.InternalOperationService in project hazelcast by hazelcast.
the class OperationServiceImpl_invokeOnPartitionLiteMemberTest method test_asyncInvokeOnPartition_onLiteMember.
@Test
public void test_asyncInvokeOnPartition_onLiteMember() {
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
final HazelcastInstance instance = factory.newHazelcastInstance(liteMemberConfig);
final InternalOperationService operationService = getOperationService(instance);
final DummyExecutionCallback callback = new DummyExecutionCallback();
operationService.asyncInvokeOnPartition(null, operation, 0, callback);
assertOpenEventually(callback.responseLatch);
assertTrue(callback.response instanceof NoDataMemberInClusterException);
}
Aggregations