當前位置: 首頁>>代碼示例>>Java>>正文


Java HazelcastInstance.shutdown方法代碼示例

本文整理匯總了Java中com.hazelcast.core.HazelcastInstance.shutdown方法的典型用法代碼示例。如果您正苦於以下問題:Java HazelcastInstance.shutdown方法的具體用法?Java HazelcastInstance.shutdown怎麽用?Java HazelcastInstance.shutdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hazelcast.core.HazelcastInstance的用法示例。


在下文中一共展示了HazelcastInstance.shutdown方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configInstanceWithName

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
@Test
public void configInstanceWithName() {
	Config config = new Config("my-test-instance");
	HazelcastInstance existingHazelcastInstance = Hazelcast
			.newHazelcastInstance(config);
	try {
		load(HazelcastConfigWithName.class,
				"spring.hazelcast.config=this-is-ignored.xml");
		HazelcastInstance hazelcastInstance = this.context
				.getBean(HazelcastInstance.class);
		assertThat(hazelcastInstance.getConfig().getInstanceName())
				.isEqualTo("my-test-instance");
		// Should reuse any existing instance by default.
		assertThat(hazelcastInstance).isEqualTo(existingHazelcastInstance);
	}
	finally {
		existingHazelcastInstance.shutdown();
	}
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:20,代碼來源:HazelcastAutoConfigurationTests.java

示例2: testFailover

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
@Test(timeout = 80000)
public void testFailover() throws Exception {
    CookieStore cookieStore = new BasicCookieStore();
    String value = executeRequest("read", SERVER_PORT_1, cookieStore);
    assertEquals("null", value);

    executeRequest("write", SERVER_PORT_1, cookieStore);

    instance1.stop();

    HazelcastInstance hzInstance1 = Hazelcast.getHazelcastInstanceByName("hzInstance1");
    if (hzInstance1 != null) {
        hzInstance1.shutdown();
    }

    value = executeRequest("read", SERVER_PORT_2, cookieStore);
    assertEquals("value", value);
}
 
開發者ID:hazelcast,項目名稱:hazelcast-tomcat-sessionmanager,代碼行數:19,代碼來源:AbstractStickySessionsTest.java

示例3: testInstanceDown

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
@Test
public void testInstanceDown(){
    ArgumentCaptor<InstanceInfo> captor = ArgumentCaptor.forClass(InstanceInfo.class);

    EurekaHttpResponse<Applications> response = generateMockResponse(Collections.<InstanceInfo>emptyList());
    when(requestHandler.getApplications()).thenReturn(response);

    HazelcastInstance hz1 = factory.newHazelcastInstance();
    HazelcastInstance hz2 = factory.newHazelcastInstance();

    verify(requestHandler, timeout(5000).times(2)).register(captor.capture());
    response = generateMockResponse(captor.getAllValues());
    when(requestHandler.getApplications()).thenReturn(response);

    hz1.shutdown();

    ArgumentCaptor<String> id = ArgumentCaptor.forClass(String.class);
    verify(requestHandler, timeout(5000).times(1)).cancel(anyString(), id.capture());

    reset(requestHandler);
    for(InstanceInfo info : captor.getAllValues()){
        if(info.getId().equals(id.getValue())){
            captor.getAllValues().remove(info);
            break;
        }
    }

    response = generateMockResponse(captor.getAllValues());
    when(requestHandler.getApplications()).thenReturn(response);

    assertClusterSizeEventually(1, hz2);
}
 
開發者ID:hazelcast,項目名稱:hazelcast-eureka,代碼行數:33,代碼來源:HazelcastClientTestCase.java

示例4: destroy

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
/**
 * Destroys currently allocated instance.
 */
public void destroy() {
    log.info("Shutting down Hazelcast instance [{}]..", hcInstanceName);
    final HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(
            hcInstanceName);
    if (instance != null) {
        instance.shutdown();
    }
}
 
開發者ID:summerDp,項目名稱:dpCms,代碼行數:12,代碼來源:HazelcastSessionDao.java

示例5: lifecycleEvent

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
@Override
public void lifecycleEvent(LifecycleEvent event) {
    String shutdown = System.getProperty("hazelcast.tomcat.shutdown_hazelcast_instance");
    if (getConfigLocation() == null) {
        setConfigLocation("hazelcast-default.xml");
    }

    if ("start".equals(event.getType())) {
        try {
            config = ConfigLoader.load(getConfigLocation());
        } catch (IOException e) {
            throw new RuntimeException("failed to load Config:", e);
        }

        if (config == null) {
            throw new RuntimeException("failed to find configLocation:" + getConfigLocation());
        }
        if (config.getInstanceName() == null) {
            config.setInstanceName(SessionManager.DEFAULT_INSTANCE_NAME);
        }
        Hazelcast.getOrCreateHazelcastInstance(config);
    } else if ("stop".equals(event.getType()) && !"false".equals(shutdown)) {
        HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(SessionManager.DEFAULT_INSTANCE_NAME);
        if (instance != null) {
            instance.shutdown();
        }
    }
}
 
開發者ID:hazelcast,項目名稱:hazelcast-tomcat-sessionmanager,代碼行數:29,代碼來源:P2PLifecycleListener.java

示例6: testNativeClient

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
@Test
public void testNativeClient() throws Exception {
    TestHazelcastFactory factory = new TestHazelcastFactory();
    Config config = new ClasspathXmlConfig("hazelcast-custom.xml");
    HazelcastInstance main = factory.newHazelcastInstance(config);
    Properties props = getDefaultProperties();
    props.remove(CacheEnvironment.CONFIG_FILE_PATH_LEGACY);
    props.setProperty(Environment.CACHE_REGION_FACTORY, HazelcastCacheRegionFactory.class.getName());
    props.setProperty(CacheEnvironment.USE_NATIVE_CLIENT, "true");
    props.setProperty(CacheEnvironment.NATIVE_CLIENT_GROUP, "dev-custom");
    props.setProperty(CacheEnvironment.NATIVE_CLIENT_PASSWORD, "dev-pass");
    props.setProperty(CacheEnvironment.CONFIG_FILE_PATH,"hazelcast-client-custom.xml");
    HazelcastMockInstanceLoader loader = new HazelcastMockInstanceLoader();
    loader.configure(props);
    loader.setInstanceFactory(factory);
    SessionFactory sf = createSessionFactory(props, loader);
    final HazelcastInstance hz = HazelcastAccessor.getHazelcastInstance(sf);
    assertTrue(hz instanceof HazelcastClientProxy);
    assertEquals(1, main.getCluster().getMembers().size());
    HazelcastClientProxy client = (HazelcastClientProxy) hz;
    ClientConfig clientConfig = client.getClientConfig();
    assertEquals("dev-custom", clientConfig.getGroupConfig().getName());
    assertEquals("dev-pass", clientConfig.getGroupConfig().getPassword());
    assertTrue(clientConfig.getNetworkConfig().isSmartRouting());
    assertTrue(clientConfig.getNetworkConfig().isRedoOperation());
    factory.newHazelcastInstance(config);
    assertEquals(2, hz.getCluster().getMembers().size());
    main.shutdown();

    assertTrueEventually(new AssertTask() {
        @Override
        public void run() throws Exception {
            assertEquals(1, hz.getCluster().getMembers().size());
        }
    });

    assertEquals(1, hz.getCluster().getMembers().size());
    Session session = sf.openSession();
    Transaction tx = session.beginTransaction();
    session.save(new DummyEntity(1L, "dummy", 0, new Date()));
    tx.commit();
    session.close();
    sf.close();
    factory.shutdownAll();
}
 
開發者ID:hazelcast,項目名稱:hazelcast-hibernate5,代碼行數:46,代碼來源:CustomPropertiesTest.java

示例7: testNativeClient

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
@Test
public void testNativeClient() throws Exception {
    TestHazelcastFactory factory = new TestHazelcastFactory();
    Config config = new ClasspathXmlConfig("hazelcast-custom.xml");
    HazelcastInstance main = factory.newHazelcastInstance(config);
    Properties props = getDefaultProperties();
    props.remove(CacheEnvironment.CONFIG_FILE_PATH_LEGACY);
    props.setProperty(Environment.CACHE_REGION_FACTORY, HazelcastCacheRegionFactory.class.getName());
    props.setProperty(CacheEnvironment.USE_NATIVE_CLIENT, "true");
    props.setProperty(CacheEnvironment.NATIVE_CLIENT_GROUP, "dev-custom");
    props.setProperty(CacheEnvironment.NATIVE_CLIENT_PASSWORD, "dev-pass");
    props.setProperty(CacheEnvironment.NATIVE_CLIENT_ADDRESS, "localhost");
    props.setProperty(CacheEnvironment.CONFIG_FILE_PATH,"hazelcast-client-custom.xml");
    HazelcastMockInstanceLoader loader = new HazelcastMockInstanceLoader();
    loader.configure(props);
    loader.setInstanceFactory(factory);
    SessionFactory sf = createSessionFactory(props, loader);
    final HazelcastInstance hz = HazelcastAccessor.getHazelcastInstance(sf);
    assertTrue(hz instanceof HazelcastClientProxy);
    assertEquals(1, main.getCluster().getMembers().size());
    HazelcastClientProxy client = (HazelcastClientProxy) hz;
    ClientConfig clientConfig = client.getClientConfig();
    assertEquals("dev-custom", clientConfig.getGroupConfig().getName());
    assertEquals("dev-pass", clientConfig.getGroupConfig().getPassword());
    assertTrue(clientConfig.getNetworkConfig().isSmartRouting());
    assertTrue(clientConfig.getNetworkConfig().isRedoOperation());
    factory.newHazelcastInstance(config);
    assertEquals(2, hz.getCluster().getMembers().size());
    main.shutdown();

    assertTrueEventually(new AssertTask() {
        @Override
        public void run() throws Exception {
            assertEquals(1, hz.getCluster().getMembers().size());
        }
    });

    assertEquals(1, hz.getCluster().getMembers().size());
    Session session = sf.openSession();
    Transaction tx = session.beginTransaction();
    session.save(new DummyEntity(1L, "dummy", 0, new Date()));
    tx.commit();
    session.close();
    sf.close();
    factory.shutdownAll();
}
 
開發者ID:hazelcast,項目名稱:hazelcast-hibernate,代碼行數:47,代碼來源:CustomPropertiesTest.java

示例8: testNativeClient

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
@Test
public void testNativeClient() throws Exception {
    TestHazelcastFactory factory = new TestHazelcastFactory();
    Config config = new ClasspathXmlConfig("hazelcast-custom.xml");
    HazelcastInstance main = factory.newHazelcastInstance(config);
    Properties props = getDefaultProperties();
    props.remove(CacheEnvironment.CONFIG_FILE_PATH_LEGACY);
    props.setProperty(Environment.CACHE_REGION_FACTORY, HazelcastCacheRegionFactory.class.getName());
    props.setProperty(CacheEnvironment.USE_NATIVE_CLIENT, "true");
    props.setProperty(CacheEnvironment.NATIVE_CLIENT_GROUP, "dev-custom");
    props.setProperty(CacheEnvironment.NATIVE_CLIENT_PASSWORD, "dev-pass");
    props.setProperty(CacheEnvironment.NATIVE_CLIENT_ADDRESS, "localhost");
    props.setProperty(CacheEnvironment.CONFIG_FILE_PATH,"hazelcast-client-custom.xml");
    HazelcastMockInstanceLoader loader = new HazelcastMockInstanceLoader();
    loader.configure(props);
    loader.setInstanceFactory(factory);
    SessionFactory sf = createSessionFactory(props, loader);
    final HazelcastInstance hz = HazelcastAccessor.getHazelcastInstance(sf);
    assertTrue(hz instanceof HazelcastClientProxy);
    assertEquals(1, main.getCluster().getMembers().size());
    HazelcastClientProxy client = (HazelcastClientProxy) hz;
    ClientConfig clientConfig = client.getClientConfig();
    assertEquals("dev-custom", clientConfig.getGroupConfig().getName());
    assertEquals("dev-pass", clientConfig.getGroupConfig().getPassword());
    assertTrue(clientConfig.getNetworkConfig().isSmartRouting());
    assertTrue(clientConfig.getNetworkConfig().isRedoOperation());
    factory.newHazelcastInstance(config);
    assertEquals(2, hz.getCluster().getMembers().size());
    main.shutdown();

    assertTrueEventually(new AssertTask() {
        @Override
        public void run() throws Exception {
            assertEquals(1, hz.getCluster().getMembers().size());
        }
    });

    Session session = sf.openSession();
    Transaction tx = session.beginTransaction();
    session.save(new DummyEntity(1L, "dummy", 0, new Date()));
    tx.commit();
    session.close();
    sf.close();
    factory.shutdownAll();
}
 
開發者ID:hazelcast,項目名稱:hazelcast-hibernate,代碼行數:46,代碼來源:CustomPropertiesTest.java


注:本文中的com.hazelcast.core.HazelcastInstance.shutdown方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。