• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LifecycleState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.hazelcast.core.LifecycleEvent.LifecycleState的典型用法代码示例。如果您正苦于以下问题:Java LifecycleState类的具体用法?Java LifecycleState怎么用?Java LifecycleState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LifecycleState类属于com.hazelcast.core.LifecycleEvent包,在下文中一共展示了LifecycleState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: stateChanged

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Override
public void stateChanged(LifecycleEvent event) {
	logger.info("stateChanged; event: {}", event);
	if (LifecycleState.STARTED == event.getState()) {
		xtxCache = nodeEngine.getHazelcastInstance().getMap(CN_XDM_TRANSACTION);
		xddCache = nodeEngine.getHazelcastInstance().getMap(CN_XDM_DOCUMENT);
		keyCache = nodeEngine.getHazelcastInstance().getMap(CN_XDM_KEY);
		//readCatalog(catalog);
		// too early
		//checkPopulation(nodeEngine.getClusterService().getSize());
	} else if (LifecycleState.SHUTTING_DOWN == event.getState()) {
		xtxCache.flush();
		xddCache.flush();
		logger.info("stateChanged; Maps were flushed");
	}
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:17,代码来源:PopulationManagementImpl.java


示例2: testGetConnection

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Test
public void testGetConnection() throws Exception {
    HazelcastClient client = mock(HazelcastClient.class);
    InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 5701);
    final Connection connection = mock(Connection.class);
    final CountDownLatch latch = new CountDownLatch(2);
    final List<LifecycleState> lifecycleEvents = new ArrayList<LifecycleState>();
    final LifecycleServiceClientImpl lifecycleService = createLifecycleServiceClientImpl(client, lifecycleEvents);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setCredentials(credentials).addInetSocketAddress(inetSocketAddress).setConnectionTimeout(60000);
    ConnectionManager connectionManager = new ConnectionManager(client, clientConfig, lifecycleService) {
        protected Connection getNextConnection() {
            latch.countDown();
            return connection;
        }
    };
    ClientBinder binder = mock(ClientBinder.class);
    connectionManager.setBinder(binder);
    connectionManager.getConnection();
    assertEquals(connection, connectionManager.getConnection());
    verify(binder).bind(connection, credentials);
    assertEquals(connection, connectionManager.getConnection());
    assertEquals(1, latch.getCount());
    assertArrayEquals(new Object[]{LifecycleState.CLIENT_CONNECTION_OPENING}, lifecycleEvents.toArray());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:26,代码来源:ConnectionManagerTest.java


示例3: testGetConnectionWhenThereIsNoConnection

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Test
public void testGetConnectionWhenThereIsNoConnection() throws Exception {
    HazelcastClient client = mock(HazelcastClient.class);
    InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 5701);
    final List<LifecycleState> lifecycleEvents = new ArrayList<LifecycleState>();
    final LifecycleServiceClientImpl lifecycleService = createLifecycleServiceClientImpl(client, lifecycleEvents);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setCredentials(credentials).addInetSocketAddress(inetSocketAddress).setConnectionTimeout(60000);
    ConnectionManager connectionManager = new ConnectionManager(client, clientConfig, lifecycleService) {
        protected Connection getNextConnection() {
            return null;
        }
    };
    ClientBinder binder = mock(ClientBinder.class);
    connectionManager.setBinder(binder);
    connectionManager.getConnection();
    assertEquals(null, connectionManager.getConnection());
    assertEquals(null, connectionManager.getConnection());
    assertArrayEquals(new Object[0], lifecycleEvents.toArray());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:21,代码来源:ConnectionManagerTest.java


示例4: testDifferentMemberAdded

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Test
public void testDifferentMemberAdded() throws Exception {
    HazelcastClient client = mock(HazelcastClient.class);
    InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 5701);
    final Connection connection = mock(Connection.class);
    final List<LifecycleState> lifecycleEvents = new ArrayList<LifecycleState>();
    final LifecycleServiceClientImpl lifecycleService = createLifecycleServiceClientImpl(client, lifecycleEvents);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setCredentials(credentials).addInetSocketAddress(inetSocketAddress).setConnectionTimeout(60000);
    ConnectionManager connectionManager = new ConnectionManager(client, clientConfig, lifecycleService) {
        protected Connection getNextConnection() {
            return connection;
        }
    };
    ClientBinder binder = mock(ClientBinder.class);
    connectionManager.setBinder(binder);
    Cluster cluster = mock(Cluster.class);
    InetSocketAddress inetSocketAddress2 = new InetSocketAddress("hostname", 5702);
    Member member = mock(Member.class);
    when(member.getInetSocketAddress()).thenReturn(inetSocketAddress2);
    MembershipEvent membershipEvent = new MembershipEvent(cluster, member, MembershipEvent.MEMBER_ADDED);
    connectionManager.memberAdded(membershipEvent);
    connectionManager.getClusterMembers().contains(inetSocketAddress2);
    assertEquals(2, connectionManager.getClusterMembers().size());
    assertArrayEquals(new Object[0], lifecycleEvents.toArray());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:27,代码来源:ConnectionManagerTest.java


示例5: testMemberRemoved

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Test
public void testMemberRemoved() throws Exception {
    HazelcastClient client = mock(HazelcastClient.class);
    InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 5701);
    final Connection connection = mock(Connection.class);
    final List<LifecycleState> lifecycleEvents = new ArrayList<LifecycleState>();
    final LifecycleServiceClientImpl lifecycleService = createLifecycleServiceClientImpl(client, lifecycleEvents);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setCredentials(credentials).addInetSocketAddress(inetSocketAddress).setConnectionTimeout(60000);
    ConnectionManager connectionManager = new ConnectionManager(client, clientConfig, lifecycleService) {
        protected Connection getNextConnection() {
            return connection;
        }
    };
    ClientBinder binder = mock(ClientBinder.class);
    connectionManager.setBinder(binder);
    Cluster cluster = mock(Cluster.class);
    Member member = mock(Member.class);
    when(member.getInetSocketAddress()).thenReturn(inetSocketAddress);
    MembershipEvent membershipEvent = new MembershipEvent(cluster, member, MembershipEvent.MEMBER_REMOVED);
    connectionManager.memberRemoved(membershipEvent);
    assertEquals(0, connectionManager.getClusterMembers().size());
    assertArrayEquals(new Object[0], lifecycleEvents.toArray());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:25,代码来源:ConnectionManagerTest.java


示例6: testShouldExecuteOnDisconnect

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Test
public void testShouldExecuteOnDisconnect() throws Exception {
    HazelcastClient client = mock(HazelcastClient.class);
    InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 5701);
    final Connection connection = mock(Connection.class);
    final List<LifecycleState> lifecycleEvents = new ArrayList<LifecycleState>();
    final LifecycleServiceClientImpl lifecycleService = createLifecycleServiceClientImpl(client, lifecycleEvents);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setCredentials(credentials).addInetSocketAddress(inetSocketAddress).setConnectionTimeout(60000);
    ConnectionManager connectionManager = new ConnectionManager(client, clientConfig, lifecycleService) {
        protected Connection getNextConnection() {
            return connection;
        }
    };
    assertTrue(connectionManager.shouldExecuteOnDisconnect(connection));
    assertFalse(connectionManager.shouldExecuteOnDisconnect(connection));
    assertArrayEquals(new Object[0], lifecycleEvents.toArray());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:19,代码来源:ConnectionManagerTest.java


示例7: waitFor

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
boolean waitFor(LifecycleEvent.LifecycleState state, int seconds) {
    long remainingMillis = TimeUnit.SECONDS.toMillis(seconds);
    while (remainingMillis >= 0) {
        LifecycleEvent.LifecycleState received = null;
        try {
            long now = Clock.currentTimeMillis();
            received = eventQueue.poll(remainingMillis, TimeUnit.MILLISECONDS);
            remainingMillis -= (Clock.currentTimeMillis() - now);
        } catch (InterruptedException e) {
            return false;
        }
        if (received != null && received == state) {
            return true;
        }
    }
    return false;
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:18,代码来源:SplitBrainHandlerTest.java


示例8: testConfigLifecycleListener

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Test
    public void testConfigLifecycleListener() throws InterruptedException {
        ClientConfig config = new ClientConfig();
        final BlockingQueue<LifecycleEvent> q = new LinkedBlockingQueue<LifecycleEvent>();
        config.addListener(new LifecycleListener() {
            public void stateChanged(final LifecycleEvent event) {
                q.offer(event);
                System.out.println(event);
            }
        });
        Hazelcast.getDefaultInstance();
        HazelcastClient client = HazelcastClient.newHazelcastClient(config);

        Assert.assertEquals(new LifecycleEvent(LifecycleState.STARTING), q.poll(3, TimeUnit.SECONDS));
        Assert.assertEquals(new LifecycleEvent(LifecycleState.CLIENT_CONNECTION_OPENING), q.poll(3, TimeUnit.SECONDS));
        Assert.assertEquals(new LifecycleEvent(LifecycleState.CLIENT_CONNECTION_OPENED), q.poll(3, TimeUnit.SECONDS));
        Assert.assertEquals(new LifecycleEvent(LifecycleState.STARTED), q.poll(3, TimeUnit.SECONDS));
        client.shutdown();
//        Assert.assertEquals(new LifecycleEvent(LifecycleState.CLIENT_CONNECTION_LOST), q.poll(3, TimeUnit.SECONDS));
        Assert.assertEquals(new LifecycleEvent(LifecycleState.SHUTTING_DOWN), q.poll(3, TimeUnit.SECONDS));
        Assert.assertEquals(new LifecycleEvent(LifecycleState.SHUTDOWN), q.poll(3, TimeUnit.SECONDS));
    }
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:23,代码来源:ListenerTest.java


示例9: testGetConnection

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Test
public void testGetConnection() throws Exception {
    HazelcastClient client = mock(HazelcastClient.class);
    InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 5701);
    final Connection connection = mock(Connection.class);
    final CountDownLatch latch = new CountDownLatch(2);
    final List<LifecycleState> lifecycleEvents = new ArrayList<LifecycleState>();
    final LifecycleServiceClientImpl lifecycleService = createLifecycleServiceClientImpl(client, lifecycleEvents);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setCredentials(credentials).addInetSocketAddress(inetSocketAddress).setConnectionTimeout(60000);
    ConnectionManager connectionManager = new ConnectionManager(client, clientConfig, lifecycleService) {
        protected Connection getNextConnection() {
            latch.countDown();
            return connection;
        }
    };
    ClientBinder binder = mock(ClientBinder.class);
    connectionManager.setBinder(binder);
    connectionManager.getConnection();
    assertEquals(connection, connectionManager.getConnection());
    verify(binder).bind(connection, credentials);
    assertEquals(connection, connectionManager.getConnection());
    assertEquals(1, latch.getCount());
    Thread.sleep(100); // wait a little events to be fired
    assertArrayEquals(new Object[]{LifecycleState.CLIENT_CONNECTION_OPENING}, lifecycleEvents.toArray());
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:27,代码来源:ConnectionManagerTest.java


示例10: stateChanged

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
public void stateChanged(LifecycleEvent event) {
    if (event.getState().equals(LifecycleState.SHUTDOWN)) {
        leaveCluster();
    } else if (event.getState().equals(LifecycleState.STARTED)) {
        joinCluster();
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:8,代码来源:ClusterListener.java


示例11: fireLifecycleEvent

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
public void fireLifecycleEvent(final LifecycleState lifecycleState) {
    callAsync(new Callable<Object>() {
        public Object call() throws Exception {
            fireLifecycleEvent(new LifecycleEvent(lifecycleState));
            return null;
        }
    });
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:9,代码来源:LifecycleServiceClientImpl.java


示例12: createLifecycleServiceClientImpl

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
private LifecycleServiceClientImpl createLifecycleServiceClientImpl(HazelcastClient hazelcastClient, final List<LifecycleState> lifecycleEvents) {
    final LifecycleServiceClientImpl lifecycleService = new LifecycleServiceClientImpl(hazelcastClient);
    lifecycleService.addLifecycleListener(new LifecycleListener() {

        public void stateChanged(LifecycleEvent event) {
            lifecycleEvents.add(event.getState());
        }
    });
    return lifecycleService;
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:11,代码来源:ConnectionManagerTest.java


示例13: testDestroyConnection

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Test
public void testDestroyConnection() throws Exception {
    HazelcastClient client = mock(HazelcastClient.class);
    InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 5701);
    final Connection connection = mock(Connection.class);
    final CountDownLatch latch = new CountDownLatch(2);
    final List<LifecycleState> lifecycleEvents = new ArrayList<LifecycleState>();
    final LifecycleServiceClientImpl lifecycleService = createLifecycleServiceClientImpl(client, lifecycleEvents);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setCredentials(credentials).addInetSocketAddress(inetSocketAddress).setConnectionTimeout(60000);
    ConnectionManager connectionManager = new ConnectionManager(client, clientConfig, lifecycleService) {
        protected Connection getNextConnection() {
            latch.countDown();
            return connection;
        }
    };
    ClientBinder binder = mock(ClientBinder.class);
    connectionManager.setBinder(binder);
    assertEquals(connection, connectionManager.getConnection());
    connectionManager.destroyConnection(connection);
    connectionManager.getConnection();
    assertTrue(latch.await(1, TimeUnit.SECONDS));
    assertArrayEquals(new Object[]{LifecycleState.CLIENT_CONNECTION_OPENING,
            LifecycleState.CLIENT_CONNECTION_LOST,
            LifecycleState.CLIENT_CONNECTION_OPENING},
            lifecycleEvents.toArray());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:28,代码来源:ConnectionManagerTest.java


示例14: testSameMemberAdded

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Test
public void testSameMemberAdded() throws Exception {
    HazelcastClient client = mock(HazelcastClient.class);
    InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 5701);
    final Connection connection = mock(Connection.class);
    final CountDownLatch latch = new CountDownLatch(2);
    final List<LifecycleState> lifecycleEvents = new ArrayList<LifecycleState>();
    final LifecycleServiceClientImpl lifecycleService = createLifecycleServiceClientImpl(client, lifecycleEvents);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setCredentials(credentials).addInetSocketAddress(inetSocketAddress).setConnectionTimeout(60000);
    ConnectionManager connectionManager = new ConnectionManager(client, clientConfig, lifecycleService) {
        protected Connection getNextConnection() {
            latch.countDown();
            return connection;
        }
    };
    ClientBinder binder = mock(ClientBinder.class);
    connectionManager.setBinder(binder);
    Cluster cluster = mock(Cluster.class);
    Member member = mock(Member.class);
    when(member.getInetSocketAddress()).thenReturn(inetSocketAddress);
    MembershipEvent membershipEvent = new MembershipEvent(cluster, member, MembershipEvent.MEMBER_ADDED);
    connectionManager.memberAdded(membershipEvent);
    connectionManager.getClusterMembers().contains(inetSocketAddress);
    assertEquals(1, connectionManager.getClusterMembers().size());
    assertArrayEquals(new Object[0], lifecycleEvents.toArray());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:28,代码来源:ConnectionManagerTest.java


示例15: testUpdateMembers

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Test
public void testUpdateMembers() throws Exception {
    HazelcastClient client = mock(HazelcastClient.class);
    Cluster cluster = mock(Cluster.class);
    when(client.getCluster()).thenReturn(cluster);
    Set<Member> members = new HashSet<Member>();
    Member member1 = mock(Member.class);
    Member member2 = mock(Member.class);
    Member member3 = mock(Member.class);
    InetSocketAddress inetSocketAddress1 = new InetSocketAddress("localhost", 9701);
    InetSocketAddress inetSocketAddress2 = new InetSocketAddress("localhost", 9702);
    InetSocketAddress inetSocketAddress3 = new InetSocketAddress("localhost", 9703);
    when(member1.getInetSocketAddress()).thenReturn(inetSocketAddress1);
    when(member2.getInetSocketAddress()).thenReturn(inetSocketAddress2);
    when(member3.getInetSocketAddress()).thenReturn(inetSocketAddress3);
    members.add(member1);
    members.add(member2);
    members.add(member3);
    when(cluster.getMembers()).thenReturn(members);
    InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 5701);
    final Connection connection = mock(Connection.class);
    final List<LifecycleState> lifecycleEvents = new ArrayList<LifecycleState>();
    final LifecycleServiceClientImpl lifecycleService = createLifecycleServiceClientImpl(client, lifecycleEvents);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setCredentials(credentials).addInetSocketAddress(inetSocketAddress).setConnectionTimeout(60000);
    ConnectionManager connectionManager = new ConnectionManager(client, clientConfig, lifecycleService) {
        protected Connection getNextConnection() {
            return connection;
        }
    };
    ClientBinder binder = mock(ClientBinder.class);
    connectionManager.setBinder(binder);
    connectionManager.updateMembers();
    assertTrue(connectionManager.getClusterMembers().contains(inetSocketAddress1));
    assertTrue(connectionManager.getClusterMembers().contains(inetSocketAddress2));
    assertTrue(connectionManager.getClusterMembers().contains(inetSocketAddress3));
    assertFalse(connectionManager.getClusterMembers().contains(inetSocketAddress));
    assertEquals(3, connectionManager.getClusterMembers().size());
    assertArrayEquals(new Object[0], lifecycleEvents.toArray());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:41,代码来源:ConnectionManagerTest.java


示例16: stateChanged

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
/**
 * On {@link com.hazelcast.core.LifecycleEvent.LifecycleState} MERGED event all the topic listeners for the local node is added back. Since the data structures except for
 * IMaps are not merged after a split brain scenario within Hazelcast (data structures from MERGED nodes are
 * discarded)
 * @param lifecycleEvent {@link LifecycleEvent}
 */
@Override
public void stateChanged(LifecycleEvent lifecycleEvent) {
    try {
        log.info("Hazelcast instance lifecycle changed state to " + lifecycleEvent.getState());
        if (lifecycleEvent.getState() == LifecycleEvent.LifecycleState.MERGED) {
            log.info("Hazelcast cluster merge detected after a split brain. Updating unmerged data structures");
            AndesContext.getInstance().getClusterNotificationListenerManager().reInitializeListener();
            AndesSubscriptionManager andesSubscriptionManager = AndesContext.getInstance()
                    .getAndesSubscriptionManager();
            if(null != andesSubscriptionManager) {
                andesSubscriptionManager.updateSubscriptionsAfterClusterMerge();
            } else {
                log.error("Andes Subscription Manager is not set. Local subscriptions are not synced with the " +
                        "main cluster");
            }
            
            // Notify that network partition has occurred.
            networkPartitionDetector.networkPartitionMerged();

        } else if (lifecycleEvent.getState() == LifecycleState.SHUTDOWN){
            networkPartitionDetector.clusterOutageOccurred();
        }


    } catch (Throwable e) {
        log.error("Error occurred while handling Hazelcast state change event " + lifecycleEvent.getState(), e);
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:35,代码来源:HazelcastLifecycleListener.java


示例17: stateChanged

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
public void stateChanged(LifecycleEvent event) {
	if (event.getState().equals(LifecycleState.SHUTDOWN)) {
		leaveCluster();
	} else if (event.getState().equals(LifecycleState.STARTED)) {
		joinCluster();
	}
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:8,代码来源:ClusterListener.java


示例18: stateChanged

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
public void stateChanged(final LifecycleEvent event) {
    if (event.getState() == LifecycleState.STARTED && managementCenterConfig.isEnabled()) {
        try {
            start();
        } catch (Exception e) {
            logger.log(Level.SEVERE, "ManagementCenterService could not be started!", e);
        }
    }
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:10,代码来源:ManagementCenterService.java


示例19: testDestroyConnection

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Test
public void testDestroyConnection() throws Exception {
    HazelcastClient client = mock(HazelcastClient.class);
    InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 5701);
    final Connection connection = mock(Connection.class);
    final CountDownLatch latch = new CountDownLatch(2);
    final List<LifecycleState> lifecycleEvents = new ArrayList<LifecycleState>();
    final LifecycleServiceClientImpl lifecycleService = createLifecycleServiceClientImpl(client, lifecycleEvents);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setCredentials(credentials).addInetSocketAddress(inetSocketAddress).setConnectionTimeout(60000);
    ConnectionManager connectionManager = new ConnectionManager(client, clientConfig, lifecycleService) {
        protected Connection getNextConnection() {
            latch.countDown();
            return connection;
        }
    };
    ClientBinder binder = mock(ClientBinder.class);
    connectionManager.setBinder(binder);
    assertEquals(connection, connectionManager.getConnection());
    connectionManager.destroyConnection(connection);
    connectionManager.getConnection();
    assertTrue(latch.await(1, TimeUnit.SECONDS));
    Thread.sleep(100); // wait a little events to be fired
    assertArrayEquals(new Object[]{LifecycleState.CLIENT_CONNECTION_OPENING,
            LifecycleState.CLIENT_CONNECTION_LOST,
            LifecycleState.CLIENT_CONNECTION_OPENING},
            lifecycleEvents.toArray());
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:29,代码来源:ConnectionManagerTest.java


示例20: testSameMemberAdded

import com.hazelcast.core.LifecycleEvent.LifecycleState; //导入依赖的package包/类
@Test
@Ignore
public void testSameMemberAdded() throws Exception {
    HazelcastClient client = mock(HazelcastClient.class);
    InetSocketAddress inetSocketAddress = new InetSocketAddress("localhost", 5701);
    final Connection connection = mock(Connection.class);
    final CountDownLatch latch = new CountDownLatch(2);
    final List<LifecycleState> lifecycleEvents = new ArrayList<LifecycleState>();
    final LifecycleServiceClientImpl lifecycleService = createLifecycleServiceClientImpl(client, lifecycleEvents);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setCredentials(credentials).addInetSocketAddress(inetSocketAddress).setConnectionTimeout(60000);
    ConnectionManager connectionManager = new ConnectionManager(client, clientConfig, lifecycleService) {
        protected Connection getNextConnection() {
            latch.countDown();
            return connection;
        }
    };
    ClientBinder binder = mock(ClientBinder.class);
    connectionManager.setBinder(binder);
    Cluster cluster = mock(Cluster.class);
    Member member = mock(Member.class);
    when(member.getInetSocketAddress()).thenReturn(inetSocketAddress);
    MembershipEvent membershipEvent = new MembershipEvent(cluster, member, MembershipEvent.MEMBER_ADDED);
    connectionManager.memberAdded(membershipEvent);
    connectionManager.getClusterMembers().contains(inetSocketAddress);
    assertEquals(1, connectionManager.getClusterMembers().size());
    assertArrayEquals(new Object[0], lifecycleEvents.toArray());
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:29,代码来源:ConnectionManagerTest.java



注:本文中的com.hazelcast.core.LifecycleEvent.LifecycleState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XQueryExpression类代码示例发布时间:2022-05-23
下一篇:
Java MutableTriple类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap