Search in sources :

Example 1 with CollectNodeOperAction

use of com.creditease.uav.collect.client.actions.CollectNodeOperAction in project uavstack by uavorg.

the class CollectDataAgent method start.

@Override
public void start() {
    // init position file. If file is not exists, create it
    String rootMetaPath = this.getConfigManager().getContext(IConfigurationManager.METADATAPATH) + "collectdata";
    IOHelper.createFolder(rootMetaPath);
    positionFilePath = rootMetaPath + File.separator + POSITION_FILE;
    taskFilePath = rootMetaPath + File.separator + TASK_FILE;
    initFiles(new String[] { positionFilePath, taskFilePath });
    // register CollectNodeOperAction
    IActionEngine engine = this.getActionEngineMgr().getActionEngine("NodeOperActionEngine");
    new CollectNodeOperAction("collectdata", feature, engine);
    // init DataCollector
    dc = new DataCollector(DataCollector.class.getName(), feature);
    List<CollectTask> tasks = loadTasks();
    dc.init(tasks);
    dc.loadPositions(IOHelper.readTxtFile(positionFilePath, "UTF-8"));
    // start data scaner
    long scanInterval = DataConvertHelper.toLong(getConfigManager().getFeatureConfiguration(feature, "interval"), 3000L);
    FileScanScheduler scanner = new FileScanScheduler(FileScanScheduler.class.getName(), feature);
    getTimerWorkManager().scheduleWork(FileScanScheduler.class.getName(), scanner, 0, scanInterval);
    // write position file scheduler
    long writePosDelay = DataConvertHelper.toLong(getConfigManager().getFeatureConfiguration(feature, "writeposdelay"), 5000L);
    long writePosInterval = DataConvertHelper.toLong(getConfigManager().getFeatureConfiguration(feature, "writeposinterval"), 3000L);
    PositionPersistence position = new PositionPersistence(PositionPersistence.class.getName(), feature);
    getTimerWorkManager().scheduleWork(PositionPersistence.class.getName(), position, writePosDelay, writePosInterval);
    // check idle file scheduler
    long idleCheckerDelay = DataConvertHelper.toLong(getConfigManager().getFeatureConfiguration(feature, "idlecheckerdelay"), 120000L);
    long idleCheckerInterval = DataConvertHelper.toLong(getConfigManager().getFeatureConfiguration(feature, "idlecheckerinterval"), 5000L);
    IdleFileChecker idleChecker = new IdleFileChecker(IdleFileChecker.class.getName(), feature);
    getTimerWorkManager().scheduleWork(IdleFileChecker.class.getName(), idleChecker, idleCheckerDelay, idleCheckerInterval);
    log.info(this, "CollectDataAgent Started. Config: interval=" + scanInterval);
}
Also used : CollectNodeOperAction(com.creditease.uav.collect.client.actions.CollectNodeOperAction) DataCollector(com.creditease.uav.collect.client.collectdata.DataCollector) IActionEngine(com.creditease.agent.spi.IActionEngine) CollectTask(com.creditease.uav.collect.client.collectdata.CollectTask)

Aggregations

IActionEngine (com.creditease.agent.spi.IActionEngine)1 CollectNodeOperAction (com.creditease.uav.collect.client.actions.CollectNodeOperAction)1 CollectTask (com.creditease.uav.collect.client.collectdata.CollectTask)1 DataCollector (com.creditease.uav.collect.client.collectdata.DataCollector)1