Search in sources :

Example 1 with ClientEngine

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());
}
Also used : JobMetricsPublisher(com.hazelcast.jet.impl.metrics.JobMetricsPublisher) ClientEngine(com.hazelcast.client.impl.ClientEngine) TaskletExecutionService(com.hazelcast.jet.impl.execution.TaskletExecutionService) MetricsService(com.hazelcast.internal.metrics.impl.MetricsService) ClientExceptionFactory(com.hazelcast.client.impl.protocol.ClientExceptionFactory)

Example 2 with ClientEngine

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());
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ClientEngine(com.hazelcast.client.impl.ClientEngine) UUID(java.util.UUID) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Example 3 with ClientEngine

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());
    }
}
Also used : ClientEngine(com.hazelcast.client.impl.ClientEngine) ClientEndpointImpl(com.hazelcast.client.impl.ClientEndpointImpl) Client(com.hazelcast.client.Client)

Example 4 with ClientEngine

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);
        }
    });
}
Also used : MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) ClientEngine(com.hazelcast.client.impl.ClientEngine) ClientStatistics(com.hazelcast.client.impl.statistics.ClientStatistics) CapturingCollector(com.hazelcast.internal.metrics.impl.CapturingCollector) Client(com.hazelcast.client.Client) UUID(java.util.UUID)

Example 5 with ClientEngine

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()));
}
Also used : ClientEngine(com.hazelcast.client.impl.ClientEngine) ClientEndpointStatisticsSnapshot(com.hazelcast.client.impl.ClientEndpointStatisticsSnapshot)

Aggregations

ClientEngine (com.hazelcast.client.impl.ClientEngine)7 Client (com.hazelcast.client.Client)2 UUID (java.util.UUID)2 ClientEndpointImpl (com.hazelcast.client.impl.ClientEndpointImpl)1 ClientEndpointStatisticsSnapshot (com.hazelcast.client.impl.ClientEndpointStatisticsSnapshot)1 ClientExceptionFactory (com.hazelcast.client.impl.protocol.ClientExceptionFactory)1 ClientStatistics (com.hazelcast.client.impl.statistics.ClientStatistics)1 LockStoreImpl (com.hazelcast.internal.locksupport.LockStoreImpl)1 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)1 CapturingCollector (com.hazelcast.internal.metrics.impl.CapturingCollector)1 MetricsService (com.hazelcast.internal.metrics.impl.MetricsService)1 TaskletExecutionService (com.hazelcast.jet.impl.execution.TaskletExecutionService)1 JobMetricsPublisher (com.hazelcast.jet.impl.metrics.JobMetricsPublisher)1 ILogger (com.hazelcast.logging.ILogger)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)1