本文整理汇总了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);
}
示例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);
}
}
}
}
示例3: prepareGetSnapshots
import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequestBuilder; //导入依赖的package包/类
/**
* Get snapshot.
*/
GetSnapshotsRequestBuilder prepareGetSnapshots(String repository);