Search in sources :

Example 61 with GridClientConfiguration

use of org.apache.ignite.internal.client.GridClientConfiguration in project gridgain by gridgain.

the class CheckIndexInlineSizes method execute.

/**
 * {@inheritDoc}
 */
@Override
public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
    try (GridClient client = Command.startClient(clientCfg)) {
        Set<GridClientNode> serverNodes = client.compute().nodes().stream().filter(SRV_NODES).collect(toSet());
        Set<GridClientNode> supportedServerNodes = serverNodes.stream().filter(n -> n.supports(CHECK_INDEX_INLINE_SIZES)).collect(toSet());
        Collection<UUID> serverNodeIds = F.transform(serverNodes, GridClientNode::nodeId);
        Collection<UUID> supportedServerNodeIds = F.transform(supportedServerNodes, GridClientNode::nodeId);
        CheckIndexInlineSizesResult res = client.compute().projection(supportedServerNodes).execute(CheckIndexInlineSizesTask.class.getName(), new VisorTaskArgument<>(supportedServerNodeIds, false));
        Set<UUID> unsupportedNodes = serverNodeIds.stream().filter(n -> !supportedServerNodeIds.contains(n)).collect(toSet());
        analyzeResults(log, unsupportedNodes, res);
    }
    return null;
}
Also used : GridClientNode(org.apache.ignite.internal.client.GridClientNode) F(org.apache.ignite.internal.util.typedef.F) GridClient(org.apache.ignite.internal.client.GridClient) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) Predicate(java.util.function.Predicate) INDENT(org.apache.ignite.internal.commandline.CommandLogger.INDENT) Collection(java.util.Collection) Set(java.util.Set) HashMap(java.util.HashMap) UUID(java.util.UUID) VisorTaskArgument(org.apache.ignite.internal.visor.VisorTaskArgument) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) HashSet(java.util.HashSet) Command(org.apache.ignite.internal.commandline.Command) CacheCommands.usageCache(org.apache.ignite.internal.commandline.cache.CacheCommands.usageCache) SB(org.apache.ignite.internal.util.typedef.internal.SB) Map(java.util.Map) AbstractCommand(org.apache.ignite.internal.commandline.AbstractCommand) CHECK_INDEX_INLINE_SIZES(org.apache.ignite.internal.IgniteFeatures.CHECK_INDEX_INLINE_SIZES) CheckIndexInlineSizesResult(org.apache.ignite.internal.commandline.cache.check_indexes_inline_size.CheckIndexInlineSizesResult) CheckIndexInlineSizesTask(org.apache.ignite.internal.commandline.cache.check_indexes_inline_size.CheckIndexInlineSizesTask) GridClientNode(org.apache.ignite.internal.client.GridClientNode) Collectors.toSet(java.util.stream.Collectors.toSet) CheckIndexInlineSizesTask(org.apache.ignite.internal.commandline.cache.check_indexes_inline_size.CheckIndexInlineSizesTask) CheckIndexInlineSizesResult(org.apache.ignite.internal.commandline.cache.check_indexes_inline_size.CheckIndexInlineSizesResult) GridClient(org.apache.ignite.internal.client.GridClient) UUID(java.util.UUID)

Example 62 with GridClientConfiguration

use of org.apache.ignite.internal.client.GridClientConfiguration in project gridgain by gridgain.

the class DrAbstractRemoteSubCommand method execute0.

/**
 */
protected VisorResultDto execute0(GridClientConfiguration clientCfg, GridClient client) throws Exception {
    GridClientCompute compute = client.compute();
    Collection<GridClientNode> nodes = compute.nodes();
    nodes.stream().filter(node -> !drControlUtilitySupported(node)).collect(toCollection(() -> nodesWithoutDrTasks));
    List<UUID> nodeIds = nodes.stream().filter(DrAbstractRemoteSubCommand::drControlUtilitySupported).map(GridClientNode::nodeId).collect(toList());
    if (F.isEmpty(nodeIds))
        throw new GridClientDisconnectedException("Connectable nodes not found", null);
    return compute.projection(DrAbstractRemoteSubCommand::drControlUtilitySupported).execute(visorTaskName(), new VisorTaskArgument<>(nodeIds, args.toVisorArgs(), false));
}
Also used : GridClientCompute(org.apache.ignite.internal.client.GridClientCompute) GridClientNode(org.apache.ignite.internal.client.GridClientNode) IgniteDataTransferObject(org.apache.ignite.internal.dto.IgniteDataTransferObject) F(org.apache.ignite.internal.util.typedef.F) GridClient(org.apache.ignite.internal.client.GridClient) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) INDENT(org.apache.ignite.internal.commandline.CommandLogger.INDENT) Collection(java.util.Collection) CommandLogger(org.apache.ignite.internal.commandline.CommandLogger) CommandArgIterator(org.apache.ignite.internal.commandline.CommandArgIterator) UUID(java.util.UUID) VisorTaskArgument(org.apache.ignite.internal.visor.VisorTaskArgument) Logger(java.util.logging.Logger) GridClientDisconnectedException(org.apache.ignite.internal.client.GridClientDisconnectedException) ArrayList(java.util.ArrayList) DR_CONTROL_UTILITY(org.apache.ignite.internal.IgniteFeatures.DR_CONTROL_UTILITY) Collectors.toCollection(java.util.stream.Collectors.toCollection) List(java.util.List) Command(org.apache.ignite.internal.commandline.Command) Collectors.toList(java.util.stream.Collectors.toList) AbstractCommand(org.apache.ignite.internal.commandline.AbstractCommand) GridClientCompute(org.apache.ignite.internal.client.GridClientCompute) GridClientNode(org.apache.ignite.internal.client.GridClientNode) GridClientDisconnectedException(org.apache.ignite.internal.client.GridClientDisconnectedException) UUID(java.util.UUID)

Example 63 with GridClientConfiguration

use of org.apache.ignite.internal.client.GridClientConfiguration in project gridgain by gridgain.

the class PartitionReconciliation method partitionReconciliationCheck.

/**
 * Prepares arguments, executes partition reconciliation task, prints logs and optionally fix inconsistency.
 *
 * @param client Client node to run initial task.
 * @param clientCfg Client configuration.
 * @param log Logger.
 * @return Result of operation.
 * @throws GridClientException If failed.
 */
private ReconciliationResult partitionReconciliationCheck(GridClient client, GridClientConfiguration clientCfg, Logger log) throws GridClientException {
    VisorPartitionReconciliationTaskArg taskArg = new VisorPartitionReconciliationTaskArg(args.caches, args.fastCheck, args.repair, args.includeSensitive, args.locOutput, args.parallelism, args.batchSize, args.recheckAttempts, args.repairAlg, args.recheckDelay);
    List<GridClientNode> unsupportedSrvNodes = client.compute().nodes().stream().filter(node -> !node.isClient()).filter(node -> !node.supports(IgniteFeatures.PARTITION_RECONCILIATION)).collect(Collectors.toList());
    if (!unsupportedSrvNodes.isEmpty()) {
        final String strErrReason = "Partition reconciliation was rejected. The node [id=%s, consistentId=%s] doesn't support this feature.";
        List<String> errs = unsupportedSrvNodes.stream().map(n -> String.format(strErrReason, n.nodeId(), n.consistentId())).collect(toList());
        print(new ReconciliationResult(new ReconciliationAffectedEntries(), new HashMap<>(), errs), log::info);
        throw new VisorIllegalStateException("There are server nodes not supported partition reconciliation.");
    } else {
        ReconciliationResult res = executeTask(client, VisorPartitionReconciliationTask.class, taskArg, clientCfg);
        print(res, log::info);
        return res;
    }
}
Also used : GridClientNode(org.apache.ignite.internal.client.GridClientNode) VisorPartitionReconciliationTaskArg(org.apache.ignite.internal.visor.checker.VisorPartitionReconciliationTaskArg) Arrays(java.util.Arrays) VisorIllegalStateException(org.apache.ignite.internal.visor.util.VisorIllegalStateException) PartitionReconciliationCommandArg(org.apache.ignite.internal.commandline.cache.argument.PartitionReconciliationCommandArg) CommandLogger(org.apache.ignite.internal.commandline.CommandLogger) HashMap(java.util.HashMap) CommandArgIterator(org.apache.ignite.internal.commandline.CommandArgIterator) IgniteFeatures(org.apache.ignite.internal.IgniteFeatures) CommandArgUtils(org.apache.ignite.internal.commandline.argument.CommandArgUtils) RECHECK_ATTEMPTS(org.apache.ignite.internal.commandline.cache.argument.PartitionReconciliationCommandArg.RECHECK_ATTEMPTS) ReconciliationResult(org.apache.ignite.internal.processors.cache.checker.objects.ReconciliationResult) SB(org.apache.ignite.internal.util.typedef.internal.SB) LOCAL_OUTPUT(org.apache.ignite.internal.commandline.cache.argument.PartitionReconciliationCommandArg.LOCAL_OUTPUT) Map(java.util.Map) RepairAlgorithm(org.apache.ignite.internal.processors.cache.verify.RepairAlgorithm) INCLUDE_SENSITIVE(org.apache.ignite.internal.commandline.cache.argument.PartitionReconciliationCommandArg.INCLUDE_SENSITIVE) GridClientNode(org.apache.ignite.internal.client.GridClientNode) CommandLogger.optional(org.apache.ignite.internal.commandline.CommandLogger.optional) FAST_CHECK(org.apache.ignite.internal.commandline.cache.argument.PartitionReconciliationCommandArg.FAST_CHECK) PatternSyntaxException(java.util.regex.PatternSyntaxException) GridClient(org.apache.ignite.internal.client.GridClient) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) VisorPartitionReconciliationTask(org.apache.ignite.internal.visor.checker.VisorPartitionReconciliationTask) IgniteException(org.apache.ignite.IgniteException) PARTITION_RECONCILIATION(org.apache.ignite.internal.commandline.cache.CacheSubcommands.PARTITION_RECONCILIATION) Set(java.util.Set) RECHECK_DELAY(org.apache.ignite.internal.commandline.cache.argument.PartitionReconciliationCommandArg.RECHECK_DELAY) UUID(java.util.UUID) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Consumer(java.util.function.Consumer) List(java.util.List) Command(org.apache.ignite.internal.commandline.Command) Collectors.toList(java.util.stream.Collectors.toList) CacheCommands.usageCache(org.apache.ignite.internal.commandline.cache.CacheCommands.usageCache) PARALLELISM(org.apache.ignite.internal.commandline.cache.argument.PartitionReconciliationCommandArg.PARALLELISM) TaskExecutor.executeTask(org.apache.ignite.internal.commandline.TaskExecutor.executeTask) GridClientException(org.apache.ignite.internal.client.GridClientException) ReconciliationAffectedEntries(org.apache.ignite.internal.processors.cache.checker.objects.ReconciliationAffectedEntries) AbstractCommand(org.apache.ignite.internal.commandline.AbstractCommand) Pattern(java.util.regex.Pattern) REPAIR(org.apache.ignite.internal.commandline.cache.argument.PartitionReconciliationCommandArg.REPAIR) BATCH_SIZE(org.apache.ignite.internal.commandline.cache.argument.PartitionReconciliationCommandArg.BATCH_SIZE) HashMap(java.util.HashMap) ReconciliationResult(org.apache.ignite.internal.processors.cache.checker.objects.ReconciliationResult) VisorIllegalStateException(org.apache.ignite.internal.visor.util.VisorIllegalStateException) VisorPartitionReconciliationTaskArg(org.apache.ignite.internal.visor.checker.VisorPartitionReconciliationTaskArg) ReconciliationAffectedEntries(org.apache.ignite.internal.processors.cache.checker.objects.ReconciliationAffectedEntries)

Example 64 with GridClientConfiguration

use of org.apache.ignite.internal.client.GridClientConfiguration in project gridgain by gridgain.

the class BinaryConfigurationCustomSerializerSelfTest method testThinClientConnected.

/**
 * Test that thin client will be able to connect to node with custom binary serializer and custom consistent ID.
 *
 * @throws Exception If failed.
 */
@Test
public void testThinClientConnected() throws Exception {
    UUID nid = ignite(0).cluster().localNode().id();
    GridClientConfiguration clnCfg = new GridClientConfiguration();
    clnCfg.setProtocol(GridClientProtocol.TCP);
    clnCfg.setServers(Collections.singleton("127.0.0.1:11211"));
    clnCfg.setBalancer(new GridClientRoundRobinBalancer());
    // Start client.
    GridClient client = GridClientFactory.start(clnCfg);
    // Execute some task.
    client.compute().execute(VisorNodePingTask.class.getName(), new VisorTaskArgument<>(nid, new VisorNodePingTaskArg(nid), false));
    GridClientFactory.stop(client.id(), false);
}
Also used : GridClientRoundRobinBalancer(org.apache.ignite.internal.client.balancer.GridClientRoundRobinBalancer) VisorNodePingTaskArg(org.apache.ignite.internal.visor.node.VisorNodePingTaskArg) GridClient(org.apache.ignite.internal.client.GridClient) VisorNodePingTask(org.apache.ignite.internal.visor.node.VisorNodePingTask) UUID(java.util.UUID) GridClientConfiguration(org.apache.ignite.internal.client.GridClientConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

GridClientConfiguration (org.apache.ignite.internal.client.GridClientConfiguration)64 GridClient (org.apache.ignite.internal.client.GridClient)18 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 GridClientDataConfiguration (org.apache.ignite.internal.client.GridClientDataConfiguration)11 UUID (java.util.UUID)10 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)10 List (java.util.List)9 Logger (java.util.logging.Logger)9 Collectors (java.util.stream.Collectors)9 GridClientNode (org.apache.ignite.internal.client.GridClientNode)9 GridClientException (org.apache.ignite.internal.client.GridClientException)8 F (org.apache.ignite.internal.util.typedef.F)7 Map (java.util.Map)6 VisorTaskArgument (org.apache.ignite.internal.visor.VisorTaskArgument)6 GridClientDisconnectedException (org.apache.ignite.internal.client.GridClientDisconnectedException)5 CommandLogger.optional (org.apache.ignite.internal.commandline.CommandLogger.optional)5 SecurityCredentials (org.apache.ignite.plugin.security.SecurityCredentials)5 SecurityCredentialsBasicProvider (org.apache.ignite.plugin.security.SecurityCredentialsBasicProvider)5 File (java.io.File)4