Search in sources :

Example 1 with ClusterMetrics

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.
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) SB(org.apache.ignite.internal.util.typedef.internal.SB) ClusterMetrics(org.apache.ignite.cluster.ClusterMetrics) IgniteException(org.apache.ignite.IgniteException) Map(java.util.Map) HashMap(java.util.HashMap) TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode)

Example 2 with ClusterMetrics

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;
}
Also used : ClusterMetrics(org.apache.ignite.cluster.ClusterMetrics) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) Ignite(org.apache.ignite.Ignite) GridCommonTest(org.apache.ignite.testframework.junits.common.GridCommonTest) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 3 with ClusterMetrics

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;
}
Also used : ClusterMetrics(org.apache.ignite.cluster.ClusterMetrics)

Example 4 with ClusterMetrics

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;
}
Also used : ClusterMetrics(org.apache.ignite.cluster.ClusterMetrics)

Example 5 with ClusterMetrics

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);
    }
}
Also used : IgniteSystemProperties.getInteger(org.apache.ignite.IgniteSystemProperties.getInteger) CacheMetrics(org.apache.ignite.cache.CacheMetrics) TcpDiscoveryMetricsUpdateMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryMetricsUpdateMessage) ClusterMetrics(org.apache.ignite.cluster.ClusterMetrics) UUID(java.util.UUID) Map(java.util.Map)

Aggregations

ClusterMetrics (org.apache.ignite.cluster.ClusterMetrics)22 Ignite (org.apache.ignite.Ignite)8 Test (org.junit.Test)8 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)7 GridCommonTest (org.apache.ignite.testframework.junits.common.GridCommonTest)6 Map (java.util.Map)5 HashMap (java.util.HashMap)4 UUID (java.util.UUID)4 ClusterNode (org.apache.ignite.cluster.ClusterNode)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 GridTestTask (org.apache.ignite.GridTestTask)2 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)2 IgniteException (org.apache.ignite.IgniteException)2 RuntimeMXBean (java.lang.management.RuntimeMXBean)1 InetAddress (java.net.InetAddress)1 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 List (java.util.List)1