@Override protected int runCmd(DistributedLogClient client) throws Exception { System.out.println("Truncating streams : " + streams); for (String stream : streams) { boolean success = Await.result(client.truncate(stream, dlsn)); System.out.println("Truncate " + stream + " to " + dlsn + " : " + success); } return 0; }
@Override public void run() { final DLSN dlsnToTruncate = prevDLSN; if (null == dlsnToTruncate) { return; } final Stopwatch stopwatch = Stopwatch.createStarted(); dlc.truncate(streamName, dlsnToTruncate).addEventListener( new FutureEventListener<Boolean>() { @Override public void onSuccess(Boolean value) { truncationStat.registerSuccessfulEvent(stopwatch.stop().elapsed(TimeUnit.MILLISECONDS)); } @Override public void onFailure(Throwable cause) { truncationStat.registerFailedEvent(stopwatch.stop().elapsed(TimeUnit.MILLISECONDS)); LOG.error("Failed to truncate stream {} to {} : ", new Object[]{streamName, dlsnToTruncate, cause}); } }); }