use of org.apache.ignite.events.TaskEvent in project ignite by apache.
the class GridTaskTimeoutSelfTest method checkTimedOutEvents.
/**
* @param execId Execution ID.
*/
private void checkTimedOutEvents(final IgniteUuid execId) {
Ignite ignite = G.ignite(getTestIgniteInstanceName());
Collection<Event> evts = ignite.events().localQuery(new PE() {
@Override
public boolean apply(Event evt) {
return ((TaskEvent) evt).taskSessionId().equals(execId);
}
}, EVT_TASK_TIMEDOUT);
assert evts.size() == 1 : "Invalid number of timed out tasks: " + evts.size();
}
use of org.apache.ignite.events.TaskEvent in project ignite by apache.
the class WeightedRandomLoadBalancingSpi method onContextInitialized0.
/** {@inheritDoc} */
@Override
protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException {
getSpiContext().addLocalEventListener(evtLsnr = new GridLocalEventListener() {
@Override
public void onEvent(Event evt) {
assert evt instanceof TaskEvent || evt instanceof JobEvent;
if (evt.type() == EVT_TASK_FINISHED || evt.type() == EVT_TASK_FAILED) {
IgniteUuid sesId = ((TaskEvent) evt).taskSessionId();
taskTops.remove(sesId);
if (log.isDebugEnabled())
log.debug("Removed task topology from topology cache for session: " + sesId);
} else // Here we set mapped property and later cache will be ignored
if (evt.type() == EVT_JOB_MAPPED) {
IgniteUuid sesId = ((JobEvent) evt).taskSessionId();
IgniteBiTuple<Boolean, WeightedTopology> weightedTop = taskTops.get(sesId);
if (weightedTop != null)
weightedTop.set1(true);
if (log.isDebugEnabled())
log.debug("Job has been mapped. Ignore cache for session: " + sesId);
}
}
}, EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED);
}
use of org.apache.ignite.events.TaskEvent in project ignite by apache.
the class GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest method testMultipleTasks.
/**
* @throws Exception If test failed.
*/
@SuppressWarnings({ "ObjectEquality" })
public void testMultipleTasks() throws Exception {
ComputeTaskSession ses1 = new GridTestTaskSession(IgniteUuid.randomUuid());
ComputeTaskSession ses2 = new GridTestTaskSession(IgniteUuid.randomUuid());
List<ClusterNode> allNodes = (List<ClusterNode>) getSpiContext().nodes();
// Initialize.
getSpi().getBalancedNode(ses1, allNodes, new GridTestJob());
getSpi().getBalancedNode(ses2, allNodes, new GridTestJob());
List<UUID> orderedNodes1 = getSpi().getNodeIds(ses1);
List<UUID> orderedNodes2 = getSpi().getNodeIds(ses2);
assert orderedNodes1 != orderedNodes2;
// Check the round-robin actually did circle.
for (int i = 0; i < allNodes.size(); i++) {
ClusterNode node1 = getSpi().getBalancedNode(ses1, allNodes, new GridTestJob());
assert orderedNodes1.get(i) == node1.id();
ClusterNode node2 = getSpi().getBalancedNode(ses2, allNodes, new GridTestJob());
assert orderedNodes2.get(i) == node2.id();
assert orderedNodes1.get(i) == orderedNodes2.get(i);
}
// Double-check.
for (int i = 0; i < allNodes.size(); i++) {
ClusterNode node1 = getSpi().getBalancedNode(ses1, allNodes, new GridTestJob());
assert orderedNodes1.get(i) == node1.id();
ClusterNode node2 = getSpi().getBalancedNode(ses2, allNodes, new GridTestJob());
assert orderedNodes2.get(i) == node2.id();
assert orderedNodes1.get(i) == orderedNodes2.get(i);
}
getSpiContext().triggerEvent(new TaskEvent(null, null, EVT_TASK_FINISHED, ses1.getId(), null, null, false, null));
getSpiContext().triggerEvent(new TaskEvent(null, null, EVT_TASK_FAILED, ses2.getId(), null, null, false, null));
}
use of org.apache.ignite.events.TaskEvent in project ignite by apache.
the class GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest method testMultipleTaskSessions.
/**
* @throws Exception If test failed.
*/
public void testMultipleTaskSessions() throws Exception {
ComputeTaskSession ses1 = new GridTestTaskSession(IgniteUuid.randomUuid());
ComputeTaskSession ses2 = new GridTestTaskSession(IgniteUuid.randomUuid());
List<ClusterNode> allNodes = (List<ClusterNode>) getSpiContext().nodes();
List<UUID> orderedNodes = getSpi().getNodeIds(ses1);
assertEquals("Balancer doesn't use all available nodes", orderedNodes.size(), allNodes.size());
checkCyclicBalancing(getSpi(), allNodes, orderedNodes, ses1, ses2);
getSpiContext().triggerEvent(new TaskEvent(null, null, EVT_TASK_FINISHED, ses1.getId(), null, null, false, null));
getSpiContext().triggerEvent(new TaskEvent(null, null, EVT_TASK_FAILED, ses2.getId(), null, null, false, null));
}
use of org.apache.ignite.events.TaskEvent in project ignite by apache.
the class TaskEventSubjectIdSelfTest method testClosure.
/**
* @throws Exception If failed.
*/
public void testClosure() throws Exception {
latch = new CountDownLatch(3);
grid().compute().run(new IgniteRunnable() {
@Override
public void run() {
// No-op.
}
});
assert latch.await(1000, MILLISECONDS);
assertEquals(3, evts.size());
Iterator<TaskEvent> it = evts.iterator();
assert it.hasNext();
TaskEvent evt = it.next();
assert evt != null;
assertEquals(EVT_TASK_STARTED, evt.type());
assertEquals(nodeId, evt.subjectId());
assert it.hasNext();
evt = it.next();
assert evt != null;
assertEquals(EVT_TASK_REDUCED, evt.type());
assertEquals(nodeId, evt.subjectId());
assert it.hasNext();
evt = it.next();
assert evt != null;
assertEquals(EVT_TASK_FINISHED, evt.type());
assertEquals(nodeId, evt.subjectId());
assert !it.hasNext();
}
Aggregations