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


Java ClusterState.custom方法代碼示例

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


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

示例1: isRepositoryInUse

import org.elasticsearch.cluster.ClusterState; //導入方法依賴的package包/類
/**
 * Checks if a repository is currently in use by one of the snapshots
 *
 * @param clusterState cluster state
 * @param repository   repository id
 * @return true if repository is currently in use by one of the running snapshots
 */
public static boolean isRepositoryInUse(ClusterState clusterState, String repository) {
    SnapshotsInProgress snapshots = clusterState.custom(SnapshotsInProgress.TYPE);
    if (snapshots != null) {
        for (SnapshotsInProgress.Entry snapshot : snapshots.entries()) {
            if (repository.equals(snapshot.snapshot().getRepository())) {
                return true;
            }
        }
    }
    SnapshotDeletionsInProgress deletionsInProgress = clusterState.custom(SnapshotDeletionsInProgress.TYPE);
    if (deletionsInProgress != null) {
        for (SnapshotDeletionsInProgress.Entry entry : deletionsInProgress.getEntries()) {
            if (entry.getSnapshot().getRepository().equals(repository)) {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:27,代碼來源:SnapshotsService.java

示例2: checkIndexClosing

import org.elasticsearch.cluster.ClusterState; //導入方法依賴的package包/類
/**
 * Check if any of the indices to be closed are currently being restored from a snapshot and fail closing if such an index
 * is found as closing an index that is being restored makes the index unusable (it cannot be recovered).
 */
public static void checkIndexClosing(ClusterState currentState, Set<IndexMetaData> indices) {
    RestoreInProgress restore = currentState.custom(RestoreInProgress.TYPE);
    if (restore != null) {
        Set<Index> indicesToFail = null;
        for (RestoreInProgress.Entry entry : restore.entries()) {
            for (ObjectObjectCursor<ShardId, RestoreInProgress.ShardRestoreStatus> shard : entry.shards()) {
                if (!shard.value.state().completed()) {
                    IndexMetaData indexMetaData = currentState.metaData().index(shard.key.getIndex());
                    if (indexMetaData != null && indices.contains(indexMetaData)) {
                        if (indicesToFail == null) {
                            indicesToFail = new HashSet<>();
                        }
                        indicesToFail.add(shard.key.getIndex());
                    }
                }
            }
        }
        if (indicesToFail != null) {
            throw new IllegalArgumentException("Cannot close indices that are being restored: " + indicesToFail);
        }
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:27,代碼來源:RestoreService.java

示例3: isRepositoryInUse

import org.elasticsearch.cluster.ClusterState; //導入方法依賴的package包/類
/**
 * Checks if a repository is currently in use by one of the snapshots
 *
 * @param clusterState cluster state
 * @param repository   repository id
 * @return true if repository is currently in use by one of the running snapshots
 */
public static boolean isRepositoryInUse(ClusterState clusterState, String repository) {
    RestoreInProgress snapshots = clusterState.custom(RestoreInProgress.TYPE);
    if (snapshots != null) {
        for (RestoreInProgress.Entry snapshot : snapshots.entries()) {
            if (repository.equals(snapshot.snapshot().getRepository())) {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,代碼來源:RestoreService.java

示例4: isRepositoryInUse

import org.elasticsearch.cluster.ClusterState; //導入方法依賴的package包/類
/**
 * Checks if a repository is currently in use by one of the snapshots
 *
 * @param clusterState cluster state
 * @param repository   repository id
 * @return true if repository is currently in use by one of the running snapshots
 */
public static boolean isRepositoryInUse(ClusterState clusterState, String repository) {
    SnapshotsInProgress snapshots = clusterState.custom(SnapshotsInProgress.TYPE);
    if (snapshots != null) {
        for (SnapshotsInProgress.Entry snapshot : snapshots.entries()) {
            if (repository.equals(snapshot.snapshotId().getRepository())) {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:19,代碼來源:SnapshotsService.java

示例5: execute

import org.elasticsearch.cluster.ClusterState; //導入方法依賴的package包/類
@Override
public ClusterTasksResult<UpdateIndexShardSnapshotStatusRequest> execute(ClusterState currentState, List<UpdateIndexShardSnapshotStatusRequest> tasks) throws Exception {
    final SnapshotsInProgress snapshots = currentState.custom(SnapshotsInProgress.TYPE);
    if (snapshots != null) {
        int changedCount = 0;
        final List<SnapshotsInProgress.Entry> entries = new ArrayList<>();
        for (SnapshotsInProgress.Entry entry : snapshots.entries()) {
            ImmutableOpenMap.Builder<ShardId, ShardSnapshotStatus> shards = ImmutableOpenMap.builder();
            boolean updated = false;

            for (UpdateIndexShardSnapshotStatusRequest updateSnapshotState : tasks) {
                if (entry.snapshot().equals(updateSnapshotState.snapshot())) {
                    logger.trace("[{}] Updating shard [{}] with status [{}]", updateSnapshotState.snapshot(), updateSnapshotState.shardId(), updateSnapshotState.status().state());
                    if (updated == false) {
                        shards.putAll(entry.shards());
                        updated = true;
                    }
                    shards.put(updateSnapshotState.shardId(), updateSnapshotState.status());
                    changedCount++;
                }
            }

            if (updated) {
                if (completed(shards.values()) == false) {
                    entries.add(new SnapshotsInProgress.Entry(entry, shards.build()));
                } else {
                    // Snapshot is finished - mark it as done
                    // TODO: Add PARTIAL_SUCCESS status?
                    SnapshotsInProgress.Entry updatedEntry = new SnapshotsInProgress.Entry(entry, State.SUCCESS, shards.build());
                    entries.add(updatedEntry);
                    // Finalize snapshot in the repository
                    snapshotsService.endSnapshot(updatedEntry);
                    logger.info("snapshot [{}] is done", updatedEntry.snapshot());
                }
            } else {
                entries.add(entry);
            }
        }
        if (changedCount > 0) {
            logger.trace("changed cluster state triggered by {} snapshot state updates", changedCount);

            final SnapshotsInProgress updatedSnapshots = new SnapshotsInProgress(entries.toArray(new SnapshotsInProgress.Entry[entries.size()]));
            return ClusterTasksResult.<UpdateIndexShardSnapshotStatusRequest>builder().successes(tasks).build(
                ClusterState.builder(currentState).putCustom(SnapshotsInProgress.TYPE, updatedSnapshots).build());
        }
    }
    return ClusterTasksResult.<UpdateIndexShardSnapshotStatusRequest>builder().successes(tasks).build(currentState);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:49,代碼來源:SnapshotShardsService.java


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