本文整理汇总了Java中com.hazelcast.core.Cluster类的典型用法代码示例。如果您正苦于以下问题:Java Cluster类的具体用法?Java Cluster怎么用?Java Cluster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Cluster类属于com.hazelcast.core包,在下文中一共展示了Cluster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import com.hazelcast.core.Cluster; //导入依赖的package包/类
@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);
}
示例2: setUp
import com.hazelcast.core.Cluster; //导入依赖的package包/类
@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());
}
示例3: ClusterListener
import com.hazelcast.core.Cluster; //导入依赖的package包/类
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();
}
示例4: ClusterListener
import com.hazelcast.core.Cluster; //导入依赖的package包/类
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();
}
示例5: createMockHazelcastInstance
import com.hazelcast.core.Cluster; //导入依赖的package包/类
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;
}
示例6: checkConnected
import com.hazelcast.core.Cluster; //导入依赖的package包/类
private void checkConnected(){
Cluster cluster = instance_.getCluster();
if(cluster.getMembers().size() > 1 && !connected_){
connected();
} else if(connected_){
disconnected();
}
}
示例7: testGetHazelcastAddress_withClientWorker_oldHazelcastVersion
import com.hazelcast.core.Cluster; //导入依赖的package包/类
@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);
}
示例8: ClusterListener
import com.hazelcast.core.Cluster; //导入依赖的package包/类
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();
}
示例9: getCluster
import com.hazelcast.core.Cluster; //导入依赖的package包/类
@Override
public Cluster getCluster() {
return null;
}
示例10: getCluster
import com.hazelcast.core.Cluster; //导入依赖的package包/类
@Nonnull @Override
public Cluster getCluster() {
return getHazelcastInstance().getCluster();
}
示例11: masterAddress
import com.hazelcast.core.Cluster; //导入依赖的package包/类
private static Address masterAddress(Cluster cluster) {
return cluster.getMembers().stream().findFirst()
.orElseThrow(() -> new IllegalStateException("No members found in cluster"))
.getAddress();
}
示例12: getCluster
import com.hazelcast.core.Cluster; //导入依赖的package包/类
@Nonnull @Override
public Cluster getCluster() {
return instance.getCluster();
}
示例13: getCluster
import com.hazelcast.core.Cluster; //导入依赖的package包/类
@Override
public Cluster getCluster() {
return getHazelcastInstance().getCluster();
}
示例14: localMemberIsOldestMember
import com.hazelcast.core.Cluster; //导入依赖的package包/类
@Override
public boolean localMemberIsOldestMember() {
Cluster cluster = getOurHazelcastInstance().getCluster();
return cluster.getLocalMember() == cluster.getMembers().iterator().next();
}
示例15: getCluster
import com.hazelcast.core.Cluster; //导入依赖的package包/类
public Cluster getCluster() {
return cache.getCluster();
}