Skip to content

Commit 2481237

Browse files
authored
Remove default getRegister impl (#131604)
This made sense in the early days of the blob-store register work but now every blob store has its own implementation of `getRegister` there's no need to include a default here.
1 parent 4ffe49c commit 2481237

File tree

4 files changed

+15
-4
lines changed
  • modules/repository-url/src/main/java/org/elasticsearch/common/blobstore/url
  • plugins/repository-hdfs/src/main/java/org/elasticsearch/repositories/hdfs
  • server/src/main/java/org/elasticsearch/common/blobstore
  • x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/cache/common

4 files changed

+15
-4
lines changed

modules/repository-url/src/main/java/org/elasticsearch/common/blobstore/url/URLBlobContainer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,8 @@ public void compareAndExchangeRegister(
169169
listener.onFailure(new UnsupportedOperationException("URL repositories do not support this operation"));
170170
}
171171

172+
@Override
173+
public void getRegister(OperationPurpose purpose, String key, ActionListener<OptionalBytesReference> listener) {
174+
listener.onFailure(new UnsupportedOperationException("URL repositories do not support this operation"));
175+
}
172176
}

plugins/repository-hdfs/src/main/java/org/elasticsearch/repositories/hdfs/HdfsBlobContainer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ public void compareAndExchangeRegister(
334334
listener.onFailure(new UnsupportedOperationException("HDFS repositories do not support this operation"));
335335
}
336336

337+
@Override
338+
public void getRegister(OperationPurpose purpose, String key, ActionListener<OptionalBytesReference> listener) {
339+
listener.onFailure(new UnsupportedOperationException("HDFS repositories do not support this operation"));
340+
}
341+
337342
private static CreateOpts[] addOptionToArray(final CreateOpts[] opts, final CreateOpts opt) {
338343
if (opts == null) {
339344
return new CreateOpts[] { opt };

server/src/main/java/org/elasticsearch/common/blobstore/BlobContainer.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import org.elasticsearch.action.ActionListener;
1313
import org.elasticsearch.common.blobstore.support.BlobMetadata;
14-
import org.elasticsearch.common.bytes.BytesArray;
1514
import org.elasticsearch.common.bytes.BytesReference;
1615
import org.elasticsearch.core.CheckedConsumer;
1716
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
@@ -377,9 +376,7 @@ default void compareAndSetRegister(
377376
* @param listener a listener, completed with the value read from the register or {@code OptionalBytesReference#MISSING} if the value
378377
* could not be read due to concurrent activity (which should not happen).
379378
*/
380-
default void getRegister(OperationPurpose purpose, String key, ActionListener<OptionalBytesReference> listener) {
381-
compareAndExchangeRegister(purpose, key, BytesArray.EMPTY, BytesArray.EMPTY, listener);
382-
}
379+
void getRegister(OperationPurpose purpose, String key, ActionListener<OptionalBytesReference> listener);
383380

384381
/**
385382
* Verify that the {@link OperationPurpose} is (somewhat) suitable for the name of the blob to which it applies:

x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/cache/common/TestUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ public void compareAndExchangeRegister(
269269
listener.onFailure(unsupportedException());
270270
}
271271

272+
@Override
273+
public void getRegister(OperationPurpose purpose, String key, ActionListener<OptionalBytesReference> listener) {
274+
listener.onFailure(unsupportedException());
275+
}
276+
272277
private UnsupportedOperationException unsupportedException() {
273278
assert false : "this operation is not supported and should have not be called";
274279
return new UnsupportedOperationException("This operation is not supported");

0 commit comments

Comments
 (0)