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

The following examples show how to use org.elasticsearch.index.shard.ShardId#getIndexName() . 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: 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 4
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 5
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();
}
 
Example 6
Source File: BlobIndicesService.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void afterIndexShardDeleted(ShardId shardId, Settings indexSettings) {
    String index = shardId.getIndexName();
    if (isBlobIndex(index)) {
        BlobIndex blobIndex = indices.get(index);
        if (blobIndex != null) {
            blobIndex.removeShard(shardId);
        }
    }
}
 
Example 7
Source File: BlobIndicesService.java    From crate with Apache License 2.0 5 votes vote down vote up
public BlobShard blobShardSafe(ShardId shardId) {
    String index = shardId.getIndexName();
    if (isBlobIndex(index)) {
        BlobShard blobShard = blobShard(shardId);
        if (blobShard == null) {
            throw new ShardNotFoundException(shardId);
        }
        return blobShard;
    }
    throw new BlobsDisabledException(shardId.getIndex());
}
 
Example 8
Source File: ReplicationOperationTests.java    From crate with Apache License 2.0 5 votes vote down vote up
Request(ShardId shardId) {
    this();
    this.shardId = shardId;
    this.index = shardId.getIndexName();
    this.waitForActiveShards = ActiveShardCount.NONE;
    // keep things simple
}
 
Example 9
Source File: ReplicationRequest.java    From crate with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new request with resolved shard id
 */
public ReplicationRequest(ShardId shardId) {
    this.index = shardId.getIndexName();
    this.shardId = shardId;
}
 
Example 10
Source File: ShardRequest.java    From crate with Apache License 2.0 4 votes vote down vote up
public ShardRequest(ShardId shardId, UUID jobId) {
    setShardId(shardId);
    this.jobId = jobId;
    this.index = shardId.getIndexName();
    items = new ArrayList<>();
}
 
Example 11
Source File: BlobTransferStatus.java    From crate with Apache License 2.0 4 votes vote down vote up
public BlobTransferStatus(ShardId shardId, UUID transferId, DigestBlob digestBlob) {
    this.shardId = shardId;
    this.index = shardId.getIndexName();
    this.transferId = transferId;
    this.digestBlob = digestBlob;
}
 
Example 12
Source File: SnapshotShardFailure.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs new snapshot shard failure object
 *
 * @param nodeId  node where failure occurred
 * @param shardId shard id
 * @param reason  failure reason
 * @param status  rest status
 */
private SnapshotShardFailure(@Nullable String nodeId, ShardId shardId, String reason, RestStatus status) {
    super(shardId.getIndexName(), shardId.id(), reason, status, new IndexShardSnapshotFailedException(shardId, reason));
    this.nodeId = nodeId;
    this.shardId = shardId;
}