当前位置: 首页>>代码示例>>Java>>正文


Java GetSnapshotsRequestBuilder类代码示例

本文整理汇总了Java中org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequestBuilder的典型用法代码示例。如果您正苦于以下问题:Java GetSnapshotsRequestBuilder类的具体用法?Java GetSnapshotsRequestBuilder怎么用?Java GetSnapshotsRequestBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

GetSnapshotsRequestBuilder类属于org.elasticsearch.action.admin.cluster.snapshots.get包,在下文中一共展示了GetSnapshotsRequestBuilder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: prepareGetSnapshots

import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequestBuilder; //导入依赖的package包/类
@Override
public GetSnapshotsRequestBuilder prepareGetSnapshots(String repository) {
    return new GetSnapshotsRequestBuilder(this, GetSnapshotsAction.INSTANCE, repository);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java


示例2: purgeOldSnapshots

import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequestBuilder; //导入依赖的package包/类
private void purgeOldSnapshots() {
	logger.info("Purging expired snapshot(s) for index(es): {} ", this.snapshotSettings.getIndices());
	// get old snapshots to remove
	GetSnapshotsRequestBuilder getBuilder = new GetSnapshotsRequestBuilder(this.client.admin().cluster(), this.snapshotSettings.getRepository());
	GetSnapshotsResponse getResp = getBuilder.get();

	Set<String> configIndices = getConfiguredIndicesAsSet();
	if (getResp != null && getResp.getSnapshots() != null) {
		ImmutableList<SnapshotInfo> snapshots = getResp.getSnapshots();
		if (snapshots == null || snapshots.isEmpty()) {
			return;
		}

		logger.debug("Found a total of {} snapshots in the repository", snapshots.size());
		List<String> purgeSnapshots = new ArrayList<String>();
		for (Iterator<SnapshotInfo> i = snapshots.iterator(); i.hasNext();) {
			SnapshotInfo snap = i.next();
			logger.debug("This snapshot [{}] includes the following indices: {}", snap.name(), StringUtils.toString(snap.indices()));

			if(this.snapshotSettings.isPurgeIndicesMustMatch()){					
				// if number of indices don't match, do not purge
				if (snap.indices().size() != configIndices.size()) {
					logger.info("Snapshot [{}] not purged. The number of indices in the snapshot ({}) must match the number of indices in the current configuration ({}). To purge all snapshots, configure purge_indices_must_match:false.", snap.name(), snap.indices().size(), configIndices.size());
					continue;
				}

				// if the size matches, verify that the indexes within the snapshot are exactly the same as those
				// configured for the river
				if (!snapshotIndicesMatch(snap, configIndices)) {
					logger.info("Snapshot [{}] not purged. In order to purge a snapshot automatically, the specific indexes must match exactly. The snapshot does not match current purge configuration indices. To purge all snapshots, configure purge_indices_must_match:false.", snap.name());
					continue;
				}
			} 

			// finally check if the snapshot is beyond the purgeAfter age
			Date expiration = new Date(snap.startTime() + this.snapshotSettings.getPurgeAfter().millis());
			if (expiration.before(new Date())) {
				purgeSnapshots.add(snap.name());
			}
		} 

		// remove old snapshots
		logger.debug("{} snapshots are scheduled to be purged.", purgeSnapshots.size());
		for (String snapshotName : purgeSnapshots) {
			DeleteSnapshotRequestBuilder deleteBuilder = new DeleteSnapshotRequestBuilder(this.client.admin().cluster());
			deleteBuilder.setRepository(this.snapshotSettings.getRepository());
			deleteBuilder.setSnapshot(snapshotName);
			DeleteSnapshotResponse deleteResp = deleteBuilder.get();
			if (deleteResp.isAcknowledged()) {
				logger.info("Expired snapshot [{}] has been deleted.", snapshotName);
			} else {
				logger.error("Not able to delete expired snapshot [{}]", snapshotName);
			}
		}
	}
}
 
开发者ID:garmin,项目名称:elasticsearch-river-snapshot,代码行数:57,代码来源:SnapshotsExecutor.java


示例3: prepareGetSnapshots

import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequestBuilder; //导入依赖的package包/类
/**
 * Get snapshot.
 */
GetSnapshotsRequestBuilder prepareGetSnapshots(String repository);
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ClusterAdminClient.java



注:本文中的org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequestBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。