"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "common/src/test/java/com/tc/net/core/NoReconnectThreadTest.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.

NoReconnectThreadTest.java  (terracotta-core-5.7.0):NoReconnectThreadTest.java  (terracotta-core-5.7.1)
skipping to change at line 40 skipping to change at line 40
import com.tc.net.protocol.tcm.CommunicationsManager; import com.tc.net.protocol.tcm.CommunicationsManager;
import com.tc.net.protocol.tcm.CommunicationsManagerImpl; import com.tc.net.protocol.tcm.CommunicationsManagerImpl;
import com.tc.net.protocol.tcm.GeneratedMessageFactory; import com.tc.net.protocol.tcm.GeneratedMessageFactory;
import com.tc.net.protocol.tcm.MessageChannel; import com.tc.net.protocol.tcm.MessageChannel;
import com.tc.net.protocol.tcm.NetworkListener; import com.tc.net.protocol.tcm.NetworkListener;
import com.tc.net.protocol.tcm.NullMessageMonitor; import com.tc.net.protocol.tcm.NullMessageMonitor;
import com.tc.net.protocol.tcm.TCMessage; import com.tc.net.protocol.tcm.TCMessage;
import com.tc.net.protocol.tcm.TCMessageRouterImpl; import com.tc.net.protocol.tcm.TCMessageRouterImpl;
import com.tc.net.protocol.tcm.TCMessageType; import com.tc.net.protocol.tcm.TCMessageType;
import com.tc.net.protocol.transport.ClientConnectionEstablisher; import com.tc.net.protocol.transport.ClientConnectionEstablisher;
import com.tc.net.protocol.transport.ConnectionID;
import com.tc.net.protocol.transport.DefaultConnectionIdFactory; import com.tc.net.protocol.transport.DefaultConnectionIdFactory;
import com.tc.net.protocol.transport.HealthCheckerConfigImpl; import com.tc.net.protocol.transport.HealthCheckerConfigImpl;
import com.tc.net.protocol.transport.MessageTransport; import com.tc.net.protocol.transport.MessageTransport;
import com.tc.net.protocol.transport.NullConnectionPolicy; import com.tc.net.protocol.transport.NullConnectionPolicy;
import com.tc.net.protocol.transport.TransportHandshakeErrorNullHandler; import com.tc.net.protocol.transport.TransportHandshakeErrorNullHandler;
import com.tc.net.proxy.TCPProxy; import com.tc.net.proxy.TCPProxy;
import com.tc.object.session.NullSessionManager; import com.tc.object.session.NullSessionManager;
import com.tc.properties.TCPropertiesImpl; import com.tc.properties.TCPropertiesImpl;
import com.tc.test.TCTestCase; import com.tc.test.TCTestCase;
import com.tc.util.PortChooser; import com.tc.util.TCTimeoutException;
import com.tc.util.concurrent.ThreadUtil; import com.tc.util.concurrent.ThreadUtil;
import com.tc.util.runtime.ThreadDumpUtil; import com.tc.util.runtime.ThreadDumpUtil;
import com.tc.properties.TCPropertiesConsts; import com.tc.properties.TCPropertiesConsts;
import com.tc.util.Assert; import com.tc.util.Assert;
import org.terracotta.utilities.test.net.PortManager;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class NoReconnectThreadTest extends TCTestCase implements ChannelEventLis tener { public class NoReconnectThreadTest extends TCTestCase implements ChannelEventLis tener {
private final int L1_RECONNECT_TIMEOUT = 5000; private final int L1_RECONNECT_TIMEOUT = 5000;
private final AtomicInteger connections = new AtomicInteger(0); private final AtomicInteger connections = new AtomicInteger(0);
skipping to change at line 118 skipping to change at line 119
.ge tProperties() .ge tProperties()
.ge tPropertiesFor(TCPropertiesConsts.L2_L2_HEALTH_CHECK_CATEGORY), .ge tPropertiesFor(TCPropertiesConsts.L2_L2_HEALTH_CHECK_CATEGORY),
"Test Server"), "Test Server"),
new Ser verID(), new Ser verID(),
new Tra nsportHandshakeErrorNullHandler(), new Tra nsportHandshakeErrorNullHandler(),
Collect ions.<TCMessageType, Class<? extends TCMessage>>emptyMap(), Collect ions.<TCMessageType, Class<? extends TCMessage>>emptyMap(),
Collect ions.<TCMessageType, GeneratedMessageFactory>emptyMap() Collect ions.<TCMessageType, GeneratedMessageFactory>emptyMap()
); );
NetworkListener listener = serverCommsMgr.createListener(new TCSocketAddress (0), true, NetworkListener listener = serverCommsMgr.createListener(new TCSocketAddress (0), true,
new DefaultConnecti onIdFactory(), (MessageTransport t)->true); new DefaultConnecti onIdFactory(), (MessageTransport t)->true);
listener.start(Collections.<ConnectionID>emptySet()); listener.start(Collections.emptySet());
int serverPort = listener.getBindPort(); try {
int serverPort = listener.getBindPort();
int proxyPort = new PortChooser().chooseRandomPort();
TCPProxy proxy = new TCPProxy(proxyPort, InetAddress.getByName("localhost"), try (PortManager.PortRef portRef = PortManager.getInstance().reservePort()
serverPort, 0, false, null); ) {
proxy.start(); int proxyPort = portRef.port();
TCPProxy proxy = new TCPProxy(proxyPort, InetAddress.getByName("localhos
ClientMessageChannel client1 = createClientMsgCh(); t"), serverPort, 0, false, null);
ClientMessageChannel client2 = createClientMsgCh(); try {
ClientMessageChannel client3 = createClientMsgCh(); proxy.start();
InetSocketAddress serverAddress = new InetSocketAddress("localhost", proxyPo ClientMessageChannel client1 = createClientMsgCh();
rt); ClientMessageChannel client2 = createClientMsgCh();
ClientMessageChannel client3 = createClientMsgCh();
client1.addListener(this);
client1.open(serverAddress); InetSocketAddress serverAddress = new InetSocketAddress("localhost", p
roxyPort);
client2.addListener(this);
client2.open(serverAddress); client1.addListener(this);
client1.open(serverAddress);
client3.addListener(this);
client3.open(serverAddress); client2.addListener(this);
client2.open(serverAddress);
ThreadUtil.reallySleep(2000);
assertTrue(client1.isConnected()); client3.addListener(this);
assertTrue(client2.isConnected()); client3.open(serverAddress);
assertTrue(client3.isConnected());
ThreadUtil.reallySleep(2000);
// closing all connections from server side assertTrue(client1.isConnected());
System.err.println("XXX closing all client connections"); assertTrue(client2.isConnected());
serverCommsMgr.getConnectionManager().closeAllConnections(1000); assertTrue(client3.isConnected());
while (connections.get() != 0) { // closing all connections from server side
ThreadUtil.reallySleep(2000); System.err.println("XXX closing all client connections");
System.err.println("."); serverCommsMgr.getConnectionManager().closeAllConnections(1000);
}
while (connections.get() != 0) {
// None of the clients should start the ClientConnectionEstablisher Thread f ThreadUtil.reallySleep(2000);
or reconnect as the Client System.err.println(".");
// CommsManager is created with reconnect 0. we might need to wait till the }
created CCE gets quit request.
while (getThreadCount(ClientConnectionEstablisher.RECONNECT_THREAD_NAME) > b // None of the clients should start the ClientConnectionEstablisher Th
aseAsyncThreads) { read for reconnect as the Client
ThreadUtil.reallySleep(1000); // CommsManager is created with reconnect 0. we might need to wait til
System.err.println("-"); l the created CCE gets quit request.
while (getThreadCount(ClientConnectionEstablisher.RECONNECT_THREAD_NAM
E) > baseAsyncThreads) {
ThreadUtil.reallySleep(1000);
System.err.println("-");
}
} finally {
proxy.stop();
}
}
} finally {
try {
listener.stop(5000);
} catch (TCTimeoutException e) {
// ignored
}
serverCommsMgr.shutdown();
connectionMgr.shutdown();
} }
listener.stop(5000);
serverCommsMgr.shutdown();
connectionMgr.shutdown();
} }
private int getThreadCount(String absentThreadName) { private int getThreadCount(String absentThreadName) {
Thread[] allThreads = ThreadDumpUtil.getAllThreads(); Thread[] allThreads = ThreadDumpUtil.getAllThreads();
int count = 0; int count = 0;
for (Thread t : allThreads) { for (Thread t : allThreads) {
if (t.getName().contains(absentThreadName)) { if (t.getName().contains(absentThreadName)) {
count++; count++;
} }
} }
 End of changes. 5 change blocks. 
52 lines changed or deleted 66 lines changed or added

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