Snapshot Create RepositoryAPIedit
The Snapshot Create RepositoryAPI allows to register a snapshot repository.
Snapshot Create RepositoryRequestedit
A PutRepositoryRequest
:
PutRepositoryRequest request = new PutRepositoryRequest();
Repository Settingsedit
Settings requirements will differ based on the repository backend chosen.
Providing the Settingsedit
The settings to be applied can be provided in different ways:
String locationKey = FsRepository.LOCATION_SETTING.getKey(); String locationValue = "."; String compressKey = FsRepository.COMPRESS_SETTING.getKey(); boolean compressValue = true; Settings settings = Settings.builder() .put(locationKey, locationValue) .put(compressKey, compressValue) .build();
Settings.Builder settingsBuilder = Settings.builder() .put(locationKey, locationValue) .put(compressKey, compressValue); request.settings(settingsBuilder);
Required Argumentsedit
The following arguments must be provided:
Optional Argumentsedit
The following arguments can optionally be provided:
Timeout to wait for the all the nodes to acknowledge the settings were applied
as a |
|
Timeout to wait for the all the nodes to acknowledge the settings were applied
as a |
Timeout to connect to the master node as a |
|
Timeout to connect to the master node as a |
Synchronous Executionedit
AcknowledgedResponse response = client.snapshot().createRepository(request, RequestOptions.DEFAULT);
Asynchronous Executionedit
The asynchronous execution of a repository put settings requires both the
PutRepositoryRequest
instance and an ActionListener
instance to be
passed to the asynchronous method:
The asynchronous method does not block and returns immediately. Once it is
completed the ActionListener
is called back using the onResponse
method
if the execution successfully completed or using the onFailure
method if
it failed.
A typical listener for PutRepositoryResponse
looks like:
Snapshot Create RepositoryResponseedit
The returned PutRepositoryResponse
allows to retrieve information about the
executed operation as follows: