use of com.hazelcast.instance.impl.HazelcastInstanceImpl in project hazelcast by hazelcast.
the class ClusterServiceImpl method shutdownNodesConcurrently.
private void shutdownNodesConcurrently(final long timeoutNanos) {
Operation op = new ShutdownNodeOp();
Collection<Member> members = getMembers(NON_LOCAL_MEMBER_SELECTOR);
long startTimeNanos = Timer.nanos();
logger.info("Sending shut down operations to all members...");
while (Timer.nanosElapsed(startTimeNanos) < timeoutNanos && !members.isEmpty()) {
for (Member member : members) {
nodeEngine.getOperationService().send(op, member.getAddress());
}
try {
Thread.sleep(CLUSTER_SHUTDOWN_SLEEP_DURATION_IN_MILLIS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
logger.warning("Shutdown sleep interrupted. ", e);
break;
}
members = getMembers(NON_LOCAL_MEMBER_SELECTOR);
}
logger.info("Number of other members remaining: " + getSize(NON_LOCAL_MEMBER_SELECTOR) + ". Shutting down itself.");
HazelcastInstanceImpl hazelcastInstance = node.hazelcastInstance;
hazelcastInstance.getLifecycleService().shutdown();
}
use of com.hazelcast.instance.impl.HazelcastInstanceImpl in project hazelcast by hazelcast.
the class TestProcessorMetaSupplierContext method setHazelcastInstance.
/**
* Sets the Hazelcast instance.
*/
@Nonnull
public TestProcessorMetaSupplierContext setHazelcastInstance(@Nonnull HazelcastInstance instance) {
this.instance = instance;
if (this.instance instanceof HazelcastInstanceProxy || this.instance instanceof HazelcastInstanceImpl) {
NodeEngineImpl nodeEngine = Util.getNodeEngine(this.instance);
this.partitionAssignment = ExecutionPlanBuilder.getPartitionAssignment(nodeEngine, Util.getMembersView(nodeEngine).getMembers()).entrySet().stream().collect(toMap(en -> en.getKey().getAddress(), Entry::getValue));
}
return this;
}
use of com.hazelcast.instance.impl.HazelcastInstanceImpl in project hazelcast by hazelcast.
the class StreamEventJournalP method init.
@Override
protected void init(@Nonnull Context context) throws Exception {
@SuppressWarnings("unchecked") CompletableFuture<EventJournalInitialSubscriberState>[] futures = new CompletableFuture[partitionIds.length];
Arrays.setAll(futures, i -> eventJournalReader.subscribeToEventJournal(partitionIds[i]));
for (int i = 0; i < futures.length; i++) {
emitOffsets[i] = readOffsets[i] = getSequence(futures[i].get());
}
if (!isRemoteReader) {
// try to serde projection/predicate to fail fast if they aren't known to IMDG
HazelcastInstanceImpl hzInstance = Util.getHazelcastInstanceImpl(context.hazelcastInstance());
InternalSerializationService ss = hzInstance.getSerializationService();
try {
deserializeWithCustomClassLoader(ss, hzInstance.getClass().getClassLoader(), ss.toData(predicate));
deserializeWithCustomClassLoader(ss, hzInstance.getClass().getClassLoader(), ss.toData(projection));
} catch (HazelcastSerializationException e) {
throw new JetException("The projection or predicate classes are not known to IMDG. It's not enough to " + "add them to the job class path, they must be deployed using User code deployment: " + e, e);
}
}
}
use of com.hazelcast.instance.impl.HazelcastInstanceImpl in project hazelcast by hazelcast.
the class CacheThroughHazelcastInstanceTest method getCache_whenOtherHazelcastExceptionIsThrown_thenFail.
@Test
public void getCache_whenOtherHazelcastExceptionIsThrown_thenFail() {
// when one attempts to getCache but a HazelcastException other than ServiceNotFoundException is thrown
HazelcastInstanceImpl hzInstanceImpl = mock(HazelcastInstanceImpl.class);
when(hzInstanceImpl.getDistributedObject(anyString(), anyString())).thenThrow(new HazelcastException("mock hz exception"));
// then the thrown HazelcastException is rethrown by getCache
ICacheManager hzCacheManager = new HazelcastInstanceCacheManager(hzInstanceImpl);
thrown.expect(HazelcastException.class);
hzCacheManager.getCache("any-cache");
}
use of com.hazelcast.instance.impl.HazelcastInstanceImpl in project hazelcast by hazelcast.
the class HazelcastStarterTest method testHazelcastInstanceCompatibility.
private static void testHazelcastInstanceCompatibility(HazelcastInstance instance, TestHazelcastInstanceFactory factory) {
Node node = TestUtil.getNode(instance);
HazelcastInstanceImpl instanceImpl = TestUtil.getHazelcastInstanceImpl(instance);
if (factory != null) {
assertEquals("Expected one active HazelcastInstance in the factory", 1, factory.getAllHazelcastInstances().size());
}
assertNode(node, true);
assertHazelcastInstanceImpl(instanceImpl);
assertSafePartitionServiceState(instance);
instance.shutdown();
assertNode(node, false);
if (factory != null) {
assertEquals("Expected no active HazelcastInstances in the factory", 0, factory.getAllHazelcastInstances().size());
}
assertGetNodeFromShutdownInstance(instance);
assertGetHazelcastInstanceImplFromShutdownInstance(instance);
assertSafePartitionServiceState(instance);
}
Aggregations