org.elasticsearch.cluster.routing.allocation.command.AllocationCommand Java Examples
The following examples show how to use
org.elasticsearch.cluster.routing.allocation.command.AllocationCommand.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlterTableReroutePlan.java From crate with Apache License 2.0 | 6 votes |
@Override protected AllocationCommand visitRerouteCancelShard(AnalyzedRerouteCancelShard statement, Context context) { var boundedRerouteCancelShard = statement .rerouteCancelShard() .map(context.eval); boolean allowPrimary = validateCancelRerouteProperty( "allow_primary", boundedRerouteCancelShard.properties()); String index = getRerouteIndex( statement.shardedTable(), Lists2.map(statement.partitionProperties(), x -> x.map(context.eval))); String nodeId = resolveNodeId( context.nodes, DataTypes.STRING.value(boundedRerouteCancelShard.nodeIdOrName())); return new CancelAllocationCommand( index, DataTypes.INTEGER.value(boundedRerouteCancelShard.shardId()), nodeId, allowPrimary ); }
Example #2
Source File: AlterTableReroutePlan.java From crate with Apache License 2.0 | 6 votes |
@Override protected AllocationCommand visitRerouteAllocateReplicaShard(AnalyzedRerouteAllocateReplicaShard statement, Context context) { var boundedRerouteAllocateReplicaShard = statement .rerouteAllocateReplicaShard() .map(context.eval); String index = getRerouteIndex( statement.shardedTable(), Lists2.map(statement.partitionProperties(), x -> x.map(context.eval))); String toNodeId = resolveNodeId( context.nodes, DataTypes.STRING.value(boundedRerouteAllocateReplicaShard.nodeIdOrName())); return new AllocateReplicaAllocationCommand( index, DataTypes.INTEGER.value(boundedRerouteAllocateReplicaShard.shardId()), toNodeId ); }
Example #3
Source File: AlterTableReroutePlan.java From crate with Apache License 2.0 | 6 votes |
@Override protected AllocationCommand visitRerouteMoveShard(AnalyzedRerouteMoveShard statement, Context context) { var boundedMoveShard = statement.rerouteMoveShard().map(context.eval); String index = getRerouteIndex( statement.shardedTable(), Lists2.map(statement.partitionProperties(), x -> x.map(context.eval))); String toNodeId = resolveNodeId( context.nodes, DataTypes.STRING.value(boundedMoveShard.toNodeIdOrName())); return new MoveAllocationCommand( index, DataTypes.INTEGER.value(boundedMoveShard.shardId()), DataTypes.STRING.value(boundedMoveShard.fromNodeIdOrName()), toNodeId ); }
Example #4
Source File: AlterTableReroutePlan.java From crate with Apache License 2.0 | 6 votes |
@Override public AllocationCommand visitReroutePromoteReplica(AnalyzedPromoteReplica statement, Context context) { var boundedPromoteReplica = statement.promoteReplica().map(context.eval); String index = getRerouteIndex( statement.shardedTable(), Lists2.map(statement.partitionProperties(), x -> x.map(context.eval))); String toNodeId = resolveNodeId( context.nodes, DataTypes.STRING.value(boundedPromoteReplica.node())); return new AllocateStalePrimaryAllocationCommand( index, DataTypes.INTEGER.value(boundedPromoteReplica.shardId()), toNodeId, DataTypes.BOOLEAN.value(context.eval.apply(statement.acceptDataLoss())) ); }
Example #5
Source File: AlterTableReroutePlan.java From crate with Apache License 2.0 | 6 votes |
@VisibleForTesting public static AllocationCommand createRerouteCommand(AnalyzedStatement reroute, CoordinatorTxnCtx txnCtx, Functions functions, Row parameters, SubQueryResults subQueryResults, DiscoveryNodes nodes) { Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate( txnCtx, functions, x, parameters, subQueryResults ); return reroute.accept( REROUTE_STATEMENTS_VISITOR, new Context(nodes, eval)); }
Example #6
Source File: RerouteExplanation.java From Elasticsearch with Apache License 2.0 | 4 votes |
public AllocationCommand command() { return this.command; }
Example #7
Source File: AlterTableReroutePlan.java From crate with Apache License 2.0 | 4 votes |
@Override protected AllocationCommand visitAnalyzedStatement(AnalyzedStatement analyzedStatement, Context context) { throw new UnsupportedOperationException( String.format(Locale.ENGLISH, "Can't handle \"%s\"", analyzedStatement)); }
Example #8
Source File: ClusterRerouteRequest.java From crate with Apache License 2.0 | 4 votes |
/** * Adds allocation commands to be applied to the cluster. Note, can be empty, in which case * will simply run a simple "reroute". */ public ClusterRerouteRequest add(AllocationCommand... commands) { this.commands.add(commands); return this; }
Example #9
Source File: ClusterRerouteRequestBuilder.java From crate with Apache License 2.0 | 4 votes |
/** * Adds allocation commands to be applied to the cluster. Note, can be empty, in which case * will simply run a simple "reroute". */ public ClusterRerouteRequestBuilder add(AllocationCommand... commands) { request.add(commands); return this; }
Example #10
Source File: RerouteExplanation.java From crate with Apache License 2.0 | 4 votes |
public static RerouteExplanation readFrom(StreamInput in) throws IOException { AllocationCommand command = in.readNamedWriteable(AllocationCommand.class); Decision decisions = Decision.readFrom(in); return new RerouteExplanation(command, decisions); }
Example #11
Source File: RerouteExplanation.java From crate with Apache License 2.0 | 4 votes |
public AllocationCommand command() { return this.command; }
Example #12
Source File: RerouteExplanation.java From crate with Apache License 2.0 | 4 votes |
public RerouteExplanation(AllocationCommand command, Decision decisions) { this.command = command; this.decisions = decisions; }
Example #13
Source File: ClusterRerouteRequestBuilder.java From elasticshell with Apache License 2.0 | 4 votes |
public ClusterRerouteRequestBuilder<JsonInput, JsonOutput> add(AllocationCommand... commands) { request.add(commands); return this; }
Example #14
Source File: ClusterRerouteRequest.java From Elasticsearch with Apache License 2.0 | 4 votes |
/** * Adds allocation commands to be applied to the cluster. Note, can be empty, in which case * will simply run a simple "reroute". */ public ClusterRerouteRequest add(AllocationCommand... commands) { this.commands.add(commands); return this; }
Example #15
Source File: ClusterRerouteRequestBuilder.java From Elasticsearch with Apache License 2.0 | 4 votes |
/** * Adds allocation commands to be applied to the cluster. Note, can be empty, in which case * will simply run a simple "reroute". */ public ClusterRerouteRequestBuilder add(AllocationCommand... commands) { request.add(commands); return this; }
Example #16
Source File: RerouteExplanation.java From Elasticsearch with Apache License 2.0 | 4 votes |
public static RerouteExplanation readFrom(StreamInput in) throws IOException { String commandName = in.readString(); AllocationCommand command = AllocationCommands.lookupFactorySafe(commandName).readFrom(in); Decision decisions = Decision.readFrom(in); return new RerouteExplanation(command, decisions); }
Example #17
Source File: RerouteExplanation.java From Elasticsearch with Apache License 2.0 | 4 votes |
public RerouteExplanation(AllocationCommand command, Decision decisions) { this.command = command; this.decisions = decisions; }
Example #18
Source File: NetworkModule.java From crate with Apache License 2.0 | 2 votes |
/** * Register an allocation command. * <p> * This lives here instead of the more aptly named ClusterModule because the Transport client needs these to be registered. * </p> * @param reader the reader to read it from a stream * @param parser the parser to read it from XContent * @param commandName the names under which the command should be parsed. The {@link ParseField#getPreferredName()} is special because * it is the name under which the command's reader is registered. */ private static <T extends AllocationCommand> void registerAllocationCommand(Writeable.Reader<T> reader, CheckedFunction<XContentParser, T, IOException> parser, ParseField commandName) { NAMED_XCONTENTS.add(new NamedXContentRegistry.Entry(AllocationCommand.class, commandName, parser)); NAMED_WRITEABLES.add(new NamedWriteableRegistry.Entry(AllocationCommand.class, commandName.getPreferredName(), reader)); }