Change single server socket to one for DMTP and one for DMAP
This commit is contained in:
parent
7d75217dbe
commit
7397ee95c4
@ -14,9 +14,11 @@ import dslab.util.Config;
|
|||||||
|
|
||||||
public class MailboxServer implements IMailboxServer, Runnable {
|
public class MailboxServer implements IMailboxServer, Runnable {
|
||||||
private static final Logger logger = Logger.getLogger(MailboxServer.class.getName());
|
private static final Logger logger = Logger.getLogger(MailboxServer.class.getName());
|
||||||
private ServerSocket serverSocket;
|
private ServerSocket dmtpServerSocket;
|
||||||
|
private ServerSocket dmapServerSocket;
|
||||||
private final Shell shell;
|
private final Shell shell;
|
||||||
private final Integer serverPort;
|
private final Integer dmtpServerPort;
|
||||||
|
private final Integer dmapServerPort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new server instance.
|
* Creates a new server instance.
|
||||||
@ -31,16 +33,18 @@ public class MailboxServer implements IMailboxServer, Runnable {
|
|||||||
this.shell = new Shell(in, out);
|
this.shell = new Shell(in, out);
|
||||||
this.shell.register(this);
|
this.shell.register(this);
|
||||||
this.shell.setPrompt("Mailboxserver> ");
|
this.shell.setPrompt("Mailboxserver> ");
|
||||||
this.serverPort = config.getInt("tcp.port");
|
this.dmtpServerPort = config.getInt("dmtp.tcp.port");
|
||||||
|
this.dmapServerPort = config.getInt("dmap.tcp.port");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
logger.info("Creating serverSocket for " + this.toString());
|
logger.info("Creating DMTP serverSocket for TransferServer + " + this.toString());
|
||||||
try {
|
try {
|
||||||
this.serverSocket = new ServerSocket(serverPort);
|
this.dmtpServerSocket = new ServerSocket(dmtpServerPort);
|
||||||
|
this.dmapServerSocket = new ServerSocket(dmapServerPort);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.severe("Error creating serverSocket " + serverSocket.toString());
|
logger.severe("Error creating one of the two server sockets");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
@ -53,10 +57,18 @@ public class MailboxServer implements IMailboxServer, Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
try {
|
try {
|
||||||
if (serverSocket != null)
|
if (dmtpServerSocket != null)
|
||||||
serverSocket.close();
|
dmtpServerSocket.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.severe("Error closing serverSocket " + serverSocket.toString());
|
logger.severe("Error closing DMTP serverSocket " + dmtpServerSocket.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (dmapServerSocket != null)
|
||||||
|
dmapServerSocket.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.severe("Error closing DMTP serverSocket " + dmapServerSocket.toString());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
throw new StopShellException();
|
throw new StopShellException();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user