Class AggregationScheduler
- java.lang.Object
-
- org.gcube.documentstore.records.aggregation.AggregationScheduler
-
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
BufferAggregationScheduler
public abstract class AggregationScheduler extends Object implements Runnable
- Author:
- Luca Frosini (ISTI - CNR)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classAggregationScheduler.ReloaderThread
-
Field Summary
Fields Modifier and Type Field Description static FileAGGREGATION_PROPERTIES_FILEstatic StringAGGREGATION_SCHEDULER_TIMEstatic StringBUFFER_RECORD_NUMBERstatic StringBUFFER_RECORD_TIMEprotected Map<String,List<Record>>bufferedRecordsbooleanchangeConfigurationstatic StringCONFIG_DIRECTORY_NAMEstatic StringFILE_NAMEprotected ScheduledFuture<?>futureFlushprotected ScheduledFuture<?>futureReloadstatic org.slf4j.Loggerloggerprotected PersistenceExecutorpersistenceExecutorstatic intRANDOM_INIT_STARTstatic longTIME_RELOAD_CONFIGURATIONThe Max amount of time for reload a configuration Get from configurationprotected inttotalBufferedRecords
-
Constructor Summary
Constructors Modifier Constructor Description protectedAggregationScheduler(PersistenceExecutor persistenceExecutor)protectedAggregationScheduler(PersistenceExecutor persistenceExecutor, AggregationConfiguration config)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaggregate(Record record, PersistenceExecutor persistenceExecutor)Get a record and try to aggregate with other buffered Records.protected voidaggregate(Record record, PersistenceExecutor persistenceExecutor, boolean forceFlush)protected static AggregationConfigurationCheckConfiguration(PersistenceBackendConfiguration configuration)protected voidclear()voidflush(PersistenceExecutor persistenceExecutor)static AggregatedRecordgetAggregatedRecord(Record record)AggregationConfigurationgetConfig()protected PersistenceBackendConfigurationgetConfiguration()Get Configuration (used from reload configuration)static PropertiesgetPropertiesFromFile()protected static AggregatedRecordinstantiateAggregatedRecord(Record record)protected abstract booleanisTimeToPersist(int maxRecordNumber, long oldRecordMaxTime)protected voidmadeAggregation(Record record)static AggregationSchedulernewInstance(PersistenceExecutor persistenceExecutor)static AggregationSchedulernewInstance(PersistenceExecutor persistenceExecutor, PersistenceBackendConfiguration configuration)protected voidreallyFlush(PersistenceExecutor persistenceExecutor)protected voidreloadConfiguration()reloadConfigurationvoidrun()protected abstract voidschedulerSpecificClear()voidsetConfig(AggregationConfiguration newConfig)voidshutdown()
-
-
-
Field Detail
-
logger
public static final org.slf4j.Logger logger
-
AGGREGATION_SCHEDULER_TIME
public static final String AGGREGATION_SCHEDULER_TIME
- See Also:
- Constant Field Values
-
BUFFER_RECORD_TIME
public static final String BUFFER_RECORD_TIME
- See Also:
- Constant Field Values
-
BUFFER_RECORD_NUMBER
public static final String BUFFER_RECORD_NUMBER
- See Also:
- Constant Field Values
-
RANDOM_INIT_START
public static final int RANDOM_INIT_START
- See Also:
- Constant Field Values
-
TIME_RELOAD_CONFIGURATION
public static final long TIME_RELOAD_CONFIGURATION
The Max amount of time for reload a configuration Get from configuration- See Also:
- Constant Field Values
-
CONFIG_DIRECTORY_NAME
public static final String CONFIG_DIRECTORY_NAME
- See Also:
- Constant Field Values
-
FILE_NAME
public static final String FILE_NAME
- See Also:
- Constant Field Values
-
AGGREGATION_PROPERTIES_FILE
public static final File AGGREGATION_PROPERTIES_FILE
-
totalBufferedRecords
protected int totalBufferedRecords
-
persistenceExecutor
protected final PersistenceExecutor persistenceExecutor
-
changeConfiguration
public boolean changeConfiguration
-
futureFlush
protected ScheduledFuture<?> futureFlush
-
futureReload
protected ScheduledFuture<?> futureReload
-
-
Constructor Detail
-
AggregationScheduler
protected AggregationScheduler(PersistenceExecutor persistenceExecutor)
-
AggregationScheduler
protected AggregationScheduler(PersistenceExecutor persistenceExecutor, AggregationConfiguration config)
-
-
Method Detail
-
newInstance
public static AggregationScheduler newInstance(PersistenceExecutor persistenceExecutor)
-
newInstance
public static AggregationScheduler newInstance(PersistenceExecutor persistenceExecutor, PersistenceBackendConfiguration configuration) throws NumberFormatException, Exception
- Throws:
NumberFormatExceptionException
-
instantiateAggregatedRecord
protected static AggregatedRecord instantiateAggregatedRecord(Record record) throws Exception
- Throws:
Exception
-
getAggregatedRecord
public static AggregatedRecord getAggregatedRecord(Record record) throws Exception
- Throws:
Exception
-
madeAggregation
protected void madeAggregation(Record record)
-
flush
public void flush(PersistenceExecutor persistenceExecutor) throws Exception
- Throws:
Exception
-
schedulerSpecificClear
protected abstract void schedulerSpecificClear()
-
clear
protected void clear()
-
aggregate
protected void aggregate(Record record, PersistenceExecutor persistenceExecutor, boolean forceFlush) throws Exception
- Throws:
Exception
-
reallyFlush
protected void reallyFlush(PersistenceExecutor persistenceExecutor) throws Exception
- Throws:
Exception
-
aggregate
public void aggregate(Record record, PersistenceExecutor persistenceExecutor) throws Exception
Get a record and try to aggregate with other buffered Records.- Parameters:
record- The RecordpersistenceExecutor-- Throws:
Exception
-
isTimeToPersist
protected abstract boolean isTimeToPersist(int maxRecordNumber, long oldRecordMaxTime)
-
reloadConfiguration
protected void reloadConfiguration()
reloadConfiguration- Throws:
Exception
-
getConfiguration
protected PersistenceBackendConfiguration getConfiguration()
Get Configuration (used from reload configuration)- Returns:
- PersistenceBackendConfiguration
-
getPropertiesFromFile
public static Properties getPropertiesFromFile() throws IOException
- Throws:
IOException
-
CheckConfiguration
protected static AggregationConfiguration CheckConfiguration(PersistenceBackendConfiguration configuration) throws IOException
- Throws:
IOException
-
getConfig
public AggregationConfiguration getConfig()
-
setConfig
public void setConfig(AggregationConfiguration newConfig)
-
shutdown
public void shutdown()
-
-