use of org.apache.ignite.internal.visor.debug.VisorThreadDumpTask 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).set(IgniteUuid.class, IgniteUuid.randomUuid()));
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(), 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);
}
Aggregations