You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by fr...@apache.org on 2016/10/04 16:58:13 UTC
svn commit: r1763302 -
/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/standby/client/StandbyClientSyncExecution.java
Author: frm
Date: Tue Oct 4 16:58:13 2016
New Revision: 1763302
URL: http://svn.apache.org/viewvc?rev=1763302&view=rev
Log:
OAK-4886 - Unify usage of the 'visited' and 'local' set
Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/standby/client/StandbyClientSyncExecution.java
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/standby/client/StandbyClientSyncExecution.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/standby/client/StandbyClientSyncExecution.java?rev=1763302&r1=1763301&r2=1763302&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/standby/client/StandbyClientSyncExecution.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/standby/client/StandbyClientSyncExecution.java Tue Oct 4 16:58:13 2016
@@ -54,8 +54,6 @@ class StandbyClientSyncExecution {
private final Supplier<Boolean> running;
- private final Set<UUID> visited = newHashSet();
-
private final Set<UUID> queued = newHashSet();
private final Set<UUID> local = newHashSet();
@@ -119,7 +117,7 @@ class StandbyClientSyncExecution {
Segment segment = copySegmentFromPrimary(current);
log.debug("Marking segment {} as loaded", current);
- visited.add(current);
+ local.add(current);
if (!SegmentId.isDataSegmentId(current.getLeastSignificantBits())) {
continue;
@@ -129,11 +127,22 @@ class StandbyClientSyncExecution {
for (int i = 0; i < segment.getReferencedSegmentIdCount(); i++) {
UUID referenced = segment.getReferencedSegmentId(i);
- // Short circuit for the "back reference problem". The segment
- // graph might or might not be acyclic. The following check
- // prevents processing segment that were already traversed.
+ // Short circuit for the "sharing-is-caring problem". If many
+ // new segments are sharing segments that are already locally
+ // available, we should not issue a request for it to the
+ // server. Moreover, if a segment was visited and persisted
+ // during this synchronization process, it will end up in the
+ // 'local' set as well.
- if (visited.contains(referenced)) {
+ if (local.contains(referenced)) {
+ continue;
+ }
+
+ if (isLocal(referenced)) {
+ local.add(referenced);
+ }
+
+ if (local.contains(referenced)) {
continue;
}
@@ -148,20 +157,6 @@ class StandbyClientSyncExecution {
continue;
}
- // Short circuit for the "sharing-is-caring problem". If many
- // new segments are sharing segments that are already locally
- // available, we should not issue a request for it to the
- // server.
-
- if (local.contains(referenced)) {
- continue;
- }
-
- if (isLocal(referenced)) {
- local.add(referenced);
- continue;
- }
-
// If we arrive at this point, the referenced segment is 1) not
// present locally, 2) not already queued for retrieval and 3)
// never visited before. We can safely add the reference to the