use of com.hazelcast.client.impl.ClientEngine in project hazelcast by hazelcast.
the class JetServiceBackend method init.
// ManagedService
@Override
public void init(NodeEngine engine, Properties hzProperties) {
this.nodeEngine = (NodeEngineImpl) engine;
this.jet = new JetInstanceImpl(nodeEngine.getNode().hazelcastInstance, jetConfig);
jobRepository = new JobRepository(engine.getHazelcastInstance());
taskletExecutionService = new TaskletExecutionService(nodeEngine, jetConfig.getCooperativeThreadCount(), nodeEngine.getProperties());
jobCoordinationService = createJobCoordinationService();
jobClassLoaderService = new JobClassLoaderService(nodeEngine, jobRepository);
jobExecutionService = new JobExecutionService(nodeEngine, taskletExecutionService, jobClassLoaderService);
MetricsService metricsService = nodeEngine.getService(MetricsService.SERVICE_NAME);
metricsService.registerPublisher(nodeEngine -> new JobMetricsPublisher(jobExecutionService, nodeEngine.getLocalMember()));
nodeEngine.getMetricsRegistry().registerDynamicMetricsProvider(jobExecutionService);
networking = new Networking(engine, jobExecutionService, jetConfig.getFlowControlPeriodMs());
ClientEngine clientEngine = engine.getService(ClientEngineImpl.SERVICE_NAME);
ClientExceptionFactory clientExceptionFactory = clientEngine.getExceptionFactory();
if (clientExceptionFactory != null) {
ExceptionUtil.registerJetExceptions(clientExceptionFactory);
} else {
logger.fine("Jet exceptions are not registered to the ClientExceptionFactory" + " since the ClientExceptionFactory is not accessible.");
}
logger.info("Setting number of cooperative threads and default parallelism to " + jetConfig.getCooperativeThreadCount());
}
use of com.hazelcast.client.impl.ClientEngine in project hazelcast by hazelcast.
the class Backup method afterRun.
@Override
public void afterRun() throws Exception {
if (validationFailure != null || !sync || getCallId() == 0 || originalCaller == null) {
return;
}
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
long callId = getCallId();
OperationServiceImpl operationService = nodeEngine.getOperationService();
if (isCallerClient()) {
ClientEngine clientEngine = ((NodeEngineImpl) getNodeEngine()).getNode().getClientEngine();
UUID clientUUID = getCallerUuid();
clientEngine.dispatchBackupEvent(clientUUID, clientCorrelationId);
} else if (nodeEngine.getThisAddress().equals(originalCaller)) {
operationService.getBackupHandler().notifyBackupComplete(callId);
} else {
operationService.getOutboundResponseHandler().sendBackupAck(getConnection().getConnectionManager(), originalCaller, callId, backupOp.isUrgent());
}
}
use of com.hazelcast.client.impl.ClientEngine in project hazelcast by hazelcast.
the class GetConnectedClientsOperation method run.
@Override
public void run() throws Exception {
ClientEngine service = getService();
final Collection<Client> serviceClients = service.getClients();
this.clients = createHashMap(serviceClients.size());
for (Client clientEndpoint : serviceClients) {
ClientEndpointImpl clientEndpointImpl = (ClientEndpointImpl) clientEndpoint;
this.clients.put(clientEndpointImpl.getUuid(), clientEndpointImpl.getClientType());
}
}
use of com.hazelcast.client.impl.ClientEngine in project hazelcast by hazelcast.
the class ClientMetricsTest method assertClientMetricsObservedEventually.
private void assertClientMetricsObservedEventually(HazelcastInstance memberInstance, MetricsRegistry metricsRegistry, String prefix, String metric, ProbeUnit unit) {
assertTrueEventually(() -> {
CapturingCollector collector = new CapturingCollector();
metricsRegistry.collect(collector);
ClientEngine clientEngine = getNode(memberInstance).getClientEngine();
Collection<Client> clients = clientEngine.getClients();
assertEquals(2, clients.size());
for (Client client : clients) {
UUID clientUuid = client.getUuid();
ClientStatistics clientStatistics = clientEngine.getClientStatistics().get(clientUuid);
assertNotNull(clientStatistics);
long timestamp = clientStatistics.timestamp();
MetricDescriptor expectedDescriptor = DEFAULT_DESCRIPTOR_SUPPLIER.get().withPrefix(prefix).withMetric(metric).withUnit(unit).withTag("client", clientUuid.toString()).withTag("clientname", client.getName()).withTag("timestamp", Long.toString(timestamp)).withExcludedTargets(asList(MetricTarget.values())).withIncludedTarget(MANAGEMENT_CENTER);
assertContains(collector.captures().keySet(), expectedDescriptor);
}
});
}
use of com.hazelcast.client.impl.ClientEngine in project hazelcast by hazelcast.
the class ClientInfoCollector method forEachMetric.
@Override
public void forEachMetric(Node node, BiConsumer<PhoneHomeMetrics, String> metricsConsumer) {
ClientEngine clientEngine = node.getClientEngine();
Map<String, Long> activeClients = clientEngine.getActiveClientsInCluster();
Map<String, ClientEndpointStatisticsSnapshot> snapshots = clientEngine.getEndpointStatisticsSnapshots();
CLIENT_TYPE_TO_HELPER.forEach((clientType, helper) -> {
long clientCount = activeClients.getOrDefault(clientType, 0L);
ClientEndpointStatisticsSnapshot snapshot = snapshots.get(clientType);
helper.collectMetrics(clientCount, snapshot, metricsConsumer);
});
metricsConsumer.accept(PhoneHomeMetrics.CLIENT_ENDPOINT_COUNT, MetricsCollector.convertToLetter(node.clientEngine.getClientEndpointCount()));
}
Aggregations