"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "dso-l2/src/test/java/com/tc/objectserver/entity/ActivePassiveAckWaiterTest.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.

ActivePassiveAckWaiterTest.java  (terracotta-core-5.7.0):ActivePassiveAckWaiterTest.java  (terracotta-core-5.7.1)
skipping to change at line 23 skipping to change at line 23
* The Covered Software is Terracotta Core. * The Covered Software is Terracotta Core.
* *
* 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.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 com.tc.util.concurrent.SetOnceFlag; import com.tc.util.concurrent.SetOnceFlag;
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;
skipping to change at line 54 skipping to change at line 55
ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(Collections.empty Map(), passives, null); ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(Collections.empty Map(), passives, null);
// This can run in a single thread. // This can run in a single thread.
Assert.assertTrue(waiter.isCompleted()); Assert.assertTrue(waiter.isCompleted());
waiter.waitForReceived(); waiter.waitForReceived();
waiter.waitForCompleted(); waiter.waitForCompleted();
Assert.assertTrue(waiter.isCompleted()); Assert.assertTrue(waiter.isCompleted());
} }
@Test @Test
public void testSingleWait() throws Exception { public void testSingleWait() throws Exception {
Map<NodeID, SessionID> map = new HashMap<>(); Map<ServerID, SessionID> map = new HashMap<>();
Set<SessionID> passives = new HashSet<>(); Set<SessionID> passives = new HashSet<>();
SessionID onePassive = mock(SessionID.class); SessionID onePassive = mock(SessionID.class);
passives.add(onePassive); passives.add(onePassive);
NodeID node = mock(NodeID.class); ServerID node = mock(ServerID.class);
map.put(node, onePassive); map.put(node, onePassive);
ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll); ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll);
Interlock interlock = new Interlock(1); Interlock interlock = new Interlock(1);
LockStep lockStep = new LockStep(waiter, interlock); LockStep lockStep = new LockStep(waiter, interlock);
lockStep.start(); lockStep.start();
interlock.waitOnStarts(); interlock.waitOnStarts();
waiter.didReceiveOnPassive(node); waiter.didReceiveOnPassive(node);
interlock.waitOnReceivesOnly(); interlock.waitOnReceivesOnly();
boolean waiterIsDone = waiter.didCompleteOnPassive(node, ReplicationResultCo de.SUCCESS); boolean waiterIsDone = waiter.didCompleteOnPassive(node, ReplicationResultCo de.SUCCESS);
Assert.assertTrue(waiterIsDone); Assert.assertTrue(waiterIsDone);
interlock.waitOnCompletes(); interlock.waitOnCompletes();
lockStep.join(); lockStep.join();
} }
@Test @Test
public void testMultiWait() throws Exception { public void testMultiWait() throws Exception {
Map<NodeID, SessionID> map = new HashMap<>(); Map<ServerID, SessionID> map = new HashMap<>();
Set<SessionID> passives = new HashSet<>(); Set<SessionID> passives = new HashSet<>();
SessionID onePassive = mock(SessionID.class); SessionID onePassive = mock(SessionID.class);
passives.add(onePassive); passives.add(onePassive);
SessionID twoPassive = mock(SessionID.class); SessionID twoPassive = mock(SessionID.class);
passives.add(twoPassive); passives.add(twoPassive);
NodeID node1 = mock(NodeID.class); ServerID node1 = mock(ServerID.class);
NodeID node2 = mock(NodeID.class); ServerID node2 = mock(ServerID.class);
map.put(node1, onePassive); map.put(node1, onePassive);
map.put(node2, twoPassive); map.put(node2, twoPassive);
ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll); ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll);
Interlock interlock = new Interlock(1); Interlock interlock = new Interlock(1);
LockStep lockStep = new LockStep(waiter, interlock); LockStep lockStep = new LockStep(waiter, interlock);
lockStep.start(); lockStep.start();
interlock.waitOnStarts(); interlock.waitOnStarts();
waiter.didReceiveOnPassive(node1); waiter.didReceiveOnPassive(node1);
waiter.didReceiveOnPassive(node2); waiter.didReceiveOnPassive(node2);
skipping to change at line 107 skipping to change at line 108
Assert.assertFalse(waiterIsDone); Assert.assertFalse(waiterIsDone);
waiterIsDone = waiter.didCompleteOnPassive(node1, ReplicationResultCode.SUCC ESS); waiterIsDone = waiter.didCompleteOnPassive(node1, ReplicationResultCode.SUCC ESS);
Assert.assertTrue(waiterIsDone); Assert.assertTrue(waiterIsDone);
interlock.waitOnCompletes(); interlock.waitOnCompletes();
lockStep.join(); lockStep.join();
} }
@Test @Test
public void testMultiWaitWithMoreThreads() throws Exception { public void testMultiWaitWithMoreThreads() throws Exception {
Set<SessionID> passives = new HashSet<>(); Set<SessionID> passives = new HashSet<>();
Map<NodeID, SessionID> map = new HashMap<>(); Map<ServerID, SessionID> map = new HashMap<>();
SessionID onePassive = mock(SessionID.class); SessionID onePassive = mock(SessionID.class);
passives.add(onePassive); passives.add(onePassive);
SessionID twoPassive = mock(SessionID.class); SessionID twoPassive = mock(SessionID.class);
passives.add(twoPassive); passives.add(twoPassive);
NodeID node1 = mock(NodeID.class); ServerID node1 = mock(ServerID.class);
NodeID node2 = mock(NodeID.class); ServerID node2 = mock(ServerID.class);
map.put(node1, onePassive); map.put(node1, onePassive);
map.put(node2, twoPassive); map.put(node2, twoPassive);
ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll); ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll);
Interlock interlock = new Interlock(2); Interlock interlock = new Interlock(2);
LockStep lockStep1 = new LockStep(waiter, interlock); LockStep lockStep1 = new LockStep(waiter, interlock);
LockStep lockStep2 = new LockStep(waiter, interlock); LockStep lockStep2 = new LockStep(waiter, interlock);
lockStep1.start(); lockStep1.start();
lockStep2.start(); lockStep2.start();
skipping to change at line 141 skipping to change at line 142
Assert.assertFalse(waiterIsDone); Assert.assertFalse(waiterIsDone);
waiterIsDone = waiter.didCompleteOnPassive(node1, ReplicationResultCode.SUCC ESS); waiterIsDone = waiter.didCompleteOnPassive(node1, ReplicationResultCode.SUCC ESS);
Assert.assertTrue(waiterIsDone); Assert.assertTrue(waiterIsDone);
interlock.waitOnCompletes(); interlock.waitOnCompletes();
lockStep1.join(); lockStep1.join();
lockStep2.join(); lockStep2.join();
} }
@Test @Test
public void testImplicitReceive() throws Exception { public void testImplicitReceive() throws Exception {
Map<NodeID, SessionID> map = new HashMap<>(); Map<ServerID, SessionID> map = new HashMap<>();
Set<SessionID> passives = new HashSet<>(); Set<SessionID> passives = new HashSet<>();
SessionID onePassive = mock(SessionID.class); SessionID onePassive = mock(SessionID.class);
passives.add(onePassive); passives.add(onePassive);
SessionID twoPassive = mock(SessionID.class); SessionID twoPassive = mock(SessionID.class);
passives.add(twoPassive); passives.add(twoPassive);
NodeID node1 = mock(NodeID.class); ServerID node1 = mock(ServerID.class);
NodeID node2 = mock(NodeID.class); ServerID node2 = mock(ServerID.class);
map.put(node1, onePassive); map.put(node1, onePassive);
map.put(node2, twoPassive); map.put(node2, twoPassive);
ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll); ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll);
Interlock interlock = new Interlock(1); Interlock interlock = new Interlock(1);
LockStep lockStep = new LockStep(waiter, interlock); LockStep lockStep = new LockStep(waiter, interlock);
lockStep.start(); lockStep.start();
interlock.waitOnStarts(); interlock.waitOnStarts();
boolean waiterIsDone = waiter.didCompleteOnPassive(node2, ReplicationResultC ode.SUCCESS); boolean waiterIsDone = waiter.didCompleteOnPassive(node2, ReplicationResultC ode.SUCCESS);
Assert.assertFalse(waiterIsDone); Assert.assertFalse(waiterIsDone);
waiterIsDone = waiter.didCompleteOnPassive(node1, ReplicationResultCode.SUCC ESS); waiterIsDone = waiter.didCompleteOnPassive(node1, ReplicationResultCode.SUCC ESS);
Assert.assertTrue(waiterIsDone); Assert.assertTrue(waiterIsDone);
interlock.waitOnCompletes(); interlock.waitOnCompletes();
lockStep.join(); lockStep.join();
} }
@Test @Test
public void testFailedDoubleComplete() throws Exception { public void testFailedDoubleComplete() throws Exception {
Map<NodeID, SessionID> map = new HashMap<>(); Map<ServerID, SessionID> map = new HashMap<>();
Set<SessionID> passives = new HashSet<>(); Set<SessionID> passives = new HashSet<>();
SessionID onePassive = mock(SessionID.class); SessionID onePassive = mock(SessionID.class);
passives.add(onePassive); passives.add(onePassive);
NodeID node1 = mock(NodeID.class); ServerID node1 = mock(ServerID.class);
map.put(node1, onePassive); map.put(node1, onePassive);
ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll); ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll);
Interlock interlock = new Interlock(1); Interlock interlock = new Interlock(1);
LockStep lockStep = new LockStep(waiter, interlock); LockStep lockStep = new LockStep(waiter, interlock);
lockStep.start(); lockStep.start();
interlock.waitOnStarts(); interlock.waitOnStarts();
waiter.didReceiveOnPassive(node1); waiter.didReceiveOnPassive(node1);
interlock.waitOnReceivesOnly(); interlock.waitOnReceivesOnly();
boolean waiterIsDone = waiter.didCompleteOnPassive(node1, ReplicationResultC ode.SUCCESS); boolean waiterIsDone = waiter.didCompleteOnPassive(node1, ReplicationResultC ode.SUCCESS);
skipping to change at line 198 skipping to change at line 199
// We expect this to fail on double-complete. // We expect this to fail on double-complete.
didFail = true; didFail = true;
} }
Assert.assertTrue(didFail); Assert.assertTrue(didFail);
interlock.waitOnCompletes(); interlock.waitOnCompletes();
lockStep.join(); lockStep.join();
} }
@Test @Test
public void testDisconnectAfterComplete() throws Exception { public void testDisconnectAfterComplete() throws Exception {
Map<NodeID, SessionID> map = new HashMap<>(); Map<ServerID, SessionID> map = new HashMap<>();
Set<SessionID> passives = new HashSet<>(); Set<SessionID> passives = new HashSet<>();
SessionID onePassive = mock(SessionID.class); SessionID onePassive = mock(SessionID.class);
passives.add(onePassive); passives.add(onePassive);
NodeID node1 = mock(NodeID.class); ServerID node1 = mock(ServerID.class);
map.put(node1, onePassive); map.put(node1, onePassive);
ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll); ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll);
Interlock interlock = new Interlock(1); Interlock interlock = new Interlock(1);
LockStep lockStep = new LockStep(waiter, interlock); LockStep lockStep = new LockStep(waiter, interlock);
lockStep.start(); lockStep.start();
interlock.waitOnStarts(); interlock.waitOnStarts();
waiter.didReceiveOnPassive(node1); waiter.didReceiveOnPassive(node1);
interlock.waitOnReceivesOnly(); interlock.waitOnReceivesOnly();
boolean waiterIsDone = waiter.didCompleteOnPassive(node1, ReplicationResultC ode.SUCCESS); boolean waiterIsDone = waiter.didCompleteOnPassive(node1, ReplicationResultC ode.SUCCESS);
Assert.assertTrue(waiterIsDone); Assert.assertTrue(waiterIsDone);
// We will try to complete, again, but this won't assert, since we are stati ng that it is not a normal complete. // We will try to complete, again, but this won't assert, since we are stati ng that it is not a normal complete.
waiterIsDone = waiter.failedToSendToPassive(onePassive); waiterIsDone = waiter.failedToSendToPassive(onePassive);
Assert.assertTrue(waiterIsDone); Assert.assertTrue(waiterIsDone);
interlock.waitOnCompletes(); interlock.waitOnCompletes();
lockStep.join(); lockStep.join();
} }
@Test @Test
public void testDisconnectRunsFinalizer() throws Exception { public void testDisconnectRunsFinalizer() throws Exception {
Map<NodeID, SessionID> map = new HashMap<>(); Map<ServerID, SessionID> map = new HashMap<>();
Set<SessionID> passives = new HashSet<>(); Set<SessionID> passives = new HashSet<>();
SessionID onePassive = mock(SessionID.class); SessionID onePassive = mock(SessionID.class);
passives.add(onePassive); passives.add(onePassive);
NodeID node1 = mock(NodeID.class); ServerID node1 = mock(ServerID.class);
map.put(node1, onePassive); map.put(node1, onePassive);
SetOnceFlag checkMark = new SetOnceFlag(); SetOnceFlag checkMark = new SetOnceFlag();
ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll); ActivePassiveAckWaiter waiter = new ActivePassiveAckWaiter(map, passives, nu ll);
waiter.runWhenCompleted(checkMark::set); waiter.runWhenCompleted(checkMark::set);
Interlock interlock = new Interlock(1); Interlock interlock = new Interlock(1);
LockStep lockStep = new LockStep(waiter, interlock); LockStep lockStep = new LockStep(waiter, interlock);
lockStep.start(); lockStep.start();
interlock.waitOnStarts(); interlock.waitOnStarts();
 End of changes. 15 change blocks. 
17 lines changed or deleted 18 lines changed or added

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