use of org.apache.ignite.cluster.ClusterMetrics in project ignite by apache.
the class ClusterNodeMetricsUpdateTest method checkMetrics0.
/**
* @param expNodes Expected nodes.
* @param expJobs Expected jobs number per node.
*/
private void checkMetrics0(int expNodes, Map<UUID, Integer> expJobs) {
List<Ignite> nodes = Ignition.allGrids();
assertEquals(expNodes, nodes.size());
assertEquals(expNodes, expJobs.size());
int totalJobs = 0;
for (Integer c : expJobs.values()) totalJobs += c;
for (final Ignite ignite : nodes) {
ClusterMetrics m = ignite.cluster().metrics();
assertEquals(expNodes, m.getTotalNodes());
assertEquals(totalJobs, m.getTotalExecutedJobs());
for (Map.Entry<UUID, Integer> e : expJobs.entrySet()) {
UUID nodeId = e.getKey();
ClusterGroup g = ignite.cluster().forNodeId(nodeId);
ClusterMetrics nodeM = g.metrics();
assertEquals(e.getValue(), (Integer) nodeM.getTotalExecutedJobs());
}
}
}
use of org.apache.ignite.cluster.ClusterMetrics in project ignite by apache.
the class ClusterNodeMetricsSelfTest method testInternalTaskMetrics.
/**
* @throws Exception If failed.
*/
@Test
public void testInternalTaskMetrics() throws Exception {
Ignite ignite = grid();
// Visor task is internal and should not affect metrics.
ignite.compute().withName("visor-test-task").execute(new TestInternalTask(), "testArg");
// Let metrics update twice.
awaitMetricsUpdate(2);
ClusterMetrics metrics = ignite.cluster().localNode().metrics();
info("Node metrics: " + metrics);
assert metrics.getAverageActiveJobs() == 0;
assert metrics.getAverageCancelledJobs() == 0;
assert metrics.getAverageJobExecuteTime() == 0;
assert metrics.getAverageJobWaitTime() == 0;
assert metrics.getAverageRejectedJobs() == 0;
assert metrics.getAverageWaitingJobs() == 0;
assert metrics.getCurrentActiveJobs() == 0;
assert metrics.getCurrentCancelledJobs() == 0;
assert metrics.getCurrentJobExecuteTime() == 0;
assert metrics.getCurrentJobWaitTime() == 0;
assert metrics.getCurrentWaitingJobs() == 0;
assert metrics.getMaximumActiveJobs() == 0;
assert metrics.getMaximumCancelledJobs() == 0;
assert metrics.getMaximumJobExecuteTime() == 0;
assert metrics.getMaximumJobWaitTime() == 0;
assert metrics.getMaximumRejectedJobs() == 0;
assert metrics.getMaximumWaitingJobs() == 0;
assert metrics.getTotalCancelledJobs() == 0;
assert metrics.getTotalExecutedJobs() == 0;
assert metrics.getTotalRejectedJobs() == 0;
assert metrics.getTotalExecutedTasks() == 0;
assert metrics.getTotalJobsExecutionTime() == 0;
assertTrue("MaximumJobExecuteTime=" + metrics.getMaximumJobExecuteTime() + " is less than AverageJobExecuteTime=" + metrics.getAverageJobExecuteTime(), metrics.getMaximumJobExecuteTime() >= metrics.getAverageJobExecuteTime());
}
use of org.apache.ignite.cluster.ClusterMetrics in project ignite by apache.
the class ClusterNodeMetricsSelfTest method testIoMetrics.
/**
* @throws Exception If failed.
*/
@Test
public void testIoMetrics() throws Exception {
Ignite ignite0 = grid();
Ignite ignite1 = startGrid(1);
Object msg = new TestMessage();
int size = ignite0.configuration().getMarshaller().marshal(msg).length;
assert size > MSG_SIZE;
final CountDownLatch latch = new CountDownLatch(MSG_CNT);
ignite0.message().localListen(null, new MessagingListenActor<TestMessage>() {
@Override
protected void receive(UUID nodeId, TestMessage rcvMsg) throws Throwable {
latch.countDown();
}
});
ignite1.message().localListen(null, new MessagingListenActor<TestMessage>() {
@Override
protected void receive(UUID nodeId, TestMessage rcvMsg) throws Throwable {
respond(rcvMsg);
}
});
for (int i = 0; i < MSG_CNT; i++) message(ignite0.cluster().forRemotes()).send(null, msg);
latch.await();
ClusterMetrics metrics = ignite0.cluster().localNode().metrics();
info("Node 0 metrics: " + metrics);
// Time sync messages are being sent.
assert metrics.getSentMessagesCount() >= MSG_CNT;
assert metrics.getSentBytesCount() > size * MSG_CNT;
assert metrics.getReceivedMessagesCount() >= MSG_CNT;
assert metrics.getReceivedBytesCount() > size * MSG_CNT;
metrics = ignite1.cluster().localNode().metrics();
info("Node 1 metrics: " + metrics);
// Time sync messages are being sent.
assert metrics.getSentMessagesCount() >= MSG_CNT;
assert metrics.getSentBytesCount() > size * MSG_CNT;
assert metrics.getReceivedMessagesCount() >= MSG_CNT;
assert metrics.getReceivedBytesCount() > size * MSG_CNT;
}
use of org.apache.ignite.cluster.ClusterMetrics in project ignite by apache.
the class ClusterNodeMetricsSelfTest method testSingleTaskMetrics.
/**
* @throws Exception If failed.
*/
@Test
public void testSingleTaskMetrics() throws Exception {
Ignite ignite = grid();
final CountDownLatch taskLatch = new CountDownLatch(1);
ignite.compute().executeAsync(new GridTestTask(taskLatch), "testArg");
// Let metrics update twice.
awaitMetricsUpdate(2);
taskLatch.countDown();
awaitMetricsUpdate(1);
ClusterMetrics metrics = ignite.cluster().localNode().metrics();
info("Node metrics: " + metrics);
assert metrics.getAverageActiveJobs() > 0;
assert metrics.getAverageCancelledJobs() == 0;
assert metrics.getAverageJobExecuteTime() >= 0;
assert metrics.getAverageJobWaitTime() >= 0;
assert metrics.getAverageRejectedJobs() == 0;
assert metrics.getAverageWaitingJobs() == 0;
assert metrics.getCurrentActiveJobs() == 0;
assert metrics.getCurrentCancelledJobs() == 0;
assert metrics.getCurrentJobExecuteTime() > 0;
assert metrics.getCurrentJobWaitTime() == 0;
assert metrics.getCurrentWaitingJobs() == 0;
assert metrics.getMaximumActiveJobs() == 1;
assert metrics.getMaximumCancelledJobs() == 0;
assert metrics.getMaximumJobExecuteTime() >= 0;
assert metrics.getMaximumJobWaitTime() >= 0;
assert metrics.getMaximumRejectedJobs() == 0;
assert metrics.getMaximumWaitingJobs() == 0;
assert metrics.getTotalCancelledJobs() == 0;
assert metrics.getTotalExecutedJobs() == 1;
assert metrics.getTotalRejectedJobs() == 0;
assert metrics.getTotalExecutedTasks() == 1;
assert metrics.getTotalJobsExecutionTime() > 0;
assertTrue("MaximumJobExecuteTime=" + metrics.getMaximumJobExecuteTime() + " is less than AverageJobExecuteTime=" + metrics.getAverageJobExecuteTime(), metrics.getMaximumJobExecuteTime() >= metrics.getAverageJobExecuteTime());
}
use of org.apache.ignite.cluster.ClusterMetrics in project ignite by apache.
the class ZookeeperClusterNode method writeExternal.
/**
* {@inheritDoc}
*/
@Override
public void writeExternal(ObjectOutput out) throws IOException {
U.writeUuid(out, id);
out.writeObject(consistentId);
out.writeLong(internalId);
out.writeLong(order);
out.writeObject(ver);
U.writeMap(out, attrs);
U.writeCollection(out, addrs);
U.writeCollection(out, hostNames);
out.writeLong(sesTimeout);
out.writeByte(flags);
// Cluster metrics
byte[] mtr = null;
ClusterMetrics metrics = this.metrics;
if (metrics != null)
mtr = ClusterMetricsSnapshot.serialize(metrics);
U.writeByteArray(out, mtr);
}
Aggregations