private long addBackedUpSeconds(long lowWatermark, int backupSecs, String watermarkType) { if (lowWatermark == ConfigurationKeys.DEFAULT_WATERMARK_VALUE) { return lowWatermark; } WatermarkType wmType = WatermarkType.valueOf(watermarkType.toUpperCase()); switch (wmType) { case SIMPLE: return lowWatermark + backupSecs; default: Date lowWaterMarkDate = Utils.toDate(lowWatermark, "yyyyMMddHHmmss"); return Long.parseLong( Utils.dateToString( Utils.addSecondsToDate(lowWaterMarkDate, backupSecs), "yyyyMMddHHmmss")); } }
/** * Get low water mark from the given work unit state. * * @param workUnitState Work unit state * @return latest low water mark */ private long getLowWatermarkFromWorkUnit(WorkUnitState workUnitState) { String watermarkType = workUnitState.getProp( ConfigurationKeys.SOURCE_QUERYBASED_WATERMARK_TYPE, ConfigurationKeys.DEFAULT_WATERMARK_TYPE); long lowWaterMark = workUnitState.getWorkunit().getLowWaterMark(); if (lowWaterMark == ConfigurationKeys.DEFAULT_WATERMARK_VALUE) { return lowWaterMark; } WatermarkType wmType = WatermarkType.valueOf(watermarkType.toUpperCase()); int deltaNum = new WatermarkPredicate(wmType).getDeltaNumForNextWatermark(); switch (wmType) { case SIMPLE: return lowWaterMark - deltaNum; default: Date lowWaterMarkDate = Utils.toDate(lowWaterMark, "yyyyMMddHHmmss"); return Long.parseLong( Utils.dateToString( Utils.addSecondsToDate(lowWaterMarkDate, deltaNum * -1), "yyyyMMddHHmmss")); } }