use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class JettyRestProcessorAbstractSelfTest method testVisorGateway.
/**
* Tests execution of Visor tasks via {@link VisorGatewayTask}.
*
* @throws Exception If failed.
*/
public void testVisorGateway() throws Exception {
ClusterNode locNode = grid(1).localNode();
final IgniteUuid cid = grid(1).context().cache().internalCache("person").context().dynamicDeploymentId();
String ret = content(new VisorGatewayArgument(VisorCacheConfigurationCollectorTask.class).forNode(locNode).argument(VisorCacheConfigurationCollectorTaskArg.class).collection(IgniteUuid.class, cid));
info("VisorCacheConfigurationCollectorTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorCacheNodesTask.class).forNode(locNode).argument(VisorCacheNodesTaskArg.class, "person"));
info("VisorCacheNodesTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorCachePartitionsTask.class).forNode(locNode).argument(VisorCachePartitionsTaskArg.class, "person"));
info("VisorCachePartitionsTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorCacheLoadTask.class).forNode(locNode).argument(VisorCacheLoadTaskArg.class).set(String.class, "person").arguments(0, "null"));
info("VisorCacheLoadTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorCacheRebalanceTask.class).forNode(locNode).argument(VisorCacheRebalanceTaskArg.class).set(String.class, "person"));
info("VisorCacheRebalanceTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorCacheMetadataTask.class).forNode(locNode).argument(VisorCacheMetadataTaskArg.class, "person"));
info("VisorCacheMetadataTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorCacheResetMetricsTask.class).forNode(locNode).argument(VisorCacheResetMetricsTaskArg.class, "person"));
info("VisorCacheResetMetricsTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorIgfsSamplingStateTask.class).forNode(locNode).argument(VisorIgfsSamplingStateTaskArg.class, "igfs", false));
info("VisorIgfsSamplingStateTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorIgfsProfilerClearTask.class).forNode(locNode).argument(VisorIgfsProfilerClearTaskArg.class, "igfs"));
info("VisorIgfsProfilerClearTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorIgfsProfilerTask.class).forNode(locNode).argument(VisorIgfsProfilerTaskArg.class, "igfs"));
info("VisorIgfsProfilerTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorIgfsFormatTask.class).forNode(locNode).argument(VisorIgfsFormatTaskArg.class, "igfs"));
info("VisorIgfsFormatTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorIgfsResetMetricsTask.class).forNode(locNode).argument(VisorIgfsResetMetricsTaskArg.class).set(String.class, "igfs"));
info("VisorIgfsResetMetricsTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorThreadDumpTask.class).forNode(locNode));
info("VisorThreadDumpTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorLatestTextFilesTask.class).forNode(locNode).argument(VisorLatestTextFilesTaskArg.class, "", ""));
info("VisorLatestTextFilesTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorLatestVersionTask.class).forNode(locNode));
info("VisorLatestVersionTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorFileBlockTask.class).forNode(locNode).argument(VisorFileBlockTaskArg.class, "", 0L, 1, 0L));
info("VisorFileBlockTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorNodePingTask.class).forNode(locNode).argument(VisorNodePingTaskArg.class, locNode.id()));
info("VisorNodePingTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorNodeConfigurationCollectorTask.class).forNode(locNode));
info("VisorNodeConfigurationCollectorTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorComputeResetMetricsTask.class).forNode(locNode));
info("VisorComputeResetMetricsTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorQueryTask.class).forNode(locNode).argument(VisorQueryTaskArg.class, "person", URLEncoder.encode("select * from Person", CHARSET), false, false, false, false, 1));
info("VisorQueryTask result: " + ret);
JsonNode res = jsonTaskResult(ret);
final String qryId = res.get("result").get("queryId").asText();
ret = content(new VisorGatewayArgument(VisorQueryNextPageTask.class).forNode(locNode).argument(VisorQueryNextPageTaskArg.class, qryId, 1));
info("VisorQueryNextPageTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorQueryCleanupTask.class).argument(VisorQueryCleanupTaskArg.class).map(UUID.class, Set.class, F.asMap(locNode.id(), qryId)));
info("VisorQueryCleanupTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorResolveHostNameTask.class).forNode(locNode));
info("VisorResolveHostNameTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorQueryCancelTask.class).argument(VisorQueryCancelTaskArg.class, 0L));
info("VisorResolveHostNameTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorQueryResetMetricsTask.class).argument(VisorQueryResetMetricsTaskArg.class, "person"));
info("VisorResolveHostNameTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorQueryCancelTask.class).argument(VisorQueryCancelTaskArg.class, 0L));
info("VisorResolveHostNameTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorQueryResetMetricsTask.class).argument(VisorQueryResetMetricsTaskArg.class, "person"));
info("VisorResolveHostNameTask result: " + ret);
jsonTaskResult(ret);
// Multinode tasks
ret = content(new VisorGatewayArgument(VisorComputeCancelSessionsTask.class).argument(VisorComputeCancelSessionsTaskArg.class).map(UUID.class, Set.class, new HashMap()));
info("VisorComputeCancelSessionsTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorCacheMetricsCollectorTask.class).argument(VisorCacheMetricsCollectorTaskArg.class, false).collection(String.class, "person"));
info("VisorCacheMetricsCollectorTask result: " + ret);
ret = content(new VisorGatewayArgument(VisorCacheMetricsCollectorTask.class).forNodes(grid(1).cluster().nodes()).argument(VisorCacheMetricsCollectorTaskArg.class, false).collection(String.class, "person"));
info("VisorCacheMetricsCollectorTask (with nodes) result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorLogSearchTask.class).argument(VisorLogSearchTaskArg.class, ".", ".", "abrakodabra.txt", 1));
info("VisorLogSearchTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorNodeGcTask.class));
info("VisorNodeGcTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorAckTask.class).argument(VisorAckTaskArg.class, "MSG"));
info("VisorAckTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorNodeEventsCollectorTask.class).argument(VisorNodeEventsCollectorTaskArg.class, "null", "null", "null", "taskName", "null"));
info("VisorNodeEventsCollectorTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorNodeDataCollectorTask.class).argument(VisorNodeDataCollectorTaskArg.class, false, "CONSOLE_" + UUID.randomUUID(), UUID.randomUUID(), 10, false));
info("VisorNodeDataCollectorTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorComputeToggleMonitoringTask.class).argument(VisorComputeToggleMonitoringTaskArg.class, UUID.randomUUID(), false));
info("VisorComputeToggleMonitoringTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorNodeSuppressedErrorsTask.class).argument(VisorNodeSuppressedErrorsTaskArg.class).map(UUID.class, Long.class, new HashMap()));
info("VisorNodeSuppressedErrorsTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorCacheClearTask.class).forNode(locNode).argument(VisorCacheClearTaskArg.class, "person"));
info("VisorCacheClearTask result: " + ret);
jsonTaskResult(ret);
// Spring XML to start cache via Visor task.
final String START_CACHE = "<beans xmlns=\"http://www.springframework.org/schema/beans\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://www.springframework.org/schema/beans\n" + " http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\">\n" + " <bean id=\"cacheConfiguration\" class=\"org.apache.ignite.configuration.CacheConfiguration\">\n" + " <property name=\"cacheMode\" value=\"PARTITIONED\"/>\n" + " <property name=\"name\" value=\"c\"/>\n" + " </bean>\n" + "</beans>";
ret = content(new VisorGatewayArgument(VisorCacheStartTask.class).argument(VisorCacheStartTaskArg.class, false, "person2", URLEncoder.encode(START_CACHE, CHARSET)));
info("VisorCacheStartTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorCacheStopTask.class).forNode(locNode).argument(VisorCacheStopTaskArg.class, "c"));
info("VisorCacheStopTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorQueryDetailMetricsCollectorTask.class).argument(VisorQueryDetailMetricsCollectorTaskArg.class, 0));
info("VisorQueryDetailMetricsCollectorTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorRunningQueriesCollectorTask.class).argument(VisorRunningQueriesCollectorTaskArg.class, 0L));
info("VisorQueryDetailMetricsCollectorTask result: " + ret);
jsonTaskResult(ret);
ret = content(new VisorGatewayArgument(VisorChangeGridActiveStateTask.class).argument(VisorChangeGridActiveStateTaskArg.class, true));
info("VisorQueryDetailMetricsCollectorTask result: " + ret);
jsonTaskResult(ret);
}
use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class ComputeTaskInternalFuture method finishedFuture.
/**
* @param ctx Context.
* @param taskCls Task class.
* @param e Error.
* @return Finished task future.
*/
public static <R> ComputeTaskInternalFuture<R> finishedFuture(final GridKernalContext ctx, final Class<?> taskCls, IgniteCheckedException e) {
assert ctx != null;
assert taskCls != null;
assert e != null;
final long time = U.currentTimeMillis();
final IgniteUuid id = IgniteUuid.fromUuid(ctx.localNodeId());
ComputeTaskSession ses = new ComputeTaskSession() {
@Override
public String getTaskName() {
return taskCls.getName();
}
@Override
public UUID getTaskNodeId() {
return ctx.localNodeId();
}
@Override
public long getStartTime() {
return time;
}
@Override
public long getEndTime() {
return time;
}
@Override
public IgniteUuid getId() {
return id;
}
@Override
public ClassLoader getClassLoader() {
return null;
}
@Override
public Collection<ComputeJobSibling> getJobSiblings() throws IgniteException {
return Collections.emptyList();
}
@Override
public Collection<ComputeJobSibling> refreshJobSiblings() throws IgniteException {
return Collections.emptyList();
}
@Nullable
@Override
public ComputeJobSibling getJobSibling(IgniteUuid jobId) throws IgniteException {
return null;
}
@Override
public void setAttribute(Object key, @Nullable Object val) throws IgniteException {
}
@Nullable
@Override
public <K, V> V getAttribute(K key) {
return null;
}
@Override
public void setAttributes(Map<?, ?> attrs) throws IgniteException {
// No-op.
}
@Override
public Map<?, ?> getAttributes() {
return Collections.emptyMap();
}
@Override
public void addAttributeListener(ComputeTaskSessionAttributeListener lsnr, boolean rewind) {
// No-op.
}
@Override
public boolean removeAttributeListener(ComputeTaskSessionAttributeListener lsnr) {
return false;
}
@Override
public <K, V> V waitForAttribute(K key, long timeout) throws InterruptedException {
throw new InterruptedException("Session was closed.");
}
@Override
public <K, V> boolean waitForAttribute(K key, @Nullable V val, long timeout) throws InterruptedException {
throw new InterruptedException("Session was closed.");
}
@Override
public Map<?, ?> waitForAttributes(Collection<?> keys, long timeout) throws InterruptedException {
throw new InterruptedException("Session was closed.");
}
@Override
public boolean waitForAttributes(Map<?, ?> attrs, long timeout) throws InterruptedException {
throw new InterruptedException("Session was closed.");
}
@Override
public void saveCheckpoint(String key, Object state) {
throw new IgniteException("Session was closed.");
}
@Override
public void saveCheckpoint(String key, Object state, ComputeTaskSessionScope scope, long timeout) {
throw new IgniteException("Session was closed.");
}
@Override
public void saveCheckpoint(String key, Object state, ComputeTaskSessionScope scope, long timeout, boolean overwrite) {
throw new IgniteException("Session was closed.");
}
@Nullable
@Override
public <T> T loadCheckpoint(String key) throws IgniteException {
throw new IgniteException("Session was closed.");
}
@Override
public boolean removeCheckpoint(String key) throws IgniteException {
throw new IgniteException("Session was closed.");
}
@Override
public Collection<UUID> getTopology() {
return Collections.emptyList();
}
@Override
public IgniteFuture<?> mapFuture() {
return new IgniteFinishedFutureImpl<Object>();
}
};
ComputeTaskInternalFuture<R> fut = new ComputeTaskInternalFuture<>(ses, ctx);
fut.onDone(e);
return fut;
}
use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class GridJobContextImpl method holdcc.
/** {@inheritDoc} */
@Override
public <T> T holdcc(long timeout) {
if (ctx != null) {
if (job == null)
job = ctx.job().activeJob(jobId);
if (job != null) {
if (!job.hold())
throw new IllegalStateException("Job has already been hold [ctx=" + this + ']');
assert timeoutObj == null;
if (timeout <= 0)
return null;
final long endTime = U.currentTimeMillis() + timeout;
// Overflow.
if (endTime > 0) {
timeoutObj = new GridTimeoutObject() {
private final IgniteUuid id = IgniteUuid.randomUuid();
@Override
public IgniteUuid timeoutId() {
return id;
}
@Override
public long endTime() {
return endTime;
}
@Override
public void onTimeout() {
try {
synchronized (mux) {
GridTimeoutObject timeoutObj0 = timeoutObj;
if (timeoutObj0 == null || timeoutObj0.timeoutId() != id)
// The timer was canceled by explicit callcc() call.
return;
timeoutObj = null;
}
ExecutorService execSvc = job.isInternal() ? ctx.getManagementExecutorService() : ctx.getExecutorService();
assert execSvc != null;
execSvc.execute(new Runnable() {
@Override
public void run() {
callcc0();
}
});
} catch (RejectedExecutionException e) {
U.error(log(), "Failed to execute job (will execute synchronously).", e);
callcc0();
}
}
};
ctx.timeout().addTimeoutObject(timeoutObj);
}
}
}
return null;
}
use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class IgfsGroupDataBlocksKeyMapper method affinityKey.
/** {@inheritDoc} */
@Override
public Object affinityKey(Object key) {
if (key instanceof IgfsBaseBlockKey) {
IgfsBaseBlockKey blockKey = (IgfsBaseBlockKey) key;
IgniteUuid affKey = blockKey.affinityKey();
if (affKey != null)
return affKey;
long grpId = blockKey.blockId() / grpSize;
return blockKey.fileHash() + (int) (grpId ^ (grpId >>> 32));
}
return super.affinityKey(key);
}
use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.
the class DirectByteBufferStreamImplV2 method readIgniteUuid.
/** {@inheritDoc} */
@Override
public IgniteUuid readIgniteUuid() {
switch(uuidState) {
case 0:
boolean isNull = readBoolean();
if (!lastFinished || isNull)
return null;
uuidState++;
case 1:
uuidMost = readLong();
if (!lastFinished)
return null;
uuidState++;
case 2:
uuidLeast = readLong();
if (!lastFinished)
return null;
uuidState++;
case 3:
uuidLocId = readLong();
if (!lastFinished)
return null;
uuidState = 0;
}
IgniteUuid val = new IgniteUuid(new UUID(uuidMost, uuidLeast), uuidLocId);
uuidMost = 0;
uuidLeast = 0;
uuidLocId = 0;
return val;
}
Aggregations