Package io.openems.shared.influxdb
Class InfluxConnector
- java.lang.Object
-
- io.openems.shared.influxdb.InfluxConnector
-
public class InfluxConnector extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InfluxConnector.InfluxConnection
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.ThreadPoolExecutor
executor
static java.lang.String
MEASUREMENT
protected java.util.concurrent.BlockingQueue<com.influxdb.client.write.Point>
pointsQueue
-
Constructor Summary
Constructors Constructor Description InfluxConnector(QueryLanguageConfig queryLanguage, java.net.URI url, java.lang.String org, java.lang.String apiKey, java.lang.String bucket, boolean isReadOnly, int poolSize, int maxQueueSize, java.util.function.Consumer<java.lang.Throwable> onWriteError)
The Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deactivate()
Close currentInfluxDBClient
.protected InfluxConnector.InfluxConnection
getInfluxConnection()
Get InfluxDB Connection.java.util.SortedMap<java.time.ZonedDateTime,java.util.SortedMap<ChannelAddress,com.google.gson.JsonElement>>
queryHistoricData(java.util.Optional<java.lang.Integer> influxEdgeId, java.time.ZonedDateTime fromDate, java.time.ZonedDateTime toDate, java.util.Set<ChannelAddress> channels, Resolution resolution)
Queries historic data.java.util.SortedMap<ChannelAddress,com.google.gson.JsonElement>
queryHistoricEnergy(java.util.Optional<java.lang.Integer> influxEdgeId, java.time.ZonedDateTime fromDate, java.time.ZonedDateTime toDate, java.util.Set<ChannelAddress> channels)
Queries historic energy.java.util.SortedMap<java.time.ZonedDateTime,java.util.SortedMap<ChannelAddress,com.google.gson.JsonElement>>
queryHistoricEnergyPerPeriod(java.util.Optional<java.lang.Integer> influxEdgeId, java.time.ZonedDateTime fromDate, java.time.ZonedDateTime toDate, java.util.Set<ChannelAddress> channels, Resolution resolution)
Queries historic energy per period.void
write(com.influxdb.client.write.Point point)
Actually write the Point to InfluxDB.
-
-
-
Field Detail
-
MEASUREMENT
public static final java.lang.String MEASUREMENT
- See Also:
- Constant Field Values
-
executor
protected final java.util.concurrent.ThreadPoolExecutor executor
-
pointsQueue
protected final java.util.concurrent.BlockingQueue<com.influxdb.client.write.Point> pointsQueue
-
-
Constructor Detail
-
InfluxConnector
public InfluxConnector(QueryLanguageConfig queryLanguage, java.net.URI url, java.lang.String org, java.lang.String apiKey, java.lang.String bucket, boolean isReadOnly, int poolSize, int maxQueueSize, java.util.function.Consumer<java.lang.Throwable> onWriteError)
The Constructor.- Parameters:
queryLanguage
- AQueryLanguageConfig
url
- URL of the InfluxDB-Server (http://ip:port)org
- The organisation; '-' for InfluxDB v1apiKey
- The apiKey; 'username:password' for InfluxDB v1bucket
- The bucket name; 'database/retentionPolicy' for InfluxDB v1isReadOnly
- If true, a 'Read-Only-Mode' is activated, where no data is actually written to the databasepoolSize
- the number of threads dedicated to handle the tasksmaxQueueSize
- queue size limit for executoronWriteError
- A consumer for write-errors
-
-
Method Detail
-
getInfluxConnection
protected InfluxConnector.InfluxConnection getInfluxConnection()
Get InfluxDB Connection.- Returns:
- the
InfluxDB
connection
-
deactivate
public void deactivate()
Close currentInfluxDBClient
.
-
queryHistoricEnergy
public java.util.SortedMap<ChannelAddress,com.google.gson.JsonElement> queryHistoricEnergy(java.util.Optional<java.lang.Integer> influxEdgeId, java.time.ZonedDateTime fromDate, java.time.ZonedDateTime toDate, java.util.Set<ChannelAddress> channels) throws OpenemsError.OpenemsNamedException
Queries historic energy.- Parameters:
influxEdgeId
- the unique, numeric Edge-ID; or Empty to query all EdgesfromDate
- the From-DatetoDate
- the To-Datechannels
- the Channels to query- Returns:
- a map between ChannelAddress and value
- Throws:
OpenemsException
- on errorOpenemsError.OpenemsNamedException
-
queryHistoricEnergyPerPeriod
public java.util.SortedMap<java.time.ZonedDateTime,java.util.SortedMap<ChannelAddress,com.google.gson.JsonElement>> queryHistoricEnergyPerPeriod(java.util.Optional<java.lang.Integer> influxEdgeId, java.time.ZonedDateTime fromDate, java.time.ZonedDateTime toDate, java.util.Set<ChannelAddress> channels, Resolution resolution) throws OpenemsError.OpenemsNamedException
Queries historic energy per period.- Parameters:
influxEdgeId
- the unique, numeric Edge-ID; or Empty to query all EdgesfromDate
- the From-DatetoDate
- the To-Datechannels
- the Channels to queryresolution
- the resolution in seconds- Returns:
- the historic data as Map
- Throws:
OpenemsException
- on errorOpenemsError.OpenemsNamedException
-
queryHistoricData
public java.util.SortedMap<java.time.ZonedDateTime,java.util.SortedMap<ChannelAddress,com.google.gson.JsonElement>> queryHistoricData(java.util.Optional<java.lang.Integer> influxEdgeId, java.time.ZonedDateTime fromDate, java.time.ZonedDateTime toDate, java.util.Set<ChannelAddress> channels, Resolution resolution) throws OpenemsError.OpenemsNamedException
Queries historic data.- Parameters:
influxEdgeId
- the unique, numeric Edge-ID; or Empty to query all EdgesfromDate
- the From-DatetoDate
- the To-Datechannels
- the Channels to queryresolution
- the resolution in seconds- Returns:
- the historic data as Map
- Throws:
OpenemsException
- on errorOpenemsError.OpenemsNamedException
-
write
public void write(com.influxdb.client.write.Point point)
Actually write the Point to InfluxDB.- Parameters:
point
- the InfluxDB Point- Throws:
OpenemsException
- on error
-
-