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.
- Loading branch information
Showing
6 changed files
with
66 additions
and
31 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
37 changes: 37 additions & 0 deletions
37
server/src/main/java/org/opensearch/cluster/coordination/PersistentStateRegistry.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,37 @@ | ||
/* | ||
* 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 java.util.HashMap; | ||
import java.util.Map; | ||
import org.opensearch.cluster.coordination.CoordinationState.PersistedState; | ||
|
||
public class PersistentStateRegistry { | ||
|
||
private static final PersistentStateRegistry INSTANCE = new PersistentStateRegistry(); | ||
|
||
private PersistentStateRegistry() { | ||
} | ||
|
||
public enum PersistedStateType { | ||
LOCAL, REMOTE | ||
} | ||
|
||
private final Map<PersistedStateType, PersistedState> persistentStates = new HashMap<>(); | ||
|
||
public static void addPersistedState(PersistedStateType persistedStateType, PersistedState persistedState) { | ||
PersistedState existingState = INSTANCE.persistentStates.putIfAbsent(persistedStateType, persistedState); | ||
assert existingState == null : "should only be set once, but already have " + existingState; | ||
} | ||
|
||
public static PersistedState getPersistedState(PersistedStateType persistedStateType) { | ||
return INSTANCE.persistentStates.get(persistedStateType); | ||
} | ||
|
||
} |
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