Search in sources :

Example 1 with GridTaskCommandHandler

use of org.apache.ignite.internal.processors.rest.handlers.task.GridTaskCommandHandler in project ignite by apache.

the class TaskCommandHandlerSelfTest method testManyTasksRun.

/**
 * @throws Exception If failed.
 */
@Test
public void testManyTasksRun() throws Exception {
    GridClientCompute compute = client.compute();
    for (int i = 0; i < 1000; i++) assertEquals(new Integer("executing".length()), compute.execute(TestTask.class.getName(), "executing"));
    GridClientFactory.stop(client.id(), true);
    IgniteKernal g = (IgniteKernal) grid(0);
    Map<GridRestCommand, GridRestCommandHandler> handlers = U.field(g.context().rest(), "handlers");
    GridTaskCommandHandler taskHnd = (GridTaskCommandHandler) F.find(handlers.values(), null, new P1<GridRestCommandHandler>() {

        @Override
        public boolean apply(GridRestCommandHandler e) {
            return e instanceof GridTaskCommandHandler;
        }
    });
    assertNotNull("GridTaskCommandHandler was not found", taskHnd);
    ConcurrentLinkedHashMap taskDesc = U.field(taskHnd, "taskDescs");
    assertTrue("Task result map size exceeded max value [mapSize=" + taskDesc.sizex() + ", " + "maxSize=" + MAX_TASK_RESULTS + ']', taskDesc.sizex() <= MAX_TASK_RESULTS);
}
Also used : GridClientCompute(org.apache.ignite.internal.client.GridClientCompute) GridRestCommandHandler(org.apache.ignite.internal.processors.rest.handlers.GridRestCommandHandler) IgniteKernal(org.apache.ignite.internal.IgniteKernal) P1(org.apache.ignite.internal.util.typedef.P1) ConcurrentLinkedHashMap(org.jsr166.ConcurrentLinkedHashMap) GridTaskCommandHandler(org.apache.ignite.internal.processors.rest.handlers.task.GridTaskCommandHandler) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with GridTaskCommandHandler

use of org.apache.ignite.internal.processors.rest.handlers.task.GridTaskCommandHandler in project ignite by apache.

the class GridRestProcessor method start.

/** {@inheritDoc} */
@Override
public void start(boolean activeOnStart) throws IgniteCheckedException {
    if (isRestEnabled()) {
        if (notStartOnClient()) {
            U.quietAndInfo(log, "REST protocols do not start on client node. " + "To start the protocols on client node set '-DIGNITE_REST_START_ON_CLIENT=true' system property.");
            return;
        }
        // Register handlers.
        addHandler(new GridCacheCommandHandler(ctx));
        addHandler(new GridTaskCommandHandler(ctx));
        addHandler(new GridTopologyCommandHandler(ctx));
        addHandler(new GridVersionCommandHandler(ctx));
        addHandler(new DataStructuresCommandHandler(ctx));
        addHandler(new QueryCommandHandler(ctx));
        addHandler(new GridLogCommandHandler(ctx));
        addHandler(new GridChangeStateCommandHandler(ctx));
        // Start protocols.
        startTcpProtocol();
        startHttpProtocol();
        for (GridRestProtocol proto : protos) {
            Collection<IgniteBiTuple<String, Object>> props = proto.getProperties();
            if (props != null) {
                for (IgniteBiTuple<String, Object> p : props) {
                    String key = p.getKey();
                    if (key == null)
                        continue;
                    if (ctx.hasNodeAttribute(key))
                        throw new IgniteCheckedException("Node attribute collision for attribute [processor=GridRestProcessor, attr=" + key + ']');
                    ctx.addNodeAttribute(key, p.getValue());
                }
            }
        }
    }
}
Also used : GridCacheCommandHandler(org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler) GridTaskCommandHandler(org.apache.ignite.internal.processors.rest.handlers.task.GridTaskCommandHandler) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) GridVersionCommandHandler(org.apache.ignite.internal.processors.rest.handlers.version.GridVersionCommandHandler) DataStructuresCommandHandler(org.apache.ignite.internal.processors.rest.handlers.datastructures.DataStructuresCommandHandler) GridTopologyCommandHandler(org.apache.ignite.internal.processors.rest.handlers.top.GridTopologyCommandHandler) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridLogCommandHandler(org.apache.ignite.internal.processors.rest.handlers.log.GridLogCommandHandler) GridChangeStateCommandHandler(org.apache.ignite.internal.processors.rest.handlers.cluster.GridChangeStateCommandHandler) QueryCommandHandler(org.apache.ignite.internal.processors.rest.handlers.query.QueryCommandHandler)

Example 3 with GridTaskCommandHandler

use of org.apache.ignite.internal.processors.rest.handlers.task.GridTaskCommandHandler in project ignite by apache.

the class GridRestProcessor method start.

/**
 * {@inheritDoc}
 */
@Override
public void start() throws IgniteCheckedException {
    if (isRestEnabled()) {
        if (notStartOnClient()) {
            U.quietAndInfo(log, "REST protocols do not start on client node. " + "To start the protocols on client node set '-DIGNITE_REST_START_ON_CLIENT=true' system property.");
            return;
        }
        // Register handlers.
        addHandler(new GridCacheCommandHandler(ctx));
        addHandler(new GridTaskCommandHandler(ctx));
        addHandler(new GridTopologyCommandHandler(ctx));
        addHandler(new GridVersionCommandHandler(ctx));
        addHandler(new DataStructuresCommandHandler(ctx));
        addHandler(new QueryCommandHandler(ctx));
        addHandler(new GridLogCommandHandler(ctx));
        addHandler(new GridChangeStateCommandHandler(ctx));
        addHandler(new GridChangeClusterStateCommandHandler(ctx));
        addHandler(new GridClusterNameCommandHandler(ctx));
        addHandler(new AuthenticationCommandHandler(ctx));
        addHandler(new UserActionCommandHandler(ctx));
        addHandler(new GridBaselineCommandHandler(ctx));
        addHandler(new MemoryMetricsCommandHandler(ctx));
        addHandler(new NodeStateBeforeStartCommandHandler(ctx));
        addHandler(new GridProbeCommandHandler(ctx));
        // Start protocols.
        startTcpProtocol();
        startHttpProtocol();
        for (GridRestProtocol proto : protos) {
            Collection<IgniteBiTuple<String, Object>> props = proto.getProperties();
            if (props != null) {
                for (IgniteBiTuple<String, Object> p : props) {
                    String key = p.getKey();
                    if (key == null)
                        continue;
                    if (ctx.hasNodeAttribute(key))
                        throw new IgniteCheckedException("Node attribute collision for attribute [processor=GridRestProcessor, attr=" + key + ']');
                    ctx.addNodeAttribute(key, p.getValue());
                }
            }
            proto.onProcessorStart();
        }
    }
}
Also used : GridCacheCommandHandler(org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler) GridTaskCommandHandler(org.apache.ignite.internal.processors.rest.handlers.task.GridTaskCommandHandler) NodeStateBeforeStartCommandHandler(org.apache.ignite.internal.processors.rest.handlers.beforeStart.NodeStateBeforeStartCommandHandler) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) GridVersionCommandHandler(org.apache.ignite.internal.processors.rest.handlers.version.GridVersionCommandHandler) DataStructuresCommandHandler(org.apache.ignite.internal.processors.rest.handlers.datastructures.DataStructuresCommandHandler) UserActionCommandHandler(org.apache.ignite.internal.processors.rest.handlers.user.UserActionCommandHandler) MemoryMetricsCommandHandler(org.apache.ignite.internal.processors.rest.handlers.memory.MemoryMetricsCommandHandler) GridTopologyCommandHandler(org.apache.ignite.internal.processors.rest.handlers.top.GridTopologyCommandHandler) GridProbeCommandHandler(org.apache.ignite.internal.processors.rest.handlers.probe.GridProbeCommandHandler) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridChangeClusterStateCommandHandler(org.apache.ignite.internal.processors.rest.handlers.cluster.GridChangeClusterStateCommandHandler) AuthenticationCommandHandler(org.apache.ignite.internal.processors.rest.handlers.auth.AuthenticationCommandHandler) GridLogCommandHandler(org.apache.ignite.internal.processors.rest.handlers.log.GridLogCommandHandler) GridChangeStateCommandHandler(org.apache.ignite.internal.processors.rest.handlers.cluster.GridChangeStateCommandHandler) GridBaselineCommandHandler(org.apache.ignite.internal.processors.rest.handlers.cluster.GridBaselineCommandHandler) GridClusterNameCommandHandler(org.apache.ignite.internal.processors.rest.handlers.cluster.GridClusterNameCommandHandler) QueryCommandHandler(org.apache.ignite.internal.processors.rest.handlers.query.QueryCommandHandler)

Aggregations

GridTaskCommandHandler (org.apache.ignite.internal.processors.rest.handlers.task.GridTaskCommandHandler)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 GridCacheCommandHandler (org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler)2 GridChangeStateCommandHandler (org.apache.ignite.internal.processors.rest.handlers.cluster.GridChangeStateCommandHandler)2 DataStructuresCommandHandler (org.apache.ignite.internal.processors.rest.handlers.datastructures.DataStructuresCommandHandler)2 GridLogCommandHandler (org.apache.ignite.internal.processors.rest.handlers.log.GridLogCommandHandler)2 QueryCommandHandler (org.apache.ignite.internal.processors.rest.handlers.query.QueryCommandHandler)2 GridTopologyCommandHandler (org.apache.ignite.internal.processors.rest.handlers.top.GridTopologyCommandHandler)2 GridVersionCommandHandler (org.apache.ignite.internal.processors.rest.handlers.version.GridVersionCommandHandler)2 IgniteBiTuple (org.apache.ignite.lang.IgniteBiTuple)2 IgniteKernal (org.apache.ignite.internal.IgniteKernal)1 GridClientCompute (org.apache.ignite.internal.client.GridClientCompute)1 GridRestCommandHandler (org.apache.ignite.internal.processors.rest.handlers.GridRestCommandHandler)1 AuthenticationCommandHandler (org.apache.ignite.internal.processors.rest.handlers.auth.AuthenticationCommandHandler)1 NodeStateBeforeStartCommandHandler (org.apache.ignite.internal.processors.rest.handlers.beforeStart.NodeStateBeforeStartCommandHandler)1 GridBaselineCommandHandler (org.apache.ignite.internal.processors.rest.handlers.cluster.GridBaselineCommandHandler)1 GridChangeClusterStateCommandHandler (org.apache.ignite.internal.processors.rest.handlers.cluster.GridChangeClusterStateCommandHandler)1 GridClusterNameCommandHandler (org.apache.ignite.internal.processors.rest.handlers.cluster.GridClusterNameCommandHandler)1 MemoryMetricsCommandHandler (org.apache.ignite.internal.processors.rest.handlers.memory.MemoryMetricsCommandHandler)1 GridProbeCommandHandler (org.apache.ignite.internal.processors.rest.handlers.probe.GridProbeCommandHandler)1