use of com.couchbase.connector.dcp.SnapshotMarker in project couchbase-elasticsearch-connector by couchbase.
the class CheckpointClear method setCheckpointToNow.
private static void setCheckpointToNow(ConnectorConfig config, Set<SeedNode> kvNodes, CheckpointDao checkpointDao) throws IOException {
final Client dcpClient = DcpHelper.newClient(config.group().name(), config.couchbase(), kvNodes, config.trustStore());
try {
dcpClient.connect().block();
final int numPartitions = dcpClient.numPartitions();
final Set<Integer> allPartitions = new HashSet<>(allPartitions(numPartitions));
DcpHelper.getCurrentSeqnos(dcpClient, allPartitions);
final SessionState sessionState = dcpClient.sessionState();
final Map<Integer, Checkpoint> now = new HashMap<>();
for (int i = 0; i < allPartitions.size(); i++) {
PartitionState p = sessionState.get(i);
final long seqno = p.getStartSeqno();
now.put(i, new Checkpoint(p.getLastUuid(), seqno, new SnapshotMarker(seqno, seqno)));
}
checkpointDao.save("", now);
} finally {
dcpClient.disconnect().block();
}
}
Aggregations