本文整理汇总了Java中org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse类的典型用法代码示例。如果您正苦于以下问题:Java PutRepositoryResponse类的具体用法?Java PutRepositoryResponse怎么用?Java PutRepositoryResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PutRepositoryResponse类属于org.elasticsearch.action.admin.cluster.repositories.put包,在下文中一共展示了PutRepositoryResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupRepo
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
private BlobStoreRepository setupRepo() {
final Client client = client();
final Path location = ESIntegTestCase.randomRepoPath(node().settings());
final String repositoryName = "test-repo";
PutRepositoryResponse putRepositoryResponse =
client.admin().cluster().preparePutRepository(repositoryName)
.setType("fs")
.setSettings(Settings.builder().put(node().settings()).put("location", location))
.get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
final RepositoriesService repositoriesService = getInstanceFromNode(RepositoriesService.class);
@SuppressWarnings("unchecked") final BlobStoreRepository repository =
(BlobStoreRepository) repositoriesService.repository(repositoryName);
return repository;
}
示例2: testNonExistingRepo_23
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
/**
* Test case for issue #23: https://github.com/elastic/elasticsearch-cloud-azure/issues/23
*/
public void testNonExistingRepo_23() {
Client client = client();
logger.info("--> creating azure repository with path [{}]", getRepositoryPath());
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
.setType("azure").setSettings(Settings.builder()
.put(Repository.CONTAINER_SETTING.getKey(), getContainerName())
.put(Repository.BASE_PATH_SETTING.getKey(), getRepositoryPath())
.put(Repository.CHUNK_SIZE_SETTING.getKey(), randomIntBetween(1000, 10000), ByteSizeUnit.BYTES)
).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
logger.info("--> restore non existing snapshot");
try {
client.admin().cluster().prepareRestoreSnapshot("test-repo", "no-existing-snapshot").setWaitForCompletion(true).get();
fail("Shouldn't be here");
} catch (SnapshotMissingException ex) {
// Expected
}
}
示例3: testRepositoryWithCustomEndpointProtocol
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch-cloud-aws/issues/211")
public void testRepositoryWithCustomEndpointProtocol() {
Client client = client();
Settings bucketSettings = internalCluster().getInstance(Settings.class).getByPrefix("repositories.s3.external-bucket.");
logger.info("--> creating s3 repostoriy with endpoint [{}], bucket[{}] and path [{}]", bucketSettings.get("endpoint"), bucketSettings.get("bucket"), basePath);
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
.setType("s3").setSettings(Settings.builder()
.put(S3Repository.Repository.BUCKET_SETTING.getKey(), bucketSettings.get("bucket"))
.put(S3Repository.Repository.ENDPOINT_SETTING.getKey(), bucketSettings.get("endpoint"))
.put(S3Repository.Repository.KEY_SETTING.getKey(), bucketSettings.get("access_key"))
.put(S3Repository.Repository.SECRET_SETTING.getKey(), bucketSettings.get("secret_key"))
.put(S3Repository.Repository.BASE_PATH_SETTING.getKey(), basePath)
).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
assertRepositoryIsOperational(client, "test-repo");
}
示例4: testNonExistingRepo86
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
/**
* Test case for issue #86: https://github.com/elastic/elasticsearch-cloud-aws/issues/86
*/
public void testNonExistingRepo86() {
Client client = client();
logger.info("--> creating s3 repository with bucket[{}] and path [{}]", internalCluster().getInstance(Settings.class).get("repositories.s3.bucket"), basePath);
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
.setType("s3").setSettings(Settings.builder()
.put(S3Repository.Repository.BASE_PATH_SETTING.getKey(), basePath)
).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
logger.info("--> restore non existing snapshot");
try {
client.admin().cluster().prepareRestoreSnapshot("test-repo", "no-existing-snapshot").setWaitForCompletion(true).execute().actionGet();
fail("Shouldn't be here");
} catch (SnapshotMissingException ex) {
// Expected
}
}
示例5: testWrongPath
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
public void testWrongPath() {
Client client = client();
logger.info("--> creating hdfs repository with path [{}]", path);
try {
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
.setType("hdfs")
.setSettings(Settings.settingsBuilder()
// .put("uri", "hdfs://127.0.0.1:51227/")
.put("conf.fs.es-hdfs.impl", "org.elasticsearch.repositories.hdfs.TestingFs")
.put("uri", "es-hdfs:///")
.put("path", path + "[email protected]$c#11:22")
.put("chunk_size", randomIntBetween(100, 1000) + "k")
.put("compress", randomBoolean()))
.get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
createIndex("test-idx-1", "test-idx-2", "test-idx-3");
ensureGreen();
fail("Path name is invalid");
} catch (RepositoryException re) {
// expected
}
}
示例6: getPutRepositoryResponse
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
@Mock
public PutRepositoryResponse getPutRepositoryResponse(Client esTransportClient, String s3RepoName) {
String localRepositoryLocation = LOCAL_DIR + PATH_SEP + s3RepositorySettingsParams.getBase_path();
PutRepositoryResponse putRepositoryResponse =
client0.admin().cluster()
.preparePutRepository(repositoryName)
.setType(AbstractRepository.RepositoryType.fs.name())
.setSettings(Settings.builder().put("location", localRepositoryLocation))
.get();
//Setting local repository location
repositoryLocation = localRepositoryLocation;
return putRepositoryResponse;
}
示例7: testSpecifiedIndexUnavailableSnapshotRestore
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
public void testSpecifiedIndexUnavailableSnapshotRestore() throws Exception {
createIndex("test1");
ensureGreen("test1");
waitForRelocation();
PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository("dummy-repo")
.setType("fs").setSettings(Settings.builder().put("location", randomRepoPath())).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
client().admin().cluster().prepareCreateSnapshot("dummy-repo", "snap1").setWaitForCompletion(true).get();
verify(snapshot("snap2", "test1", "test2"), true);
verify(restore("snap1", "test1", "test2"), true);
IndicesOptions options = IndicesOptions.strictExpandOpen();
verify(snapshot("snap2", "test1", "test2").setIndicesOptions(options), true);
verify(restore("snap1", "test1", "test2").setIndicesOptions(options), true);
options = IndicesOptions.lenientExpandOpen();
verify(snapshot("snap2", "test1", "test2").setIndicesOptions(options), false);
verify(restore("snap2", "test1", "test2").setIndicesOptions(options), false);
options = IndicesOptions.strictExpandOpen();
createIndex("test2");
//TODO: temporary work-around for #5531
ensureGreen("test2");
waitForRelocation();
verify(snapshot("snap3", "test1", "test2").setIndicesOptions(options), false);
verify(restore("snap3", "test1", "test2").setIndicesOptions(options), false);
}
示例8: testWildcardBehaviourSnapshotRestore
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
public void testWildcardBehaviourSnapshotRestore() throws Exception {
createIndex("foobar");
ensureGreen("foobar");
waitForRelocation();
PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository("dummy-repo")
.setType("fs").setSettings(Settings.builder().put("location", randomRepoPath())).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
client().admin().cluster().prepareCreateSnapshot("dummy-repo", "snap1").setWaitForCompletion(true).get();
IndicesOptions options = IndicesOptions.fromOptions(false, false, true, false);
verify(snapshot("snap2", "foo*", "bar*").setIndicesOptions(options), true);
verify(restore("snap1", "foo*", "bar*").setIndicesOptions(options), true);
options = IndicesOptions.strictExpandOpen();
verify(snapshot("snap2", "foo*", "bar*").setIndicesOptions(options), false);
verify(restore("snap2", "foo*", "bar*").setIndicesOptions(options), false);
assertAcked(prepareCreate("barbaz"));
//TODO: temporary work-around for #5531
ensureGreen("barbaz");
waitForRelocation();
options = IndicesOptions.fromOptions(false, false, true, false);
verify(snapshot("snap3", "foo*", "bar*").setIndicesOptions(options), false);
verify(restore("snap3", "foo*", "bar*").setIndicesOptions(options), false);
options = IndicesOptions.fromOptions(false, false, true, false);
verify(snapshot("snap4", "foo*", "baz*").setIndicesOptions(options), true);
verify(restore("snap3", "foo*", "baz*").setIndicesOptions(options), true);
}
示例9: testEmptySnapshot
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
public void testEmptySnapshot() throws Exception {
Client client = client();
logger.info("--> creating repository");
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
.setType("fs").setSettings(Settings.builder().put("location", randomRepoPath())).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
logger.info("--> snapshot");
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).get();
assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(0));
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(0));
assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
}
示例10: testRepositoryAckTimeout
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
public void testRepositoryAckTimeout() throws Exception {
logger.info("--> creating repository test-repo-1 with 0s timeout - shouldn't ack");
PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository("test-repo-1")
.setType("fs").setSettings(Settings.builder()
.put("location", randomRepoPath())
.put("compress", randomBoolean())
.put("chunk_size", randomIntBetween(5, 100), ByteSizeUnit.BYTES)
)
.setTimeout("0s").get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(false));
logger.info("--> creating repository test-repo-2 with standard timeout - should ack");
putRepositoryResponse = client().admin().cluster().preparePutRepository("test-repo-2")
.setType("fs").setSettings(Settings.builder()
.put("location", randomRepoPath())
.put("compress", randomBoolean())
.put("chunk_size", randomIntBetween(5, 100), ByteSizeUnit.BYTES)
).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
logger.info("--> deleting repository test-repo-2 with 0s timeout - shouldn't ack");
DeleteRepositoryResponse deleteRepositoryResponse = client().admin().cluster().prepareDeleteRepository("test-repo-2")
.setTimeout("0s").get();
assertThat(deleteRepositoryResponse.isAcknowledged(), equalTo(false));
logger.info("--> deleting repository test-repo-1 with standard timeout - should ack");
deleteRepositoryResponse = client().admin().cluster().prepareDeleteRepository("test-repo-1").get();
assertThat(deleteRepositoryResponse.isAcknowledged(), equalTo(true));
}
示例11: testList
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
public void testList() throws Exception {
Client client = client();
logger.info("--> creating azure primary repository");
PutRepositoryResponse putRepositoryResponsePrimary = client.admin().cluster().preparePutRepository("primary")
.setType("azure").setSettings(Settings.builder()
.put(Repository.CONTAINER_SETTING.getKey(), containerName)
).get();
assertThat(putRepositoryResponsePrimary.isAcknowledged(), equalTo(true));
logger.info("--> start get snapshots on primary");
long startWait = System.currentTimeMillis();
client.admin().cluster().prepareGetSnapshots("primary").get();
long endWait = System.currentTimeMillis();
// definitely should be done in 30s, and if its not working as expected, it takes over 1m
assertThat(endWait - startWait, lessThanOrEqualTo(30000L));
logger.info("--> creating azure secondary repository");
PutRepositoryResponse putRepositoryResponseSecondary = client.admin().cluster().preparePutRepository("secondary")
.setType("azure").setSettings(Settings.builder()
.put(Repository.CONTAINER_SETTING.getKey(), containerName)
.put(Repository.LOCATION_MODE_SETTING.getKey(), "secondary_only")
).get();
assertThat(putRepositoryResponseSecondary.isAcknowledged(), equalTo(true));
logger.info("--> start get snapshots on secondary");
startWait = System.currentTimeMillis();
client.admin().cluster().prepareGetSnapshots("secondary").get();
endWait = System.currentTimeMillis();
logger.info("--> end of get snapshots on secondary. Took {} ms", endWait - startWait);
assertThat(endWait - startWait, lessThanOrEqualTo(30000L));
}
示例12: testRepositoryWithBasePath
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
public void testRepositoryWithBasePath() {
Client client = client();
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
.setType("s3").setSettings(Settings.builder()
.put(S3Repository.Repository.BASE_PATH_SETTING.getKey(), basePath)
).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
assertRepositoryIsOperational(client, "test-repo");
}
示例13: testRepositoryWithCustomCredentials
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
public void testRepositoryWithCustomCredentials() {
Client client = client();
Settings bucketSettings = internalCluster().getInstance(Settings.class).getByPrefix("repositories.s3.private-bucket.");
logger.info("--> creating s3 repository with bucket[{}] and path [{}]", bucketSettings.get("bucket"), basePath);
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
.setType("s3").setSettings(Settings.builder()
.put(S3Repository.Repository.BASE_PATH_SETTING.getKey(), basePath)
.put(S3Repository.Repository.KEY_SETTING.getKey(), bucketSettings.get("access_key"))
.put(S3Repository.Repository.SECRET_SETTING.getKey(), bucketSettings.get("secret_key"))
.put(S3Repository.Repository.BUCKET_SETTING.getKey(), bucketSettings.get("bucket"))
).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
assertRepositoryIsOperational(client, "test-repo");
}
示例14: testRepositoryInRemoteRegion
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch-cloud-aws/issues/211")
public void testRepositoryInRemoteRegion() {
Client client = client();
Settings settings = internalCluster().getInstance(Settings.class);
Settings bucketSettings = settings.getByPrefix("repositories.s3.remote-bucket.");
logger.info("--> creating s3 repository with bucket[{}] and path [{}]", bucketSettings.get("bucket"), basePath);
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
.setType("s3").setSettings(Settings.builder()
.put(S3Repository.Repository.BASE_PATH_SETTING.getKey(), basePath)
.put(S3Repository.Repository.BUCKET_SETTING.getKey(), bucketSettings.get("bucket"))
).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
assertRepositoryIsOperational(client, "test-repo");
}
示例15: execute
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; //导入依赖的package包/类
public ListenableFuture<Long> execute(CreateRepositoryAnalyzedStatement statement) {
final SettableFuture<Long> result = SettableFuture.create();
final String repoName = statement.repositoryName();
PutRepositoryRequest request = new PutRepositoryRequest(repoName);
request.type(statement.repositoryType());
request.settings(statement.settings());
transportActionProvider.transportPutRepositoryAction().execute(request, new ActionListener<PutRepositoryResponse>() {
@Override
public void onResponse(PutRepositoryResponse putRepositoryResponse) {
result.set(1L);
}
@Override
public void onFailure(Throwable e) {
final Throwable t = convertRepositoryException(e);
// in case the put repo action fails in the verificationPhase the repository got already created
// but an exception is raised anyway.
// --> remove the repo and then return the exception to the user
dropIfExists(repoName, new Runnable() {
@Override
public void run() {
result.setException(t);
}
});
}
});
return result;
}