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

The following examples show how to use org.elasticsearch.index.shard.ShardId#getIndexName() . These examples are extracted from open source projects. 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 Project: foxtrot   File: ClusterRerouteManager.java    License: 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 Project: crate   File: ShardRowContext.java    License: 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 Project: crate   File: SnapshotShardFailure.java    License: 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 Project: crate   File: ReplicationResponse.java    License: 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 Project: crate   File: ReplicationResponse.java    License: 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 Project: crate   File: BlobIndicesService.java    License: 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 Project: crate   File: BlobIndicesService.java    License: 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 Project: crate   File: ReplicationOperationTests.java    License: 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 Project: crate   File: ReplicationRequest.java    License: 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 Project: crate   File: ShardRequest.java    License: 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 Project: crate   File: BlobTransferStatus.java    License: 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 Project: crate   File: SnapshotShardFailure.java    License: 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;
}