use of com.nokia.dempsy.executor.DefaultDempsyExecutor in project Dempsy by Dempsy.
the class TcpReceiver method start.
@Override
public synchronized void start() throws MessageTransportException {
if (isStarted())
return;
// check to see that the overflowHandler and the failFast setting are consistent.
if (!failFast && overflowHandler != null)
logger.warn("TcpReceiver/TcpTransport is configured with an OverflowHandler that will never be used because it's also configured to NOT 'fail fast' so it will always block waiting for messages to be processed.");
// this sets the destination instance
getDestination();
// we need to call bind here in case the getDestination didn't do it
// (which it wont if the port is not ephemeral)
bind();
// in case this is a restart, we want to reset the stopMe value.
stopMe.set(false);
serverThread = new Thread(new Runnable() {
@Override
public void run() {
while (!stopMe.get()) {
try {
// Wait for an event one of the registered channels
Socket clientSocket = serverSocket.accept();
// So we need to lock it.
synchronized (clientThreads) {
// unless we're done.
if (!stopMe.get()) {
// This should come from a thread pool
ClientThread clientThread = makeNewClientThread(clientSocket);
Thread thread = new Thread(clientThread, "Client Handler for " + getClientDescription(clientSocket));
thread.setDaemon(true);
thread.start();
clientThreads.add(clientThread);
}
}
}// socket from another thread is the only way to make this happen.
catch (SocketException se) {
// however, if we didn't explicitly stop the server, then there's another problem
if (!stopMe.get())
logger.error("Socket error on the server managing " + destination, se);
} catch (Throwable th) {
logger.error("Major error on the server managing " + destination, th);
}
}
// we're leaving so signal
synchronized (eventLock) {
eventSignaled = true;
eventLock.notifyAll();
}
}
}, "Server for " + destination);
if (executor == null) {
DefaultDempsyExecutor defexecutor = new DefaultDempsyExecutor();
defexecutor.setCoresFactor(1.0);
defexecutor.setAdditionalThreads(1);
defexecutor.setMaxNumberOfQueuedLimitedTasks(10000);
executor = defexecutor;
iStartedIt = true;
executor.start();
}
setPendingGague();
serverThread.start();
}
use of com.nokia.dempsy.executor.DefaultDempsyExecutor in project Dempsy by Dempsy.
the class TestDempsy method testTcpTransportExecutorConfigurationThroughApplication.
@Test
public void testTcpTransportExecutorConfigurationThroughApplication() throws Throwable {
ClassPathXmlApplicationContext actx = null;
DefaultDempsyExecutor executor = null;
try {
actx = new ClassPathXmlApplicationContext("testDempsy/Dempsy-IndividualClusterStart.xml", "testDempsy/Transport-TcpNoBatchingActx.xml", "testDempsy/ClusterInfo-LocalActx.xml", "testDempsy/Serializer-KryoActx.xml", "testDempsy/SimpleMultistageApplicationWithExecutorActx.xml");
actx.registerShutdownHook();
Dempsy dempsy = (Dempsy) actx.getBean("dempsy");
for (Dempsy.Application.Cluster cluster : dempsy.applications.get(0).appClusters) {
// get the receiver from the node
TcpReceiver r = (TcpReceiver) cluster.getNodes().get(0).receiver;
executor = (DefaultDempsyExecutor) TcpReceiverAccess.getExecutor(r);
assertEquals(123456, executor.getMaxNumberOfQueuedLimitedTasks());
assertTrue(executor.isRunning());
}
} finally {
try {
actx.stop();
} catch (Throwable th) {
}
try {
actx.destroy();
} catch (Throwable th) {
}
}
assertNotNull(executor);
assertTrue(!executor.isRunning());
}
Aggregations