use of org.apache.ignite.IgniteCompute in project ignite by apache.
the class GridClusterStateProcessor method sendComputeCheckGlobalState.
/**
* Check cluster state.
*
* @return Cluster state, {@code True} if cluster active, {@code False} if inactive.
*/
private boolean sendComputeCheckGlobalState() {
AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
if (log.isInfoEnabled()) {
log.info("Sending check cluster state request from node [id=" + ctx.localNodeId() + ", topVer=" + topVer + ", client=" + ctx.clientNode() + ", daemon" + ctx.isDaemon() + "]");
}
IgniteCompute comp = ((ClusterGroupAdapter) ctx.cluster().get().forServers()).compute();
return comp.call(new IgniteCallable<Boolean>() {
@IgniteInstanceResource
private Ignite ig;
@Override
public Boolean call() throws Exception {
return ig.active();
}
});
}
use of org.apache.ignite.IgniteCompute in project ignite by apache.
the class GridClusterStateProcessor method sendComputeChangeGlobalState.
/**
* @param activate New cluster state.
* @param resFut State change future.
*/
private void sendComputeChangeGlobalState(boolean activate, BaselineTopology blt, boolean forceBlt, final GridFutureAdapter<Void> resFut) {
AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
if (log.isInfoEnabled()) {
log.info("Sending " + prettyStr(activate) + " request from node [id=" + ctx.localNodeId() + ", topVer=" + topVer + ", client=" + ctx.clientNode() + ", daemon=" + ctx.isDaemon() + "]");
}
IgniteCompute comp = ((ClusterGroupAdapter) ctx.cluster().get().forServers()).compute();
IgniteFuture<Void> fut = comp.runAsync(new ClientChangeGlobalStateComputeRequest(activate, blt, forceBlt));
fut.listen(new CI1<IgniteFuture>() {
@Override
public void apply(IgniteFuture fut) {
try {
fut.get();
resFut.onDone();
} catch (Exception e) {
resFut.onDone(e);
}
}
});
}
use of org.apache.ignite.IgniteCompute in project ignite by apache.
the class PlatformCompute method executeJavaTask.
/**
* Execute task taking arguments from the given reader.
*
* @param reader Reader.
* @param async Execute asynchronously flag.
* @return Task result.
* @throws IgniteCheckedException On error.
*/
protected Object executeJavaTask(BinaryRawReaderEx reader, boolean async) throws IgniteCheckedException {
String taskName = reader.readString();
boolean keepBinary = reader.readBoolean();
Object arg = reader.readObjectDetached();
Collection<UUID> nodeIds = readNodeIds(reader);
IgniteCompute compute0 = computeForTask(nodeIds);
if (!keepBinary && arg instanceof BinaryObjectImpl)
arg = ((BinaryObject) arg).deserialize();
if (async)
return readAndListenFuture(reader, new ComputeConvertingFuture(compute0.executeAsync(taskName, arg)));
else
return toBinary(compute0.execute(taskName, arg));
}
use of org.apache.ignite.IgniteCompute in project ignite by apache.
the class GridDsiClient method call.
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked", "InfiniteLoopStatement" })
@Nullable
@Override
public Object call() throws Exception {
IgniteCompute comp = g.compute(g.cluster().forPredicate(serverNode()));
while (!finish.get()) {
try {
long t0 = System.currentTimeMillis();
long submitTime1 = t0;
ComputeTaskFuture<T3<Long, Integer, Integer>> f1 = comp.executeAsync(GridDsiRequestTask.class, new GridDsiMessage(terminalId, nodeId));
submitTime.setIfGreater(System.currentTimeMillis() - submitTime1);
T3<Long, Integer, Integer> res1 = f1.get();
submitTime1 = System.currentTimeMillis();
ComputeTaskFuture<T3<Long, Integer, Integer>> f2 = comp.executeAsync(GridDsiResponseTask.class, new GridDsiMessage(terminalId, nodeId));
submitTime.setIfGreater(System.currentTimeMillis() - submitTime1);
T3<Long, Integer, Integer> res2 = f2.get();
long t1 = System.currentTimeMillis();
txCnt.incrementAndGet();
latency.addAndGet(t1 - t0);
if (res1 != null)
srvStats = res1;
if (res2 != null)
srvStats = res2;
} catch (IgniteException e) {
e.printStackTrace();
}
}
return null;
}
use of org.apache.ignite.IgniteCompute in project ignite by apache.
the class GridJobExecutionLoadTestClient method warmUp.
/**
* Warms the JVM up.
*
* @param noThreads Number of threads to use.
*/
private static void warmUp(int noThreads) {
X.println("Warming up...");
final IgniteCompute rmts = g.compute(g.cluster().forRemotes());
GridLoadTestUtils.runMultithreadedInLoop(new Callable<Object>() {
@Nullable
@Override
public Object call() {
try {
rmts.execute(GridJobExecutionLoadTestTask.class, null);
} catch (IgniteException e) {
e.printStackTrace();
}
return null;
}
}, noThreads, WARM_UP_DURATION);
// Run GC on all nodes.
try {
g.compute().run(new GridAbsClosure() {
@Override
public void apply() {
System.gc();
}
});
} catch (IgniteException e) {
throw new IllegalStateException(e);
}
}
Aggregations