Class BasicDatasourcePartitionManager
- java.lang.Object
-
- com.inductiveautomation.gateway.tags.history.partitions.BasicDatasourcePartitionManager
-
- All Implemented Interfaces:
PartitionManager
- Direct Known Subclasses:
AbstractDirectorPartitionManager
public class BasicDatasourcePartitionManager extends java.lang.Object implements PartitionManager
This base partition manager provides read support, but otherwise no real management.
-
-
Constructor Summary
Constructors Constructor Description BasicDatasourcePartitionManager(GatewayContext context, java.lang.String dataSource, int driverId)
BasicDatasourcePartitionManager(GatewayContext context, java.lang.String queryId, java.lang.String dataSource, int driverId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteOldPartitions(long ageMS)
Will delete all partitions older than the given age.protected Datasource
getDatasource()
protected int
getDriverId()
LoggerEx
getLogger()
java.util.List<Partition>
getMostRecentPartitions(int count, long windowSize)
Retrieves partitions order by start time desc.java.util.List<Partition>
getOlderPartitions(long time, long windowSize, int limit)
Retrieves the partitions with data equal to or older than the specified time, sorted DESC (most recent first).Partition
getPartition(long time, long windowSize)
Retrieves the partition that contains the given time, as close to the resolution as possiblejava.util.List<Partition>
getPartitions(long start, long end, long windowSize)
Returns the partitions for a span of time, choosing the coarsest partitions available for the window size.QueryCache
getQueryCache()
void
initialize()
protected Partition
loadPartitionFromDS(Dataset data)
Returns the first partition defined in the dataset, or null if there isn't one.protected java.util.List<Partition>
loadPartitionsFromDS(Dataset data)
Returns all of the partitions defined in a dataset.protected boolean
partitionExists(java.lang.String name)
protected java.util.List<Partition>
runPartitionQuery(java.lang.String query, java.lang.Object... params)
Runs the getOlderPartitions and getPartitions queries.void
shutdown()
-
-
-
Constructor Detail
-
BasicDatasourcePartitionManager
public BasicDatasourcePartitionManager(GatewayContext context, java.lang.String dataSource, int driverId)
-
BasicDatasourcePartitionManager
public BasicDatasourcePartitionManager(GatewayContext context, java.lang.String queryId, java.lang.String dataSource, int driverId)
-
-
Method Detail
-
getLogger
public LoggerEx getLogger()
-
getQueryCache
public QueryCache getQueryCache()
-
getDriverId
protected int getDriverId()
-
getDatasource
protected Datasource getDatasource()
-
initialize
public void initialize() throws java.lang.Exception
- Specified by:
initialize
in interfacePartitionManager
- Throws:
java.lang.Exception
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfacePartitionManager
-
getPartition
public Partition getPartition(long time, long windowSize) throws java.lang.Exception
Description copied from interface:PartitionManager
Retrieves the partition that contains the given time, as close to the resolution as possible- Specified by:
getPartition
in interfacePartitionManager
- Throws:
java.lang.Exception
-
getOlderPartitions
public java.util.List<Partition> getOlderPartitions(long time, long windowSize, int limit) throws java.lang.Exception
Description copied from interface:PartitionManager
Retrieves the partitions with data equal to or older than the specified time, sorted DESC (most recent first).- Specified by:
getOlderPartitions
in interfacePartitionManager
limit
- if 0, no limit, otherwise only returns up to that many partitions.- Throws:
java.lang.Exception
-
getPartitions
public java.util.List<Partition> getPartitions(long start, long end, long windowSize) throws java.lang.Exception
Returns the partitions for a span of time, choosing the coarsest partitions available for the window size. The partition objects returned will be resized such that coarse partitions will not overlap with raw. In other words, it should be appropriate to simply loop through them and query data.- Specified by:
getPartitions
in interfacePartitionManager
- Throws:
java.lang.Exception
-
runPartitionQuery
protected java.util.List<Partition> runPartitionQuery(java.lang.String query, java.lang.Object... params) throws java.lang.Exception
Runs the getOlderPartitions and getPartitions queries.- Throws:
java.lang.Exception
-
loadPartitionFromDS
protected Partition loadPartitionFromDS(Dataset data)
Returns the first partition defined in the dataset, or null if there isn't one.
-
loadPartitionsFromDS
protected java.util.List<Partition> loadPartitionsFromDS(Dataset data)
Returns all of the partitions defined in a dataset.
-
getMostRecentPartitions
public java.util.List<Partition> getMostRecentPartitions(int count, long windowSize) throws java.lang.Exception
Description copied from interface:PartitionManager
Retrieves partitions order by start time desc. Only returns up to the number specified by count.- Specified by:
getMostRecentPartitions
in interfacePartitionManager
- Throws:
java.lang.Exception
-
deleteOldPartitions
public void deleteOldPartitions(long ageMS) throws java.lang.Exception
Will delete all partitions older than the given age.- Specified by:
deleteOldPartitions
in interfacePartitionManager
- Throws:
java.lang.Exception
-
partitionExists
protected boolean partitionExists(java.lang.String name) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-