Java Code Examples for com.hazelcast.core.Hazelcast#shutdownAll()

The following examples show how to use com.hazelcast.core.Hazelcast#shutdownAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientBasicTestCase.java    From snowcast with Apache License 2.0 6 votes vote down vote up
@Test(expected = SnowcastStateException.class)
public void test_id_generation_in_detached_state()
        throws Exception {

    Hazelcast.newHazelcastInstance();
    HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(client);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        assertNotNull(sequencer);
        assertNotNull(sequencer.next());

        // Detach the node and free the currently used logical node ID
        sequencer.detachLogicalNode();

        sequencer.next();
    } finally {
        HazelcastClient.shutdownAll();
        Hazelcast.shutdownAll();
    }
}
 
Example 2
Source File: ClientBasicTestCase.java    From snowcast with Apache License 2.0 5 votes vote down vote up
@Test(expected = SnowcastStateException.class)
public void test_destroyed_state_from_node()
        throws Exception {

    HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);

    try {
        SnowcastEpoch epoch = buildEpoch();

        Snowcast snowcastClient = SnowcastSystem.snowcast(client);
        SnowcastSequencer sequencerClient = buildSnowcastSequencer(snowcastClient, epoch);

        assertNotNull(sequencerClient);
        assertNotNull(sequencerClient.next());

        Snowcast snowcastNode = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencerNode = buildSnowcastSequencer(snowcastNode, epoch);

        assertNotNull(sequencerNode);
        assertNotNull(sequencerNode.next());

        snowcastNode.destroySequencer(sequencerNode);

        long deadline = System.currentTimeMillis() + 60000;
        while (true) {
            // Will eventually fail
            sequencerClient.next();

            if (System.currentTimeMillis() >= deadline) {
                // Safe exit after another minute of waiting for the event
                return;
            }
        }

    } finally {
        HazelcastClient.shutdownAll();
        Hazelcast.shutdownAll();
    }
}
 
Example 3
Source File: HazelcastLockProviderClusterTest.java    From ShedLock with Apache License 2.0 4 votes vote down vote up
@AfterEach
public void resetLockProvider() {
    Hazelcast.shutdownAll();
}
 
Example 4
Source File: CacheConfiguration.java    From jhipster-microservices-example with Apache License 2.0 4 votes vote down vote up
@PreDestroy
public void destroy() {
    log.info("Closing Cache Manager");
    Hazelcast.shutdownAll();
}
 
Example 5
Source File: Hazelcast3CacheMetricsCompatibilityTest.java    From micrometer with Apache License 2.0 4 votes vote down vote up
@AfterEach
void cleanup() {
    Hazelcast.shutdownAll();
}
 
Example 6
Source File: KeyValueTemplateTestsUsingHazelcastTest.java    From spring-data-hazelcast with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown()
        throws Exception {
    this.operations.destroy();
    Hazelcast.shutdownAll();
}
 
Example 7
Source File: KeyUtilsTest.java    From hazelcast-simulator with Apache License 2.0 4 votes vote down vote up
@AfterClass
public static void afterClass() {
    HazelcastClient.shutdownAll();
    Hazelcast.shutdownAll();
}
 
Example 8
Source File: SnapshotBasedTradeUpdater.java    From JPPF with Apache License 2.0 4 votes vote down vote up
/**
 * Main loop.
 */
@Override
public void run() {
  try {
    if (debugEnabled) log.debug("starting trade updater");
    initializeData();
    // start the ticker
    final Ticker ticker = new Ticker(marketDataList, config.getInt("minTickerInterval", 50), config.getInt("maxTickerInterval", 1000),
        config.getInt("nbTickerEvents", 0), dataFactory);
    ticker.addTickerListener(marketDataHandler);
    ticker.addTickerListener(this);
    final long snapshotInterval = config.getLong("snapshotInterval", 1000L);
    final ProcessSnapshotTask snapshotTask = new ProcessSnapshotTask();
    print("starting ticker ...");
    final long start = System.nanoTime();
    new Thread(ticker, "ticker thread").start();
    timer.schedule(snapshotTask, snapshotInterval, snapshotInterval);
    // let it run for the configured time
    Thread.sleep(config.getLong("simulationDuration", 60000L));
    // stop the ticker
    ticker.setStopped(true);
    print("ticker stopped: " + ticker.getEventCount() + " events generated");
    timer.cancel();
    lock.lock();
    try {
      snapshotTask.run();
    } finally       {
      lock.unlock();
    }
    jobExecutor.shutdown();
    while (!jobExecutor.isTerminated()) Thread.sleep(10);
    resultsExecutor.shutdown();
    while (!resultsExecutor.isTerminated()) Thread.sleep(10);
    final long elapsed = DateTimeUtils.elapsedFrom(start);
    //timer.purge();
    statsCollector.setTotalTime(elapsed);
    print(statsCollector.toString());
    marketDataHandler.close();
    Hazelcast.shutdownAll();
  } catch(final Exception e) {
    System.out.println(e.getMessage());
    log.error(e.getMessage(), e);
  }
  System.exit(0);
}
 
Example 9
Source File: CacheConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@PreDestroy
public void destroy() {
    log.info("Closing Cache Manager");
    Hazelcast.shutdownAll();
}
 
Example 10
Source File: HazelcastSessionDataStorageTest.java    From pippo with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
    Hazelcast.shutdownAll();
}
 
Example 11
Source File: CacheConfiguration.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 4 votes vote down vote up
@PreDestroy
public void destroy() {
    log.info("Closing Cache Manager");
    Hazelcast.shutdownAll();
}
 
Example 12
Source File: CacheConfiguration.java    From flair-engine with Apache License 2.0 4 votes vote down vote up
@PreDestroy
public void destroy() {
    log.info("Closing Cache Manager");
    Hazelcast.shutdownAll();
}
 
Example 13
Source File: ClientSequencerBackupTestCase.java    From snowcast with Apache License 2.0 4 votes vote down vote up
@Test
public void test_simple_backup_create_sequencer_definition_client() {
    HazelcastInstance hazelcastInstance1 = Hazelcast.newHazelcastInstance(config1);
    HazelcastInstance hazelcastInstance2 = Hazelcast.newHazelcastInstance(config2);

    HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);

    try {
        final String sequencerName = generateKeyOwnedBy(hazelcastInstance1);

        // Build the custom epoch
        SnowcastEpoch epoch = buildEpoch();

        Snowcast clientSnowcast = SnowcastSystem.snowcast(client);
        Snowcast snowcast1 = SnowcastSystem.snowcast(hazelcastInstance1);
        Snowcast snowcast2 = SnowcastSystem.snowcast(hazelcastInstance2);

        buildSnowcastSequencer(clientSnowcast, sequencerName, epoch);

        InternalSequencer sequencer1 = (InternalSequencer) buildSnowcastSequencer(snowcast1, sequencerName, epoch);
        InternalSequencer sequencer2 = (InternalSequencer) buildSnowcastSequencer(snowcast2, sequencerName, epoch);

        NodeSequencerService sequencerService1 = (NodeSequencerService) sequencer1.getSequencerService();
        NodeSequencerService sequencerService2 = (NodeSequencerService) sequencer2.getSequencerService();

        PartitionService partitionService = hazelcastInstance1.getPartitionService();
        int partitionId = partitionService.getPartition(sequencerName).getPartitionId();

        final SequencerPartition partition1 = sequencerService1.getSequencerPartition(partitionId);
        final SequencerPartition partition2 = sequencerService2.getSequencerPartition(partitionId);

        assertTrueEventually(new AssertTask() {
            @Override
            public void run()
                    throws Exception {

                SequencerDefinition sequencerDefinition1 = partition1.getSequencerDefinition(sequencerName);
                SequencerDefinition sequencerDefinition2 = partition2.getSequencerDefinition(sequencerName);

                assertEquals(sequencerDefinition1, sequencerDefinition2);
            }
        });
    } finally {
        HazelcastClient.shutdownAll();
        Hazelcast.shutdownAll();
    }
}
 
Example 14
Source File: HazelCastConfigration.java    From sctalk with Apache License 2.0 4 votes vote down vote up
@PreDestroy
public void destroy() {
    log.info("Closing Cache Manager");
    Hazelcast.shutdownAll();
}
 
Example 15
Source File: HazelcastManaged.java    From cqrs-eventsourcing-kafka with Apache License 2.0 4 votes vote down vote up
@Override
public void stop() throws Exception {
    Hazelcast.shutdownAll();
}
 
Example 16
Source File: CacheConfiguration.java    From cubeai with Apache License 2.0 4 votes vote down vote up
@PreDestroy
public void destroy() {
    log.info("Closing Cache Manager");
    Hazelcast.shutdownAll();
}
 
Example 17
Source File: CacheConfiguration.java    From cubeai with Apache License 2.0 4 votes vote down vote up
@PreDestroy
public void destroy() {
    log.info("Closing Cache Manager");
    Hazelcast.shutdownAll();
}
 
Example 18
Source File: CacheConfiguration.java    From cubeai with Apache License 2.0 4 votes vote down vote up
@PreDestroy
public void destroy() {
    log.info("Closing Cache Manager");
    Hazelcast.shutdownAll();
}
 
Example 19
Source File: CacheConfiguration.java    From java-microservices-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void destroy() throws Exception {
    log.info("Closing Cache Manager");
    Hazelcast.shutdownAll();
}
 
Example 20
Source File: CacheConfiguration.java    From java-microservices-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void destroy() throws Exception {
    log.info("Closing Cache Manager");
    Hazelcast.shutdownAll();
}