use of org.apache.ignite.cluster.ClusterMetrics in project ignite by apache.
the class IgniteKernal method ackNodeMetrics.
/**
* Logs out node metrics.
*
* @param dblFmt Decimal format.
* @param execSvc Executor service.
* @param sysExecSvc System executor service.
* @param customExecSvcs Custom named executors.
*/
private void ackNodeMetrics(DecimalFormat dblFmt, ExecutorService execSvc, ExecutorService sysExecSvc, ExecutorService stripedExecSvc, Map<String, ? extends ExecutorService> customExecSvcs) {
if (!log.isInfoEnabled())
return;
try {
ClusterMetrics m = cluster().localNode().metrics();
int localCpus = m.getTotalCpus();
double cpuLoadPct = m.getCurrentCpuLoad() * 100;
double avgCpuLoadPct = m.getAverageCpuLoad() * 100;
double gcPct = m.getCurrentGcCpuLoad() * 100;
// Heap params.
long heapUsed = m.getHeapMemoryUsed();
long heapMax = m.getHeapMemoryMaximum();
long heapUsedInMBytes = heapUsed / MEGABYTE;
long heapCommInMBytes = m.getHeapMemoryCommitted() / MEGABYTE;
double freeHeapPct = heapMax > 0 ? ((double) ((heapMax - heapUsed) * 100)) / heapMax : -1;
int hosts = 0;
int servers = 0;
int clients = 0;
int cpus = 0;
try {
ClusterMetrics metrics = cluster().metrics();
Collection<ClusterNode> nodes0 = cluster().nodes();
hosts = U.neighborhood(nodes0).size();
servers = cluster().forServers().nodes().size();
clients = cluster().forClients().nodes().size();
cpus = metrics.getTotalCpus();
} catch (IgniteException ignore) {
// No-op.
}
String dataStorageInfo = dataStorageReport(ctx.cache().context().database(), dblFmt, true);
String id = U.id8(localNode().id());
AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
ClusterNode locNode = ctx.discovery().localNode();
String networkDetails = "";
if (!F.isEmpty(cfg.getLocalHost()))
networkDetails += ", localHost=" + cfg.getLocalHost();
if (locNode instanceof TcpDiscoveryNode)
networkDetails += ", discoPort=" + ((TcpDiscoveryNode) locNode).discoveryPort();
if (cfg.getCommunicationSpi() instanceof TcpCommunicationSpi)
networkDetails += ", commPort=" + ((TcpCommunicationSpi) cfg.getCommunicationSpi()).boundPort();
SB msg = new SB();
msg.nl().a("Metrics for local node (to disable set 'metricsLogFrequency' to 0)").nl().a(" ^-- Node [id=").a(id).a(name() != null ? ", name=" + name() : "").a(", uptime=").a(upTimeFormatted()).a("]").nl().a(" ^-- Cluster [hosts=").a(hosts).a(", CPUs=").a(cpus).a(", servers=").a(servers).a(", clients=").a(clients).a(", topVer=").a(topVer.topologyVersion()).a(", minorTopVer=").a(topVer.minorTopologyVersion()).a("]").nl().a(" ^-- Network [addrs=").a(locNode.addresses()).a(networkDetails).a("]").nl().a(" ^-- CPU [CPUs=").a(localCpus).a(", curLoad=").a(dblFmt.format(cpuLoadPct)).a("%, avgLoad=").a(dblFmt.format(avgCpuLoadPct)).a("%, GC=").a(dblFmt.format(gcPct)).a("%]").nl().a(" ^-- Heap [used=").a(dblFmt.format(heapUsedInMBytes)).a("MB, free=").a(dblFmt.format(freeHeapPct)).a("%, comm=").a(dblFmt.format(heapCommInMBytes)).a("MB]").nl().a(dataStorageInfo).a(" ^-- Outbound messages queue [size=").a(m.getOutboundMessagesQueueSize()).a("]").nl().a(" ^-- ").a(createExecutorDescription("Public thread pool", execSvc)).nl().a(" ^-- ").a(createExecutorDescription("System thread pool", sysExecSvc)).nl().a(" ^-- ").a(createExecutorDescription("Striped thread pool", stripedExecSvc));
if (customExecSvcs != null) {
for (Map.Entry<String, ? extends ExecutorService> entry : customExecSvcs.entrySet()) msg.nl().a(" ^-- ").a(createExecutorDescription(entry.getKey(), entry.getValue()));
}
log.info(msg.toString());
ctx.cache().context().database().dumpStatistics(log);
} catch (IgniteClientDisconnectedException ignore) {
// No-op.
}
}
use of org.apache.ignite.cluster.ClusterMetrics in project ignite by apache.
the class ClusterNodeMetricsSelfTest method testClusterNodeMetrics.
/**
* @throws Exception If failed.
*/
@Test
public void testClusterNodeMetrics() throws Exception {
final Ignite ignite0 = grid();
final Ignite ignite1 = startGrid(1);
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return ignite0.cluster().nodes().size() == 2 && ignite1.cluster().nodes().size() == 2;
}
}, 3000L);
ClusterMetrics metrics0 = ignite0.cluster().localNode().metrics();
ClusterMetrics nodesMetrics = ignite0.cluster().forNode(ignite0.cluster().localNode(), ignite1.cluster().localNode()).metrics();
assertEquals(metrics0.getTotalCpus(), nodesMetrics.getTotalCpus());
assertEquals(1, metrics0.getTotalNodes());
assertEquals(2, nodesMetrics.getTotalNodes());
assert metrics0.getHeapMemoryUsed() > 0;
assert metrics0.getHeapMemoryTotal() > 0;
}
use of org.apache.ignite.cluster.ClusterMetrics in project ignite by apache.
the class AdaptiveProcessingTimeLoadProbe method getLoad.
/**
* {@inheritDoc}
*/
@Override
public double getLoad(ClusterNode node, int jobsSentSinceLastUpdate) {
ClusterMetrics metrics = node.metrics();
if (useAvg) {
double load = metrics.getAverageJobExecuteTime() + metrics.getAverageJobWaitTime();
// Otherwise, we will proceed to using current times.
if (load > 0)
return load;
}
double load = metrics.getCurrentJobExecuteTime() + metrics.getCurrentJobWaitTime();
return load < 0 ? 0 : load;
}
use of org.apache.ignite.cluster.ClusterMetrics in project ignite by apache.
the class TcpDiscoveryNode method metrics.
/**
* {@inheritDoc}
*/
@Override
public ClusterMetrics metrics() {
if (metricsProvider != null) {
ClusterMetrics metrics0 = metricsProvider.metrics();
metrics = metrics0;
return metrics0;
}
return metrics;
}
use of org.apache.ignite.cluster.ClusterMetrics in project ignite by apache.
the class TcpDiscoveryImpl method processMsgCacheMetrics.
/**
*/
public void processMsgCacheMetrics(TcpDiscoveryMetricsUpdateMessage msg, long tsNanos) {
for (Map.Entry<UUID, TcpDiscoveryMetricsUpdateMessage.MetricsSet> e : msg.metrics().entrySet()) {
UUID nodeId = e.getKey();
TcpDiscoveryMetricsUpdateMessage.MetricsSet metricsSet = e.getValue();
Map<Integer, CacheMetrics> cacheMetrics = msg.hasCacheMetrics(nodeId) ? msg.cacheMetrics().get(nodeId) : Collections.emptyMap();
if (endTimeMetricsSizeProcessWait <= U.currentTimeMillis() && cacheMetrics.size() >= METRICS_QNT_WARN) {
log.warning("The Discovery message has metrics for " + cacheMetrics.size() + " caches.\n" + "To prevent Discovery blocking use -DIGNITE_DISCOVERY_DISABLE_CACHE_METRICS_UPDATE=true option.");
endTimeMetricsSizeProcessWait = U.currentTimeMillis() + LOG_WARN_MSG_TIMEOUT;
}
updateMetrics(nodeId, metricsSet.metrics(), cacheMetrics, tsNanos);
for (T2<UUID, ClusterMetrics> t : metricsSet.clientMetrics()) updateMetrics(t.get1(), t.get2(), cacheMetrics, tsNanos);
}
}
Aggregations