Class DataRoutingStateAdapter
java.lang.Object
com.illumon.iris.db.v2.routing.impl.kv.DataRoutingStateAdapter
- All Implemented Interfaces:
WatchClient.UnitListener
Adapts a
WatchClient.UnitListener into a WatchClient.StateListener. Track all kv state and updates
for the routing-file prefix, and provide synchronized access to current data and routing service.-
Method Summary
Modifier and TypeMethodDescriptioncreateWatch(@NotNull KVClient kvClient, @NotNull WatchClient watchClient, @NotNull GetPrefix request) Returns a future that will create, but not start, the watch.@NotNull DataRoutingServiceGet the data routing service.@Nullable StringGet the data routing data as a yaml String.longGet the current wrt revision of the additional DISes container.longGet the current wrt revision of the named additional DIS file.@NotNull Map<String,DataImportServiceConfig> Get the configured additional DISes as a map.Get the configured additional DIS names as a set.Get the configured additional DISes as a map of name to raw yml string.longGet the current wrt revision of the routing file.voidInvoked on completion.voidInvoked on errors.voidonNext(@NotNull WatchResponseUnit unit) Invoked on new events.voidpublishInitial(@NotNull HeaderResponse initialHeader, @NotNull KeyValuesCollection initialState) Initialize the state.
-
Method Details
-
getDataRoutingYmlString
Get the data routing data as a yaml String. This is the routing file only and does not include additional DISes.- Returns:
- the data routing configuration, or null if not present
-
getDataRoutingService
Get the data routing service. This is the etcd implementation, parsed from the routing file and additional DISes. The service might be invalid/non-functional if the routing file is missing, or there are errors parsing the configuration.- Returns:
- the data routing service
-
getRoutingFileRev
public long getRoutingFileRev()Get the current wrt revision of the routing file.- Returns:
- the current wrt of the routing file, or 0 if it does not exist.
-
getDisesRev
public long getDisesRev()Get the current wrt revision of the additional DISes container.- Returns:
- the current wrt of the DISes prefix, or 0 if it does not exist.
-
getDisRev
Get the current wrt revision of the named additional DIS file.- Parameters:
disName- the name of the DIS- Returns:
- the current wrt of the named DIS, or 0 if it does not exist.
-
getExtraDisMap
Get the configured additional DISes as a map.- Returns:
- map of additional DISes
-
getExtraDisNames
Get the configured additional DIS names as a set.- Returns:
- set of additional DIS names
-
getExtraDisText
Get the configured additional DISes as a map of name to raw yml string. For error handling.- Returns:
- map of additional DIS names to raw yml strings
-
publishInitial
public void publishInitial(@NotNull @NotNull HeaderResponse initialHeader, @NotNull @NotNull KeyValuesCollection initialState) Initialize the state.- Parameters:
initialHeader- the initial headerinitialState- the initial state - all keys and values starting at the GetPrefix root
-
onNext
Description copied from interface:WatchClient.UnitListenerInvoked on new events.Can be called many times but is never called after
WatchClient.UnitListener.onError(Throwable)orWatchClient.UnitListener.onCompleted()are called.- Specified by:
onNextin interfaceWatchClient.UnitListener- Parameters:
unit- the watch response unit
-
onError
Description copied from interface:WatchClient.UnitListenerInvoked on errors.May only be called once and if called it must be the last method called.
- Specified by:
onErrorin interfaceWatchClient.UnitListener- Parameters:
t- the error
-
onCompleted
public void onCompleted()Description copied from interface:WatchClient.UnitListenerInvoked on completion.May only be called once and if called it must be the last method called.
- Specified by:
onCompletedin interfaceWatchClient.UnitListener
-
createWatch
public CompletableFuture<WatchClient.Watch> createWatch(@NotNull @NotNull KVClient kvClient, @NotNull @NotNull WatchClient watchClient, @NotNull @NotNull GetPrefix request) Returns a future that will create, but not start, the watch.- Parameters:
kvClient- the kv clientwatchClient- the watch clientrequest- the get prefix request- Returns:
- a future for the watch
-