forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create interface RemoteEntitiesManager
Signed-off-by: Shivansh Arora <[email protected]>
- Loading branch information
Showing
8 changed files
with
261 additions
and
224 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
server/src/main/java/org/opensearch/common/remote/AbstractRemoteEntitiesManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.common.remote; | ||
|
||
import org.opensearch.action.LatchedActionListener; | ||
import org.opensearch.common.CheckedRunnable; | ||
import org.opensearch.core.action.ActionListener; | ||
import org.opensearch.gateway.remote.ClusterMetadataManifest; | ||
import org.opensearch.gateway.remote.model.RemoteReadResult; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public abstract class AbstractRemoteEntitiesManager implements RemoteEntitiesManager { | ||
protected final Map<String, RemoteWritableEntityStore> remoteWritableEntityStores = new HashMap<>(); | ||
|
||
protected RemoteWritableEntityStore getStore(AbstractRemoteWritableBlobEntity entity) { | ||
RemoteWritableEntityStore remoteStore = remoteWritableEntityStores.get(entity.getType()); | ||
if (remoteStore == null) { | ||
throw new IllegalArgumentException("Unknown entity type [" + entity.getType() + "]"); | ||
} | ||
return remoteStore; | ||
} | ||
|
||
protected abstract ActionListener<Void> getWriteActionListener( | ||
String component, | ||
AbstractRemoteWritableBlobEntity remoteObject, | ||
LatchedActionListener<ClusterMetadataManifest.UploadedMetadata> latchedActionListener | ||
); | ||
|
||
protected abstract ActionListener<Object> getReadActionListener( | ||
String component, | ||
AbstractRemoteWritableBlobEntity remoteObject, | ||
LatchedActionListener<RemoteReadResult> latchedActionListener | ||
); | ||
|
||
@Override | ||
public CheckedRunnable<IOException> getAsyncWriteRunnable( | ||
String component, | ||
AbstractRemoteWritableBlobEntity entity, | ||
LatchedActionListener<ClusterMetadataManifest.UploadedMetadata> latchedActionListener | ||
) { | ||
return () -> getStore(entity).writeAsync(entity, getWriteActionListener(component, entity, latchedActionListener)); | ||
} | ||
|
||
@Override | ||
public CheckedRunnable<IOException> getAsyncReadRunnable( | ||
String component, | ||
AbstractRemoteWritableBlobEntity entity, | ||
LatchedActionListener<RemoteReadResult> latchedActionListener | ||
) { | ||
return () -> getStore(entity).readAsync(entity, getReadActionListener(component, entity, latchedActionListener)); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
server/src/main/java/org/opensearch/common/remote/RemoteEntitiesManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.common.remote; | ||
|
||
import org.opensearch.action.LatchedActionListener; | ||
import org.opensearch.common.CheckedRunnable; | ||
import org.opensearch.gateway.remote.ClusterMetadataManifest.UploadedMetadata; | ||
import org.opensearch.gateway.remote.model.RemoteReadResult; | ||
|
||
import java.io.IOException; | ||
|
||
public interface RemoteEntitiesManager { | ||
CheckedRunnable<IOException> getAsyncReadRunnable( | ||
String component, | ||
AbstractRemoteWritableBlobEntity entity, | ||
LatchedActionListener<RemoteReadResult> latchedActionListener | ||
); | ||
|
||
CheckedRunnable<IOException> getAsyncWriteRunnable( | ||
String component, | ||
AbstractRemoteWritableBlobEntity entity, | ||
LatchedActionListener<UploadedMetadata> latchedActionListener | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.