use of ClientServerCommunication.ThreadPooledServer in project SmartCity-Market by TechnionYP5777.
the class Main method main.
public static void main(String[] args) {
if (!parseArguments(args))
return;
/* Setting log properties */
PropertyConfigurator.configure("../log4j.properties");
log.setLevel(verbosity);
CommandProcess commandProcess = new CommandProcess();
ThreadPooledServer server = null;
try {
server = new ThreadPooledServer(port, numOfThreads, commandProcess, serverIP);
} catch (UnknownHostException e1) {
log.fatal("Server IP address leads to unknown host, server won't start.");
return;
}
SQLDatabaseConnection connection = new SQLDatabaseConnection();
log.info("Disconnect from all clients");
try {
connection.logoutAllUsers();
connection.close();
} catch (CriticalError e1) {
log.fatal("Disconnect failed");
return;
}
log.info("Starting Server.");
new Thread(server).start();
try {
Thread.sleep(1000 * timeout);
} catch (InterruptedException e) {
/* Get interrupt to stop server */
log.info("Server Got interrupted.");
}
log.info("Stopping server.");
server.stop();
}
use of ClientServerCommunication.ThreadPooledServer in project SmartCity-Market by TechnionYP5777.
the class ThreadPooledServerTest method ServerWorkerRunnableHelloWorldIPTest.
@Test
public void ServerWorkerRunnableHelloWorldIPTest() {
ProcessRequestTester processRequestTester = new ProcessRequestTester();
ThreadPooledServer server = null;
try {
server = new ThreadPooledServer(SERVER_PORT, 1, processRequestTester, SERVER_HOST_IP);
} catch (UnknownHostException e1) {
fail();
}
Thread client;
new Thread(server).start();
while (server.isStopped()) {
}
client = new Thread(new ClientRunner(SERVER_HOST_IP));
client.start();
try {
client.join();
} catch (InterruptedException e) {
fail();
}
server.stop();
}
use of ClientServerCommunication.ThreadPooledServer in project SmartCity-Market by TechnionYP5777.
the class ThreadPooledServerTest method ServerWorkerRunnableHelloWorldLocalTest.
@Test
public void ServerWorkerRunnableHelloWorldLocalTest() {
ProcessRequestTester processRequestTester = new ProcessRequestTester();
ThreadPooledServer server = null;
try {
server = new ThreadPooledServer(SERVER_PORT, 1, processRequestTester);
} catch (UnknownHostException e1) {
fail();
}
Thread client;
new Thread(server).start();
/* waiting for server to run */
while (server.isStopped()) {
}
client = new Thread(new ClientRunner(SERVER_HOST_NAME_LOCAL));
client.start();
try {
client.join();
} catch (InterruptedException e) {
fail();
}
server.stop();
}
Aggregations