Class InfluxConnector<CO,CI>

java.lang.Object
de.iip_ecosphere.platform.connectors.AbstractConnector<Object,Object,CO,CI>
de.iip_ecosphere.platform.connectors.AbstractThreadedConnector<Object,Object,CO,CI,InfluxModelAccess>
de.iip_ecosphere.platform.connectors.influxv3.InfluxConnector<CO,CI>
Type Parameters:
CO - the output type of the connector
CI - the input type of the connector
All Implemented Interfaces:
de.iip_ecosphere.platform.connectors.Connector<Object,Object,CO,CI>, de.iip_ecosphere.platform.connectors.events.EventHandlingConnector, de.iip_ecosphere.platform.connectors.model.AbstractModelAccess.NotificationChangedListener

@MachineConnector(hasModel=false, supportsModelStructs=false, supportsEvents=false, specificSettings={"DATABASE","MEASUREMENT","TAGS","BATCH","BASETIME"}) @MachineConnectorSupportedQueries({de.iip_ecosphere.platform.connectors.events.StringTriggerQuery.class,de.iip_ecosphere.platform.connectors.events.SimpleTimeseriesQuery.class}) public class InfluxConnector<CO,CI> extends de.iip_ecosphere.platform.connectors.AbstractThreadedConnector<Object,Object,CO,CI,InfluxModelAccess>
Implements the generic INFLUX connector.
Author:
Holger Eichelberger
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    The descriptor of this connector (see META-INF/services).

    Nested classes/interfaces inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector

    de.iip_ecosphere.platform.connectors.AbstractConnector.BasicAdapterProvider
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private long
     
    private int
     
    private com.influxdb.v3.client.InfluxDBClient
     
    private String
     
    private static final Object
     
    private static final de.iip_ecosphere.platform.support.logging.Logger
     
    private String
     
    static final String
     
    private de.iip_ecosphere.platform.connectors.ConnectorParameter
     
    private de.iip_ecosphere.platform.connectors.types.RecordCompletePredicate
     
    private Set<String>
     

    Fields inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector

    DEFAULT_CHANNEL
  • Constructor Summary

    Constructors
    Constructor
    Description
    InfluxConnector(de.iip_ecosphere.platform.connectors.AdapterSelector<Object,Object,CO,CI> selector, de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<Object,Object,CO,CI>... adapter)
    Creates an instance and installs the protocol adapter.
    InfluxConnector(de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<Object,Object,CO,CI>... adapter)
    Creates an instance and installs the protocol adapter.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    connectImpl(de.iip_ecosphere.platform.connectors.ConnectorParameter params)
     
    protected void
     
     
    protected void
    error(String message, Throwable th)
     
    private void
    Flushes aggregated/collected values per record.
    (package private) float
    fromTimestamp(long value)
    Turns a timestamp into a float considering baseTime if specified.
    (package private) int
    Returns the configured batch size.
    (package private) com.influxdb.v3.client.InfluxDBClient
    Returns the INFLUX client instance.
    (package private) String
    Returns the database.
    (package private) String
    Returns the data type/measurement name.
     
    (package private) de.iip_ecosphere.platform.connectors.ConnectorParameter
    Returns the connector parameters.
    (package private) Set<String>
    Returns the tag names.
    protected void
     
    protected Object
     
    private String
    relativeTimePart(int time, String unit)
    Returns the relative time expression in a time range part.
     
    private com.influxdb.v3.client.query.QueryOptions
    Turns the query type to query options.
    private String
    toTimePart(int time, de.iip_ecosphere.platform.connectors.events.SimpleTimeseriesQuery.TimeKind kind)
    Turns a query time specification into a range query part.
    (package private) long
    toTimestamp(float value)
    Turns a float time into a timestamp considering baseTime if specified.
    void
    trigger(de.iip_ecosphere.platform.connectors.events.ConnectorTriggerQuery query)
     
    protected void
     

    Methods inherited from class de.iip_ecosphere.platform.connectors.AbstractThreadedConnector

    configureAdapter, connect, getCleanupPeriod, getModelAccess, getModelAccess, getModelAccessSupplier, setCleanupPeriod, setModelAccessSupplier, uninstallPollTask

    Methods inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector

    checkCache, configureModelAccess, createTlsContext, disconnect, dispose, doPolling, enableNotifications, enablePolling, getCachingStrategy, getCachingStrategyCls, getConnectorInputType, getConnectorOutputType, getConnectorParameter, getInitCachingStrategyCls, getInstanceIdentification, getProtocolInputType, getProtocolOutputType, getSelector, getStorageValue, initializeModelAccess, initSelector, isPolling, notificationsChanged, notifyDataTimeDifference, notifyReconfigured, received, received, request, request, setDataTimeDifference, setDataTimeDifferenceProvider, setInstanceIdentification, setReceptionCallback, setStorageValue, trigger, useTls, write

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface de.iip_ecosphere.platform.connectors.Connector

    createSharedSpace, disconnectSafe, enableSharedSpace, enumerateFields, enumerateFields, setReceptionCallbackSafe
  • Field Details

    • NAME

      public static final String NAME
      See Also:
    • LOGGER

      private static final de.iip_ecosphere.platform.support.logging.Logger LOGGER
    • DUMMY

      private static final Object DUMMY
    • client

      private com.influxdb.v3.client.InfluxDBClient client
    • params

      private de.iip_ecosphere.platform.connectors.ConnectorParameter params
    • database

      private String database
    • measurement

      private String measurement
    • tags

      private Set<String> tags
    • batchSize

      private int batchSize
    • recordComplete

      private de.iip_ecosphere.platform.connectors.types.RecordCompletePredicate recordComplete
    • baseTime

      private long baseTime
  • Constructor Details

    • InfluxConnector

      @SafeVarargs public InfluxConnector(de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<Object,Object,CO,CI>... adapter)
      Creates an instance and installs the protocol adapter.
      Parameters:
      adapter - the protocol adapter
    • InfluxConnector

      @SafeVarargs public InfluxConnector(de.iip_ecosphere.platform.connectors.AdapterSelector<Object,Object,CO,CI> selector, de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<Object,Object,CO,CI>... adapter)
      Creates an instance and installs the protocol adapter.
      Parameters:
      selector - the adapter selector (null leads to a default selector for the first adapter)
      adapter - the protocol adapter(s)
  • Method Details

    • getName

      public String getName()
    • connectImpl

      protected void connectImpl(de.iip_ecosphere.platform.connectors.ConnectorParameter params) throws IOException
      Specified by:
      connectImpl in class de.iip_ecosphere.platform.connectors.AbstractConnector<Object,Object,CO,CI>
      Throws:
      IOException
    • disconnectImpl

      protected void disconnectImpl() throws IOException
      Specified by:
      disconnectImpl in class de.iip_ecosphere.platform.connectors.AbstractConnector<Object,Object,CO,CI>
      Throws:
      IOException
    • installPollTask

      protected void installPollTask()
      Overrides:
      installPollTask in class de.iip_ecosphere.platform.connectors.AbstractConnector<Object,Object,CO,CI>
    • error

      protected void error(String message, Throwable th)
      Specified by:
      error in class de.iip_ecosphere.platform.connectors.AbstractConnector<Object,Object,CO,CI>
    • read

      protected Object read() throws IOException
      Specified by:
      read in class de.iip_ecosphere.platform.connectors.AbstractConnector<Object,Object,CO,CI>
      Throws:
      IOException
    • toTimePart

      private String toTimePart(int time, de.iip_ecosphere.platform.connectors.events.SimpleTimeseriesQuery.TimeKind kind)
      Turns a query time specification into a range query part.
      Parameters:
      time - the time value
      kind - the kind
      Returns:
      the range part
    • relativeTimePart

      private String relativeTimePart(int time, String unit)
      Returns the relative time expression in a time range part.
      Parameters:
      time - the time value
      unit - the unit
      Returns:
      the expression
    • toQueryOptions

      private com.influxdb.v3.client.query.QueryOptions toQueryOptions(String type)
      Turns the query type to query options.
      Parameters:
      type - the query type, may be null or empty for none
      Returns:
      the query options
    • trigger

      public void trigger(de.iip_ecosphere.platform.connectors.events.ConnectorTriggerQuery query)
      Specified by:
      trigger in interface de.iip_ecosphere.platform.connectors.events.EventHandlingConnector
      Overrides:
      trigger in class de.iip_ecosphere.platform.connectors.AbstractConnector<Object,Object,CO,CI>
    • flush

      private void flush(InfluxModelAccess acc, Map<String,Object> values)
      Flushes aggregated/collected values per record.
      Parameters:
      acc - the model access instance
      values - the values
    • writeImpl

      protected void writeImpl(Object data) throws IOException
      Specified by:
      writeImpl in class de.iip_ecosphere.platform.connectors.AbstractConnector<Object,Object,CO,CI>
      Throws:
      IOException
    • supportedEncryption

      public String supportedEncryption()
    • enabledEncryption

      public String enabledEncryption()
    • getClient

      com.influxdb.v3.client.InfluxDBClient getClient()
      Returns the INFLUX client instance.
      Returns:
      the client instance
    • getParameter

      de.iip_ecosphere.platform.connectors.ConnectorParameter getParameter()
      Returns the connector parameters.
      Returns:
      the connector parameters
    • getDatabase

      String getDatabase()
      Returns the database.
      Returns:
      the database
    • getMeasurement

      String getMeasurement()
      Returns the data type/measurement name.
      Returns:
      the data type/measurement name
    • getTags

      Set<String> getTags()
      Returns the tag names.
      Returns:
      the tag names
    • getBatchSize

      int getBatchSize()
      Returns the configured batch size.
      Returns:
      the batch size, batching is enabled if the value is greater than 1
    • toTimestamp

      long toTimestamp(float value)
      Turns a float time into a timestamp considering baseTime if specified. May loose decimal places.
      Parameters:
      float - the received float value
      Returns:
      the time stamp
    • fromTimestamp

      float fromTimestamp(long value)
      Turns a timestamp into a float considering baseTime if specified. May not return initial decimal places.
      Parameters:
      value - the timestamp
      Returns:
      the float value