use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.
the class NodeSslConnectionMetricTest method testJdbc.
/**
* Tests SSL metrics produced by JDBC connection.
*/
@Test
public void testJdbc() throws Exception {
MetricRegistry reg = mreg(startClusterNode(0), CLIENT_CONNECTOR_METRICS);
assertEquals(0, reg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value());
assertEquals(0, reg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value());
try (Connection ignored = getConnection(jdbcConfiguration("thinClient", "trusttwo", CIPHER_SUITE, "TLSv1.2"))) {
checkSslCommunicationMetrics(reg, 1, 1, 0);
}
assertTrue(reg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value() > 0);
assertTrue(reg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value() > 0);
checkSslCommunicationMetrics(reg, 1, 0, 0);
// Tests untrusted certificate.
assertThrowsWithCause(() -> getConnection(jdbcConfiguration("client", "trusttwo", CIPHER_SUITE, "TLSv1.2")), SQLException.class);
checkSslCommunicationMetrics(reg, 2, 0, 1);
// Tests unsupported cipher suite.
assertThrowsWithCause(() -> getConnection(jdbcConfiguration("thinClient", "trusttwo", UNSUPPORTED_CIPHER_SUITE, "TLSv1.2")), SQLException.class);
checkSslCommunicationMetrics(reg, 3, 0, 2);
assertThrowsWithCause(() -> getConnection(jdbcConfiguration("thinClient", "trusttwo", null, "TLSv1.1")), SQLException.class);
checkSslCommunicationMetrics(reg, 4, 0, 3);
}
use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.
the class NodeSslConnectionMetricTest method testClientConnector.
/**
* Tests SSL metrics produced by thin client connection.
*/
@Test
public void testClientConnector() throws Exception {
MetricRegistry reg = mreg(startClusterNode(0), CLIENT_CONNECTOR_METRICS);
assertEquals(0, reg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value());
assertEquals(0, reg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value());
try (IgniteClient ignored = startClient(clientConfiguration("thinClient", "trusttwo", CIPHER_SUITE, "TLSv1.2"))) {
checkSslCommunicationMetrics(reg, 1, 1, 0);
}
assertTrue(reg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value() > 0);
assertTrue(reg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value() > 0);
checkSslCommunicationMetrics(reg, 1, 0, 0);
// Tests untrusted certificate.
assertThrowsWithCause(() -> startClient(clientConfiguration("client", "trustboth", CIPHER_SUITE, "TLSv1.2")), ClientConnectionException.class);
checkSslCommunicationMetrics(reg, 2, 0, 1);
// Tests unsupported cipher suites.
assertThrowsWithCause(() -> startClient(clientConfiguration("thinClient", "trusttwo", UNSUPPORTED_CIPHER_SUITE, "TLSv1.2")), ClientConnectionException.class);
checkSslCommunicationMetrics(reg, 3, 0, 2);
// Tests mismatched protocol versions.
assertThrowsWithCause(() -> startClient(clientConfiguration("thinClient", "trusttwo", null, "TLSv1.1")), ClientConnectionException.class);
checkSslCommunicationMetrics(reg, 4, 0, 3);
}
use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.
the class NodeSslConnectionMetricTest method testRestClientConnector.
/**
* Tests SSL metrics produced by REST TCP client connection.
*/
@Test
public void testRestClientConnector() throws Exception {
MetricRegistry reg = mreg(startClusterNode(0), REST_CONNECTOR_METRIC_REGISTRY_NAME);
assertEquals(0, reg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value());
assertEquals(0, reg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value());
try (GridClient ignored = start(gridClientConfiguration("connectorClient", "trustthree", CIPHER_SUITE, "TLSv1.2"))) {
checkSslCommunicationMetrics(reg, 1, 1, 0);
}
assertTrue(reg.<LongMetric>findMetric(SENT_BYTES_METRIC_NAME).value() > 0);
assertTrue(reg.<LongMetric>findMetric(RECEIVED_BYTES_METRIC_NAME).value() > 0);
checkSslCommunicationMetrics(reg, 1, 0, 0);
// Tests untrusted certificate.
try (GridClient ignored = start(gridClientConfiguration("client", "trustthree", CIPHER_SUITE, "TLSv1.2"))) {
// GridClient makes 2 additional silent connection attempts if an SSL error occurs.
}
checkSslCommunicationMetrics(reg, 4, 0, 3);
// Tests unsupported cipher suite.
try (GridClient ignored = start(gridClientConfiguration("connectorClient", "trustthree", UNSUPPORTED_CIPHER_SUITE, "TLSv1.2"))) {
// GridClient makes 2 additional silent connection attempts if an SSL error occurs.
}
checkSslCommunicationMetrics(reg, 7, 0, 6);
// Tests mismatched protocol versions.
try (GridClient ignored = start(gridClientConfiguration("connectorClient", "trustthree", null, "TLSv1.1"))) {
// GridClient makes 2 additional silent connection attempts if an SSL error occurs.
}
checkSslCommunicationMetrics(reg, 10, 0, 9);
}
use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.
the class DiskPageCompressionIntegrationTest method doTestPageCompression.
/**
* @throws Exception If failed.
*/
@Override
protected void doTestPageCompression() throws Exception {
IgniteEx ignite = startGrid(0);
ignite.cluster().active(true);
String cacheName = "test";
CacheConfiguration<Integer, TestVal> ccfg = new CacheConfiguration<Integer, TestVal>().setName(cacheName).setBackups(0).setAtomicityMode(ATOMIC).setIndexedTypes(Integer.class, TestVal.class).setDiskPageCompression(compression).setDiskPageCompressionLevel(compressionLevel);
IgniteCache<Integer, TestVal> cache = ignite.getOrCreateCache(ccfg);
int cnt = 2_000;
for (int i = 0; i < cnt; i++) assertTrue(cache.putIfAbsent(i, new TestVal(i)));
for (int i = 0; i < cnt; i += 2) assertEquals(new TestVal(i), cache.getAndRemove(i));
GridCacheDatabaseSharedManager dbMgr = ((GridCacheDatabaseSharedManager) ignite.context().cache().context().database());
dbMgr.forceCheckpoint("test compression").futureFor(FINISHED).get();
FilePageStoreManager storeMgr = dbMgr.getFileStoreManager();
checkFileIOFactory(storeMgr.getPageStoreFileIoFactory());
// Wait for metrics update.
Thread.sleep(100);
long storeSize = ignite.dataStorageMetrics().getStorageSize();
long sparseStoreSize = ignite.dataStorageMetrics().getSparseStorageSize();
assertTrue("storeSize: " + storeSize, storeSize > 0);
if (U.isLinux()) {
assertTrue("sparseSize: " + sparseStoreSize, sparseStoreSize > 0);
assertTrue(storeSize + " > " + sparseStoreSize, storeSize > sparseStoreSize);
} else
assertTrue(sparseStoreSize < 0);
GridCacheContext<?, ?> cctx = ignite.cachex(cacheName).context();
int cacheId = cctx.cacheId();
int groupId = cctx.groupId();
assertEquals(cacheId, groupId);
MetricRegistry mreg = ignite.context().metric().registry(metricName(CACHE_GROUP_METRICS_PREFIX, cctx.group().cacheOrGroupName()));
storeSize = mreg.<LongMetric>findMetric("StorageSize").value();
sparseStoreSize = mreg.<LongMetric>findMetric("SparseStorageSize").value();
assertTrue("storeSize: " + storeSize, storeSize > 0);
if (U.isLinux()) {
assertTrue("sparseSize: " + sparseStoreSize, sparseStoreSize > 0);
assertTrue(storeSize + " > " + sparseStoreSize, storeSize > sparseStoreSize);
} else
assertTrue(sparseStoreSize < 0);
int parts = cctx.affinity().partitions();
for (int i = 0; i < parts; i++) {
PageStore store = storeMgr.getStore(cacheId, i);
long realSize = store.size();
long virtualSize = store.getPageSize() * store.pages();
long sparseSize = store.getSparseSize();
assertTrue(virtualSize > 0);
error("virt: " + virtualSize + ", real: " + realSize + ", sparse: " + sparseSize);
if (!store.exists())
continue;
if (virtualSize > sparseSize)
return;
}
fail("No files were compacted.");
}
use of org.apache.ignite.spi.metric.LongMetric in project ignite by apache.
the class CacheGroupsMetricsRebalanceTest method testRebalancingLastCancelledTime.
/**
* @throws Exception If failed.
*/
@Test
public void testRebalancingLastCancelledTime() throws Exception {
// Used for trigger rebalance cancellation.
rebalanceDelay = REBALANCE_DELAY;
IgniteEx ignite0 = startGrid(0);
List<String> cacheNames = Arrays.asList(CACHE4, CACHE5);
for (String cacheName : cacheNames) {
ignite0.getOrCreateCache(cacheName).putAll(new Random().ints(KEYS_COUNT).distinct().boxed().collect(Collectors.toMap(i -> i, i -> (long) i)));
}
TestRecordingCommunicationSpi.spi(ignite0).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
@Override
public boolean apply(ClusterNode node, Message msg) {
return (msg instanceof GridDhtPartitionSupplyMessage) && ((GridCacheGroupIdMessage) msg).groupId() == CU.cacheId(GROUP2);
}
});
IgniteEx ignite1 = startGrid(1);
TestRecordingCommunicationSpi.spi(ignite0).waitForBlocked();
MetricRegistry mreg = ignite1.context().metric().registry(metricName(CACHE_GROUP_METRICS_PREFIX, GROUP2));
LongMetric startTime = mreg.findMetric("RebalancingStartTime");
LongMetric lastCancelledTime = mreg.findMetric("RebalancingLastCancelledTime");
LongMetric endTime = mreg.findMetric("RebalancingEndTime");
LongMetric partitionsLeft = mreg.findMetric("RebalancingPartitionsLeft");
IntMetric partitionsTotal = mreg.findMetric("RebalancingPartitionsTotal");
assertEquals("During the start of the rebalancing, the number of partitions in the metric should be " + "equal to the number of partitions in the cache group.", DFLT_PARTITION_COUNT, partitionsLeft.value());
assertEquals("The total number of partitions in the metric should be " + "equal to the number of partitions in the cache group.", DFLT_PARTITION_COUNT, partitionsTotal.value());
long rebalancingStartTime = startTime.value();
assertNotSame("During rebalancing start, the start time metric must be determined.", -1, startTime.value());
assertEquals("Rebalancing last cancelled time must be undefined.", -1, lastCancelledTime.value());
assertEquals("Before the rebalancing is completed, the end time metric must be undefined.", -1, endTime.value());
IgniteInternalFuture chain = ignite1.context().cache().internalCache(CACHE5).preloader().rebalanceFuture().chain(f -> {
assertEquals("After the rebalancing is ended, the rebalancing start time must be equal to " + "the start time measured immediately after the rebalancing start.", rebalancingStartTime, startTime.value());
assertEquals("If the rebalancing has been cancelled, the end time must not be set.", -1, endTime.value());
return null;
});
TestRecordingCommunicationSpi.spi(ignite0).stopBlock(false);
chain.get();
assertNotSame("The rebalancing start time must not be equal to the previously measured start time, since" + " the first rebalancing was cancelled and restarted.", rebalancingStartTime, startTime.value());
waitForCondition(() -> lastCancelledTime.value() != -1, 5000);
assertTrue("The rebalancing last cancelled time must be greater than or equal to the start time of the " + "cancelled rebalancing [RebalancingStartTime=" + rebalancingStartTime + ", rebalancingLastCancelledTime=" + lastCancelledTime.value() + "].", rebalancingStartTime <= lastCancelledTime.value());
}
Aggregations