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;
}
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;
}
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;
}
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;
}
};
}
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;
}
Aggregations