Source:
public void start() throws ReplicationException { virtualReplicatorCluster.addListener(new VirtualReplicatorClusterListener() { @Override public void onPartitionAdded(PartitionId partitionId) { try { addPartition(partitionId); logger.info("Partition added to {}", partitionId, dataNodeId); } catch (ReplicationException e) { vcrMetrics.addPartitionErrorCount.inc(); logger.error("Exception on adding Partition to {}: {}", partitionId, dataNodeId, e); } catch (Exception e) { vcrMetrics.addPartitionErrorCount.inc(); logger.error("Unknown Exception on adding Partition to {}: {}", partitionId, dataNodeId, e); } } @Override public void onPartitionRemoved(PartitionId partitionId) { try { PartitionInfo partitionInfo = partitionToPartitionInfo.remove(partitionId); if (partitionInfo == null) { logger.error("Partition not exist when remove from {}. ", partitionId, dataNodeId); vcrMetrics.removePartitionErrorCount.inc(); return; } removeRemoteReplicaInfoFromReplicaThread(partitionInfo.getRemoteReplicaInfos()); if (replicationConfig.replicationPersistTokenOnShutdownOrReplicaRemove) { try { persistor.write(partitionInfo.getLocalReplicaId().getMountPath(), false); } catch (IOException | ReplicationException e) { logger.error("Exception on token write when remove Partition from {}: {}", partitionId, dataNodeId, e); vcrMetrics.removePartitionErrorCount.inc(); } } logger.info("Partition removed from {}", partitionId, dataNodeId); } catch (Exception e) { vcrMetrics.removePartitionErrorCount.inc(); logger.error("Unknown Exception on removing Partition from {}: {}", partitionId, dataNodeId, e); } } }); try { virtualReplicatorCluster.participate(InstanceType.PARTICIPANT); } catch (Exception e) { throw new ReplicationException("Cluster participate failed.", e); } scheduler.scheduleAtFixedRate(persistor, replicationConfig.replicationTokenFlushDelaySeconds, replicationConfig.replicationTokenFlushIntervalSeconds, TimeUnit.SECONDS); }

Target:
public void start() throws ReplicationException { virtualReplicatorCluster.addListener(new VirtualReplicatorClusterListener() { @Override public void onPartitionAdded(PartitionId partitionId) { try { addPartition(partitionId); logger.info("Partition added to {}", partitionId, dataNodeId); } catch (ReplicationException e) { vcrMetrics.addPartitionErrorCount.inc(); logger.error("Exception on adding Partition to {}: ", partitionId, dataNodeId, e); } catch (Exception e) { vcrMetrics.addPartitionErrorCount.inc(); logger.error("Unknown Exception on adding Partition to {}: ", partitionId, dataNodeId, e); } } @Override public void onPartitionRemoved(PartitionId partitionId) { try { PartitionInfo partitionInfo = partitionToPartitionInfo.remove(partitionId); if (partitionInfo == null) { logger.error("Partition not exist when remove from {}. ", partitionId, dataNodeId); vcrMetrics.removePartitionErrorCount.inc(); return; } removeRemoteReplicaInfoFromReplicaThread(partitionInfo.getRemoteReplicaInfos()); if (replicationConfig.replicationPersistTokenOnShutdownOrReplicaRemove) { try { persistor.write(partitionInfo.getLocalReplicaId().getMountPath(), false); } catch (IOException | ReplicationException e) { logger.error("Exception on token write when remove Partition from {}: ", partitionId, dataNodeId, e); vcrMetrics.removePartitionErrorCount.inc(); } } logger.info("Partition removed from {}", partitionId, dataNodeId); } catch (Exception e) { vcrMetrics.removePartitionErrorCount.inc(); logger.error("Unknown Exception on removing Partition from {}: ", partitionId, dataNodeId, e); } } }); try { virtualReplicatorCluster.participate(InstanceType.PARTICIPANT); } catch (Exception e) { throw new ReplicationException("Cluster participate failed.", e); } scheduler.scheduleAtFixedRate(persistor, replicationConfig.replicationTokenFlushDelaySeconds, replicationConfig.replicationTokenFlushIntervalSeconds, TimeUnit.SECONDS); }