@Override public void close() { esConnector.stop(); if (hzMember != null) { if (healthStateSharing != null) { healthStateSharing.stop(); } try { // Removing listeners operationalProcesses.removeEntryListener(operationalProcessListenerUUID); hzMember.getCluster().removeMembershipListener(nodeDisconnectedListenerUUID); // Removing the operationalProcess from the replicated map operationalProcesses.keySet().forEach( clusterNodeProcess -> { if (clusterNodeProcess.getNodeUuid().equals(hzMember.getUuid())) { operationalProcesses.remove(clusterNodeProcess); } }); // Shutdown Hazelcast properly hzMember.close(); } catch (HazelcastInstanceNotActiveException e) { // hazelcastCluster may be already closed by the shutdown hook LOGGER.debug("Unable to close Hazelcast cluster", e); } } }
public V remove(K key) { return map.remove(key); }
public void removeQueries(Set<Integer> qKeys) { for (Integer qKey: qKeys) { xqCache.remove(qKey); } }
@Override public void close() { if (hzMember != null) { if (healthStateSharing != null) { healthStateSharing.stop(); } try { // Removing listeners operationalProcesses.removeEntryListener(operationalProcessListenerUUID); hzMember.getCluster().removeMembershipListener(nodeDisconnectedListenerUUID); // Removing the operationalProcess from the replicated map operationalProcesses.keySet().forEach( clusterNodeProcess -> { if (clusterNodeProcess.getNodeUuid().equals(hzMember.getUuid())) { operationalProcesses.remove(clusterNodeProcess); } }); // Shutdown Hazelcast properly hzMember.close(); } catch (HazelcastInstanceNotActiveException e) { // hazelcastCluster may be already closed by the shutdown hook LOGGER.debug("Unable to close Hazelcast cluster", e); } } }
private void delete(Object oid) { this.cache.remove(oid); }
public V remove(K key) { return map.remove(key); }
@Override public void clientDisconnected(Client client) { String clientId = client.getUuid(); logger.trace("clientDisconnected.enter; client: {}", clientId); // check and destroy client's resources for (Map.Entry<String, Properties> entry: clientsCache.entrySet()) { Properties props = entry.getValue(); String uuid = props.getProperty(pn_client_memberId); if (clientId.equals(uuid)) { clientsCache.remove(entry.getKey()); } } }
@TimeStep(prob = -1) public void remove(ThreadState state) { int key = state.randomInt(keyCount); map.remove(key); }
public static void main(String[] args) { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); ReplicatedMap<String, String> map = hz.getReplicatedMap("somemap"); String key = "" + System.nanoTime(); String value = "1"; map.put(key, value); map.put(key, "2"); map.remove(key); hz.shutdown(); } }
@Override public void memberRemoved(MembershipEvent membershipEvent) { replicatedMap.remove(membershipEvent.getMember().getUuid()); }
@Override public Path[] dropIndex(Index index) throws BagriException { // we must not do translate here! Set<Integer> paths = getPathsForIndex(index); Path[] result = new Path[paths.size()]; int idx = 0; for (Integer pathId: paths) { idxDict.remove(pathId); //indexStats.deleteStats(index.getName()); if (index.isRange()) { rangeIndex.remove(pathId); logger.trace("deleteIndex; unregistered range index path: {}", index.getName()); } result[idx] = mdlMgr.getPath(pathId); idx++; } patterns.remove(index); return result; }
@Override public void run() { if (hzClient.getLifecycleService().isRunning()) { ReplicatedMap<String, Properties> clientProps = hzClient.getReplicatedMap(CN_XDM_CLIENT); clientProps.remove(clientId); if (shutdown) { logger.info("disconnect; shutting down HZ instance: {}", hzClient.getLocalEndpoint().getUuid()); long stamp = System.currentTimeMillis(); hzClient.getLifecycleService().shutdown(); logger.info("disconnect; instance shutdown, time taken: {}", System.currentTimeMillis() - stamp); } } else { logger.info("disconnect; attempted to shutdown not-running client!"); } } }.start();
@ManagedOperation(description="Disconnects active client") @ManagedOperationParameters({ @ManagedOperationParameter(name = "clientId", description = "Client identifier")}) public boolean disconnectClient(String clientId) { // not equals to kill node! just kill the particular client // don't see how to implement this. must perform client.doShutdown on the client side.. // thus, client should listen on some command topic! for (Client c: this.hzClient.getClientService().getConnectedClients()) { if (clientId.equals(c.getUuid())) { logger.info("disconnectClient; found client: {}", c); break; } } // then remove it from clients, at least return clientCache.remove(clientId) != null; }
@Override public void destroy() { try { ILock lock = hazelcastInstance.getLock(nodeId); lock.lock(); try { Set<String> urls = replicatedMap.remove(nodeId); notify(toUrl(urls)); } finally { lock.unlock(); } hazelcastInstance.shutdown(); } catch (Exception e) { logger.warn(e.getMessage()); } }
@Test public void testEventDrivenForOnlyREMOVEDEntryEvent() { edReplicatedMap3 .put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1")); edReplicatedMap3 .put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2")); edReplicatedMap3.remove(2); Message<?> msg = edReplicatedMapChannel3 .receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT); Assert.assertNotNull(msg); Assert.assertNotNull(msg.getPayload()); Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload); Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER)); Assert.assertEquals(EntryEventType.REMOVED.name(), msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE)); Assert.assertEquals("edReplicatedMap3", msg.getHeaders().get(HazelcastHeaders.CACHE_NAME)); Assert.assertEquals(Integer.valueOf(2), ((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg .getPayload()).key); Assert.assertEquals(2, (((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg .getPayload()).oldValue).getId()); Assert.assertEquals("TestName2", (((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg .getPayload()).oldValue).getName()); Assert.assertEquals("TestSurname2", (((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg .getPayload()).oldValue).getSurname()); }
public static void testEventDrivenForReplicatedMapEntryEvents( final ReplicatedMap<Integer, HazelcastIntegrationTestUser> replicatedMap, final PollableChannel channel, final String cacheName) { replicatedMap .put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1")); Message<?> msg = channel.receive(TIMEOUT); verifyEntryEvent(msg, cacheName, EntryEventType.ADDED); replicatedMap.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurnameUpdated")); msg = channel.receive(TIMEOUT); verifyEntryEvent(msg, cacheName, EntryEventType.UPDATED); replicatedMap.remove(1); msg = channel.receive(TIMEOUT); verifyEntryEvent(msg, cacheName, EntryEventType.REMOVED); replicatedMap .put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2")); msg = channel.receive(TIMEOUT); verifyEntryEvent(msg, cacheName, EntryEventType.ADDED); }