NOTE: You are looking at documentation for an older release. For the latest information, see the current release documentation.
Snapshot Create RepositoryAPI
editSnapshot Create RepositoryAPI
editThe Snapshot Create RepositoryAPI allows to register a snapshot repository.
Snapshot Create RepositoryRequest
editA PutRepositoryRequest
:
PutRepositoryRequest request = new PutRepositoryRequest();
Repository Settings
editSettings requirements will differ based on the repository backend chosen.
Providing the Settings
editThe 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 Arguments
editThe following arguments must be provided:
Optional Arguments
editThe 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 Execution
editAcknowledgedResponse response = client.snapshot().createRepository(request, RequestOptions.DEFAULT);
Asynchronous Execution
editThe 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 RepositoryResponse
editThe returned PutRepositoryResponse
allows to retrieve information about the
executed operation as follows: