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.
[Remote state] Integrate remote cluster state in publish/commit flow (o…
…pensearch-project#9665) * Integrate remote cluster state in publish/commit flow Signed-off-by: Sooraj Sinha <[email protected]> Signed-off-by: Kaushal Kumar <[email protected]>
- Loading branch information
1 parent
5f588ac
commit 6c887fd
Showing
20 changed files
with
419 additions
and
72 deletions.
There are no files selected for viewing
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
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
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
52 changes: 52 additions & 0 deletions
52
server/src/main/java/org/opensearch/cluster/coordination/PersistedStateRegistry.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,52 @@ | ||
/* | ||
* 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.cluster.coordination; | ||
|
||
import org.opensearch.cluster.coordination.CoordinationState.PersistedState; | ||
import org.opensearch.common.util.io.IOUtils; | ||
|
||
import java.io.Closeable; | ||
import java.io.IOException; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* A class which encapsulates the PersistedStates | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class PersistedStateRegistry implements Closeable { | ||
|
||
public PersistedStateRegistry() {} | ||
|
||
/** | ||
* Distinct Types PersistedState which can be present on a node | ||
*/ | ||
public enum PersistedStateType { | ||
LOCAL, | ||
REMOTE; | ||
} | ||
|
||
private final Map<PersistedStateType, PersistedState> persistedStates = new ConcurrentHashMap<>(); | ||
|
||
public void addPersistedState(PersistedStateType persistedStateType, PersistedState persistedState) { | ||
PersistedState existingState = this.persistedStates.putIfAbsent(persistedStateType, persistedState); | ||
assert existingState == null : "should only be set once, but already have " + existingState; | ||
} | ||
|
||
public PersistedState getPersistedState(PersistedStateType persistedStateType) { | ||
return this.persistedStates.get(persistedStateType); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
IOUtils.close(persistedStates.values()); | ||
} | ||
|
||
} |
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.