@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); }
@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()); }
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(); }
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; }
private void checkConnected(){ Cluster cluster = instance_.getCluster(); if(cluster.getMembers().size() > 1 && !connected_){ connected(); } else if(connected_){ disconnected(); } }
@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); }
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(); }
@Override public Cluster getCluster() { return null; }
@Nonnull @Override public Cluster getCluster() { return getHazelcastInstance().getCluster(); }
private static Address masterAddress(Cluster cluster) { return cluster.getMembers().stream().findFirst() .orElseThrow(() -> new IllegalStateException("No members found in cluster")) .getAddress(); }
@Nonnull @Override public Cluster getCluster() { return instance.getCluster(); }
@Override public Cluster getCluster() { return getHazelcastInstance().getCluster(); }
@Override public boolean localMemberIsOldestMember() { Cluster cluster = getOurHazelcastInstance().getCluster(); return cluster.getLocalMember() == cluster.getMembers().iterator().next(); }
public Cluster getCluster() { return cache.getCluster(); }
/** * Returns information about the cluster this Jet instance is part of. */ @Nonnull Cluster getCluster();