use of org.apache.ignite.internal.processors.metric.MetricRegistry 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.internal.processors.metric.MetricRegistry 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.internal.processors.metric.MetricRegistry 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.internal.processors.metric.MetricRegistry in project ignite by apache.
the class GridIoManager method start.
/**
* {@inheritDoc}
*/
@Override
public void start() throws IgniteCheckedException {
ctx.addNodeAttribute(DIRECT_PROTO_VER_ATTR, DIRECT_PROTO_VER);
MessageFormatter[] formatterExt = ctx.plugins().extensions(MessageFormatter.class);
if (formatterExt != null && formatterExt.length > 0) {
if (formatterExt.length > 1)
throw new IgniteCheckedException("More than one MessageFormatter extension is defined. Check your " + "plugins configuration and make sure that only one of them provides custom message format.");
formatter = formatterExt[0];
} else {
formatter = new MessageFormatter() {
@Override
public MessageWriter writer(UUID rmtNodeId) throws IgniteCheckedException {
assert rmtNodeId != null;
return new DirectMessageWriter(U.directProtocolVersion(ctx, rmtNodeId));
}
@Override
public MessageReader reader(UUID rmtNodeId, MessageFactory msgFactory) throws IgniteCheckedException {
return new DirectMessageReader(msgFactory, rmtNodeId != null ? U.directProtocolVersion(ctx, rmtNodeId) : DIRECT_PROTO_VER);
}
};
}
MessageFactory[] msgs = ctx.plugins().extensions(MessageFactory.class);
if (msgs == null)
msgs = EMPTY;
List<MessageFactory> compMsgs = new ArrayList<>();
compMsgs.add(new GridIoMessageFactory());
for (IgniteComponentType compType : IgniteComponentType.values()) {
MessageFactory f = compType.messageFactory();
if (f != null)
compMsgs.add(f);
}
if (!compMsgs.isEmpty())
msgs = F.concat(msgs, compMsgs.toArray(new MessageFactory[compMsgs.size()]));
msgFactory = new IgniteMessageFactoryImpl(msgs);
CommunicationSpi<Serializable> spi = getSpi();
if ((CommunicationSpi<?>) spi instanceof TcpCommunicationSpi)
getTcpCommunicationSpi().setConnectionRequestor(invConnHandler);
startSpi();
MetricRegistry ioMetric = ctx.metric().registry(COMM_METRICS);
ioMetric.register(OUTBOUND_MSG_QUEUE_CNT, spi::getOutboundMessagesQueueSize, "Outbound messages queue size.");
ioMetric.register(SENT_MSG_CNT, spi::getSentMessagesCount, "Sent messages count.");
ioMetric.register(SENT_BYTES_CNT, spi::getSentBytesCount, "Sent bytes count.");
ioMetric.register(RCVD_MSGS_CNT, spi::getReceivedMessagesCount, "Received messages count.");
ioMetric.register(RCVD_BYTES_CNT, spi::getReceivedBytesCount, "Received bytes count.");
getSpi().setListener(commLsnr = new CommunicationListenerEx<Serializable>() {
@Override
public void onMessage(UUID nodeId, Serializable msg, IgniteRunnable msgC) {
try {
onMessage0(nodeId, (GridIoMessage) msg, msgC);
} catch (ClassCastException ignored) {
U.error(log, "Communication manager received message of unknown type (will ignore): " + msg.getClass().getName() + ". Most likely GridCommunicationSpi is being used directly, " + "which is illegal - make sure to send messages only via GridProjection API.");
}
}
@Override
public void onDisconnected(UUID nodeId) {
for (GridDisconnectListener lsnr : disconnectLsnrs) lsnr.onNodeDisconnected(nodeId);
}
@Override
public void onChannelOpened(UUID rmtNodeId, Serializable initMsg, Channel channel) {
try {
onChannelOpened0(rmtNodeId, (GridIoMessage) initMsg, channel);
} catch (ClassCastException ignored) {
U.error(log, "Communication manager received message of unknown type (will ignore): " + initMsg.getClass().getName() + ". Most likely GridCommunicationSpi is being used directly, " + "which is illegal - make sure to send messages only via GridProjection API.");
}
}
});
if (log.isDebugEnabled())
log.debug(startInfo());
addMessageListener(GridTopic.TOPIC_IO_TEST, new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg, byte plc) {
ClusterNode node = ctx.discovery().node(nodeId);
if (node == null)
return;
IgniteIoTestMessage msg0 = (IgniteIoTestMessage) msg;
msg0.senderNodeId(nodeId);
if (msg0.request()) {
IgniteIoTestMessage res = new IgniteIoTestMessage(msg0.id(), false, null);
res.flags(msg0.flags());
res.onRequestProcessed();
res.copyDataFromRequest(msg0);
try {
sendToGridTopic(node, GridTopic.TOPIC_IO_TEST, res, GridIoPolicy.SYSTEM_POOL);
} catch (IgniteCheckedException e) {
U.error(log, "Failed to send IO test response [msg=" + msg0 + "]", e);
}
} else {
IoTestFuture fut = ioTestMap().get(msg0.id());
msg0.onResponseProcessed();
if (fut == null)
U.warn(log, "Failed to find IO test future [msg=" + msg0 + ']');
else
fut.onResponse(msg0);
}
}
});
}
use of org.apache.ignite.internal.processors.metric.MetricRegistry in project ignite by apache.
the class GridCacheProcessor method start.
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
@Override
public void start() throws IgniteCheckedException {
ctx.internalSubscriptionProcessor().registerMetastorageListener(recovery);
ctx.internalSubscriptionProcessor().registerDatabaseListener(recovery);
cachesInfo = new ClusterCachesInfo(ctx);
DeploymentMode depMode = ctx.config().getDeploymentMode();
if (!F.isEmpty(ctx.config().getCacheConfiguration())) {
if (depMode != CONTINUOUS && depMode != SHARED)
U.warn(log, "Deployment mode for cache is not CONTINUOUS or SHARED " + "(it is recommended that you change deployment mode and restart): " + depMode);
}
Collection<CacheStoreSessionListener> sessionListeners = CU.startStoreSessionListeners(ctx, ctx.config().getCacheStoreSessionListenerFactories());
sharedCtx = createSharedContext(ctx, sessionListeners);
locCfgMgr = new GridLocalConfigManager(this, ctx);
transactions = new IgniteTransactionsImpl(sharedCtx, null, false);
// Start shared managers.
for (GridCacheSharedManager mgr : sharedCtx.managers()) mgr.start(sharedCtx);
if (!ctx.isDaemon() && (!CU.isPersistenceEnabled(ctx.config())) || ctx.config().isClientMode()) {
CacheJoinNodeDiscoveryData data = locCfgMgr.restoreCacheConfigurations();
if (data != null)
cachesInfo.onStart(data);
}
if (log.isDebugEnabled())
log.debug("Started cache processor.");
ctx.state().cacheProcessorStarted();
ctx.systemView().registerFiltrableView(CACHE_GRP_PAGE_LIST_VIEW, CACHE_GRP_PAGE_LIST_VIEW_DESC, new CachePagesListViewWalker(), this::pagesListViewSupplier, Function.identity());
ctx.systemView().registerFiltrableView(PART_STATES_VIEW, PART_STATES_VIEW_DESC, new PartitionStateViewWalker(), this::partStatesViewSupplier, Function.identity());
ctx.systemView().registerView(CACHE_GRP_IO_VIEW, CACHE_GRP_IO_VIEW_DESC, new CacheGroupIoViewWalker(), () -> F.view(cacheGrps.values(), grp -> !grp.systemCache()), grpCtx -> {
MetricRegistry mreg = ctx.metric().registry(metricName(IoStatisticsType.CACHE_GROUP.metricGroupName(), grpCtx.cacheOrGroupName()));
return new CacheGroupIoView(grpCtx, mreg);
});
}
Aggregations