Search in sources :

Example 1 with GridClientStateRequest

use of org.apache.ignite.internal.processors.rest.client.message.GridClientStateRequest in project ignite by apache.

the class GridClientNioTcpConnection method changeState.

/** {@inheritDoc} */
@Override
public GridClientFuture<?> changeState(boolean active, UUID destNodeId) throws GridClientClosedException, GridClientConnectionResetException {
    GridClientStateRequest msg = new GridClientStateRequest();
    msg.active(active);
    return makeRequest(msg, destNodeId);
}
Also used : GridClientStateRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientStateRequest)

Example 2 with GridClientStateRequest

use of org.apache.ignite.internal.processors.rest.client.message.GridClientStateRequest in project ignite by apache.

the class GridClientNioTcpConnection method currentState.

/** {@inheritDoc} */
@Override
public GridClientFuture<Boolean> currentState(UUID destNodeId) throws GridClientClosedException, GridClientConnectionResetException {
    GridClientStateRequest msg = new GridClientStateRequest();
    msg.requestCurrentState();
    return makeRequest(msg, destNodeId);
}
Also used : GridClientStateRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientStateRequest)

Example 3 with GridClientStateRequest

use of org.apache.ignite.internal.processors.rest.client.message.GridClientStateRequest in project ignite by apache.

the class GridTcpRestNioListener method createRestRequest.

/**
     * Creates a REST request object from client TCP binary packet.
     *
     * @param ses NIO session.
     * @param msg Request message.
     * @return REST request object.
     */
@Nullable
private GridRestRequest createRestRequest(GridNioSession ses, GridClientMessage msg) {
    GridRestRequest restReq = null;
    if (msg instanceof GridClientAuthenticationRequest) {
        GridClientAuthenticationRequest req = (GridClientAuthenticationRequest) msg;
        restReq = new GridRestTaskRequest();
        restReq.command(NOOP);
        restReq.credentials(req.credentials());
    } else if (msg instanceof GridClientCacheRequest) {
        GridClientCacheRequest req = (GridClientCacheRequest) msg;
        GridRestCacheRequest restCacheReq = new GridRestCacheRequest();
        restCacheReq.cacheName(req.cacheName());
        restCacheReq.cacheFlags(req.cacheFlagsOn());
        restCacheReq.key(req.key());
        restCacheReq.value(req.value());
        restCacheReq.value2(req.value2());
        Map vals = req.values();
        if (vals != null)
            restCacheReq.values(new HashMap<Object, Object>(vals));
        restCacheReq.command(cacheCmdMap.get(req.operation()));
        restReq = restCacheReq;
    } else if (msg instanceof GridClientTaskRequest) {
        GridClientTaskRequest req = (GridClientTaskRequest) msg;
        GridRestTaskRequest restTaskReq = new GridRestTaskRequest();
        restTaskReq.command(EXE);
        restTaskReq.taskName(req.taskName());
        restTaskReq.params(Arrays.asList(req.argument()));
        restReq = restTaskReq;
    } else if (msg instanceof GridClientTopologyRequest) {
        GridClientTopologyRequest req = (GridClientTopologyRequest) msg;
        GridRestTopologyRequest restTopReq = new GridRestTopologyRequest();
        restTopReq.includeMetrics(req.includeMetrics());
        restTopReq.includeAttributes(req.includeAttributes());
        if (req.nodeId() != null) {
            restTopReq.command(NODE);
            restTopReq.nodeId(req.nodeId());
        } else if (req.nodeIp() != null) {
            restTopReq.command(NODE);
            restTopReq.nodeIp(req.nodeIp());
        } else
            restTopReq.command(TOPOLOGY);
        restReq = restTopReq;
    } else if (msg instanceof GridClientStateRequest) {
        GridClientStateRequest req = (GridClientStateRequest) msg;
        GridRestChangeStateRequest restChangeReq = new GridRestChangeStateRequest();
        if (req.isReqCurrentState()) {
            restChangeReq.reqCurrentState();
            restChangeReq.command(CLUSTER_CURRENT_STATE);
        } else {
            restChangeReq.active(req.active());
            restChangeReq.command(req.active() ? CLUSTER_ACTIVE : CLUSTER_INACTIVE);
        }
        restReq = restChangeReq;
    }
    if (restReq != null) {
        restReq.destinationId(msg.destinationId());
        restReq.clientId(msg.clientId());
        restReq.sessionToken(msg.sessionToken());
        restReq.address(ses.remoteAddress());
    }
    return restReq;
}
Also used : GridClientAuthenticationRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientAuthenticationRequest) GridRestTopologyRequest(org.apache.ignite.internal.processors.rest.request.GridRestTopologyRequest) GridRestCacheRequest(org.apache.ignite.internal.processors.rest.request.GridRestCacheRequest) GridRestChangeStateRequest(org.apache.ignite.internal.processors.rest.request.GridRestChangeStateRequest) GridRestTaskRequest(org.apache.ignite.internal.processors.rest.request.GridRestTaskRequest) GridClientStateRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientStateRequest) GridClientTopologyRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientTopologyRequest) GridRestRequest(org.apache.ignite.internal.processors.rest.request.GridRestRequest) GridClientCacheRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest) Map(java.util.Map) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap) GridClientTaskRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientTaskRequest) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

GridClientStateRequest (org.apache.ignite.internal.processors.rest.client.message.GridClientStateRequest)3 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 GridClientAuthenticationRequest (org.apache.ignite.internal.processors.rest.client.message.GridClientAuthenticationRequest)1 GridClientCacheRequest (org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest)1 GridClientTaskRequest (org.apache.ignite.internal.processors.rest.client.message.GridClientTaskRequest)1 GridClientTopologyRequest (org.apache.ignite.internal.processors.rest.client.message.GridClientTopologyRequest)1 GridRestCacheRequest (org.apache.ignite.internal.processors.rest.request.GridRestCacheRequest)1 GridRestChangeStateRequest (org.apache.ignite.internal.processors.rest.request.GridRestChangeStateRequest)1 GridRestRequest (org.apache.ignite.internal.processors.rest.request.GridRestRequest)1 GridRestTaskRequest (org.apache.ignite.internal.processors.rest.request.GridRestTaskRequest)1 GridRestTopologyRequest (org.apache.ignite.internal.processors.rest.request.GridRestTopologyRequest)1 Nullable (org.jetbrains.annotations.Nullable)1