@Override public void onFatalError(Exception e) { String hzName = nodeEngine.getHazelcastInstance().getName(); Thread thread = new Thread(createThreadName(hzName, "io.error.shutdown")) { public void run() { node.shutdown(false); } }; thread.start(); }
@Override public void onFatalError(Exception e) { String hzName = nodeEngine.getHazelcastInstance().getName(); Thread thread = new Thread(createThreadName(hzName, "io.error.shutdown")) { public void run() { node.shutdown(false); } }; thread.start(); }
private Diagnostics newDiagnostics() { Address address = node.getThisAddress(); String addressString = address.getHost().replace(":", "_") + "_" + address.getPort(); String name = "diagnostics-" + addressString + "-" + currentTimeMillis(); return new Diagnostics( name, loggingService.getLogger(Diagnostics.class), getHazelcastInstance().getName(), node.getProperties()); }
private ManagedExecutorService createExecutor(String name, int poolSize, int queueCapacity, ExecutorType type) { ManagedExecutorService executor; if (type == ExecutorType.CACHED) { executor = new CachedExecutorServiceDelegate(nodeEngine, name, cachedExecutorService, poolSize, queueCapacity); } else if (type == ExecutorType.CONCRETE) { ClassLoader classLoader = nodeEngine.getConfigClassLoader(); String hzName = nodeEngine.getHazelcastInstance().getName(); String internalName = name.startsWith("hz:") ? name.substring(BEGIN_INDEX) : name; String threadNamePrefix = createThreadPoolName(hzName, internalName); PoolExecutorThreadFactory threadFactory = new PoolExecutorThreadFactory(threadNamePrefix, classLoader); NamedThreadPoolExecutor pool = new NamedThreadPoolExecutor(name, poolSize, poolSize, KEEP_ALIVE_TIME, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(queueCapacity), threadFactory ); pool.allowCoreThreadTimeOut(true); executor = pool; } else { throw new IllegalArgumentException("Unknown executor type: " + type); } return executor; }
public OperationParkerImpl(NodeEngineImpl nodeEngine) { this.nodeEngine = nodeEngine; Node node = nodeEngine.getNode(); this.logger = node.getLogger(OperationParker.class); this.expirationExecutor = Executors.newSingleThreadExecutor( new SingleExecutorThreadFactory(node.getConfigClassLoader(), createThreadName(nodeEngine.getHazelcastInstance().getName(), "operation-parker"))); this.expirationTaskFuture = expirationExecutor.submit(new ExpirationTask()); }
private ManagedExecutorService createExecutor(String name, int poolSize, int queueCapacity, ExecutorType type) { ManagedExecutorService executor; if (type == ExecutorType.CACHED) { executor = new CachedExecutorServiceDelegate(nodeEngine, name, cachedExecutorService, poolSize, queueCapacity); } else if (type == ExecutorType.CONCRETE) { ClassLoader classLoader = nodeEngine.getConfigClassLoader(); String hzName = nodeEngine.getHazelcastInstance().getName(); String internalName = name.startsWith("hz:") ? name.substring(BEGIN_INDEX) : name; String threadNamePrefix = createThreadPoolName(hzName, internalName); PoolExecutorThreadFactory threadFactory = new PoolExecutorThreadFactory(threadNamePrefix, classLoader); NamedThreadPoolExecutor pool = new NamedThreadPoolExecutor(name, poolSize, poolSize, KEEP_ALIVE_TIME, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(queueCapacity), threadFactory ); pool.allowCoreThreadTimeOut(true); executor = pool; } else { throw new IllegalArgumentException("Unknown executor type: " + type); } return executor; }
private Diagnostics newDiagnostics() { Address address = node.getThisAddress(); String addressString = address.getHost().replace(":", "_") + "_" + address.getPort(); String name = "diagnostics-" + addressString + "-" + currentTimeMillis(); return new Diagnostics( name, loggingService.getLogger(Diagnostics.class), getHazelcastInstance().getName(), node.getProperties()); }
public OperationParkerImpl(NodeEngineImpl nodeEngine) { this.nodeEngine = nodeEngine; Node node = nodeEngine.getNode(); this.logger = node.getLogger(OperationParker.class); this.expirationExecutor = Executors.newSingleThreadExecutor( new SingleExecutorThreadFactory(node.getConfigClassLoader(), createThreadName(nodeEngine.getHazelcastInstance().getName(), "operation-parker"))); this.expirationTaskFuture = expirationExecutor.submit(new ExpirationTask()); }
private MetricsRegistryImpl newMetricRegistry(Node node) { ProbeLevel probeLevel = node.getProperties().getEnum(METRICS_LEVEL, ProbeLevel.class); return new MetricsRegistryImpl(getHazelcastInstance().getName(), node.getLogger(MetricsRegistry.class), probeLevel); }
public SystemLogPlugin(NodeEngineImpl nodeEngine) { this(nodeEngine.getProperties(), nodeEngine.getNode().connectionManager, nodeEngine.getHazelcastInstance(), nodeEngine.getLogger(SystemLogPlugin.class), nodeEngine.getNode().getNodeExtension()); }
private MetricsRegistryImpl newMetricRegistry(Node node) { ProbeLevel probeLevel = node.getProperties().getEnum(METRICS_LEVEL, ProbeLevel.class); return new MetricsRegistryImpl(getHazelcastInstance().getName(), node.getLogger(MetricsRegistry.class), probeLevel); }
public SystemLogPlugin(NodeEngineImpl nodeEngine) { this(nodeEngine.getProperties(), nodeEngine.getNode().connectionManager, nodeEngine.getHazelcastInstance(), nodeEngine.getLogger(SystemLogPlugin.class), nodeEngine.getNode().getNodeExtension()); }
private List<MetricsPublisher> getPublishers() { List<MetricsPublisher> publishers = new ArrayList<>(); if (config.isEnabled()) { int journalSize = Math.max( 1, (int) Math.ceil((double) config.getRetentionSeconds() / config.getCollectionIntervalSeconds()) ); metricsJournal = new ConcurrentArrayRingbuffer<>(journalSize); ManagementCenterPublisher publisher = new ManagementCenterPublisher(this.nodeEngine.getLoggingService(), (blob, ts) -> { metricsJournal.add(entry(ts, blob)); pendingReads.forEach(this::tryCompleteRead); } ); publishers.add(publisher); } if (config.isJmxEnabled()) { publishers.add(new JmxPublisher(nodeEngine.getHazelcastInstance().getName(), "com.hazelcast")); } return publishers; }
InvocationMonitor(NodeEngineImpl nodeEngine, Address thisAddress, HazelcastProperties properties, InvocationRegistry invocationRegistry, ILogger logger, InternalSerializationService serializationService, ServiceManager serviceManager) { this.nodeEngine = nodeEngine; this.thisAddress = thisAddress; this.serializationService = serializationService; this.serviceManager = serviceManager; this.invocationRegistry = invocationRegistry; this.logger = logger; this.backupTimeoutMillis = backupTimeoutMillis(properties); this.invocationTimeoutMillis = invocationTimeoutMillis(properties); this.heartbeatBroadcastPeriodMillis = heartbeatBroadcastPeriodMillis(properties); this.scheduler = newScheduler(nodeEngine.getHazelcastInstance().getName()); }
public TaskletExecutionService(NodeEngineImpl nodeEngine, int threadCount) { this.hzInstanceName = nodeEngine.getHazelcastInstance().getName(); this.cooperativeWorkers = new CooperativeWorker[threadCount]; this.cooperativeThreadPool = new Thread[threadCount]; this.logger = nodeEngine.getLoggingService().getLogger(TaskletExecutionService.class); nodeEngine.getMetricsRegistry().newProbeBuilder() .withTag("module", "jet") .scanAndRegister(this); Arrays.setAll(cooperativeWorkers, i -> new CooperativeWorker()); Arrays.setAll(cooperativeThreadPool, i -> new Thread(cooperativeWorkers[i], String.format("hz.%s.jet.cooperative.thread-%d", hzInstanceName, i))); Arrays.stream(cooperativeThreadPool).forEach(Thread::start); for (int i = 0; i < cooperativeWorkers.length; i++) { nodeEngine.getMetricsRegistry().newProbeBuilder() .withTag("module", "jet") .withTag("cooperativeWorker", String.valueOf(i)) .scanAndRegister(cooperativeWorkers[i]); } }
InvocationMonitor(NodeEngineImpl nodeEngine, Address thisAddress, HazelcastProperties properties, InvocationRegistry invocationRegistry, ILogger logger, InternalSerializationService serializationService, ServiceManager serviceManager) { this.nodeEngine = nodeEngine; this.thisAddress = thisAddress; this.serializationService = serializationService; this.serviceManager = serviceManager; this.invocationRegistry = invocationRegistry; this.logger = logger; this.backupTimeoutMillis = backupTimeoutMillis(properties); this.invocationTimeoutMillis = invocationTimeoutMillis(properties); this.heartbeatBroadcastPeriodMillis = heartbeatBroadcastPeriodMillis(properties); this.scheduler = newScheduler(nodeEngine.getHazelcastInstance().getName()); }
private void rewriteDagWithSnapshotRestore(DAG dag, long snapshotId, String mapName) { IMap<Object, Object> snapshotMap = nodeEngine.getHazelcastInstance().getMap(mapName); snapshotId = SnapshotValidator.validateSnapshot(snapshotId, jobIdString(), snapshotMap); logger.info("State of " + jobIdString() + " will be restored from snapshot " + snapshotId + ", map=" + mapName); List<Vertex> originalVertices = new ArrayList<>(); dag.iterator().forEachRemaining(originalVertices::add); Map<String, Integer> vertexToOrdinal = new HashMap<>(); Vertex readSnapshotVertex = dag.newVertex(SNAPSHOT_VERTEX_PREFIX + "read", readMapP(mapName)); long finalSnapshotId = snapshotId; Vertex explodeVertex = dag.newVertex(SNAPSHOT_VERTEX_PREFIX + "explode", () -> new ExplodeSnapshotP(vertexToOrdinal, finalSnapshotId)); dag.edge(between(readSnapshotVertex, explodeVertex).isolated()); int index = 0; // add the edges for (Vertex userVertex : originalVertices) { vertexToOrdinal.put(userVertex.getName(), index); int destOrdinal = dag.getInboundEdges(userVertex.getName()).size(); dag.edge(new SnapshotRestoreEdge(explodeVertex, index, userVertex, destOrdinal)); index++; } }
public EventServiceImpl(NodeEngineImpl nodeEngine) { this.nodeEngine = nodeEngine; this.serializationService = (InternalSerializationService) nodeEngine.getSerializationService(); this.logger = nodeEngine.getLogger(EventService.class.getName()); HazelcastProperties hazelcastProperties = nodeEngine.getProperties(); this.eventThreadCount = hazelcastProperties.getInteger(EVENT_THREAD_COUNT); this.eventQueueCapacity = hazelcastProperties.getInteger(EVENT_QUEUE_CAPACITY); this.eventQueueTimeoutMs = hazelcastProperties.getMillis(EVENT_QUEUE_TIMEOUT_MILLIS); this.sendEventSyncTimeoutMillis = hazelcastProperties.getInteger(EVENT_SYNC_TIMEOUT_MILLIS); this.eventSyncFrequency = loadEventSyncFrequency(); this.eventExecutor = new StripedExecutor( nodeEngine.getNode().getLogger(EventServiceImpl.class), createThreadName(nodeEngine.getHazelcastInstance().getName(), "event"), eventThreadCount, eventQueueCapacity); this.segments = new ConcurrentHashMap<String, EventServiceSegment>(); }
public EventServiceImpl(NodeEngineImpl nodeEngine) { this.nodeEngine = nodeEngine; this.serializationService = (InternalSerializationService) nodeEngine.getSerializationService(); this.logger = nodeEngine.getLogger(EventService.class.getName()); HazelcastProperties hazelcastProperties = nodeEngine.getProperties(); this.eventThreadCount = hazelcastProperties.getInteger(EVENT_THREAD_COUNT); this.eventQueueCapacity = hazelcastProperties.getInteger(EVENT_QUEUE_CAPACITY); this.eventQueueTimeoutMs = hazelcastProperties.getMillis(EVENT_QUEUE_TIMEOUT_MILLIS); this.sendEventSyncTimeoutMillis = hazelcastProperties.getInteger(EVENT_SYNC_TIMEOUT_MILLIS); this.eventSyncFrequency = loadEventSyncFrequency(); this.eventExecutor = new StripedExecutor( nodeEngine.getNode().getLogger(EventServiceImpl.class), createThreadName(nodeEngine.getHazelcastInstance().getName(), "event"), eventThreadCount, eventQueueCapacity); this.segments = new ConcurrentHashMap<String, EventServiceSegment>(); }
@Override public void run() { final ClusterServiceImpl clusterService = getService(); final ILogger logger = getLogger(); final ClusterState clusterState = clusterService.getClusterState(); if (clusterState == ClusterState.PASSIVE) { final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine(); if (nodeEngine.isRunning()) { logger.info("Shutting down node in cluster passive state. Requested by: " + getCallerAddress()); new Thread(new Runnable() { @Override public void run() { final Node node = nodeEngine.getNode(); node.hazelcastInstance.getLifecycleService().shutdown(); } }, createThreadName(nodeEngine.getHazelcastInstance().getName(), ".clusterShutdown")).start(); } else { logger.info("Node is already shutting down. NodeState: " + nodeEngine.getNode().getState()); } } else { logger.severe("Can not shut down node because cluster is in " + clusterState + " state. Requested by: " + getCallerAddress()); } }