Class DataRoutingServiceYmlImpl

java.lang.Object
com.illumon.iris.db.v2.routing.impl.yaml.DataRoutingServiceYmlImpl
All Implemented Interfaces:
DataRoutingService, DataRoutingService.NonListening, StorageLookup, EndpointResolver, ClaimsProvider, SafeCloseable, NamedImplementation, AutoCloseable
Direct Known Subclasses:
DataRoutingServiceYmlImpl.ResolvingImpl

public abstract class DataRoutingServiceYmlImpl extends Object implements DataRoutingService.NonListening
Reads data routing instructions from a YAML file. This class parses and manages configuration, but does not know how to resolve client or server endpoints.
  • Constructor Details

    • DataRoutingServiceYmlImpl

      protected DataRoutingServiceYmlImpl(@NotNull String sourceIdentifier)
      Protected constructor. Subclasses must ensure parse() is called to complete construction.
      Parameters:
      sourceIdentifier - identifier for this instance
    • DataRoutingServiceYmlImpl

      protected DataRoutingServiceYmlImpl(@NotNull String sourceIdentifier, @NotNull String originalInput, @NotNull Collection<DataImportServiceConfig> disConfigs)
      This is useful for testing. It's only called from a factory method.
      Parameters:
      sourceIdentifier - identifier for this instance
      originalInput - the input data to parse, and will be returned from asYamlString
      disConfigs - the DataImportServiceConfig instances to add in
  • Method Details

    • registerClaims

      public void registerClaims(@NotNull DataImportServiceConfig disConfig)
      Notify this DataRoutingService that a claim has been made by a DIS. This information will be made globally available in a parsing step, either now or later.
      Specified by:
      registerClaims in interface ClaimsProvider
      Parameters:
      disConfig - the configuration of the DIS making the claims
    • createFilter

      @NotNull public static Filter createFilter(@NotNull CollectedClaims collectedClaims, @Nullable Object ymlFilterSpecObj, @NotNull String context)
      Factory method for creating a Filter from yml input.
      Parameters:
      collectedClaims - the collected claims of the full routing service, for claimed/unclaimed filters
      ymlFilterSpecObj - the raw yml chunk.
      context - string for context in the possible exception
      Returns:
      a valid Filter based on the yml spec.
    • createIfNotClaimedFilter

      @NotNull public static Filter createIfNotClaimedFilter(@NotNull CollectedClaims collectedClaims, @Nullable Object ymlFilterSpecObj, @NotNull String context)
      Factory method for creating a IfNotClaimedFilter from yml input. Only the DIS filter supports Claims.
      Parameters:
      collectedClaims - the collected claims of the full routing service, for claimed/unclaimed filters
      ymlFilterSpecObj - the raw yml chunk.
      context - string for context in the possible exception
      Returns:
      a valid Filter based on the yml spec.
    • parseClaims

      public static ClaimSet parseClaims(@Nullable Object ymlFilterSpecObj, @NotNull String context)
      Parse the claims section.
      Parameters:
      ymlFilterSpecObj - the raw yml chunk.
      context - string for context in the possible exception
      Returns:
      parsed summary of claims made
    • getCollectedClaims

      @NotNull public CollectedClaims getCollectedClaims()
      Description copied from interface: ClaimsProvider
      Get the current claims for this owner (DataRoutingService).
      Specified by:
      getCollectedClaims in interface ClaimsProvider
      Returns:
      the current CollectedClaims
    • about

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

      @Nullable public DataImportServiceConfig getDataImportServiceConfig(@NotNull String name)
      Description copied from interface: DataRoutingService
      Get DIS parameters for this named DIS instance. For consumption by a DIS instance or TableDataService consumer.
      Specified by:
      getDataImportServiceConfig in interface DataRoutingService
      Parameters:
      name - DIS configuration name
      Returns:
      the configuration for the named DIS, or null if it does not exist.
    • getDataImportServiceDestinationConfigs

      @NotNull public Collection<? extends DataImportServiceConfig.EndpointConfig> getDataImportServiceDestinationConfigs(@NotNull TableIdentifier tableIdentifier)
      Description copied from interface: DataRoutingService
      Get DIS destination configs for a table key. For consumption by a Tailer.
      Specified by:
      getDataImportServiceDestinationConfigs in interface DataRoutingService
      Parameters:
      tableIdentifier - the identifier of the data to be logged
      Returns:
      a possibly empty collection of DIS destinations that should receive data for the given table.
    • 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
      Parameters:
      excludeCoreConfigs - if true, exclude core configs
      Returns:
      a possibly empty collection of all/non-core DIS configs
    • getAllDataImportServiceDestinationConfigs

      @NotNull public Collection<? extends DataImportServiceConfig.EndpointConfig> getAllDataImportServiceDestinationConfigs()
      Description copied from interface: DataRoutingService
      Get all known DataImportServer destination configs. This includes destination configs with disabled tailer ports. For consumption by a Tailer.
      Specified by:
      getAllDataImportServiceDestinationConfigs in interface DataRoutingService
      Returns:
      a possibly null collection of all known DIS destinations.
    • getLogAggregatorConfig

      public LogAggregatorConfig getLogAggregatorConfig(@NotNull String name)
      Description copied from interface: DataRoutingService
      Get configuration for the named log aggregator service instance.
      Specified by:
      getLogAggregatorConfig in interface DataRoutingService
      Parameters:
      name - the LAS configuration name
      Returns:
      the configuration for the named log aggregator, no null if it does not exist
    • getLogAggregatorDestinationConfig

      @Nullable public LogAggregatorConfig.EndpointConfig getLogAggregatorDestinationConfig(@NotNull TableIdentifier tableIdentifier)
      Description copied from interface: DataRoutingService
      Get the single LAS destination configuration for the given table key.
      Specified by:
      getLogAggregatorDestinationConfig in interface DataRoutingService
      Parameters:
      tableIdentifier - the identifier of the data to be logged
      Returns:
      the LogAggregatorEndpoint for the given tableIdentifier, or null if none match the key.
    • getAllLogAggregatorServiceConfigs

      @NotNull public Collection<? extends LogAggregatorConfig> getAllLogAggregatorServiceConfigs()
      Description copied from interface: DataRoutingService
      Return all log aggregator configurations.
      Specified by:
      getAllLogAggregatorServiceConfigs in interface DataRoutingService
      Returns:
      a collection of all configured log aggregators.
    • getTableDataServiceConfig

      @Nullable public TableDataServiceConfig getTableDataServiceConfig(@NotNull String name)
      Description copied from interface: DataRoutingService
      Information needed to configure a table data service server. For use by a TableDataService provider (LocalTableDataServer, TableDataCacheProxy).
      Specified by:
      getTableDataServiceConfig in interface DataRoutingService
      Parameters:
      name - configuration name
      Returns:
      the named TableDataServiceConfig, or null if not found.
    • getTableDataServiceConfigs

      @NotNull public Collection<? extends TableDataServiceConfig> getTableDataServiceConfigs()
      Description copied from interface: DataRoutingService
      Get all known table data service configurations. The data includes name description and tags.
      Specified by:
      getTableDataServiceConfigs in interface DataRoutingService
      Returns:
      all known TableDataServiceConfigs
    • asYamlString

      @NotNull public String asYamlString()
      This gets the input YAML, saved so it can be sent via grpc.
      Specified by:
      asYamlString in interface DataRoutingService
      Returns:
      YAML representation of the configuration
    • getStorage

      @Nullable public StorageConfig getStorage(@Nullable String name)
      Description copied from interface: StorageLookup
      Get the StorageConfig associated with the given name.
      Specified by:
      getStorage in interface StorageLookup
      Parameters:
      name - The name of the storage to look up. May be null, in which case null will always be returned.
      Returns:
      The storage config, or null if not found
    • getImplementationName

      public 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
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface SafeCloseable
    • parseFile

      public void parseFile(@NotNull String filename) throws IOException
      Open and read a file and delegate to the string parser.
      Parameters:
      filename - the filename to read. Resources on the classpath will be searched.
      Throws:
      IOException - if the file can't be found or processed.
    • parseFile

      public void parseFile(@NotNull String filename, @NotNull Collection<DataImportServiceConfig> disConfigs) throws IOException
      Open and read a file and delegate to the string parser.
      Parameters:
      filename - the filename to read. Resources on the classpath will be searched.
      disConfigs - the DataImportServiceConfig instances to add in
      Throws:
      IOException - if the file can't be found or processed.
    • parseString

      public void parseString(@NotNull String ymlString, Collection<DataImportServiceConfig> disConfigs)
      Parse the yaml data in the given string.
      Parameters:
      ymlString - the string to parse
      disConfigs - the DataImportServiceConfig instances to add in
    • toString

      public String toString()
      Overrides:
      toString in class Object