@Override public String getUuid() { return hzInstance.getLocalEndpoint().getUuid(); }
private String nextMarkerId() { return hazelcastInstance.getLocalEndpoint().getUuid() + markerIdCounter.getAndIncrement(); }
private String nextMarkerId() { return hazelcastInstance.getLocalEndpoint().getUuid() + markerIdCounter.getAndIncrement(); }
private String nextMarkerId() { return hazelcastInstance.getLocalEndpoint().getUuid() + markerIdCounter.getAndIncrement(); }
private String nextMarkerId() { return hazelcastInstance.getLocalEndpoint().getUuid() + markerIdCounter.getAndIncrement(); }
private Object addEdgeServer( HazelcastInstance hazelcastInstance ) { String uuid = hazelcastInstance.getLocalEndpoint().getUuid(); String addresses = connectorAddresses.toString(); log.debug( "Adding edge server into cluster (%s -> %s)", uuid, addresses ); return hazelcastInstance.getMap( EDGE_SERVER_BOLT_ADDRESS_MAP_NAME ) .put( uuid, addresses, edgeTimeToLiveTimeout, MILLISECONDS ); }
@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();
private void disconnectFromCore() { try { String uuid = hzInstance.apply( hzInstance -> hzInstance.getLocalEndpoint().getUuid() ); hzInstance.apply( hz -> hz.getMap( READ_REPLICA_BOLT_ADDRESS_MAP ).remove( uuid ) ); hzInstance.shutdown(); } catch ( Throwable e ) { // Hazelcast is not able to stop correctly sometimes and throws a bunch of different exceptions // let's simply log the current problem but go on with our shutdown log.warn( "Unable to shutdown hazelcast cleanly", e ); } }
@Override public synchronized void stop() throws Throwable { if ( hazelcastInstance != null ) { try { String uuid = hazelcastInstance.getLocalEndpoint().getUuid(); hazelcastInstance.getMap( EDGE_SERVER_BOLT_ADDRESS_MAP_NAME ).remove( uuid ); hazelcastInstance.shutdown(); } catch ( HazelcastException | HazelcastClientNotActiveException | HazelcastInstanceNotActiveException e ) { /* Sometimes on shutdown hazelcast throws a Hazelcast exception with a RetryableIOException as a cause * because it failed to send some packets on the network, since we are shutting it down we don't really * care */ if ( e instanceof HazelcastException && !(e.getCause() instanceof RetryableIOException) ) { throw e; } log.info( "Unable to shutdown Hazelcast", e ); } } edgeRefreshTimer.cancel(); }
private void keepReadReplicaAlive() throws HazelcastInstanceNotActiveException { hzInstance.perform( hazelcastInstance -> { String uuid = hazelcastInstance.getLocalEndpoint().getUuid(); String addresses = connectorAddresses.toString(); log.debug( "Adding read replica into cluster (%s -> %s)", uuid, addresses ); hazelcastInstance.getMap( READ_REPLICAS_DB_NAME_MAP ).put( uuid, dbName, timeToLive, MILLISECONDS); hazelcastInstance.getMap( READ_REPLICA_TRANSACTION_SERVER_ADDRESS_MAP ).put( uuid, transactionSource.toString(), timeToLive, MILLISECONDS ); hazelcastInstance.getMap( READ_REPLICA_MEMBER_ID_MAP ).put( uuid, myself.getUuid().toString(), timeToLive, MILLISECONDS ); refreshGroups( hazelcastInstance, uuid, groups ); // this needs to be last as when we read from it in HazelcastClusterTopology.readReplicas // we assume that all the other maps have been populated if an entry exists in this one hazelcastInstance.getMap( READ_REPLICA_BOLT_ADDRESS_MAP ).put( uuid, addresses, timeToLive, MILLISECONDS ); } ); } }