Search in sources :

Example 1 with MetricsRegistry

use of com.hazelcast.internal.metrics.MetricsRegistry in project hazelcast-jet by hazelcast.

the class ExecutionContext method completeExecution.

/**
 * Complete local execution. If local execution was started, it should be
 * called after execution has completed.
 */
public void completeExecution(Throwable error) {
    assert executionFuture == null || executionFuture.isDone() : "If execution was begun, then completeExecution() should not be called before execution is done.";
    for (Processor processor : processors) {
        try {
            processor.close(error);
        } catch (Throwable e) {
            logger.severe(jobAndExecutionId(jobId, executionId) + " encountered an exception in Processor.close(), ignoring it", e);
        }
    }
    for (ProcessorSupplier s : procSuppliers) {
        try {
            s.close(error);
        } catch (Throwable e) {
            logger.severe(jobAndExecutionId(jobId, executionId) + " encountered an exception in ProcessorSupplier.complete(), ignoring it", e);
        }
    }
    MetricsRegistry metricsRegistry = ((NodeEngineImpl) nodeEngine).getMetricsRegistry();
    processors.forEach(metricsRegistry::deregister);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry) Processor(com.hazelcast.jet.core.Processor) ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier)

Example 2 with MetricsRegistry

use of com.hazelcast.internal.metrics.MetricsRegistry in project hazelcast by hazelcast.

the class ClusterServiceImpl method registerMetrics.

private void registerMetrics() {
    MetricsRegistry metricsRegistry = node.nodeEngine.getMetricsRegistry();
    metricsRegistry.registerStaticMetrics(clusterClock, CLUSTER_PREFIX_CLOCK);
    metricsRegistry.registerStaticMetrics(clusterHeartbeatManager, CLUSTER_PREFIX_HEARTBEAT);
    metricsRegistry.registerStaticMetrics(this, CLUSTER_PREFIX);
}
Also used : MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry)

Example 3 with MetricsRegistry

use of com.hazelcast.internal.metrics.MetricsRegistry in project hazelcast by hazelcast.

the class EventServiceImpl method getSegment.

/**
 * Returns the {@link EventServiceSegment} for the {@code service}. If the segment is {@code null} and
 * {@code forceCreate} is {@code true}, the segment is created and registered with the {@link MetricsRegistry}.
 *
 * @param service     the service of the segment
 * @param forceCreate whether the segment should be created in case there is no segment
 * @return the segment for the service or null if there is no segment and {@code forceCreate} is {@code false}
 */
public EventServiceSegment getSegment(@Nonnull String service, boolean forceCreate) {
    EventServiceSegment segment = segments.get(service);
    if (segment == null && forceCreate) {
        // we can't make use of the ConcurrentUtil; we need to register the segment to the metricsRegistry in case of creation
        EventServiceSegment newSegment = new EventServiceSegment(service, nodeEngine.getService(service));
        EventServiceSegment existingSegment = segments.putIfAbsent(service, newSegment);
        if (existingSegment == null) {
            segment = newSegment;
            MetricsRegistry metricsRegistry = nodeEngine.getMetricsRegistry();
            MetricDescriptor descriptor = metricsRegistry.newMetricDescriptor().withPrefix(EVENT_PREFIX).withDiscriminator(EVENT_DISCRIMINATOR_SERVICE, service);
            metricsRegistry.registerStaticMetrics(descriptor, newSegment);
        } else {
            segment = existingSegment;
        }
    }
    return segment;
}
Also used : MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor)

Example 4 with MetricsRegistry

use of com.hazelcast.internal.metrics.MetricsRegistry in project hazelcast by hazelcast.

the class CachePutAllTest method testPutAll_whenEntryExpiresOnCreate.

@Test
public void testPutAll_whenEntryExpiresOnCreate() {
    Factory<? extends ExpiryPolicy> expiryPolicyFactory = FactoryBuilder.factoryOf(new CreatedExpiryPolicy(Duration.ZERO));
    CacheConfig<String, String> cacheConfig = new CacheConfig<String, String>();
    cacheConfig.setTypes(String.class, String.class);
    cacheConfig.setExpiryPolicyFactory(expiryPolicyFactory);
    cacheConfig.setStatisticsEnabled(true);
    cacheConfig.setBackupCount(1);
    Cache<String, String> cache = createCache(cacheConfig);
    String key = generateKeyOwnedBy(hazelcastInstance);
    // need to count the number of backup failures on backup member
    OperationService operationService = getOperationService(hazelcastInstances[1]);
    MetricsRegistry metricsRegistry = getMetricsRegistry(hazelcastInstances[1]);
    assertEquals(0L, OperationServiceAccessor.getFailedBackupsCount(hazelcastInstances[1]).get());
    Map<String, String> entries = new HashMap<String, String>();
    entries.put(key, randomString());
    cache.putAll(entries);
    assertNull(cache.get(key));
    // force collect metrics
    metricsRegistry.provideMetrics(operationService);
    assertEquals(0L, OperationServiceAccessor.getFailedBackupsCount(hazelcastInstances[1]).get());
}
Also used : MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry) Accessors.getMetricsRegistry(com.hazelcast.test.Accessors.getMetricsRegistry) HashMap(java.util.HashMap) CreatedExpiryPolicy(javax.cache.expiry.CreatedExpiryPolicy) Accessors.getOperationService(com.hazelcast.test.Accessors.getOperationService) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) CacheConfig(com.hazelcast.config.CacheConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with MetricsRegistry

use of com.hazelcast.internal.metrics.MetricsRegistry in project hazelcast by hazelcast.

the class DistributedDatastructuresMetricsTest method assertHasNoStats.

private void assertHasNoStats(final String dsName, final String metricPrefix) {
    final MetricsRegistry registry = getNode(hz).nodeEngine.getMetricsRegistry();
    final StringMetricsCollector collector = new StringMetricsCollector(dsName, metricPrefix);
    registry.collect(collector);
    assertTrue(collector.probes.isEmpty());
}
Also used : MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry)

Aggregations

MetricsRegistry (com.hazelcast.internal.metrics.MetricsRegistry)29 QuickTest (com.hazelcast.test.annotation.QuickTest)16 Test (org.junit.Test)16 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)10 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)6 MetricsCollector (com.hazelcast.internal.metrics.collectors.MetricsCollector)4 Config (com.hazelcast.config.Config)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 ExecutionService (com.hazelcast.spi.impl.executionservice.ExecutionService)2 CacheConfig (com.hazelcast.config.CacheConfig)1 ConfigAccessor.getActiveMemberNetworkConfig (com.hazelcast.config.ConfigAccessor.getActiveMemberNetworkConfig)1 MemberAddressProviderConfig (com.hazelcast.config.MemberAddressProviderConfig)1 HazelcastThreadGroup (com.hazelcast.instance.HazelcastThreadGroup)1 Node (com.hazelcast.instance.Node)1 ProtocolType (com.hazelcast.instance.ProtocolType)1 Node (com.hazelcast.instance.impl.Node)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 IOThreadingModel (com.hazelcast.internal.networking.IOThreadingModel)1 Networking (com.hazelcast.internal.networking.Networking)1