Java 类com.hazelcast.core.Cluster 实例源码

项目:hazelcast-hibernate5    文件:HazelcastTimestampsRegionTest.java   
@Before
public void setUp() throws Exception {
    mapConfig = mock(MapConfig.class);
    when(mapConfig.getMaxSizeConfig()).thenReturn(new MaxSizeConfig(50, MaxSizeConfig.MaxSizePolicy.PER_NODE));
    when(mapConfig.getTimeToLiveSeconds()).thenReturn(timeout);

    config = mock(Config.class);
    when(config.findMapConfig(eq(REGION_NAME))).thenReturn(mapConfig);

    Cluster cluster = mock(Cluster.class);
    when(cluster.getClusterTime()).thenAnswer(new Answer<Long>() {
        @Override
        public Long answer(InvocationOnMock invocation) throws Throwable {
            return System.currentTimeMillis();
        }
    });

    instance = mock(HazelcastInstance.class);
    when(instance.getConfig()).thenReturn(config);
    when(instance.getCluster()).thenReturn(cluster);

    cache = mock(RegionCache.class);

    region = new HazelcastTimestampsRegion<RegionCache>(instance, REGION_NAME, new Properties(), cache);
}
项目:hazelcast-hibernate5    文件:HazelcastQueryResultsRegionTest.java   
@Before
public void setUp() throws Exception {
    mapConfig = mock(MapConfig.class);
    when(mapConfig.getMaxSizeConfig()).thenReturn(new MaxSizeConfig(maxSize, MaxSizeConfig.MaxSizePolicy.PER_NODE));
    when(mapConfig.getTimeToLiveSeconds()).thenReturn(timeout);

    config = mock(Config.class);
    when(config.findMapConfig(eq(REGION_NAME))).thenReturn(mapConfig);

    Cluster cluster = mock(Cluster.class);
    when(cluster.getClusterTime()).thenAnswer(new Answer<Long>() {
        @Override
        public Long answer(InvocationOnMock invocation) throws Throwable {
            return System.currentTimeMillis();
        }
    });

    instance = mock(HazelcastInstance.class);
    when(instance.getConfig()).thenReturn(config);
    when(instance.getCluster()).thenReturn(cluster);

    region = new HazelcastQueryResultsRegion(instance, REGION_NAME, new Properties());
}
项目:hazelcast-hibernate    文件:HazelcastTimestampsRegionTest.java   
@Before
public void setUp() throws Exception {
    mapConfig = mock(MapConfig.class);
    when(mapConfig.getMaxSizeConfig()).thenReturn(new MaxSizeConfig(50, MaxSizeConfig.MaxSizePolicy.PER_NODE));
    when(mapConfig.getTimeToLiveSeconds()).thenReturn(timeout);

    config = mock(Config.class);
    when(config.findMapConfig(eq(REGION_NAME))).thenReturn(mapConfig);

    Cluster cluster = mock(Cluster.class);
    when(cluster.getClusterTime()).thenAnswer(new Answer<Long>() {
        @Override
        public Long answer(InvocationOnMock invocation) throws Throwable {
            return System.currentTimeMillis();
        }
    });

    instance = mock(HazelcastInstance.class);
    when(instance.getConfig()).thenReturn(config);
    when(instance.getCluster()).thenReturn(cluster);

    cache = mock(RegionCache.class);

    region = new HazelcastTimestampsRegion<RegionCache>(instance, REGION_NAME, new Properties(), cache);
}
项目:hazelcast-hibernate    文件:HazelcastQueryResultsRegionTest.java   
@Before
public void setUp() throws Exception {
    mapConfig = mock(MapConfig.class);
    when(mapConfig.getMaxSizeConfig()).thenReturn(new MaxSizeConfig(maxSize, MaxSizeConfig.MaxSizePolicy.PER_NODE));
    when(mapConfig.getTimeToLiveSeconds()).thenReturn(timeout);

    config = mock(Config.class);
    when(config.findMapConfig(eq(REGION_NAME))).thenReturn(mapConfig);

    Cluster cluster = mock(Cluster.class);
    when(cluster.getClusterTime()).thenAnswer(new Answer<Long>() {
        @Override
        public Long answer(InvocationOnMock invocation) throws Throwable {
            return System.currentTimeMillis();
        }
    });

    instance = mock(HazelcastInstance.class);
    when(instance.getConfig()).thenReturn(config);
    when(instance.getCluster()).thenReturn(cluster);

    region = new HazelcastQueryResultsRegion(instance, REGION_NAME, new Properties());
}
项目:hazelcast-hibernate    文件:HazelcastTimestampsRegionTest.java   
@Before
public void setUp() throws Exception {
    mapConfig = mock(MapConfig.class);
    when(mapConfig.getMaxSizeConfig()).thenReturn(new MaxSizeConfig(50, MaxSizeConfig.MaxSizePolicy.PER_NODE));
    when(mapConfig.getTimeToLiveSeconds()).thenReturn(timeout);

    config = mock(Config.class);
    when(config.findMapConfig(eq(REGION_NAME))).thenReturn(mapConfig);

    Cluster cluster = mock(Cluster.class);
    when(cluster.getClusterTime()).thenAnswer(new Answer<Long>() {
        @Override
        public Long answer(InvocationOnMock invocation) throws Throwable {
            return System.currentTimeMillis();
        }
    });

    instance = mock(HazelcastInstance.class);
    when(instance.getConfig()).thenReturn(config);
    when(instance.getCluster()).thenReturn(cluster);

    cache = mock(RegionCache.class);

    region = new HazelcastTimestampsRegion<RegionCache>(instance, REGION_NAME, new Properties(), cache);
}
项目:hazelcast-hibernate    文件:HazelcastQueryResultsRegionTest.java   
@Before
public void setUp() throws Exception {
    mapConfig = mock(MapConfig.class);
    when(mapConfig.getMaxSizeConfig()).thenReturn(new MaxSizeConfig(maxSize, MaxSizeConfig.MaxSizePolicy.PER_NODE));
    when(mapConfig.getTimeToLiveSeconds()).thenReturn(timeout);

    config = mock(Config.class);
    when(config.findMapConfig(eq(REGION_NAME))).thenReturn(mapConfig);

    Cluster cluster = mock(Cluster.class);
    when(cluster.getClusterTime()).thenAnswer(new Answer<Long>() {
        @Override
        public Long answer(InvocationOnMock invocation) throws Throwable {
            return System.currentTimeMillis();
        }
    });

    instance = mock(HazelcastInstance.class);
    when(instance.getConfig()).thenReturn(config);
    when(instance.getCluster()).thenReturn(cluster);

    region = new HazelcastQueryResultsRegion(instance, REGION_NAME, new Properties());
}
项目:Openfire    文件:ClusterListener.java   
public ClusterListener(Cluster cluster) {

    this.cluster = cluster;
    for (Member member : cluster.getMembers()) {
        clusterNodesInfo.put(member.getUuid(), 
                new HazelcastClusterNodeInfo(member, cluster.getClusterTime()));
    }

    C2SCache = CacheFactory.createCache(RoutingTableImpl.C2S_CACHE_NAME);
    anonymousC2SCache = CacheFactory.createCache(RoutingTableImpl.ANONYMOUS_C2S_CACHE_NAME);
    S2SCache = CacheFactory.createCache(RoutingTableImpl.S2S_CACHE_NAME);
    componentsCache = CacheFactory.createCache(RoutingTableImpl.COMPONENT_CACHE_NAME);

    sessionInfoCache = CacheFactory.createCache(SessionManager.C2S_INFO_CACHE_NAME);
    componentSessionsCache = CacheFactory.createCache(SessionManager.COMPONENT_SESSION_CACHE_NAME);
    multiplexerSessionsCache = CacheFactory.createCache(SessionManager.CM_CACHE_NAME);
    incomingServerSessionsCache = CacheFactory.createCache(SessionManager.ISS_CACHE_NAME);

    directedPresencesCache = CacheFactory.createCache(PresenceUpdateHandler.PRESENCE_CACHE_NAME);

    joinCluster();
}
项目:openfire    文件:ClusterListener.java   
public ClusterListener(Cluster cluster) {

    this.cluster = cluster;
    for (Member member : cluster.getMembers()) {
        clusterNodesInfo.put(member.getUuid(), 
                new HazelcastClusterNodeInfo(member, cluster.getClusterTime()));
    }

    C2SCache = CacheFactory.createCache(RoutingTableImpl.C2S_CACHE_NAME);
    anonymousC2SCache = CacheFactory.createCache(RoutingTableImpl.ANONYMOUS_C2S_CACHE_NAME);
    S2SCache = CacheFactory.createCache(RoutingTableImpl.S2S_CACHE_NAME);
    componentsCache = CacheFactory.createCache(RoutingTableImpl.COMPONENT_CACHE_NAME);

    sessionInfoCache = CacheFactory.createCache(SessionManager.C2S_INFO_CACHE_NAME);
    componentSessionsCache = CacheFactory.createCache(SessionManager.COMPONENT_SESSION_CACHE_NAME);
    multiplexerSessionsCache = CacheFactory.createCache(SessionManager.CM_CACHE_NAME);
    incomingServerSessionsCache = CacheFactory.createCache(SessionManager.ISS_CACHE_NAME);

    directedPresencesCache = CacheFactory.createCache(PresenceUpdateHandler.PRESENCE_CACHE_NAME);

    joinCluster();
}
项目:hazelcast-simulator    文件:HazelcastUtilsTest.java   
private HazelcastInstance createMockHazelcastInstance(Member member, boolean returnMember, Exception getClusterException) {
    Set<Member> memberSet = new HashSet<Member>();
    memberSet.add(member);

    Cluster cluster = mock(Cluster.class);
    when(cluster.getMembers()).thenReturn(memberSet);
    when(cluster.getLocalMember()).thenReturn(returnMember ? member : null);

    HazelcastInstance hazelcastInstance = mock(HazelcastInstance.class);
    when(hazelcastInstance.getLocalEndpoint()).thenReturn(returnMember ? member : null);
    if (getClusterException == null) {
        when(hazelcastInstance.getCluster()).thenReturn(cluster);
    } else {
        when(hazelcastInstance.getCluster()).thenReturn(cluster).thenThrow(getClusterException);
    }

    return hazelcastInstance;
}
项目:CSX278    文件:HazelcastTransport.java   
private void checkConnected(){
    Cluster cluster = instance_.getCluster();
    if(cluster.getMembers().size() > 1 && !connected_){
        connected();
    } else if(connected_){
        disconnected();
    }
}
项目:hazelcast-simulator    文件:HazelcastUtilsTest.java   
@Test
public void testGetHazelcastAddress_withClientWorker_oldHazelcastVersion() {
    Cluster cluster = mock(Cluster.class);
    when(cluster.getLocalMember()).thenThrow(new UnsupportedOperationException("Client has no local member!"));

    hazelcastInstance = mock(HazelcastInstance.class);
    when(hazelcastInstance.getLocalEndpoint()).thenThrow(new NoSuchMethodError("expected exception"));
    when(hazelcastInstance.getCluster()).thenReturn(cluster);

    String address = getHazelcastAddress("javaclient", "172.16.16.1", hazelcastInstance);

    assertEquals("client:172.16.16.1", address);
}
项目:openfire-bespoke    文件:ClusterListener.java   
public ClusterListener(Cluster cluster) {

    this.cluster = cluster;
    for (Member member : cluster.getMembers()) {
        clusterNodesInfo.put(member.getUuid(), 
                new HazelcastClusterNodeInfo(member, cluster.getClusterTime()));
    }

    C2SCache = CacheFactory.createCache(RoutingTableImpl.C2S_CACHE_NAME);
    anonymousC2SCache = CacheFactory.createCache(RoutingTableImpl.ANONYMOUS_C2S_CACHE_NAME);
    S2SCache = CacheFactory.createCache(RoutingTableImpl.S2S_CACHE_NAME);
    componentsCache = CacheFactory.createCache(RoutingTableImpl.COMPONENT_CACHE_NAME);

    sessionInfoCache = CacheFactory.createCache(SessionManager.C2S_INFO_CACHE_NAME);
    componentSessionsCache = CacheFactory.createCache(SessionManager.COMPONENT_SESSION_CACHE_NAME);
    multiplexerSessionsCache = CacheFactory.createCache(SessionManager.CM_CACHE_NAME);
    incomingServerSessionsCache = CacheFactory.createCache(SessionManager.ISS_CACHE_NAME);

    directedPresencesCache = CacheFactory.createCache(PresenceUpdateHandler.PRESENCE_CACHE_NAME);

    addEntryListener(C2SCache, new CacheListener(this, C2SCache.getName()));
    addEntryListener(anonymousC2SCache, new CacheListener(this, anonymousC2SCache.getName()));
    addEntryListener(S2SCache, new CacheListener(this, S2SCache.getName()));
    addEntryListener(componentsCache, new ComponentCacheListener());

    addEntryListener(sessionInfoCache, new CacheListener(this, sessionInfoCache.getName()));
    addEntryListener(componentSessionsCache, new CacheListener(this, componentSessionsCache.getName()));
    addEntryListener(multiplexerSessionsCache, new CacheListener(this, multiplexerSessionsCache.getName()));
    addEntryListener(incomingServerSessionsCache, new CacheListener(this, incomingServerSessionsCache.getName()));

    addEntryListener(directedPresencesCache, new DirectedPresenceListener());

    joinCluster();
}
项目:xm-ms-entity    文件:WebConfigurerIntTest.java   
@Override
public Cluster getCluster() {
    return null;
}
项目:hazelcast-jet    文件:AbstractJetInstance.java   
@Nonnull @Override
public Cluster getCluster() {
    return getHazelcastInstance().getCluster();
}
项目:hazelcast-jet    文件:JetClientInstanceImpl.java   
private static Address masterAddress(Cluster cluster) {
    return cluster.getMembers().stream().findFirst()
                  .orElseThrow(() -> new IllegalStateException("No members found in cluster"))
                  .getAddress();
}
项目:hazelcast-jet    文件:JetBootstrap.java   
@Nonnull @Override
public Cluster getCluster() {
    return instance.getCluster();
}
项目:Cherry    文件:HazelcastService.java   
@Override
public Cluster getCluster() {
  return getHazelcastInstance().getCluster();
}
项目:tesora-dve-pub    文件:HazelcastCoordinationServices.java   
@Override
public boolean localMemberIsOldestMember() {
    Cluster cluster = getOurHazelcastInstance().getCluster();
    return cluster.getLocalMember() == cluster.getMembers().iterator().next();
}
项目:gw2live    文件:HazelcastCache.java   
public Cluster getCluster() {
    return cache.getCluster();
}
项目:hazelcast-jet    文件:JetInstance.java   
/**
 * Returns information about the cluster this Jet instance is part of.
 */
@Nonnull
Cluster getCluster();