summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Arès <hugo.ares@ericsson.com>2018-08-08 10:42:56 -0400
committerMarco Miller <marco.miller@ericsson.com>2018-09-05 11:52:42 -0400
commitd557ccc642c59a55750f560ce0d98870e1550d65 (patch)
tree5adc0d2f8642f8a790dd83972e2632cbacffbca7
parentb62f006b1350180de0af02c82fb18fb290a2548f (diff)
Delete event file only after replication completed for all destinations
The event file is created only once even if the ref is replicated to more than one destination, but it was deleting after replication is completed to each destination. This was wrong, as only after the first destination completes the file was successfully deleted. And upon subsequent destination completion, the deletion was failing with NoSuchFileException. On top of the error getting logged, this is also wrong as the plugin could be reloaded before replication is completed on all destinations. And if one of them completed, then replication for that ref would not have been rescheduled. Change-Id: I07b3b88e42382330da409dd9e156498c0bf434a9
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationState.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationState.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationState.java
index 6f0803a..ec878db 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationState.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationState.java
@@ -86,7 +86,6 @@ public class ReplicationState {
URIish uri,
RefPushResult status,
RemoteRefUpdate.Status refUpdateStatus) {
- deleteEvent();
pushResultProcessing.onRefReplicatedToOneNode(project, ref, uri, status, refUpdateStatus);
RefReplicationStatus completedRefStatus = null;
@@ -116,12 +115,6 @@ public class ReplicationState {
}
}
- private void deleteEvent() {
- if (eventKey != null) {
- eventsStorage.delete(eventKey);
- }
- }
-
public void markAllPushTasksScheduled() {
countingLock.lock();
try {
@@ -152,10 +145,17 @@ public class ReplicationState {
}
private void doRefPushTasksCompleted(RefReplicationStatus refStatus) {
+ deleteEvent();
pushResultProcessing.onRefReplicatedToAllNodes(
refStatus.project, refStatus.ref, refStatus.nodesToReplicateCount);
}
+ private void deleteEvent() {
+ if (eventKey != null) {
+ eventsStorage.delete(eventKey);
+ }
+ }
+
private RefReplicationStatus getRefStatus(String project, String ref) {
if (!statusByProjectRef.contains(project, ref)) {
RefReplicationStatus refStatus = new RefReplicationStatus(project, ref);