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 ChannelFactory
cf
protected SocketChannel[]
channels
protected static java.lang.String
DEFAULT_MFILE
default machine file.protected static int
DEFAULT_PORT
default port.protected int[]
ports
protected java.lang.String[]
servers
-
Constructor Summary
Constructors Modifier Constructor Description protected
ExecutableChannels()
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 void
close()
close all channels and ChannelFactory.SocketChannel
getChannel(int i)
getChannel.java.lang.String
getMasterHost()
get master host.int
getMasterPort()
get master port.int
numChannels()
number of channels.int
numServers()
number of servers.void
open()
open, setup of SocketChannels.void
open(int nc)
open, setup of SocketChannels.java.lang.Object
receive(int i)
receive on channel i.void
send(int i, java.lang.Object o)
send on channel i.protected void
setServerPort(int i, java.lang.String srv)
java.lang.String
toString()
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:
toString
in 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
receive on channel i.- Parameters:
i
- channel number.- Returns:
- object received.
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
-