本文整理汇总了Java中org.elasticsearch.index.shard.ShardId.id方法的典型用法代码示例。如果您正苦于以下问题:Java ShardId.id方法的具体用法?Java ShardId.id怎么用?Java ShardId.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.index.shard.ShardId
的用法示例。
在下文中一共展示了ShardId.id方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllocationStatus
import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
private IndicesShardStoresResponse.StoreStatus.AllocationStatus getAllocationStatus(String index, int shardID, DiscoveryNode node) {
for (ShardRouting shardRouting : routingNodes.node(node.getId())) {
ShardId shardId = shardRouting.shardId();
if (shardId.id() == shardID && shardId.getIndexName().equals(index)) {
if (shardRouting.primary()) {
return IndicesShardStoresResponse.StoreStatus.AllocationStatus.PRIMARY;
} else if (shardRouting.assignedToNode()) {
return IndicesShardStoresResponse.StoreStatus.AllocationStatus.REPLICA;
} else {
return IndicesShardStoresResponse.StoreStatus.AllocationStatus.UNUSED;
}
}
}
return IndicesShardStoresResponse.StoreStatus.AllocationStatus.UNUSED;
}
示例2: createContext
import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
public CrateSearchContext createContext(
int jobSearchContextId,
IndexShard indexshard,
Engine.Searcher engineSearcher,
WhereClause whereClause) {
ShardId shardId = indexshard.shardId();
SearchShardTarget searchShardTarget = new SearchShardTarget(
clusterService.state().nodes().localNodeId(),
shardId.getIndex(),
shardId.id()
);
IndexService indexService = indexshard.indexService();
CrateSearchContext searchContext = new CrateSearchContext(
jobSearchContextId,
System.currentTimeMillis(),
searchShardTarget,
engineSearcher,
indexService,
indexshard,
scriptService,
pageCacheRecycler,
bigArrays,
threadPool.estimatedTimeInMillisCounter(),
Optional.<Scroll>absent()
);
LuceneQueryBuilder.Context context = luceneQueryBuilder.convert(
whereClause, indexService.mapperService(), indexService.fieldData(), indexService.cache());
searchContext.parsedQuery(new ParsedQuery(context.query(), EMPTY_NAMED_FILTERS));
Float minScore = context.minScore();
if (minScore != null) {
searchContext.minimumScore(minScore);
}
return searchContext;
}
示例3: UnassignedShard
import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
public UnassignedShard(ShardId shardId,
ClusterService clusterService,
Boolean primary,
ShardRoutingState state) {
String index = shardId.index().name();
boolean isBlobIndex = BlobIndices.isBlobIndex(index);
String tableName;
String ident = "";
if (isBlobIndex) {
this.schemaName = BlobSchemaInfo.NAME;
tableName = BlobIndices.STRIP_PREFIX.apply(index);
} else if (PartitionName.isPartition(index)) {
PartitionName partitionName = PartitionName.fromIndexOrTemplate(index);
schemaName = partitionName.tableIdent().schema();
tableName = partitionName.tableIdent().name();
ident = partitionName.ident();
if (!clusterService.state().metaData().hasConcreteIndex(tableName)) {
orphanedPartition = true;
}
} else {
Matcher matcher = Schemas.SCHEMA_PATTERN.matcher(index);
if (matcher.matches()) {
this.schemaName = matcher.group(1);
tableName = matcher.group(2);
} else {
this.schemaName = Schemas.DEFAULT_SCHEMA_NAME;
tableName = index;
}
}
this.tableName = tableName;
partitionIdent = ident;
this.primary = primary;
this.id = shardId.id();
this.state = state == ShardRoutingState.UNASSIGNED ? UNASSIGNED : INITIALIZING;
}
示例4: ShardSearchLocalRequest
import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
public ShardSearchLocalRequest(ShardId shardId, int numberOfShards, SearchType searchType,
BytesReference source, String[] types, Boolean requestCache) {
this.index = shardId.getIndex();
this.shardId = shardId.id();
this.numberOfShards = numberOfShards;
this.searchType = searchType;
this.source = source;
this.types = types;
this.requestCache = requestCache;
}
示例5: getAllocation
import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
private IndicesShardStoresResponse.StoreStatus.Allocation getAllocation(String index, int shardID, DiscoveryNode node) {
for (ShardRouting shardRouting : routingNodes.node(node.id())) {
ShardId shardId = shardRouting.shardId();
if (shardId.id() == shardID && shardId.getIndex().equals(index)) {
if (shardRouting.primary()) {
return IndicesShardStoresResponse.StoreStatus.Allocation.PRIMARY;
} else if (shardRouting.assignedToNode()) {
return IndicesShardStoresResponse.StoreStatus.Allocation.REPLICA;
} else {
return IndicesShardStoresResponse.StoreStatus.Allocation.UNUSED;
}
}
}
return IndicesShardStoresResponse.StoreStatus.Allocation.UNUSED;
}
示例6: parse
import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
@Override
public ScoreFunction parse(QueryParseContext parseContext, XContentParser parser) throws IOException, QueryParsingException {
int seed = -1;
String currentFieldName = null;
XContentParser.Token token;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
if ("seed".equals(currentFieldName)) {
if (token == XContentParser.Token.VALUE_NUMBER) {
if (parser.numberType() == XContentParser.NumberType.INT) {
seed = parser.intValue();
} else if (parser.numberType() == XContentParser.NumberType.LONG) {
seed = Longs.hashCode(parser.longValue());
} else {
throw new QueryParsingException(parseContext, "random_score seed must be an int, long or string, not '"
+ token.toString() + "'");
}
} else if (token == XContentParser.Token.VALUE_STRING) {
seed = parser.text().hashCode();
} else {
throw new QueryParsingException(parseContext, "random_score seed must be an int/long or string, not '"
+ token.toString() + "'");
}
} else {
throw new QueryParsingException(parseContext, NAMES[0] + " query does not support [" + currentFieldName + "]");
}
}
}
final MappedFieldType fieldType = SearchContext.current().mapperService().smartNameFieldType("_uid");
if (fieldType == null) {
// mapper could be null if we are on a shard with no docs yet, so this won't actually be used
return new RandomScoreFunction();
}
if (seed == -1) {
seed = Longs.hashCode(parseContext.nowInMillis());
}
final ShardId shardId = SearchContext.current().indexShard().shardId();
final int salt = (shardId.index().name().hashCode() << 10) | shardId.id();
final IndexFieldData<?> uidFieldData = SearchContext.current().fieldData().getForField(fieldType);
return new RandomScoreFunction(seed, salt, uidFieldData);
}
示例7: buildMessage
import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
private static String buildMessage(ShardId shardId, String message) {
if (shardId == null) {
return message;
}
return "[" + shardId.index().name() + "][" + shardId.id() + "] " + message;
}