use of com.linkedin.databus.client.pub.FileSystemCheckpointPersistenceProvider in project databus by linkedin.
the class CheckpointSerializerMain method main.
public static void main(String[] args) throws Exception {
parseArgs(args);
PatternLayout defaultLayout = new PatternLayout("%d{ISO8601} +%r [%t] (%p) {%c{1}} %m%n");
ConsoleAppender defaultAppender = new ConsoleAppender(defaultLayout);
Logger.getRootLogger().removeAllAppenders();
Logger.getRootLogger().addAppender(defaultAppender);
Logger.getRootLogger().setLevel(Level.INFO);
Logger.getRootLogger().info("NOTE. This tool works only with V2/V1 checkpoints");
CheckpointPersistenceProvider cp3 = null;
if (null != _cp3Props) {
CheckpointPersistenceStaticConfigBuilder cp3ConfBuilder = new CheckpointPersistenceStaticConfigBuilder();
ConfigLoader<CheckpointPersistenceStaticConfig> configLoader = new ConfigLoader<DatabusHttpClientImpl.CheckpointPersistenceStaticConfig>(_propPrefix, cp3ConfBuilder);
configLoader.loadConfig(_cp3Props);
CheckpointPersistenceStaticConfig cp3Conf = cp3ConfBuilder.build();
if (cp3Conf.getType() != CheckpointPersistenceStaticConfig.ProviderType.FILE_SYSTEM) {
throw new RuntimeException("don't know what to do with cp3 type:" + cp3Conf.getType());
}
cp3 = new FileSystemCheckpointPersistenceProvider(cp3Conf.getFileSystem(), 2);
} else if (null != _clientProps) {
DatabusHttpClientImpl.Config clientConfBuilder = new DatabusHttpClientImpl.Config();
ConfigLoader<DatabusHttpClientImpl.StaticConfig> configLoader = new ConfigLoader<DatabusHttpClientImpl.StaticConfig>(_propPrefix, clientConfBuilder);
configLoader.loadConfig(_clientProps);
DatabusHttpClientImpl.StaticConfig clientConf = clientConfBuilder.build();
if (clientConf.getCheckpointPersistence().getType() != CheckpointPersistenceStaticConfig.ProviderType.FILE_SYSTEM) {
throw new RuntimeException("don't know what to do with cp3 type:" + clientConf.getCheckpointPersistence().getType());
}
cp3 = new FileSystemCheckpointPersistenceProvider(clientConf.getCheckpointPersistence().getFileSystem(), 2);
}
List<String> sourceList = Arrays.asList(_sources);
Checkpoint cpOld = null != cp3 ? cp3.loadCheckpoint(sourceList) : new Checkpoint();
Checkpoint cpNew;
if (Action.PRINT == _action) {
cpNew = updateCheckpoint(cpOld);
} else if (Action.CHANGE == _action) {
cpNew = updateCheckpoint(cpOld);
cp3.storeCheckpoint(sourceList, cpNew);
// reread as a sanity check
cpNew = cp3.loadCheckpoint(sourceList);
} else if (Action.DELETE == _action) {
cp3.removeCheckpoint(sourceList);
cpNew = cp3.loadCheckpoint(sourceList);
} else {
throw new RuntimeException("don't know what to do with action: " + _action);
}
if (null != cpOld)
System.out.println("old: " + cpOld.toString());
else
System.out.println("old: null");
if (null != cpNew)
System.out.println("new: " + cpNew.toString());
else
System.out.println("new: null");
}
Aggregations