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 connectorCI- 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 ClassesModifier and TypeClassDescriptionstatic classThe 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
FieldsModifier and TypeFieldDescriptionprivate longprivate intprivate com.influxdb.v3.client.InfluxDBClientprivate Stringprivate static final Objectprivate static final de.iip_ecosphere.platform.support.logging.Loggerprivate Stringstatic final Stringprivate de.iip_ecosphere.platform.connectors.ConnectorParameterprivate de.iip_ecosphere.platform.connectors.types.RecordCompletePredicateFields inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector
DEFAULT_CHANNEL -
Constructor Summary
ConstructorsConstructorDescriptionInfluxConnector(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 TypeMethodDescriptionprotected voidconnectImpl(de.iip_ecosphere.platform.connectors.ConnectorParameter params) protected voidprotected voidprivate voidflush(InfluxModelAccess acc, Map<String, Object> values) Flushes aggregated/collected values per record.(package private) floatfromTimestamp(long value) Turns a timestamp into a float consideringbaseTimeif specified.(package private) intReturns the configured batch size.(package private) com.influxdb.v3.client.InfluxDBClientReturns the INFLUX client instance.(package private) StringReturns the database.(package private) StringReturns the data type/measurement name.getName()(package private) de.iip_ecosphere.platform.connectors.ConnectorParameterReturns the connector parameters.getTags()Returns the tag names.protected voidprotected Objectread()private StringrelativeTimePart(int time, String unit) Returns the relative time expression in a time range part.private com.influxdb.v3.client.query.QueryOptionstoQueryOptions(String type) Turns the query type to query options.private StringtoTimePart(int time, de.iip_ecosphere.platform.connectors.events.SimpleTimeseriesQuery.TimeKind kind) Turns a query time specification into a range query part.(package private) longtoTimestamp(float value) Turns a float time into a timestamp consideringbaseTimeif specified.voidtrigger(de.iip_ecosphere.platform.connectors.events.ConnectorTriggerQuery query) protected voidMethods inherited from class de.iip_ecosphere.platform.connectors.AbstractThreadedConnector
configureAdapter, connect, getCleanupPeriod, getModelAccess, getModelAccess, getModelAccessSupplier, setCleanupPeriod, setModelAccessSupplier, uninstallPollTaskMethods 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, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.iip_ecosphere.platform.connectors.Connector
createSharedSpace, disconnectSafe, enableSharedSpace, enumerateFields, enumerateFields, setReceptionCallbackSafe
-
Field Details
-
NAME
- See Also:
-
LOGGER
private static final de.iip_ecosphere.platform.support.logging.Logger LOGGER -
DUMMY
-
client
private com.influxdb.v3.client.InfluxDBClient client -
params
private de.iip_ecosphere.platform.connectors.ConnectorParameter params -
database
-
measurement
-
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
-
connectImpl
protected void connectImpl(de.iip_ecosphere.platform.connectors.ConnectorParameter params) throws IOException - Specified by:
connectImplin classde.iip_ecosphere.platform.connectors.AbstractConnector<Object,Object, CO, CI> - Throws:
IOException
-
disconnectImpl
- Specified by:
disconnectImplin classde.iip_ecosphere.platform.connectors.AbstractConnector<Object,Object, CO, CI> - Throws:
IOException
-
installPollTask
protected void installPollTask() -
error
-
read
- Specified by:
readin classde.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 valuekind- the kind- Returns:
- the range part
-
relativeTimePart
Returns the relative time expression in a time range part.- Parameters:
time- the time valueunit- the unit- Returns:
- the expression
-
toQueryOptions
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) -
flush
Flushes aggregated/collected values per record.- Parameters:
acc- the model access instancevalues- the values
-
writeImpl
- Specified by:
writeImplin classde.iip_ecosphere.platform.connectors.AbstractConnector<Object,Object, CO, CI> - Throws:
IOException
-
supportedEncryption
-
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
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 consideringbaseTimeif 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 consideringbaseTimeif specified. May not return initial decimal places.- Parameters:
value- the timestamp- Returns:
- the float value
-