當前位置: 首頁>>代碼示例>>Java>>正文


Java ImmutableOpenMap.of方法代碼示例

本文整理匯總了Java中org.elasticsearch.common.collect.ImmutableOpenMap.of方法的典型用法代碼示例。如果您正苦於以下問題:Java ImmutableOpenMap.of方法的具體用法?Java ImmutableOpenMap.of怎麽用?Java ImmutableOpenMap.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.common.collect.ImmutableOpenMap的用法示例。


在下文中一共展示了ImmutableOpenMap.of方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: InternalClusterInfoService

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
public InternalClusterInfoService(Settings settings, ClusterService clusterService, ThreadPool threadPool, NodeClient client) {
    super(settings);
    this.leastAvailableSpaceUsages = ImmutableOpenMap.of();
    this.mostAvailableSpaceUsages = ImmutableOpenMap.of();
    this.shardRoutingToDataPath = ImmutableOpenMap.of();
    this.shardSizes = ImmutableOpenMap.of();
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    this.client = client;
    this.updateFrequency = INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING.get(settings);
    this.fetchTimeout = INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING.get(settings);
    this.enabled = DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.get(settings);
    ClusterSettings clusterSettings = clusterService.getClusterSettings();
    clusterSettings.addSettingsUpdateConsumer(INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING, this::setFetchTimeout);
    clusterSettings.addSettingsUpdateConsumer(INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING, this::setUpdateFrequency);
    clusterSettings.addSettingsUpdateConsumer(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING, this::setEnabled);

    // Add InternalClusterInfoService to listen for Master changes
    this.clusterService.addLocalNodeMasterListener(this);
    // Add to listen for state changes (when nodes are added)
    this.clusterService.addListener(this);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:23,代碼來源:InternalClusterInfoService.java

示例2: Entry

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
public Entry(Snapshot snapshot, boolean includeGlobalState, boolean partial, State state, List<IndexId> indices,
             long startTime, long repositoryStateId, ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards) {
    this.state = state;
    this.snapshot = snapshot;
    this.includeGlobalState = includeGlobalState;
    this.partial = partial;
    this.indices = indices;
    this.startTime = startTime;
    if (shards == null) {
        this.shards = ImmutableOpenMap.of();
        this.waitingIndices = ImmutableOpenMap.of();
    } else {
        this.shards = shards;
        this.waitingIndices = findWaitingIndices(shards);
    }
    this.repositoryStateId = repositoryStateId;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:18,代碼來源:SnapshotsInProgress.java

示例3: Entry

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
/**
 * Creates new restore metadata
 *
 * @param snapshot   snapshot
 * @param state      current state of the restore process
 * @param indices    list of indices being restored
 * @param shards     map of shards being restored to their current restore status
 */
public Entry(Snapshot snapshot, State state, List<String> indices, ImmutableOpenMap<ShardId, ShardRestoreStatus> shards) {
    this.snapshot = Objects.requireNonNull(snapshot);
    this.state = Objects.requireNonNull(state);
    this.indices = Objects.requireNonNull(indices);
    if (shards == null) {
        this.shards = ImmutableOpenMap.of();
    } else {
        this.shards = shards;
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,代碼來源:RestoreInProgress.java

示例4: testGlobalBlocksCheckedIfNoIndicesSpecified

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
public void testGlobalBlocksCheckedIfNoIndicesSpecified() {
    EnumSet<ClusterBlockLevel> levels = EnumSet.noneOf(ClusterBlockLevel.class);
    int nbLevels = randomIntBetween(1, ClusterBlockLevel.values().length);
    for (int j = 0; j < nbLevels; j++) {
        levels.add(randomFrom(ClusterBlockLevel.values()));
    }
    ClusterBlock globalBlock = new ClusterBlock(randomInt(), "cluster block #" + randomInt(), randomBoolean(),
        randomBoolean(), randomFrom(RestStatus.values()), levels);
    ClusterBlocks clusterBlocks = new ClusterBlocks(Collections.singleton(globalBlock), ImmutableOpenMap.of());
    ClusterBlockException exception = clusterBlocks.indicesBlockedException(randomFrom(globalBlock.levels()), new String[0]);
    assertNotNull(exception);
    assertEquals(exception.blocks(), Collections.singleton(globalBlock));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:14,代碼來源:ClusterBlockTests.java

示例5: testDeleteSnapshotting

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
public void testDeleteSnapshotting() {
    String index = randomAsciiOfLength(5);
    Snapshot snapshot = new Snapshot("doesn't matter", new SnapshotId("snapshot name", "snapshot uuid"));
    SnapshotsInProgress snaps = new SnapshotsInProgress(new SnapshotsInProgress.Entry(snapshot, true, false,
            SnapshotsInProgress.State.INIT, singletonList(new IndexId(index, "doesn't matter")),
            System.currentTimeMillis(), (long) randomIntBetween(0, 1000), ImmutableOpenMap.of()));
    ClusterState state = ClusterState.builder(clusterState(index))
            .putCustom(SnapshotsInProgress.TYPE, snaps)
            .build();
    Exception e = expectThrows(IllegalArgumentException.class,
            () -> service.deleteIndices(state, singleton(state.metaData().getIndices().get(index).getIndex())));
    assertEquals("Cannot delete indices that are being snapshotted: [[" + index + "]]. Try again after snapshot finishes "
            + "or cancel the currently running snapshot.", e.getMessage());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:15,代碼來源:MetaDataDeleteIndexServiceTests.java

示例6: empty

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
public static MultiFields empty() {
    return new MultiFields(ImmutableOpenMap.<String, FieldMapper>of());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:4,代碼來源:FieldMapper.java

示例7: ClusterInfo

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
protected ClusterInfo() {
   this(ImmutableOpenMap.of(), ImmutableOpenMap.of(), ImmutableOpenMap.of(), ImmutableOpenMap.of());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:4,代碼來源:ClusterInfo.java

示例8: doMasterOperation

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
@Override
protected void doMasterOperation(final GetIndexRequest request, String[] concreteIndices, final ClusterState state,
                                 final ActionListener<GetIndexResponse> listener) {
    ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappingsResult = ImmutableOpenMap.of();
    ImmutableOpenMap<String, List<AliasMetaData>> aliasesResult = ImmutableOpenMap.of();
    ImmutableOpenMap<String, Settings> settings = ImmutableOpenMap.of();
    Feature[] features = request.features();
    boolean doneAliases = false;
    boolean doneMappings = false;
    boolean doneSettings = false;
    for (Feature feature : features) {
        switch (feature) {
        case MAPPINGS:
                if (!doneMappings) {
                    mappingsResult = state.metaData().findMappings(concreteIndices, request.types());
                    doneMappings = true;
                }
                break;
        case ALIASES:
                if (!doneAliases) {
                    aliasesResult = state.metaData().findAliases(Strings.EMPTY_ARRAY, concreteIndices);
                    doneAliases = true;
                }
                break;
        case SETTINGS:
                if (!doneSettings) {
                    ImmutableOpenMap.Builder<String, Settings> settingsMapBuilder = ImmutableOpenMap.builder();
                    for (String index : concreteIndices) {
                        Settings indexSettings = state.metaData().index(index).getSettings();
                        if (request.humanReadable()) {
                            indexSettings = IndexMetaData.addHumanReadableSettings(indexSettings);
                        }
                        settingsMapBuilder.put(index, indexSettings);
                    }
                    settings = settingsMapBuilder.build();
                    doneSettings = true;
                }
                break;

            default:
                throw new IllegalStateException("feature [" + feature + "] is not valid");
        }
    }
    listener.onResponse(new GetIndexResponse(concreteIndices, mappingsResult, aliasesResult, settings));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:46,代碼來源:TransportGetIndexAction.java

示例9: IndicesShardStoresResponse

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
IndicesShardStoresResponse() {
    this(ImmutableOpenMap.<String, ImmutableOpenIntMap<List<StoreStatus>>>of(), Collections.<Failure>emptyList());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:4,代碼來源:IndicesShardStoresResponse.java

示例10: testCanAllocateUsesMaxAvailableSpace

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
public void testCanAllocateUsesMaxAvailableSpace() {
    ClusterSettings nss = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
    DiskThresholdDecider decider = new DiskThresholdDecider(Settings.EMPTY, nss);

    MetaData metaData = MetaData.builder()
            .put(IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1))
            .build();

    final Index index = metaData.index("test").getIndex();

    ShardRouting test_0 = ShardRouting.newUnassigned(new ShardId(index, 0), true, StoreRecoverySource.EMPTY_STORE_INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "foo"));
    DiscoveryNode node_0 = new DiscoveryNode("node_0", buildNewFakeTransportAddress(), Collections.emptyMap(),
            new HashSet<>(Arrays.asList(DiscoveryNode.Role.values())), Version.CURRENT);
    DiscoveryNode node_1 = new DiscoveryNode("node_1", buildNewFakeTransportAddress(), Collections.emptyMap(),
            new HashSet<>(Arrays.asList(DiscoveryNode.Role.values())), Version.CURRENT);

    RoutingTable routingTable = RoutingTable.builder()
            .addAsNew(metaData.index("test"))
            .build();

    ClusterState clusterState = ClusterState.builder(org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).metaData(metaData).routingTable(routingTable).build();

    clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder()
                    .add(node_0)
                    .add(node_1)
    ).build();

    // actual test -- after all that bloat :)
    ImmutableOpenMap.Builder<String, DiskUsage> leastAvailableUsages = ImmutableOpenMap.builder();
    leastAvailableUsages.put("node_0", new DiskUsage("node_0", "node_0", "_na_", 100, 0)); // all full
    leastAvailableUsages.put("node_1", new DiskUsage("node_1", "node_1", "_na_", 100, 0)); // all full

    ImmutableOpenMap.Builder<String, DiskUsage> mostAvailableUsage = ImmutableOpenMap.builder();
    mostAvailableUsage.put("node_0", new DiskUsage("node_0", "node_0", "_na_", 100, randomIntBetween(20, 100))); // 20 - 99 percent since after allocation there must be at least 10% left and shard is 10byte
    mostAvailableUsage.put("node_1", new DiskUsage("node_1", "node_1", "_na_", 100, randomIntBetween(0, 10))); // this is weird and smells like a bug! it should be up to 20%?

    ImmutableOpenMap.Builder<String, Long> shardSizes = ImmutableOpenMap.builder();
    shardSizes.put("[test][0][p]", 10L); // 10 bytes
    final ClusterInfo clusterInfo = new ClusterInfo(leastAvailableUsages.build(), mostAvailableUsage.build(), shardSizes.build(), ImmutableOpenMap.of());
    RoutingAllocation allocation = new RoutingAllocation(new AllocationDeciders(Settings.EMPTY, Collections.singleton(decider)), clusterState.getRoutingNodes(), clusterState, clusterInfo, System.nanoTime(), false);
    allocation.debugDecision(true);
    Decision decision = decider.canAllocate(test_0, new RoutingNode("node_0", node_0), allocation);
    assertEquals(mostAvailableUsage.toString(), Decision.Type.YES, decision.type());
    assertThat(((Decision.Single) decision).getExplanation(), containsString("enough disk for shard on node"));
    decision = decider.canAllocate(test_0, new RoutingNode("node_1", node_1), allocation);
    assertEquals(mostAvailableUsage.toString(), Decision.Type.NO, decision.type());
    assertThat(((Decision.Single) decision).getExplanation(), containsString(
        "the node is above the high watermark cluster setting [cluster.routing.allocation.disk.watermark.high=90%], using more " +
        "disk space than the maximum allowed [90.0%]"));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:51,代碼來源:DiskThresholdDeciderUnitTests.java

示例11: getContext

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
@Override
public ImmutableOpenMap<Object, Object> getContext() {
    return ImmutableOpenMap.of();
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:5,代碼來源:PercolateContext.java

示例12: empty

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
@Override
protected AtomicParentChildFieldData empty(int maxDoc) {
    return new ParentChildAtomicFieldData(ImmutableOpenMap.<String, AtomicOrdinalsFieldData>of());
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:5,代碼來源:ParentChildIndexFieldData.java

示例13: empty

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
public static MultiFields empty() {
    return new MultiFields(ContentPath.Type.FULL, ImmutableOpenMap.<String, FieldMapper>of());
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:4,代碼來源:FieldMapper.java

示例14: getContext

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
@Override
public synchronized ImmutableOpenMap<Object, Object> getContext() {
    return context != null ? ImmutableOpenMap.copyOf(context) : ImmutableOpenMap.of();
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:5,代碼來源:ContextAndHeaderHolder.java

示例15: doMasterOperation

import org.elasticsearch.common.collect.ImmutableOpenMap; //導入方法依賴的package包/類
@Override
protected void doMasterOperation(final GetIndexRequest request, String[] concreteIndices, final ClusterState state,
                                 final ActionListener<GetIndexResponse> listener) {
    ImmutableOpenMap<String, List<Entry>> warmersResult = ImmutableOpenMap.of();
    ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappingsResult = ImmutableOpenMap.of();
    ImmutableOpenMap<String, List<AliasMetaData>> aliasesResult = ImmutableOpenMap.of();
    ImmutableOpenMap<String, Settings> settings = ImmutableOpenMap.of();
    Feature[] features = request.features();
    boolean doneAliases = false;
    boolean doneMappings = false;
    boolean doneSettings = false;
    boolean doneWarmers = false;
    for (Feature feature : features) {
        switch (feature) {
        case WARMERS:
                if (!doneWarmers) {
                    warmersResult = state.metaData().findWarmers(concreteIndices, request.types(), Strings.EMPTY_ARRAY);
                    doneWarmers = true;
                }
                break;
        case MAPPINGS:
                if (!doneMappings) {
                    mappingsResult = state.metaData().findMappings(concreteIndices, request.types());
                    doneMappings = true;
                }
                break;
        case ALIASES:
                if (!doneAliases) {
                    aliasesResult = state.metaData().findAliases(Strings.EMPTY_ARRAY, concreteIndices);
                    doneAliases = true;
                }
                break;
        case SETTINGS:
                if (!doneSettings) {
                    ImmutableOpenMap.Builder<String, Settings> settingsMapBuilder = ImmutableOpenMap.builder();
                    for (String index : concreteIndices) {
                        Settings indexSettings = state.metaData().index(index).getSettings();
                        if (request.humanReadable()) {
                            indexSettings = IndexMetaData.addHumanReadableSettings(indexSettings);
                        }
                        settingsMapBuilder.put(index, indexSettings);
                    }
                    settings = settingsMapBuilder.build();
                    doneSettings = true;
                }
                break;

            default:
                throw new IllegalStateException("feature [" + feature + "] is not valid");
        }
    }
    listener.onResponse(new GetIndexResponse(concreteIndices, warmersResult, mappingsResult, aliasesResult, settings));
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:54,代碼來源:TransportGetIndexAction.java


注:本文中的org.elasticsearch.common.collect.ImmutableOpenMap.of方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。