Search in sources :

Example 1 with VisorNodeDataCollectorTask

use of org.apache.ignite.internal.visor.node.VisorNodeDataCollectorTask 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);
}
Also used : VisorCacheMetricsCollectorTask(org.apache.ignite.internal.visor.cache.VisorCacheMetricsCollectorTask) VisorIgfsResetMetricsTask(org.apache.ignite.internal.visor.igfs.VisorIgfsResetMetricsTask) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) VisorComputeCancelSessionsTaskArg(org.apache.ignite.internal.visor.compute.VisorComputeCancelSessionsTaskArg) JsonNode(com.fasterxml.jackson.databind.JsonNode) VisorLogSearchTask(org.apache.ignite.internal.visor.log.VisorLogSearchTask) VisorQueryCleanupTaskArg(org.apache.ignite.internal.visor.query.VisorQueryCleanupTaskArg) VisorNodeEventsCollectorTask(org.apache.ignite.internal.visor.node.VisorNodeEventsCollectorTask) VisorCacheStartTask(org.apache.ignite.internal.visor.cache.VisorCacheStartTask) VisorAckTask(org.apache.ignite.internal.visor.misc.VisorAckTask) VisorThreadDumpTask(org.apache.ignite.internal.visor.debug.VisorThreadDumpTask) VisorResolveHostNameTask(org.apache.ignite.internal.visor.misc.VisorResolveHostNameTask) IgniteUuid(org.apache.ignite.lang.IgniteUuid) VisorQueryCancelTask(org.apache.ignite.internal.visor.query.VisorQueryCancelTask) VisorCacheRebalanceTask(org.apache.ignite.internal.visor.cache.VisorCacheRebalanceTask) ClusterNode(org.apache.ignite.cluster.ClusterNode) VisorIgfsResetMetricsTaskArg(org.apache.ignite.internal.visor.igfs.VisorIgfsResetMetricsTaskArg) VisorComputeToggleMonitoringTask(org.apache.ignite.internal.visor.compute.VisorComputeToggleMonitoringTask) VisorChangeGridActiveStateTask(org.apache.ignite.internal.visor.misc.VisorChangeGridActiveStateTask) VisorComputeResetMetricsTask(org.apache.ignite.internal.visor.compute.VisorComputeResetMetricsTask) VisorCacheMetricsCollectorTaskArg(org.apache.ignite.internal.visor.cache.VisorCacheMetricsCollectorTaskArg) VisorNodeDataCollectorTask(org.apache.ignite.internal.visor.node.VisorNodeDataCollectorTask) VisorQueryResetMetricsTask(org.apache.ignite.internal.visor.query.VisorQueryResetMetricsTask) VisorRunningQueriesCollectorTask(org.apache.ignite.internal.visor.query.VisorRunningQueriesCollectorTask) VisorNodeSuppressedErrorsTaskArg(org.apache.ignite.internal.visor.node.VisorNodeSuppressedErrorsTaskArg) VisorQueryDetailMetricsCollectorTask(org.apache.ignite.internal.visor.query.VisorQueryDetailMetricsCollectorTask) VisorCacheRebalanceTaskArg(org.apache.ignite.internal.visor.cache.VisorCacheRebalanceTaskArg) VisorLatestVersionTask(org.apache.ignite.internal.visor.misc.VisorLatestVersionTask) VisorNodeConfigurationCollectorTask(org.apache.ignite.internal.visor.node.VisorNodeConfigurationCollectorTask)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 VisorCacheMetricsCollectorTask (org.apache.ignite.internal.visor.cache.VisorCacheMetricsCollectorTask)1 VisorCacheMetricsCollectorTaskArg (org.apache.ignite.internal.visor.cache.VisorCacheMetricsCollectorTaskArg)1 VisorCacheRebalanceTask (org.apache.ignite.internal.visor.cache.VisorCacheRebalanceTask)1 VisorCacheRebalanceTaskArg (org.apache.ignite.internal.visor.cache.VisorCacheRebalanceTaskArg)1 VisorCacheStartTask (org.apache.ignite.internal.visor.cache.VisorCacheStartTask)1 VisorComputeCancelSessionsTaskArg (org.apache.ignite.internal.visor.compute.VisorComputeCancelSessionsTaskArg)1 VisorComputeResetMetricsTask (org.apache.ignite.internal.visor.compute.VisorComputeResetMetricsTask)1 VisorComputeToggleMonitoringTask (org.apache.ignite.internal.visor.compute.VisorComputeToggleMonitoringTask)1 VisorThreadDumpTask (org.apache.ignite.internal.visor.debug.VisorThreadDumpTask)1 VisorIgfsResetMetricsTask (org.apache.ignite.internal.visor.igfs.VisorIgfsResetMetricsTask)1 VisorIgfsResetMetricsTaskArg (org.apache.ignite.internal.visor.igfs.VisorIgfsResetMetricsTaskArg)1 VisorLogSearchTask (org.apache.ignite.internal.visor.log.VisorLogSearchTask)1 VisorAckTask (org.apache.ignite.internal.visor.misc.VisorAckTask)1 VisorChangeGridActiveStateTask (org.apache.ignite.internal.visor.misc.VisorChangeGridActiveStateTask)1 VisorLatestVersionTask (org.apache.ignite.internal.visor.misc.VisorLatestVersionTask)1 VisorResolveHostNameTask (org.apache.ignite.internal.visor.misc.VisorResolveHostNameTask)1