use of org.apache.ignite.internal.managers.discovery.IgniteClusterNode in project ignite by apache.
the class CacheMetricsForClusterGroupSelfTest method testMetricsStatisticsDisabled.
/**
* Test cluster group metrics in case of statistics disabled.
*
* @throws Exception If failed.
*/
@Test
public void testMetricsStatisticsDisabled() throws Exception {
startGrids();
try {
createCaches(false);
populateCacheData(cache1, ENTRY_CNT_CACHE1);
populateCacheData(cache2, ENTRY_CNT_CACHE2);
readCacheData(cache1, ENTRY_CNT_CACHE1);
readCacheData(cache2, ENTRY_CNT_CACHE2);
awaitMetricsUpdate(1);
Collection<ClusterNode> nodes = grid(0).cluster().forRemotes().nodes();
for (ClusterNode node : nodes) {
Map<Integer, CacheMetrics> metrics = ((IgniteClusterNode) node).cacheMetrics();
assertNotNull(metrics);
assertTrue(metrics.isEmpty());
}
assertMetrics(cache1, false);
assertMetrics(cache2, false);
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.managers.discovery.IgniteClusterNode in project ignite by apache.
the class VisorBaselineTaskResult method toMapWithResolvedAddresses.
/**
* @param nodes Nodes to process.
* @return Map of DTO objects, with resolved ip->hostname pairs.
*/
private static Map<String, VisorBaselineNode> toMapWithResolvedAddresses(Collection<? extends BaselineNode> nodes) {
if (F.isEmpty(nodes))
return null;
Map<String, VisorBaselineNode> map = new TreeMap<>();
for (BaselineNode node : nodes) {
Collection<VisorBaselineNode.ResolvedAddresses> addrs = new ArrayList<>();
if (node instanceof IgniteClusterNode) {
for (InetAddress inetAddress : resolveInetAddresses((ClusterNode) node)) addrs.add(new VisorBaselineNode.ResolvedAddresses(inetAddress));
}
VisorBaselineNode dto = new VisorBaselineNode(node, addrs);
map.put(dto.getConsistentId(), dto);
}
return map;
}
use of org.apache.ignite.internal.managers.discovery.IgniteClusterNode in project ignite by apache.
the class ClusterProcessor method updateMetrics.
/**
*/
private void updateMetrics() {
if (ctx.isStopping() || ctx.clientDisconnected())
return;
ClusterNode oldest = ctx.discovery().oldestAliveServerNode(AffinityTopologyVersion.NONE);
if (oldest == null)
return;
if (ctx.localNodeId().equals(oldest.id())) {
IgniteClusterNode locNode = (IgniteClusterNode) ctx.discovery().localNode();
locNode.setMetrics(metricsProvider.metrics());
locNode.setCacheMetrics(metricsProvider.cacheMetrics());
ClusterNodeMetrics metrics = new ClusterNodeMetrics(locNode.metrics(), locNode.cacheMetrics());
try {
byte[] metricsBytes = U.zip(U.marshal(ctx.config().getMarshaller(), metrics));
allNodesMetrics.put(ctx.localNodeId(), metricsBytes);
} catch (IgniteCheckedException e) {
U.warn(log, "Failed to marshal local node metrics: " + e, e);
}
ctx.discovery().metricsUpdateEvent(ctx.discovery().discoCache(), locNode);
Collection<ClusterNode> allNodes = ctx.discovery().allNodes();
ClusterMetricsUpdateMessage msg = new ClusterMetricsUpdateMessage(new HashMap<>(allNodesMetrics));
for (ClusterNode node : allNodes) {
if (ctx.localNodeId().equals(node.id()) || !ctx.discovery().alive(node.id()))
continue;
try {
ctx.io().sendToGridTopic(node, TOPIC_METRICS, msg, GridIoPolicy.SYSTEM_POOL);
} catch (ClusterTopologyCheckedException e) {
if (log.isDebugEnabled())
log.debug("Failed to send metrics update, node failed: " + e);
} catch (IgniteCheckedException e) {
U.warn(log, "Failed to send metrics update: " + e, e);
}
}
} else {
ClusterNodeMetrics metrics = new ClusterNodeMetrics(metricsProvider.metrics(), metricsProvider.cacheMetrics());
try {
byte[] metricsBytes = U.zip(U.marshal(ctx.config().getMarshaller(), metrics));
ClusterMetricsUpdateMessage msg = new ClusterMetricsUpdateMessage(metricsBytes);
ctx.io().sendToGridTopic(oldest, TOPIC_METRICS, msg, GridIoPolicy.SYSTEM_POOL);
} catch (ClusterTopologyCheckedException e) {
if (log.isDebugEnabled())
log.debug("Failed to send metrics update to oldest, node failed: " + e);
} catch (IgniteCheckedException e) {
LT.warn(log, e, "Failed to send metrics update to oldest: " + e, false, false);
}
}
}
use of org.apache.ignite.internal.managers.discovery.IgniteClusterNode in project ignite by apache.
the class ClusterProcessor method updateNodeMetrics.
/**
* @param discoCache Discovery data cache.
* @param nodeId Node ID.
* @param metricsBytes Marshalled metrics.
*/
private void updateNodeMetrics(DiscoCache discoCache, UUID nodeId, byte[] metricsBytes) {
ClusterNode node = discoCache.node(nodeId);
if (node == null || !discoCache.alive(nodeId))
return;
try {
ClusterNodeMetrics metrics = U.unmarshalZip(ctx.config().getMarshaller(), metricsBytes, null);
assert node instanceof IgniteClusterNode : node;
IgniteClusterNode node0 = (IgniteClusterNode) node;
node0.setMetrics(ClusterMetricsSnapshot.deserialize(metrics.metrics(), 0));
node0.setCacheMetrics(metrics.cacheMetrics());
ctx.discovery().metricsUpdateEvent(discoCache, node0);
} catch (IgniteCheckedException e) {
U.warn(log, "Failed to unmarshal node metrics: " + e);
}
}
use of org.apache.ignite.internal.managers.discovery.IgniteClusterNode in project ignite by apache.
the class CacheMetricsForClusterGroupSelfTest method testMetricsStatisticsEnabled.
/**
* Test cluster group metrics in case of statistics enabled.
*/
@Test
public void testMetricsStatisticsEnabled() throws Exception {
startGrids();
try {
createCaches(true);
populateCacheData(cache1, ENTRY_CNT_CACHE1);
populateCacheData(cache2, ENTRY_CNT_CACHE2);
readCacheData(cache1, ENTRY_CNT_CACHE1);
readCacheData(cache2, ENTRY_CNT_CACHE2);
awaitMetricsUpdate(1);
Collection<ClusterNode> nodes = grid(0).cluster().forRemotes().nodes();
for (ClusterNode node : nodes) {
Map<Integer, CacheMetrics> metrics = ((IgniteClusterNode) node).cacheMetrics();
assertNotNull(metrics);
assertFalse(metrics.isEmpty());
}
assertMetrics(cache1, true);
assertMetrics(cache2, true);
} finally {
stopAllGrids();
}
}
Aggregations