Java Code Examples for org.elasticsearch.index.shard.ShardId#getId()

The following examples show how to use org.elasticsearch.index.shard.ShardId#getId() . 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: ClusterRerouteManager.java    From foxtrot with Apache License 2.0 6 votes vote down vote up
private boolean reallocateShard(ShardId shardId, String fromNode, String toNode) {
    MoveAllocationCommand moveAllocationCommand = new MoveAllocationCommand(shardId.getIndexName(),
                                                                            shardId.getId(),
                                                                            fromNode,
                                                                            toNode);
    ClusterRerouteRequest clusterRerouteRequest = new ClusterRerouteRequest();
    clusterRerouteRequest.add(moveAllocationCommand);
    try {
        ClusterRerouteResponse clusterRerouteResponse = connection.getClient()
                .admin()
                .cluster()
                .reroute(clusterRerouteRequest)
                .actionGet();
        log.info(String.format("Reallocating Shard. From Node: %s To Node: %s", fromNode, toNode));
        Thread.sleep((new Date(DateTime.now()).getHourOfDay() + 1) * 4000L);
        return clusterRerouteResponse.isAcknowledged();
    }
    catch (Exception e) {
        log.error(String.format("Error in Reallocating Shard. From Node: %s To Node: %s. Error Message: %s",
                                fromNode,
                                toNode,
                                e.getMessage()), e);
        return false;
    }
}
 
Example 2
Source File: ShardRowContext.java    From crate with Apache License 2.0 6 votes vote down vote up
private ShardRowContext(IndexShard indexShard,
                        @Nullable BlobShard blobShard,
                        ClusterService clusterService,
                        Supplier<Long> sizeSupplier) {
    this.indexShard = indexShard;
    this.blobShard = blobShard;
    this.clusterService = clusterService;
    this.sizeSupplier = sizeSupplier;
    ShardId shardId = indexShard.shardId();
    String indexName = shardId.getIndexName();
    this.id = shardId.getId();
    this.indexParts = new IndexParts(indexName);
    if (indexParts.isPartitioned()) {
        partitionIdent = indexParts.getPartitionIdent();
        RelationName relationName = indexParts.toRelationName();
        aliasName = relationName.indexNameOrAlias();
        templateName = PartitionName.templateName(relationName.schema(), relationName.name());
    } else {
        partitionIdent = "";
        aliasName = null;
        templateName = null;
    }
    path = indexShard.shardPath().getDataPath().toString();
    blobPath = blobShard == null ? null : blobShard.blobContainer().getBaseDirectory().toString();
}
 
Example 3
Source File: IndicesService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new pending delete of an index
 */
public PendingDelete(ShardId shardId, Settings settings) {
    this.index = shardId.getIndex();
    this.shardId = shardId.getId();
    this.settings = settings;
    this.deleteIndex = false;
}
 
Example 4
Source File: SnapshotsService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private SnapshotShardFailure findShardFailure(List<SnapshotShardFailure> shardFailures, ShardId shardId) {
    for (SnapshotShardFailure shardFailure : shardFailures) {
        if (shardId.getIndex().equals(shardFailure.index()) && shardId.getId() == shardFailure.shardId()) {
            return shardFailure;
        }
    }
    return null;
}
 
Example 5
Source File: IndicesService.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new pending delete of an index
 */
PendingDelete(ShardId shardId, IndexSettings settings) {
    this.index = shardId.getIndex();
    this.shardId = shardId.getId();
    this.settings = settings;
    this.deleteIndex = false;
}
 
Example 6
Source File: SnapshotsService.java    From crate with Apache License 2.0 5 votes vote down vote up
private static SnapshotShardFailure findShardFailure(List<SnapshotShardFailure> shardFailures, ShardId shardId) {
    for (SnapshotShardFailure shardFailure : shardFailures) {
        if (shardId.getIndexName().equals(shardFailure.index()) && shardId.getId() == shardFailure.shardId()) {
            return shardFailure;
        }
    }
    return null;
}
 
Example 7
Source File: SnapshotShardFailure.java    From crate with Apache License 2.0 5 votes vote down vote up
public SnapshotShardFailure(StreamInput in) throws IOException {
    nodeId = in.readOptionalString();
    shardId = new ShardId(in);
    super.shardId = shardId.getId();
    index = shardId.getIndexName();
    reason = in.readString();
    status = RestStatus.readFrom(in);
}
 
Example 8
Source File: ReplicationResponse.java    From crate with Apache License 2.0 5 votes vote down vote up
public Failure(ShardId shardId,
               @Nullable String nodeId,
               Exception cause,
               RestStatus status,
               boolean primary) {
    super(shardId.getIndexName(), shardId.getId(), ExceptionsHelper.detailedMessage(cause), status, cause);
    this.shardId = shardId;
    this.nodeId = nodeId;
    this.primary = primary;
}
 
Example 9
Source File: ReplicationResponse.java    From crate with Apache License 2.0 5 votes vote down vote up
public Failure(StreamInput in) throws IOException {
    shardId = new ShardId(in);
    super.shardId = shardId.getId();
    index = shardId.getIndexName();
    nodeId = in.readOptionalString();
    cause = in.readException();
    status = RestStatus.readFrom(in);
    primary = in.readBoolean();
}