Search in sources :

Example 1 with ClusterMetricsSnapshot

use of org.apache.ignite.internal.ClusterMetricsSnapshot in project ignite by apache.

the class GridJobStealingCollisionSpiCustomTopologySelfTest method initSpiContext.

/** {@inheritDoc} */
@Override
protected GridSpiTestContext initSpiContext() throws Exception {
    GridSpiTestContext ctx = super.initSpiContext();
    GridTestNode locNode = new GridTestNode(UUID.randomUUID());
    ctx.setLocalNode(locNode);
    rmtNode1 = new GridTestNode(UUID.randomUUID());
    rmtNode2 = new GridTestNode(UUID.randomUUID());
    addSpiDependency(locNode);
    addSpiDependency(rmtNode1);
    addSpiDependency(rmtNode2);
    ClusterMetricsSnapshot metrics = new ClusterMetricsSnapshot();
    metrics.setCurrentWaitingJobs(2);
    rmtNode1.setMetrics(metrics);
    rmtNode2.setMetrics(metrics);
    ctx.addNode(rmtNode1);
    ctx.addNode(rmtNode2);
    return ctx;
}
Also used : ClusterMetricsSnapshot(org.apache.ignite.internal.ClusterMetricsSnapshot) GridSpiTestContext(org.apache.ignite.testframework.GridSpiTestContext) GridTestNode(org.apache.ignite.testframework.GridTestNode)

Example 2 with ClusterMetricsSnapshot

use of org.apache.ignite.internal.ClusterMetricsSnapshot in project ignite by apache.

the class GridTopologyHeapSizeSelfTest method getNode.

/**
     * Creates test node with specified attributes.
     *
     * @param mac Node mac addresses.
     * @param pid Node PID.
     * @return Node.
     */
private GridTestNode getNode(String mac, int pid) {
    ClusterMetricsSnapshot metrics = new ClusterMetricsSnapshot();
    metrics.setHeapMemoryMaximum(1024 * 1024 * 1024);
    metrics.setHeapMemoryInitialized(1024 * 1024 * 1024);
    GridTestNode node = new GridTestNode(UUID.randomUUID(), metrics);
    node.addAttribute(ATTR_MACS, mac);
    node.addAttribute(ATTR_JVM_PID, pid);
    return node;
}
Also used : ClusterMetricsSnapshot(org.apache.ignite.internal.ClusterMetricsSnapshot) GridTestNode(org.apache.ignite.testframework.GridTestNode)

Example 3 with ClusterMetricsSnapshot

use of org.apache.ignite.internal.ClusterMetricsSnapshot in project ignite by apache.

the class ClusterMetricsSnapshotSerializeSelfTest method createMetrics.

/**
     * @return Test metrics.
     */
private ClusterMetrics createMetrics() {
    ClusterMetricsSnapshot metrics = new ClusterMetricsSnapshot();
    metrics.setAvailableProcessors(1);
    metrics.setAverageActiveJobs(2);
    metrics.setAverageCancelledJobs(3);
    metrics.setAverageJobExecuteTime(4);
    metrics.setAverageJobWaitTime(5);
    metrics.setAverageRejectedJobs(6);
    metrics.setAverageWaitingJobs(7);
    metrics.setCurrentActiveJobs(8);
    metrics.setCurrentCancelledJobs(9);
    metrics.setCurrentIdleTime(10);
    metrics.setCurrentIdleTime(11);
    metrics.setCurrentJobExecuteTime(12);
    metrics.setCurrentJobWaitTime(13);
    metrics.setCurrentRejectedJobs(14);
    metrics.setCurrentWaitingJobs(15);
    metrics.setCurrentDaemonThreadCount(16);
    metrics.setHeapMemoryCommitted(17);
    metrics.setHeapMemoryInitialized(18);
    metrics.setHeapMemoryMaximum(19);
    metrics.setHeapMemoryUsed(20);
    metrics.setLastUpdateTime(21);
    metrics.setMaximumActiveJobs(22);
    metrics.setMaximumCancelledJobs(23);
    metrics.setMaximumJobExecuteTime(24);
    metrics.setMaximumJobWaitTime(25);
    metrics.setMaximumRejectedJobs(26);
    metrics.setMaximumWaitingJobs(27);
    metrics.setNonHeapMemoryCommitted(28);
    metrics.setNonHeapMemoryInitialized(29);
    metrics.setNonHeapMemoryMaximum(30);
    metrics.setNonHeapMemoryUsed(31);
    metrics.setMaximumThreadCount(32);
    metrics.setStartTime(33);
    metrics.setCurrentCpuLoad(34);
    metrics.setCurrentThreadCount(35);
    metrics.setTotalCancelledJobs(36);
    metrics.setTotalExecutedJobs(37);
    metrics.setTotalIdleTime(38);
    metrics.setTotalRejectedJobs(39);
    metrics.setTotalStartedThreadCount(40);
    metrics.setUpTime(41);
    metrics.setSentMessagesCount(42);
    metrics.setSentBytesCount(43);
    metrics.setReceivedMessagesCount(44);
    metrics.setReceivedBytesCount(45);
    metrics.setOutboundMessagesQueueSize(46);
    metrics.setNonHeapMemoryTotal(47);
    metrics.setHeapMemoryTotal(48);
    return metrics;
}
Also used : ClusterMetricsSnapshot(org.apache.ignite.internal.ClusterMetricsSnapshot)

Example 4 with ClusterMetricsSnapshot

use of org.apache.ignite.internal.ClusterMetricsSnapshot in project ignite by apache.

the class GridDiscoveryManager method createMetricsProvider.

/**
     * @return Metrics provider.
     */
private DiscoveryMetricsProvider createMetricsProvider() {
    return new DiscoveryMetricsProvider() {

        /** */
        private final long startTime = U.currentTimeMillis();

        /** {@inheritDoc} */
        @Override
        public ClusterMetrics metrics() {
            GridJobMetrics jm = ctx.jobMetric().getJobMetrics();
            ClusterMetricsSnapshot nm = new ClusterMetricsSnapshot();
            nm.setLastUpdateTime(U.currentTimeMillis());
            // Job metrics.
            nm.setMaximumActiveJobs(jm.getMaximumActiveJobs());
            nm.setCurrentActiveJobs(jm.getCurrentActiveJobs());
            nm.setAverageActiveJobs(jm.getAverageActiveJobs());
            nm.setMaximumWaitingJobs(jm.getMaximumWaitingJobs());
            nm.setCurrentWaitingJobs(jm.getCurrentWaitingJobs());
            nm.setAverageWaitingJobs(jm.getAverageWaitingJobs());
            nm.setMaximumRejectedJobs(jm.getMaximumRejectedJobs());
            nm.setCurrentRejectedJobs(jm.getCurrentRejectedJobs());
            nm.setAverageRejectedJobs(jm.getAverageRejectedJobs());
            nm.setMaximumCancelledJobs(jm.getMaximumCancelledJobs());
            nm.setCurrentCancelledJobs(jm.getCurrentCancelledJobs());
            nm.setAverageCancelledJobs(jm.getAverageCancelledJobs());
            nm.setTotalRejectedJobs(jm.getTotalRejectedJobs());
            nm.setTotalCancelledJobs(jm.getTotalCancelledJobs());
            nm.setTotalExecutedJobs(jm.getTotalExecutedJobs());
            nm.setMaximumJobWaitTime(jm.getMaximumJobWaitTime());
            nm.setCurrentJobWaitTime(jm.getCurrentJobWaitTime());
            nm.setAverageJobWaitTime(jm.getAverageJobWaitTime());
            nm.setMaximumJobExecuteTime(jm.getMaximumJobExecuteTime());
            nm.setCurrentJobExecuteTime(jm.getCurrentJobExecuteTime());
            nm.setAverageJobExecuteTime(jm.getAverageJobExecuteTime());
            nm.setCurrentIdleTime(jm.getCurrentIdleTime());
            nm.setTotalIdleTime(jm.getTotalIdleTime());
            nm.setAverageCpuLoad(jm.getAverageCpuLoad());
            // Job metrics.
            nm.setTotalExecutedTasks(ctx.task().getTotalExecutedTasks());
            // VM metrics.
            nm.setAvailableProcessors(metrics.getAvailableProcessors());
            nm.setCurrentCpuLoad(metrics.getCurrentCpuLoad());
            nm.setCurrentGcCpuLoad(metrics.getCurrentGcCpuLoad());
            nm.setHeapMemoryInitialized(metrics.getHeapMemoryInitialized());
            nm.setHeapMemoryUsed(metrics.getHeapMemoryUsed());
            nm.setHeapMemoryCommitted(metrics.getHeapMemoryCommitted());
            nm.setHeapMemoryMaximum(metrics.getHeapMemoryMaximum());
            nm.setHeapMemoryTotal(metrics.getHeapMemoryMaximum());
            nm.setNonHeapMemoryInitialized(metrics.getNonHeapMemoryInitialized());
            nonHeapMemoryUsed(nm);
            nm.setNonHeapMemoryCommitted(metrics.getNonHeapMemoryCommitted());
            nm.setNonHeapMemoryMaximum(metrics.getNonHeapMemoryMaximum());
            nm.setNonHeapMemoryTotal(metrics.getNonHeapMemoryMaximum());
            nm.setUpTime(metrics.getUptime());
            nm.setStartTime(metrics.getStartTime());
            nm.setNodeStartTime(startTime);
            nm.setCurrentThreadCount(metrics.getThreadCount());
            nm.setMaximumThreadCount(metrics.getPeakThreadCount());
            nm.setTotalStartedThreadCount(metrics.getTotalStartedThreadCount());
            nm.setCurrentDaemonThreadCount(metrics.getDaemonThreadCount());
            nm.setTotalNodes(1);
            // Data metrics.
            nm.setLastDataVersion(ctx.cache().lastDataVersion());
            GridIoManager io = ctx.io();
            // IO metrics.
            nm.setSentMessagesCount(io.getSentMessagesCount());
            nm.setSentBytesCount(io.getSentBytesCount());
            nm.setReceivedMessagesCount(io.getReceivedMessagesCount());
            nm.setReceivedBytesCount(io.getReceivedBytesCount());
            nm.setOutboundMessagesQueueSize(io.getOutboundMessagesQueueSize());
            return nm;
        }

        /**
             * @param nm Initializing metrics snapshot.
             */
        private void nonHeapMemoryUsed(ClusterMetricsSnapshot nm) {
            long nonHeapUsed = metrics.getNonHeapMemoryUsed();
            Map<Integer, CacheMetrics> nodeCacheMetrics = cacheMetrics();
            if (nodeCacheMetrics != null) {
                for (Map.Entry<Integer, CacheMetrics> entry : nodeCacheMetrics.entrySet()) {
                    CacheMetrics e = entry.getValue();
                    if (e != null)
                        nonHeapUsed += e.getOffHeapAllocatedSize();
                }
            }
            nm.setNonHeapMemoryUsed(nonHeapUsed);
        }

        /** {@inheritDoc} */
        @Override
        public Map<Integer, CacheMetrics> cacheMetrics() {
            Collection<GridCacheAdapter<?, ?>> caches = ctx.cache().internalCaches();
            if (F.isEmpty(caches))
                return Collections.emptyMap();
            Map<Integer, CacheMetrics> metrics = null;
            for (GridCacheAdapter<?, ?> cache : caches) {
                if (cache.configuration().isStatisticsEnabled() && cache.context().started() && cache.context().affinity().affinityTopologyVersion().topologyVersion() > 0) {
                    if (metrics == null)
                        metrics = U.newHashMap(caches.size());
                    metrics.put(cache.context().cacheId(), cache.localMetrics());
                }
            }
            return metrics == null ? Collections.<Integer, CacheMetrics>emptyMap() : metrics;
        }
    };
}
Also used : CacheMetrics(org.apache.ignite.cache.CacheMetrics) ClusterMetricsSnapshot(org.apache.ignite.internal.ClusterMetricsSnapshot) IgniteSystemProperties.getInteger(org.apache.ignite.IgniteSystemProperties.getInteger) GridJobMetrics(org.apache.ignite.internal.processors.jobmetrics.GridJobMetrics) GridIoManager(org.apache.ignite.internal.managers.communication.GridIoManager) GridCacheAdapter(org.apache.ignite.internal.processors.cache.GridCacheAdapter) DiscoveryMetricsProvider(org.apache.ignite.spi.discovery.DiscoveryMetricsProvider) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) GridBoundedConcurrentLinkedHashMap(org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap)

Example 5 with ClusterMetricsSnapshot

use of org.apache.ignite.internal.ClusterMetricsSnapshot in project ignite by apache.

the class GridJobStealingCollisionSpiSelfTest method initSpiContext.

/** {@inheritDoc} */
@Override
protected GridSpiTestContext initSpiContext() throws Exception {
    GridSpiTestContext ctx = super.initSpiContext();
    GridTestNode locNode = new GridTestNode(UUID.randomUUID());
    addSpiDependency(locNode);
    ctx.setLocalNode(locNode);
    GridTestNode rmtNode = new GridTestNode(UUID.randomUUID());
    addSpiDependency(rmtNode);
    rmtNode.setAttribute(U.spiAttribute(getSpi(), WAIT_JOBS_THRESHOLD_NODE_ATTR), getWaitJobsThreshold());
    ClusterMetricsSnapshot metrics = new ClusterMetricsSnapshot();
    metrics.setCurrentWaitingJobs(2);
    rmtNode.setMetrics(metrics);
    ctx.addNode(rmtNode);
    return ctx;
}
Also used : ClusterMetricsSnapshot(org.apache.ignite.internal.ClusterMetricsSnapshot) GridSpiTestContext(org.apache.ignite.testframework.GridSpiTestContext) GridTestNode(org.apache.ignite.testframework.GridTestNode)

Aggregations

ClusterMetricsSnapshot (org.apache.ignite.internal.ClusterMetricsSnapshot)7 GridTestNode (org.apache.ignite.testframework.GridTestNode)4 GridSpiTestContext (org.apache.ignite.testframework.GridSpiTestContext)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 IgniteSystemProperties.getInteger (org.apache.ignite.IgniteSystemProperties.getInteger)1 CacheMetrics (org.apache.ignite.cache.CacheMetrics)1 GridIoManager (org.apache.ignite.internal.managers.communication.GridIoManager)1 GridCacheAdapter (org.apache.ignite.internal.processors.cache.GridCacheAdapter)1 GridJobMetrics (org.apache.ignite.internal.processors.jobmetrics.GridJobMetrics)1 GridBoundedConcurrentLinkedHashMap (org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap)1 DiscoveryMetricsProvider (org.apache.ignite.spi.discovery.DiscoveryMetricsProvider)1