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


Java GetSnapshotsResponse.getSnapshots方法代码示例

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


在下文中一共展示了GetSnapshotsResponse.getSnapshots方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: blockForSnapshot

import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; //导入方法依赖的package包/类
/**
 * Block for index snapshots to be complete
 * 
 * @param snapshotRepoName
 * @param indicies
 * @param timeoutMS
 */
private void blockForSnapshot(String snapshotRepoName, List<String> indicies, long timeoutMS) {
	long start = System.currentTimeMillis();
	while(System.currentTimeMillis() - start < timeoutMS) {

		GetSnapshotsResponse repos = node.client().admin().cluster().getSnapshots(new GetSnapshotsRequest(snapshotRepoName)).actionGet();
			for(SnapshotInfo i : repos.getSnapshots()) {
				if(i.state().completed() && i.successfulShards() == i.totalShards() && i.totalShards() >= indicies.size()) {
					logger.info("Snapshot completed {} out of {} indicies. Snapshot state {}. ", i.successfulShards(), i.totalShards(), i.state().completed());
					return;
				} else {
					logger.info("Snapshotted {} out of {} indicies, polling for completion. Snapshot state {}.", i.successfulShards(), i.totalShards(), i.state().completed());
				}
			}
		try {
			// Don't slam ES with snapshot status requests in a tight loop
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			Thread.currentThread().interrupt();
		}
	}
}
 
开发者ID:MyPureCloud,项目名称:elasticsearch-lambda,代码行数:29,代码来源:ESEmbededContainer.java

示例2: buildTable

import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; //导入方法依赖的package包/类
private Table buildTable(RestRequest req, GetSnapshotsResponse getSnapshotsResponse) {
    Table table = getTableWithHeader(req);
    for (SnapshotInfo snapshotStatus : getSnapshotsResponse.getSnapshots()) {
        table.startRow();

        table.addCell(snapshotStatus.snapshotId().getName());
        table.addCell(snapshotStatus.state());
        table.addCell(TimeUnit.SECONDS.convert(snapshotStatus.startTime(), TimeUnit.MILLISECONDS));
        table.addCell(dateFormat.print(snapshotStatus.startTime()));
        table.addCell(TimeUnit.SECONDS.convert(snapshotStatus.endTime(), TimeUnit.MILLISECONDS));
        table.addCell(dateFormat.print(snapshotStatus.endTime()));
        final long durationMillis;
        if (snapshotStatus.state() == SnapshotState.IN_PROGRESS) {
            durationMillis = System.currentTimeMillis() - snapshotStatus.startTime();
        } else {
            durationMillis = snapshotStatus.endTime() - snapshotStatus.startTime();
        }
        table.addCell(TimeValue.timeValueMillis(durationMillis));
        table.addCell(snapshotStatus.indices().size());
        table.addCell(snapshotStatus.successfulShards());
        table.addCell(snapshotStatus.failedShards());
        table.addCell(snapshotStatus.totalShards());
        table.addCell(snapshotStatus.reason());

        table.endRow();
    }

    return table;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:RestSnapshotAction.java

示例3: buildTable

import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; //导入方法依赖的package包/类
private Table buildTable(RestRequest req, GetSnapshotsResponse getSnapshotsResponse) {
    Table table = getTableWithHeader(req);
    for (SnapshotInfo snapshotStatus : getSnapshotsResponse.getSnapshots()) {
        table.startRow();

        table.addCell(snapshotStatus.name());
        table.addCell(snapshotStatus.state());
        table.addCell(TimeUnit.SECONDS.convert(snapshotStatus.startTime(), TimeUnit.MILLISECONDS));
        table.addCell(dateFormat.print(snapshotStatus.startTime()));
        table.addCell(TimeUnit.SECONDS.convert(snapshotStatus.endTime(), TimeUnit.MILLISECONDS));
        table.addCell(dateFormat.print(snapshotStatus.endTime()));
        final long durationMillis;
        if (snapshotStatus.state() == SnapshotState.IN_PROGRESS) {
            durationMillis = System.currentTimeMillis() - snapshotStatus.startTime();
        } else {
            durationMillis = snapshotStatus.endTime() - snapshotStatus.startTime();
        }
        table.addCell(TimeValue.timeValueMillis(durationMillis));
        table.addCell(snapshotStatus.indices().size());
        table.addCell(snapshotStatus.successfulShards());
        table.addCell(snapshotStatus.failedShards());
        table.addCell(snapshotStatus.totalShards());
        table.addCell(snapshotStatus.reason());

        table.endRow();
    }

    return table;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:30,代码来源:RestSnapshotAction.java

示例4: getAvailableSnapshots

import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; //导入方法依赖的package包/类
public static List<String> getAvailableSnapshots(Client transportClient, String repositoryName) {
    logger.info("Searching for available snapshots");

    List<String> snapshots = new ArrayList<>();
    GetSnapshotsResponse getSnapshotsResponse = transportClient.admin().cluster()
            .prepareGetSnapshots(repositoryName)
            .get();

    for (SnapshotInfo snapshotInfo : getSnapshotsResponse.getSnapshots()) {
        snapshots.add(snapshotInfo.snapshotId().getName());
    }

    return snapshots;
}
 
开发者ID:Netflix,项目名称:Raigad,代码行数:15,代码来源:ElasticsearchUtils.java

示例5: purgeOldSnapshots

import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; //导入方法依赖的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


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