use of org.opensearch.cluster.metadata.RepositoryMetadata in project OpenSearch by opensearch-project.
the class SnapshotClientDocumentationIT method testSnapshotGetRepository.
public void testSnapshotGetRepository() throws IOException {
RestHighLevelClient client = highLevelClient();
createTestRepositories();
// tag::get-repository-request
GetRepositoriesRequest request = new GetRepositoriesRequest();
// end::get-repository-request
// tag::get-repository-request-repositories
String[] repositories = new String[] { repositoryName };
// <1>
request.repositories(repositories);
// end::get-repository-request-repositories
// tag::get-repository-request-local
// <1>
request.local(true);
// end::get-repository-request-local
// tag::get-repository-request-masterTimeout
// <1>
request.masterNodeTimeout(TimeValue.timeValueMinutes(1));
// <2>
request.masterNodeTimeout("1m");
// end::get-repository-request-masterTimeout
// tag::get-repository-execute
GetRepositoriesResponse response = client.snapshot().getRepository(request, RequestOptions.DEFAULT);
// end::get-repository-execute
// tag::get-repository-response
List<RepositoryMetadata> repositoryMetadataResponse = response.repositories();
// end::get-repository-response
assertThat(1, equalTo(repositoryMetadataResponse.size()));
assertThat(repositoryName, equalTo(repositoryMetadataResponse.get(0).name()));
}
use of org.opensearch.cluster.metadata.RepositoryMetadata in project OpenSearch by opensearch-project.
the class S3BlobContainerRetriesTests method createBlobContainer.
@Override
protected BlobContainer createBlobContainer(@Nullable final Integer maxRetries, @Nullable final TimeValue readTimeout, @Nullable final Boolean disableChunkedEncoding, @Nullable final ByteSizeValue bufferSize) {
final Settings.Builder clientSettings = Settings.builder();
final String clientName = randomAlphaOfLength(5).toLowerCase(Locale.ROOT);
final InetSocketAddress address = httpServer.getAddress();
final String endpoint = "http://" + InetAddresses.toUriString(address.getAddress()) + ":" + address.getPort();
clientSettings.put(ENDPOINT_SETTING.getConcreteSettingForNamespace(clientName).getKey(), endpoint);
if (maxRetries != null) {
clientSettings.put(MAX_RETRIES_SETTING.getConcreteSettingForNamespace(clientName).getKey(), maxRetries);
}
if (readTimeout != null) {
clientSettings.put(READ_TIMEOUT_SETTING.getConcreteSettingForNamespace(clientName).getKey(), readTimeout);
}
if (disableChunkedEncoding != null) {
clientSettings.put(DISABLE_CHUNKED_ENCODING.getConcreteSettingForNamespace(clientName).getKey(), disableChunkedEncoding);
}
final MockSecureSettings secureSettings = new MockSecureSettings();
secureSettings.setString(S3ClientSettings.ACCESS_KEY_SETTING.getConcreteSettingForNamespace(clientName).getKey(), "access");
secureSettings.setString(S3ClientSettings.SECRET_KEY_SETTING.getConcreteSettingForNamespace(clientName).getKey(), "secret");
clientSettings.setSecureSettings(secureSettings);
service.refreshAndClearCache(S3ClientSettings.load(clientSettings.build()));
final RepositoryMetadata repositoryMetadata = new RepositoryMetadata("repository", S3Repository.TYPE, Settings.builder().put(S3Repository.CLIENT_NAME.getKey(), clientName).build());
return new S3BlobContainer(BlobPath.cleanPath(), new S3BlobStore(service, "bucket", S3Repository.SERVER_SIDE_ENCRYPTION_SETTING.getDefault(Settings.EMPTY), bufferSize == null ? S3Repository.BUFFER_SIZE_SETTING.getDefault(Settings.EMPTY) : bufferSize, S3Repository.CANNED_ACL_SETTING.getDefault(Settings.EMPTY), S3Repository.STORAGE_CLASS_SETTING.getDefault(Settings.EMPTY), repositoryMetadata)) {
@Override
public InputStream readBlob(String blobName) throws IOException {
return new AssertingInputStream(super.readBlob(blobName), blobName);
}
@Override
public InputStream readBlob(String blobName, long position, long length) throws IOException {
return new AssertingInputStream(super.readBlob(blobName, position, length), blobName, position, length);
}
};
}
use of org.opensearch.cluster.metadata.RepositoryMetadata in project OpenSearch by opensearch-project.
the class S3RepositoryTests method testDefaultBufferSize.
public void testDefaultBufferSize() {
final RepositoryMetadata metadata = new RepositoryMetadata("dummy-repo", "mock", Settings.EMPTY);
try (S3Repository s3repo = createS3Repo(metadata)) {
assertThat(s3repo.getBlobStore(), is(nullValue()));
s3repo.start();
final long defaultBufferSize = ((S3BlobStore) s3repo.blobStore()).bufferSizeInBytes();
assertThat(s3repo.getBlobStore(), not(nullValue()));
assertThat(defaultBufferSize, Matchers.lessThanOrEqualTo(100L * 1024 * 1024));
assertThat(defaultBufferSize, Matchers.greaterThanOrEqualTo(5L * 1024 * 1024));
}
}
use of org.opensearch.cluster.metadata.RepositoryMetadata in project OpenSearch by opensearch-project.
the class S3ServiceTests method testCachedClientsAreReleased.
public void testCachedClientsAreReleased() {
final S3Service s3Service = new S3Service();
final Settings settings = Settings.builder().put("endpoint", "http://first").build();
final RepositoryMetadata metadata1 = new RepositoryMetadata("first", "s3", settings);
final RepositoryMetadata metadata2 = new RepositoryMetadata("second", "s3", settings);
final S3ClientSettings clientSettings = s3Service.settings(metadata2);
final S3ClientSettings otherClientSettings = s3Service.settings(metadata2);
assertSame(clientSettings, otherClientSettings);
final AmazonS3Reference reference = s3Service.client(metadata1);
reference.close();
s3Service.close();
final AmazonS3Reference referenceReloaded = s3Service.client(metadata1);
assertNotSame(referenceReloaded, reference);
referenceReloaded.close();
s3Service.close();
final S3ClientSettings clientSettingsReloaded = s3Service.settings(metadata1);
assertNotSame(clientSettings, clientSettingsReloaded);
}
use of org.opensearch.cluster.metadata.RepositoryMetadata in project OpenSearch by opensearch-project.
the class AzureRepositorySettingsTests method azureRepository.
private AzureRepository azureRepository(Settings settings) {
Settings internalSettings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toAbsolutePath()).putList(Environment.PATH_DATA_SETTING.getKey(), tmpPaths()).put(settings).build();
final AzureRepository azureRepository = new AzureRepository(new RepositoryMetadata("foo", "azure", internalSettings), NamedXContentRegistry.EMPTY, mock(AzureStorageService.class), BlobStoreTestUtil.mockClusterService(), new RecoverySettings(settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)));
assertThat(azureRepository.getBlobStore(), is(nullValue()));
return azureRepository;
}
Aggregations