"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "dso-l2/src/main/java/com/tc/objectserver/entity/ActivePassiveAckWaiter.java" between
terracotta-core-5.7.0.tar.gz and terracotta-core-5.7.1.tar.gz

About: Terracotta - Clustering technology for Java ("Network Attached Memory", "Distributed Cache"). Source code of the server (5.x) core components.

ActivePassiveAckWaiter.java  (terracotta-core-5.7.0):ActivePassiveAckWaiter.java  (terracotta-core-5.7.1)
skipping to change at line 24 skipping to change at line 24
* *
* The Initial Developer of the Covered Software is * The Initial Developer of the Covered Software is
* Terracotta, Inc., a Software AG company * Terracotta, Inc., a Software AG company
* *
*/ */
package com.tc.objectserver.entity; package com.tc.objectserver.entity;
import com.tc.exception.TCServerRestartException; import com.tc.exception.TCServerRestartException;
import com.tc.l2.msg.ReplicationResultCode; import com.tc.l2.msg.ReplicationResultCode;
import com.tc.net.NodeID; import com.tc.net.NodeID;
import com.tc.net.ServerID;
import com.tc.object.session.SessionID; import com.tc.object.session.SessionID;
import com.tc.util.Assert; import com.tc.util.Assert;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
/** /**
* This type is used by ActiveToPassiveReplication in order to wait on all the p assives either sending a RECEIVED or * This type is used by ActiveToPassiveReplication in order to wait on all the p assives either sending a RECEIVED or
* COMPLETED acknowledgement for a specific message. * COMPLETED acknowledgement for a specific message.
*/ */
public class ActivePassiveAckWaiter { public class ActivePassiveAckWaiter {
private final Map<NodeID, SessionID> session; private final Map<ServerID, SessionID> session;
private final Set<SessionID> start; private final Set<SessionID> start;
private final Set<SessionID> receivedPending; private final Set<SessionID> receivedPending;
private final Set<SessionID> receivedByComplete; private final Set<SessionID> receivedByComplete;
private final Set<SessionID> completedPending; private final Set<SessionID> completedPending;
private Runnable finalizer; private Runnable finalizer;
private final Map<NodeID, ReplicationResultCode> results; private final Map<NodeID, ReplicationResultCode> results;
private final PassiveReplicationBroker parent; private final PassiveReplicationBroker parent;
public ActivePassiveAckWaiter(Map<NodeID, SessionID> map, Set<SessionID> allPa ssiveNodes, PassiveReplicationBroker parent) { public ActivePassiveAckWaiter(Map<ServerID, SessionID> map, Set<SessionID> all PassiveNodes, PassiveReplicationBroker parent) {
this.session = map; this.session = map;
this.start = Collections.unmodifiableSet(allPassiveNodes); this.start = Collections.unmodifiableSet(allPassiveNodes);
this.receivedPending = new HashSet<>(allPassiveNodes); this.receivedPending = new HashSet<>(allPassiveNodes);
this.completedPending = new HashSet<>(allPassiveNodes); this.completedPending = new HashSet<>(allPassiveNodes);
this.receivedByComplete = new HashSet<>(); this.receivedByComplete = new HashSet<>();
this.results = new HashMap<>(); this.results = new HashMap<>();
this.parent = parent; this.parent = parent;
} }
public synchronized void waitForReceived() { public synchronized void waitForReceived() {
skipping to change at line 120 skipping to change at line 121
} }
return zapped; return zapped;
} }
return false; return false;
} }
public synchronized boolean isCompleted() { public synchronized boolean isCompleted() {
return this.completedPending.isEmpty(); return this.completedPending.isEmpty();
} }
private SessionID nodeToSession(NodeID node) { private SessionID nodeToSession(ServerID node) {
return this.session.get(node); return this.session.getOrDefault(node, SessionID.NULL_ID);
} }
public synchronized void didReceiveOnPassive(NodeID onePassive) { public synchronized void didReceiveOnPassive(ServerID onePassive) {
boolean didContain = this.receivedPending.remove(nodeToSession(onePassive)); SessionID current = nodeToSession(onePassive);
boolean didContain = this.receivedPending.remove(current);
// We must have contained this passive in order to receive. // We must have contained this passive in order to receive.
if (!didContain) { if (!didContain) {
Assert.assertTrue(onePassive + " " + toString(), this.receivedByComplete.c ontains(nodeToSession(onePassive))); Assert.assertTrue(onePassive + " " + toString(), this.receivedByComplete.c ontains(current));
} }
// Wake everyone up if this changed something. // Wake everyone up if this changed something.
if (this.receivedPending.isEmpty()) { if (this.receivedPending.isEmpty()) {
notifyAll(); notifyAll();
} }
} }
/** /**
* Notifies the waiter that it is complete for the given node. * Notifies the waiter that it is complete for the given node.
* *
* @param onePassive The passive which has completed the replicated message * @param onePassive The passive which has completed the replicated message
* @param payload * @param payload
* @return True if this was the last outstanding completion required and the w aiter is now done. * @return True if this was the last outstanding completion required and the w aiter is now done.
*/ */
public boolean didCompleteOnPassive(NodeID onePassive, ReplicationResultCode p ayload) { public boolean didCompleteOnPassive(ServerID onePassive, ReplicationResultCode payload) {
// do this first to prevent updating the map while it is being checked // do this first to prevent updating the map while it is being checked
this.results.put(onePassive, payload); this.results.put(onePassive, payload);
return runFinalizerOnComplete(updateCompletionFlags(nodeToSession(onePassive ), true)); return runFinalizerOnComplete(updateCompletionFlags(nodeToSession(onePassive ), true));
} }
public boolean failedToSendToPassive(SessionID session) { public boolean failedToSendToPassive(SessionID session) {
return runFinalizerOnComplete(updateCompletionFlags(session, false)); return runFinalizerOnComplete(updateCompletionFlags(session, false));
} }
private boolean runFinalizerOnComplete(boolean completed) { private boolean runFinalizerOnComplete(boolean completed) {
 End of changes. 7 change blocks. 
8 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)