use of com.creditease.uav.collect.client.collectdata.CollectTask in project uavstack by uavorg.
the class CollectDataAgent method exchange.
@Override
public Object exchange(String eventKey, Object... data) {
if (log.isDebugEnable()) {
log.debug(this, "exchange: eventKey=" + eventKey + ", data=" + Arrays.toString(data));
}
if ("collectdata.add".equals(eventKey)) {
TaskContext ctx = new TaskContext((String) data[0]);
if (ctx.hasCallback()) {
ctxCaching.put(ctx.id, ctx);
}
for (CollectTask task : ctx.tasks) {
dc.add(task);
}
persistTasks();
} else if ("collectdata.del".equals(eventKey)) {
TaskContext ctx = new TaskContext((String) data[0]);
for (CollectTask task : ctx.tasks) {
dc.delete(task);
}
persistTasks();
} else if ("collectdata.status".equals(eventKey)) {
return JSONHelper.toString(dc.tasks());
} else {
throw new UnsupportedOperationException("Unsupported Operation: " + eventKey);
}
return null;
}
use of com.creditease.uav.collect.client.collectdata.CollectTask in project uavstack by uavorg.
the class ReliableTaildirEventReader method getFilePaths.
private Map<String, LogPatternInfo> getFilePaths(Map<String, CollectTask> tasks) {
Map<String, LogPatternInfo> filePaths = new HashMap<>();
for (Entry<String, CollectTask> en : tasks.entrySet()) {
CollectTask t = en.getValue();
LogPatternInfo lpi = new LogPatternInfo(t.getTarget(), t.getAction(), t.getFile());
lpi.setUnsplit(t.isUnsplit());
filePaths.put(lpi.getUUID(), lpi);
}
return filePaths;
}
use of com.creditease.uav.collect.client.collectdata.CollectTask 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);
}
Aggregations