Package edu.jas.util
Class ExecutableChannels
- java.lang.Object
-
- edu.jas.util.ExecutableChannels
-
public class ExecutableChannels extends java.lang.Object
ExecutableChannels used to receive and execute classes.- Author:
- Heinz Kredel
-
-
Field Summary
Fields Modifier and Type Field Description protected ChannelFactorycfprotected SocketChannel[]channelsprotected static java.lang.StringDEFAULT_MFILEdefault machine file.protected static intDEFAULT_PORTdefault port.protected int[]portsprotected java.lang.String[]servers
-
Constructor Summary
Constructors Modifier Constructor Description protectedExecutableChannels()Internal constructor.ExecutableChannels(java.lang.String mfile)Constructor from machine file.ExecutableChannels(java.lang.String[] srvs)Constructor from array of server:port strings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()close all channels and ChannelFactory.SocketChannelgetChannel(int i)getChannel.java.lang.StringgetMasterHost()get master host.intgetMasterPort()get master port.intnumChannels()number of channels.intnumServers()number of servers.voidopen()open, setup of SocketChannels.voidopen(int nc)open, setup of SocketChannels.java.lang.Objectreceive(int i)recieve on channel i.voidsend(int i, java.lang.Object o)send on channel i.protected voidsetServerPort(int i, java.lang.String srv)java.lang.StringtoString()String representation.
-
-
-
Field Detail
-
DEFAULT_PORT
protected static final int DEFAULT_PORT
default port.- See Also:
- Constant Field Values
-
DEFAULT_MFILE
protected static final java.lang.String DEFAULT_MFILE
default machine file.- See Also:
- Constant Field Values
-
cf
protected final ChannelFactory cf
-
channels
protected SocketChannel[] channels
-
servers
protected java.lang.String[] servers
-
ports
protected int[] ports
-
-
Constructor Detail
-
ExecutableChannels
protected ExecutableChannels()
Internal constructor.
-
ExecutableChannels
public ExecutableChannels(java.lang.String[] srvs)
Constructor from array of server:port strings.- Parameters:
srvs- A String array.
-
ExecutableChannels
public ExecutableChannels(java.lang.String mfile) throws java.io.FileNotFoundException
Constructor from machine file.- Parameters:
mfile-- Throws:
java.io.FileNotFoundException
-
-
Method Detail
-
setServerPort
protected void setServerPort(int i, java.lang.String srv)
-
toString
public java.lang.String toString()
String representation.- Overrides:
toStringin classjava.lang.Object
-
numServers
public int numServers()
number of servers.
-
getMasterHost
public java.lang.String getMasterHost()
get master host.
-
getMasterPort
public int getMasterPort()
get master port.
-
numChannels
public int numChannels()
number of channels.
-
open
public void open() throws java.io.IOException
open, setup of SocketChannels.- Throws:
java.io.IOException
-
open
public void open(int nc) throws java.io.IOException
open, setup of SocketChannels. If nc > servers.length open in round robin fashion.- Parameters:
nc- number of channels to open.- Throws:
java.io.IOException
-
close
public void close()
close all channels and ChannelFactory.
-
getChannel
public SocketChannel getChannel(int i)
getChannel.- Parameters:
i- channel number.
-
send
public void send(int i, java.lang.Object o) throws java.io.IOException
send on channel i.- Parameters:
i- channel number.o- object to send.- Throws:
java.io.IOException
-
receive
public java.lang.Object receive(int i) throws java.io.IOException, java.lang.ClassNotFoundException
recieve on channel i.- Parameters:
i- channel number.- Returns:
- object recieved.
- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-