Class DataRoutingServiceKvImpl

java.lang.Object
com.illumon.iris.db.v2.routing.DataRoutingService.Delegating
com.illumon.iris.db.v2.routing.impl.kv.DataRoutingServiceKvImpl
All Implemented Interfaces:
DataRoutingService, StorageLookup, EndpointResolver, ClaimsProvider, WritableDataRoutingService, WritableDataRoutingServiceInternal, SafeCloseable, NamedImplementation, AutoCloseable
Direct Known Subclasses:
DataRoutingServiceKvEtcdImpl, DataRoutingServiceKvInMemImpl

public abstract class DataRoutingServiceKvImpl extends DataRoutingService.Delegating implements WritableDataRoutingServiceInternal
Initializes the DataRoutingService from a kv store. Delegates all operations to a "file based" DataRoutingService constructed from etcd data. Implements the WritableDataRoutingService interface, storing changes to etcd.
  • Method Details

    • getAllDataImportServiceConfigs

      @NotNull public Map<String,DataImportServiceConfig> getAllDataImportServiceConfigs(boolean excludeCoreConfigs)
      Description copied from interface: DataRoutingService
      Get all DIS configs, optionally excluding core configs (those defined in the main routing yml file) For consumption by administrative tools.
      Specified by:
      getAllDataImportServiceConfigs in interface DataRoutingService
      Overrides:
      getAllDataImportServiceConfigs in class DataRoutingService.Delegating
      Parameters:
      excludeCoreConfigs - if true, exclude core configs
      Returns:
      a possibly empty collection of all/non-core DIS configs
    • getAllDataImportServiceConfigsRaw

      @NotNull public Map<String,String> getAllDataImportServiceConfigsRaw()
    • asYamlStringRaw

      @Nullable public String asYamlStringRaw()
      Return the raw routing file data as a string. May contain errors, and may be null if etcd is empty.
      Returns:
      the raw routing file data as a string, or null.
    • update

      public void update(@NotNull String ymlString, @NotNull String code, @NotNull String comment)
      Description copied from interface: WritableDataRoutingService
      Replace the existing data routing configuration.
      Specified by:
      update in interface WritableDataRoutingService
      Parameters:
      ymlString - YAML representation of the new data routing configuration
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
    • update

      public void update(@NotNull byte[] yamldata, @NotNull String user, @NotNull String code, @NotNull String comment)
      Description copied from interface: WritableDataRoutingServiceInternal
      Replace the existing data routing configuration.
      Specified by:
      update in interface WritableDataRoutingServiceInternal
      Parameters:
      yamldata - YAML representation of the new data routing configuration
      user - pass-thru to kv persistence, indicates the user making this change
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
    • addDises

      public void addDises(@NotNull Collection<DataImportServiceConfig> disConfigs, @NotNull String code, @NotNull String comment)
      Description copied from interface: WritableDataRoutingService
      Add one or more DataImportServiceConfigs to the data routing configuration. The disConfigs will be checked as they are added, ensuring that the configuration as a whole is valid.
      Specified by:
      addDises in interface WritableDataRoutingService
      Parameters:
      disConfigs - the DataImportServiceConfigs to add
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
    • addDises

      public void addDises(@NotNull Collection<DataImportServiceConfig> disConfigs, @NotNull String user, @NotNull String code, @NotNull String comment)
      Description copied from interface: WritableDataRoutingServiceInternal
      Add one or more DataImportServiceConfigs to the data routing configuration. The disConfigs will be checked as they are added, ensuring that the configuration as a whole is valid.
      Specified by:
      addDises in interface WritableDataRoutingServiceInternal
      Parameters:
      disConfigs - the DataImportServiceConfigs to add
      user - pass-thru to kv persistence, indicates the user making this change
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
    • updateDises

      public void updateDises(@NotNull Collection<DataImportServiceConfig> disConfigs, @NotNull String code, @NotNull String comment)
      Description copied from interface: WritableDataRoutingService
      Update one or more DataImportServiceConfigs in the data routing configuration. Configurations that do not exist will be added. The disConfigs will be checked as they are updated, ensuring that the configuration as a whole is valid.
      Specified by:
      updateDises in interface WritableDataRoutingService
      Parameters:
      disConfigs - the DataImportServiceConfigs to update
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
    • updateDises

      public void updateDises(@NotNull Collection<DataImportServiceConfig> disConfigs, @NotNull String user, @NotNull String code, @NotNull String comment)
      Description copied from interface: WritableDataRoutingServiceInternal
      Update one or more DataImportServiceConfigs in the data routing configuration. The disConfigs will be checked as they are updated, ensuring that the configuration as a whole is valid.
      Specified by:
      updateDises in interface WritableDataRoutingServiceInternal
      Parameters:
      disConfigs - the DataImportServiceConfigs to update
      user - pass-thru to kv persistence, indicates the user making this change
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
    • removeDises

      public void removeDises(@NotNull Collection<String> disNames, @NotNull String code, @NotNull String comment, WritableDataRoutingService.Options... options)
      Description copied from interface: WritableDataRoutingService
      Remove one or more DataImportServiceConfigs from the data routing configuration. The named dises must exist, as separately added configurations (not inline in the main file). The routing configuration will be checked as they are removed, ensuring that the configuration as a whole is valid.
      Specified by:
      removeDises in interface WritableDataRoutingService
      Parameters:
      disNames - the names of the DataImportServiceConfigs to remove
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
      options - if WritableDataRoutingService.Options.LENIENT is given, it is not considered an error if any of the named dises do not exist. if WritableDataRoutingService.Options.IGNORE_ERRORS is given, any parsing errors encountered while removing the dises will be ignored.
    • removeDises

      public void removeDises(@NotNull Collection<String> disNames, @NotNull String user, @NotNull String code, @NotNull String comment, WritableDataRoutingService.Options... options)
      Description copied from interface: WritableDataRoutingServiceInternal
      Remove one or more DataImportServiceConfigs from the data routing configuration. The named dises must exist as a separately added configuration (not inline in the main file). The routing configuration will be checked as they are removed, ensuring that the configuration as a whole is valid.
      Specified by:
      removeDises in interface WritableDataRoutingServiceInternal
      Parameters:
      disNames - the names of the DataImportServiceConfigs to remove
      user - pass-thru to kv persistence, indicates the user making this change
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
      options - if WritableDataRoutingService.Options.LENIENT is given, it is not considered an error if any of the named dises do not exist. if WritableDataRoutingService.Options.IGNORE_ERRORS is given, any parsing errors encountered while removing the dises will be ignored. * @throws DataRoutingConfigurationException if the updated routing configuration is invalid in any way
    • replaceConfiguration

      public void replaceConfiguration(@Nullable String routingYmlString, @NotNull Collection<DataImportServiceConfig> disConfigs, @NotNull String code, @NotNull String comment, WritableDataRoutingService.Options... options)
      Description copied from interface: WritableDataRoutingService
      Replace the existing base and set of configurations with the given configurations. Any existing DIS configurations not in disConfigs will be removed.
      Specified by:
      replaceConfiguration in interface WritableDataRoutingService
      Parameters:
      routingYmlString - (optional) YAML representation of the new data routing configuration. If not specified, the existing base configuration will be used.
      disConfigs - the DataImportServiceConfigs to add
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
      options - use IGNORE_ERRORS with extreme caution. If set, any errors encountered while adding the dises will be ignored, and it is therefore possible to persist an invalid configuration.
    • replaceConfiguration

      public void replaceConfiguration(@Nullable String routingYmlString, @NotNull Collection<DataImportServiceConfig> disConfigs, @NotNull String user, @NotNull String code, @NotNull String comment, WritableDataRoutingService.Options... options)
      Description copied from interface: WritableDataRoutingServiceInternal
      Replace the existing set of configurations with the given collection. Any existing configurations not in disConfigs will be removed.
      Specified by:
      replaceConfiguration in interface WritableDataRoutingServiceInternal
      Parameters:
      routingYmlString - (optional) YAML representation of the new data routing configuration. If not specified, the existing base configuration will be used.
      disConfigs - the DataImportServiceConfigs to add
      user - pass-thru to kv persistence, indicates the user making this change
      code - pass-thru to kv persistence, indicates the code source of this update
      comment - pass-thru to kv persistence - a comment for this update
      options - use IGNORE_ERRORS with extreme caution. If set, any errors encountered while adding the dises will be ignored, and it is therefore possible to persist an invalid configuration.
    • getImplementationName

      public abstract String getImplementationName()
      Description copied from interface: NamedImplementation

      Get a name for the implementing class. Useful for abstract classes that implement LogOutputAppendable or override toString.

      The default implementation is correct, but not suitable for high-frequency usage.

      Specified by:
      getImplementationName in interface NamedImplementation
      Returns:
      A name for the implementing class
    • about

      public String about()
      Description copied from interface: DataRoutingService
      Information about a DataRoutingService instance. Useful for debugging.
      Specified by:
      about in interface DataRoutingService
      Specified by:
      about in class DataRoutingService.Delegating
      Returns:
      a string containing information about the instance
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface SafeCloseable
      Overrides:
      close in class DataRoutingService.Delegating
    • asYamlString

      @NotNull public String asYamlString()
      Description copied from interface: DataRoutingService
      Serialize the data routing as a YAML string. Internal use only.
      Specified by:
      asYamlString in interface DataRoutingService
      Overrides:
      asYamlString in class DataRoutingService.Delegating
      Returns:
      YAML representation of the configuration
    • getDelegate

      @NotNull protected DataRoutingService getDelegate()
      Specified by:
      getDelegate in class DataRoutingService.Delegating
    • supportsChangeNotification

      public boolean supportsChangeNotification()
      Description copied from interface: DataRoutingService
      Probe the implementation to find out if change notification is supported.
      Specified by:
      supportsChangeNotification in interface DataRoutingService
      Overrides:
      supportsChangeNotification in class DataRoutingService.Delegating
      Returns:
      true if change notifications are supported.
    • listen

      public long listen(@NotNull DataRoutingConfigListener listener)
      Description copied from interface: DataRoutingService
      Add a listener for changes to the DataRoutingService configuration.
      Specified by:
      listen in interface DataRoutingService
      Overrides:
      listen in class DataRoutingService.Delegating
      Parameters:
      listener - configuration change notices will be published to this listener
      Returns:
      the current configuration version
    • removeListener

      public boolean removeListener(@NotNull DataRoutingConfigListener listener)
      Description copied from interface: DataRoutingService
      Remove the given listener from the list of listeners.
      Specified by:
      removeListener in interface DataRoutingService
      Overrides:
      removeListener in class DataRoutingService.Delegating
      Parameters:
      listener - the listener to remove
      Returns:
      true if a listener was removed, false if it could not be found or could not be removed