Package edu.jas.util
Class ExecutableChannels
java.lang.Object
edu.jas.util.ExecutableChannels
ExecutableChannels used to receive and execute classes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ChannelFactory
protected SocketChannel[]
protected static final String
default machine file.protected static final int
default port.private static final org.apache.logging.log4j.Logger
protected int[]
protected String[]
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Internal constructor.ExecutableChannels
(String mfile) Constructor from machine file.ExecutableChannels
(String[] srvs) Constructor from array of server:port strings. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
close all channels and ChannelFactory.getChannel
(int i) getChannel.(package private) SocketChannel[]
getChannels.get master host.int
get master port.int
number of channels.int
number of servers.void
open()
open, setup of SocketChannels.void
open
(int nc) open, setup of SocketChannels.receive
(int i) receive on channel i.void
send on channel i.protected void
setServerPort
(int i, String srv) toString()
String representation.
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger -
DEFAULT_PORT
protected static final int DEFAULT_PORTdefault port.- See Also:
-
DEFAULT_MFILE
default machine file.- See Also:
-
cf
-
channels
-
servers
-
ports
protected int[] ports
-
-
Constructor Details
-
ExecutableChannels
protected ExecutableChannels()Internal constructor. -
ExecutableChannels
Constructor from array of server:port strings.- Parameters:
srvs
- A String array.
-
ExecutableChannels
Constructor from machine file.- Parameters:
mfile
-- Throws:
FileNotFoundException
-
-
Method Details
-
setServerPort
-
toString
String representation. -
numServers
public int numServers()number of servers. -
getMasterHost
get master host. -
getMasterPort
public int getMasterPort()get master port. -
numChannels
public int numChannels()number of channels. -
open
open, setup of SocketChannels.- Throws:
IOException
-
open
open, setup of SocketChannels. If nc > servers.length open in round robin fashion.- Parameters:
nc
- number of channels to open.- Throws:
IOException
-
close
public void close()close all channels and ChannelFactory. -
getChannel
getChannel.- Parameters:
i
- channel number.
-
getChannels
SocketChannel[] getChannels()getChannels. -
send
send on channel i.- Parameters:
i
- channel number.o
- object to send.- Throws:
IOException
-
receive
receive on channel i.- Parameters:
i
- channel number.- Returns:
- object received.
- Throws:
IOException
ClassNotFoundException
-