Package edu.jas.util

Class ExecutableChannels

java.lang.Object
edu.jas.util.ExecutableChannels

public class ExecutableChannels extends Object
ExecutableChannels used to receive and execute classes.
  • Field Details

    • logger

      private static final org.apache.logging.log4j.Logger logger
    • DEFAULT_PORT

      protected static final int DEFAULT_PORT
      default port.
      See Also:
    • DEFAULT_MFILE

      protected static final String DEFAULT_MFILE
      default machine file.
      See Also:
    • cf

      protected final ChannelFactory cf
    • channels

      protected SocketChannel[] channels
    • servers

      protected String[] servers
    • ports

      protected int[] ports
  • Constructor Details

    • ExecutableChannels

      protected ExecutableChannels()
      Internal constructor.
    • ExecutableChannels

      public ExecutableChannels(String[] srvs)
      Constructor from array of server:port strings.
      Parameters:
      srvs - A String array.
    • ExecutableChannels

      public ExecutableChannels(String mfile) throws FileNotFoundException
      Constructor from machine file.
      Parameters:
      mfile -
      Throws:
      FileNotFoundException
  • Method Details

    • setServerPort

      protected void setServerPort(int i, String srv)
    • toString

      public String toString()
      String representation.
      Overrides:
      toString in class Object
    • numServers

      public int numServers()
      number of servers.
    • getMasterHost

      public String getMasterHost()
      get master host.
    • getMasterPort

      public int getMasterPort()
      get master port.
    • numChannels

      public int numChannels()
      number of channels.
    • open

      public void open() throws IOException
      open, setup of SocketChannels.
      Throws:
      IOException
    • open

      public void open(int nc) throws IOException
      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

      public SocketChannel getChannel(int i)
      getChannel.
      Parameters:
      i - channel number.
    • getChannels

      SocketChannel[] getChannels()
      getChannels.
    • send

      public void send(int i, Object o) throws IOException
      send on channel i.
      Parameters:
      i - channel number.
      o - object to send.
      Throws:
      IOException
    • receive

      public Object receive(int i) throws IOException, ClassNotFoundException
      receive on channel i.
      Parameters:
      i - channel number.
      Returns:
      object received.
      Throws:
      IOException
      ClassNotFoundException