Search in sources :

Example 1 with ClientFeatureNotSupportedByServerException

use of org.apache.ignite.client.ClientFeatureNotSupportedByServerException in project ignite by apache.

the class ClientClusterImpl method state.

/**
 * {@inheritDoc}
 */
@Override
public void state(ClusterState newState) throws ClientException {
    try {
        ch.service(ClientOperation.CLUSTER_CHANGE_STATE, req -> {
            ProtocolContext protocolCtx = req.clientChannel().protocolCtx();
            checkClusterApiSupported(protocolCtx);
            if (newState.ordinal() > 1 && !protocolCtx.isFeatureSupported(ProtocolBitmaskFeature.CLUSTER_STATES)) {
                throw new ClientFeatureNotSupportedByServerException("State " + newState.name() + " is not " + "supported by the server");
            }
            req.out().writeByte((byte) newState.ordinal());
        }, null);
    } catch (ClientError e) {
        throw new ClientException(e);
    }
}
Also used : ClientException(org.apache.ignite.client.ClientException) ClientFeatureNotSupportedByServerException(org.apache.ignite.client.ClientFeatureNotSupportedByServerException)

Example 2 with ClientFeatureNotSupportedByServerException

use of org.apache.ignite.client.ClientFeatureNotSupportedByServerException in project ignite by apache.

the class ClientClusterGroupImpl method requestNodeIds.

/**
 * Requests node IDs from the server.
 */
private synchronized Collection<UUID> requestNodeIds() {
    try {
        return ch.service(ClientOperation.CLUSTER_GROUP_GET_NODE_IDS, req -> {
            if (!req.clientChannel().protocolCtx().isFeatureSupported(ProtocolBitmaskFeature.CLUSTER_GROUPS))
                throw new ClientFeatureNotSupportedByServerException(ProtocolBitmaskFeature.CLUSTER_GROUPS);
            try (BinaryRawWriterEx writer = utils.createBinaryWriter(req.out())) {
                writer.writeLong(cachedTopVer);
                projectionFilters.write(writer);
            }
        }, res -> {
            if (!res.in().readBoolean())
                // There were no changes since last request.
                return new ArrayList<>(cachedNodeIds);
            // Topology version.
            long topVer = res.in().readLong();
            int nodesCnt = res.in().readInt();
            Collection<UUID> nodeIds = new ArrayList<>(nodesCnt);
            for (int i = 0; i < nodesCnt; i++) nodeIds.add(new UUID(res.in().readLong(), res.in().readLong()));
            cachedNodes.keySet().retainAll(nodeIds);
            cachedTopVer = topVer;
            cachedNodeIds = nodeIds;
            return new ArrayList<>(nodeIds);
        });
    } catch (ClientError e) {
        throw new ClientException(e);
    }
}
Also used : ArrayList(java.util.ArrayList) ClientException(org.apache.ignite.client.ClientException) UUID(java.util.UUID) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx) ClientFeatureNotSupportedByServerException(org.apache.ignite.client.ClientFeatureNotSupportedByServerException)

Example 3 with ClientFeatureNotSupportedByServerException

use of org.apache.ignite.client.ClientFeatureNotSupportedByServerException in project ignite by apache.

the class ClientClusterGroupImpl method requestNodesByIds.

/**
 * Requests nodes from the server.
 *
 * @param nodeIds Node ids.
 */
private Collection<ClusterNode> requestNodesByIds(Collection<UUID> nodeIds) {
    try {
        return ch.service(ClientOperation.CLUSTER_GROUP_GET_NODE_INFO, req -> {
            if (!req.clientChannel().protocolCtx().isFeatureSupported(ProtocolBitmaskFeature.CLUSTER_GROUPS))
                throw new ClientFeatureNotSupportedByServerException(ProtocolBitmaskFeature.CLUSTER_GROUPS);
            req.out().writeInt(nodeIds.size());
            for (UUID nodeId : nodeIds) {
                req.out().writeLong(nodeId.getMostSignificantBits());
                req.out().writeLong(nodeId.getLeastSignificantBits());
            }
        }, res -> {
            try (BinaryReaderExImpl reader = utils.createBinaryReader(res.in())) {
                int nodesCnt = reader.readInt();
                Collection<ClusterNode> nodes = new ArrayList<>();
                for (int i = 0; i < nodesCnt; i++) {
                    ClusterNode node = readClusterNode(reader);
                    cachedNodes.put(node.id(), node);
                    if (projectionFilters.testClientSidePredicates(node))
                        nodes.add(node);
                }
                return nodes;
            } catch (IOException e) {
                throw new ClientError(e);
            }
        });
    } catch (ClientError e) {
        throw new ClientException(e);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) BinaryReaderExImpl(org.apache.ignite.internal.binary.BinaryReaderExImpl) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ClientException(org.apache.ignite.client.ClientException) UUID(java.util.UUID) ClientFeatureNotSupportedByServerException(org.apache.ignite.client.ClientFeatureNotSupportedByServerException)

Example 4 with ClientFeatureNotSupportedByServerException

use of org.apache.ignite.client.ClientFeatureNotSupportedByServerException in project ignite by apache.

the class ClientComputeImpl method writeExecuteTaskRequest.

/**
 */
private <T> void writeExecuteTaskRequest(PayloadOutputChannel ch, String taskName, @Nullable T arg, Collection<UUID> nodeIds, byte flags, long timeout) throws ClientException {
    if (!ch.clientChannel().protocolCtx().isFeatureSupported(ProtocolBitmaskFeature.EXECUTE_TASK_BY_NAME)) {
        throw new ClientFeatureNotSupportedByServerException("Compute grid functionality for thin " + "client not supported by server node (" + ch.clientChannel().serverNodeId() + ')');
    }
    try (BinaryRawWriterEx w = utils.createBinaryWriter(ch.out())) {
        if (// Include all nodes.
        nodeIds == null)
            w.writeInt(0);
        else {
            w.writeInt(nodeIds.size());
            for (UUID nodeId : nodeIds) {
                w.writeLong(nodeId.getMostSignificantBits());
                w.writeLong(nodeId.getLeastSignificantBits());
            }
        }
        w.writeByte(flags);
        w.writeLong(timeout);
        w.writeString(taskName);
        w.writeObject(arg);
    }
}
Also used : UUID(java.util.UUID) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx) ClientFeatureNotSupportedByServerException(org.apache.ignite.client.ClientFeatureNotSupportedByServerException)

Aggregations

ClientFeatureNotSupportedByServerException (org.apache.ignite.client.ClientFeatureNotSupportedByServerException)4 UUID (java.util.UUID)3 ClientException (org.apache.ignite.client.ClientException)3 ArrayList (java.util.ArrayList)2 BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)2 IOException (java.io.IOException)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 BinaryReaderExImpl (org.apache.ignite.internal.binary.BinaryReaderExImpl)1