use of org.apache.ignite.spi.metric.BooleanMetric in project ignite by apache.
the class NodeSslConnectionMetricTest method testDiscovery.
/**
* Tests SSL discovery metrics produced by node connection.
*/
@Test
public void testDiscovery() throws Exception {
MetricRegistry reg = mreg(startClusterNode(0), DISCO_METRICS);
startGrid(nodeConfiguration(1, true, "client", "trustone", CIPHER_SUITE, "TLSv1.2"));
assertTrue(reg.<BooleanMetric>findMetric("SslEnabled").value());
assertEquals(0, reg.<IntMetric>findMetric("RejectedSslConnectionsCount").value());
// Tests untrusted certificate.
checkNodeJoinFails(2, true, "thinClient", "trusttwo", CIPHER_SUITE, "TLSv1.2");
checkNodeJoinFails(2, false, "thinClient", "trusttwo", CIPHER_SUITE, "TLSv1.2");
// Tests untrusted cipher suites.
checkNodeJoinFails(2, true, "client", "trustone", UNSUPPORTED_CIPHER_SUITE, "TLSv1.2");
checkNodeJoinFails(2, false, "node01", "trustone", UNSUPPORTED_CIPHER_SUITE, "TLSv1.2");
// Tests mismatched protocol versions.
checkNodeJoinFails(2, true, "client", "trustone", null, "TLSv1.1");
checkNodeJoinFails(2, false, "node01", "trustone", null, "TLSv1.1");
// In case of an SSL error, the client and server nodes make 2 additional connection attempts.
assertTrue(waitForCondition(() -> 18 == reg.<IntMetric>findMetric("RejectedSslConnectionsCount").value(), getTestTimeout()));
}
use of org.apache.ignite.spi.metric.BooleanMetric in project ignite by apache.
the class NodeSslConnectionMetricTest method testSslDisabled.
/**
* Checks the status of the SSL metric if SSL is not configured on the node.
*/
@Test
public void testSslDisabled() throws Exception {
IgniteEx srv = startGrid();
MetricRegistry discoReg = mreg(srv, DISCO_METRICS);
assertFalse(discoReg.<BooleanMetric>findMetric("SslEnabled").value());
assertEquals(0, discoReg.<IntMetric>findMetric("RejectedSslConnectionsCount").value());
MetricRegistry commReg = mreg(srv, COMMUNICATION_METRICS_GROUP_NAME);
assertFalse(commReg.<BooleanMetric>findMetric(SSL_ENABLED_METRIC_NAME).value());
assertNull(commReg.<IntMetric>findMetric(SSL_REJECTED_SESSIONS_CNT_METRIC_NAME));
assertNull(commReg.<HistogramMetric>findMetric(SSL_HANDSHAKE_DURATION_HISTOGRAM_METRIC_NAME));
assertEquals(0, commReg.<IntMetric>findMetric(SESSIONS_CNT_METRIC_NAME).value());
MetricRegistry cliConnReg = mreg(srv, CLIENT_CONNECTOR_METRICS);
assertFalse(cliConnReg.<BooleanMetric>findMetric(SSL_ENABLED_METRIC_NAME).value());
assertNull(cliConnReg.<IntMetric>findMetric(SSL_REJECTED_SESSIONS_CNT_METRIC_NAME));
assertNull(cliConnReg.<HistogramMetric>findMetric(SSL_HANDSHAKE_DURATION_HISTOGRAM_METRIC_NAME));
assertEquals(0, cliConnReg.<IntMetric>findMetric(SESSIONS_CNT_METRIC_NAME).value());
MetricRegistry restConnReg = mreg(srv, REST_CONNECTOR_METRIC_REGISTRY_NAME);
assertNull(restConnReg.<BooleanMetric>findMetric(SSL_ENABLED_METRIC_NAME));
assertNull(restConnReg.<IntMetric>findMetric(SSL_REJECTED_SESSIONS_CNT_METRIC_NAME));
assertNull(restConnReg.<HistogramMetric>findMetric(SSL_HANDSHAKE_DURATION_HISTOGRAM_METRIC_NAME));
assertNull(restConnReg.<IntMetric>findMetric(SESSIONS_CNT_METRIC_NAME));
stopAllGrids();
srv = startGrid(getConfiguration().setConnectorConfiguration(new ConnectorConfiguration()));
restConnReg = mreg(srv, REST_CONNECTOR_METRIC_REGISTRY_NAME);
assertFalse(restConnReg.<BooleanMetric>findMetric(SSL_ENABLED_METRIC_NAME).value());
assertEquals(0, restConnReg.<IntMetric>findMetric(SESSIONS_CNT_METRIC_NAME).value());
}
use of org.apache.ignite.spi.metric.BooleanMetric in project ignite by apache.
the class CacheGroupReencryptionTest method validateMetrics.
/**
* @param node Grid.
* @param finished Expected reencryption status.
*/
private void validateMetrics(IgniteEx node, boolean finished) throws IgniteInterruptedCheckedException {
MetricRegistry registry = node.context().metric().registry(metricName(CacheGroupMetricsImpl.CACHE_GROUP_METRICS_PREFIX, cacheName()));
LongMetric bytesLeft = registry.findMetric("ReencryptionBytesLeft");
if (finished)
assertEquals(0, bytesLeft.value());
else
assertTrue(waitForCondition(() -> bytesLeft.value() > 0, MAX_AWAIT_MILLIS));
BooleanMetric reencryptionFinished = registry.findMetric("ReencryptionFinished");
assertEquals(finished, reencryptionFinished.value());
}
use of org.apache.ignite.spi.metric.BooleanMetric in project ignite by apache.
the class IndexMetricsTest method testIndexRebuildingMetric.
/**
* @throws Exception If failed.
*/
@Test
public void testIndexRebuildingMetric() throws Exception {
IgniteEx n = startGrid(0);
n.cluster().active(true);
String cacheName1 = "cache1";
String cacheName2 = "cache2";
IgniteCache<KeyClass, ValueClass> cache1 = n.getOrCreateCache(cacheConfiguration(cacheName1));
IgniteCache<KeyClass, ValueClass> cache2 = n.getOrCreateCache(cacheConfiguration(cacheName2));
int entryCnt1 = 100;
int entryCnt2 = 200;
for (int i = 0; i < entryCnt1; i++) cache1.put(new KeyClass(i), new ValueClass((long) i));
for (int i = 0; i < entryCnt2; i++) cache2.put(new KeyClass(i), new ValueClass((long) i));
List<Path> idxPaths = getIndexBinPaths(cacheName1);
idxPaths.addAll(getIndexBinPaths(cacheName2));
stopAllGrids();
idxPaths.forEach(idxPath -> assertTrue(U.delete(idxPath)));
IndexProcessor.idxRebuildCls = BlockingIndexesRebuildTask.class;
n = startGrid(0);
BooleanMetric idxRebuildInProgress1 = indexRebuildMetric(n, cacheName1, "IsIndexRebuildInProgress");
BooleanMetric idxRebuildInProgress2 = indexRebuildMetric(n, cacheName2, "IsIndexRebuildInProgress");
LongAdderMetric idxRebuildKeyProcessed1 = indexRebuildMetric(n, cacheName1, "IndexRebuildKeyProcessed");
LongAdderMetric idxRebuildKeyProcessed2 = indexRebuildMetric(n, cacheName2, "IndexRebuildKeyProcessed");
CacheMetrics cacheMetrics1 = cacheMetrics(n, cacheName1);
CacheMetrics cacheMetrics2 = cacheMetrics(n, cacheName2);
CacheMetricsMXBean cacheMetricsMXBean1 = cacheMetricsMXBean(n, cacheName1, CacheLocalMetricsMXBeanImpl.class);
CacheMetricsMXBean cacheMetricsMXBean2 = cacheMetricsMXBean(n, cacheName2, CacheLocalMetricsMXBeanImpl.class);
CacheMetricsMXBean cacheClusterMetricsMXBean1 = cacheMetricsMXBean(n, cacheName1, CacheClusterMetricsMXBeanImpl.class);
CacheMetricsMXBean cacheClusterMetricsMXBean2 = cacheMetricsMXBean(n, cacheName2, CacheClusterMetricsMXBeanImpl.class);
n.cluster().active(true);
BooleanSupplier[] idxRebuildProgressCache1 = { idxRebuildInProgress1::value, cacheMetrics1::isIndexRebuildInProgress, cacheMetricsMXBean1::isIndexRebuildInProgress };
BooleanSupplier[] idxRebuildProgressCache2 = { idxRebuildInProgress2::value, cacheMetrics2::isIndexRebuildInProgress, cacheMetricsMXBean2::isIndexRebuildInProgress };
// It must always be false, because metric is only per node.
BooleanSupplier[] idxRebuildProgressCluster = { cacheClusterMetricsMXBean1::isIndexRebuildInProgress, cacheClusterMetricsMXBean2::isIndexRebuildInProgress };
LongSupplier[] idxRebuildKeyProcessedCache1 = { idxRebuildKeyProcessed1::value, cacheMetrics1::getIndexRebuildKeysProcessed, cacheMetricsMXBean1::getIndexRebuildKeysProcessed };
LongSupplier[] idxRebuildKeyProcessedCache2 = { idxRebuildKeyProcessed2::value, cacheMetrics2::getIndexRebuildKeysProcessed, cacheMetricsMXBean2::getIndexRebuildKeysProcessed };
// It must always be 0, because metric is only per node.
LongSupplier[] idxRebuildKeyProcessedCluster = { cacheClusterMetricsMXBean1::getIndexRebuildKeysProcessed, cacheClusterMetricsMXBean2::getIndexRebuildKeysProcessed };
assertEquals(true, idxRebuildProgressCache1);
assertEquals(true, idxRebuildProgressCache2);
assertEquals(false, idxRebuildProgressCluster);
assertEquals(0, idxRebuildKeyProcessedCache1);
assertEquals(0, idxRebuildKeyProcessedCache2);
assertEquals(0, idxRebuildKeyProcessedCluster);
((BlockingIndexesRebuildTask) n.context().indexProcessor().idxRebuild()).stopBlock(cacheName1);
n.cache(cacheName1).indexReadyFuture().get(30_000);
assertEquals(false, idxRebuildProgressCache1);
assertEquals(true, idxRebuildProgressCache2);
assertEquals(false, idxRebuildProgressCluster);
assertEquals(entryCnt1, idxRebuildKeyProcessedCache1);
assertEquals(0, idxRebuildKeyProcessedCache2);
assertEquals(0, idxRebuildKeyProcessedCluster);
((BlockingIndexesRebuildTask) n.context().indexProcessor().idxRebuild()).stopBlock(cacheName2);
n.cache(cacheName2).indexReadyFuture().get(30_000);
assertEquals(false, idxRebuildProgressCache1);
assertEquals(false, idxRebuildProgressCache2);
assertEquals(false, idxRebuildProgressCluster);
assertEquals(entryCnt1, idxRebuildKeyProcessedCache1);
assertEquals(entryCnt2, idxRebuildKeyProcessedCache2);
assertEquals(0, idxRebuildKeyProcessedCluster);
}
use of org.apache.ignite.spi.metric.BooleanMetric in project ignite by apache.
the class OpenCensusMetricExporterSpi method export.
/**
* {@inheritDoc}
*/
@Override
public void export() {
StatsRecorder recorder = Stats.getStatsRecorder();
try (Scope globalScope = tagScope()) {
MeasureMap mmap = recorder.newMeasureMap();
mreg.forEach(mreg -> {
if (filter != null && !filter.test(mreg))
return;
mreg.forEach(metric -> {
if (metric instanceof LongMetric || metric instanceof IntMetric || metric instanceof BooleanMetric || (metric instanceof ObjectMetric && ((ObjectMetric) metric).type() == Date.class) || (metric instanceof ObjectMetric && ((ObjectMetric) metric).type() == OffsetDateTime.class)) {
long val;
if (metric instanceof LongMetric)
val = ((LongMetric) metric).value();
else if (metric instanceof IntMetric)
val = ((IntMetric) metric).value();
else if (metric instanceof BooleanMetric)
val = ((BooleanMetric) metric).value() ? 1 : 0;
else if (metric instanceof ObjectMetric && ((ObjectMetric) metric).type() == Date.class)
val = ((ObjectMetric<Date>) metric).value().getTime();
else
val = ((ObjectMetric<OffsetDateTime>) metric).value().toInstant().toEpochMilli();
if (val < 0) {
if (log.isDebugEnabled())
log.debug("OpenCensus doesn't support negative values. Skip record of " + metric.name());
return;
}
MeasureLong msr = (MeasureLong) measures.computeIfAbsent(metric.name(), k -> createMeasure(metric, CREATE_LONG));
mmap.put(msr, val);
} else if (metric instanceof DoubleMetric) {
double val = ((DoubleMetric) metric).value();
if (val < 0) {
if (log.isDebugEnabled())
log.debug("OpenCensus doesn't support negative values. Skip record of " + metric.name());
return;
}
MeasureDouble msr = (MeasureDouble) measures.computeIfAbsent(metric.name(), k -> createMeasure(metric, CREATE_DOUBLE));
mmap.put(msr, val);
} else if (metric instanceof HistogramMetric) {
String[] names = histogramBucketNames((HistogramMetric) metric);
long[] vals = ((HistogramMetric) metric).value();
assert names.length == vals.length;
for (int i = 0; i < vals.length; i++) {
String name = names[i];
MeasureLong msr = (MeasureLong) measures.computeIfAbsent(name, k -> createMeasureLong(name, metric.description()));
mmap.put(msr, vals[i]);
}
} else if (log.isDebugEnabled()) {
log.debug(metric.name() + "[" + metric.getClass() + "] not supported by Opencensus exporter");
}
});
});
mmap.record();
}
}
Aggregations