com.ace.moab.api.connect
Class MoabInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.ace.moab.api.connect.MoabInputStream
All Implemented Interfaces:
java.io.Closeable

public class MoabInputStream
extends java.io.InputStream

This class is essentially a wrapper for the standard out stream that come from running a moab command. However, it contains some optional information like the command that was run and a reference to the error stream (comes from standard error) to help MCM properly report the results of this command if desired. If the command is run over SSH or from a jar file, the errorStream will be null because the error stream data will be included with the input. If running on the local machine, the error stream may be separate from the input stream.

Author:
seeleyn

Constructor Summary
MoabInputStream()
          creates an empty moab input stream
MoabInputStream(java.io.InputStream inStream, java.io.InputStream errStream, java.lang.String cmd)
          Creates a new instance
 
Method Summary
 int available()
          Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
 void close()
          Closes the input stream
 void closeAll()
          Closes both the input and error stream
 java.lang.String getCommand()
          The moab command that was run to create this input stream
 java.io.InputStream getErrorStream()
          returns the error stream from running the moab client command if the command was run on the local host
 int getExitCode()
          Returns the exit code returned from the process or session that returned this Moab input stream.
 void mark(int readlimit)
          Marks the current position in this input stream.
 boolean markSupported()
          Tests if this input stream supports the mark and reset methods.
 int read()
          reads a byte from the inputStream, which comes from the standard out of the moab client command.
 int read(byte[] b)
          Reads some number of bytes from the input stream and stores them into the buffer array b
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from the input stream into an array of bytes.
 void reset()
          Repositions this stream to the position at the time the mark method was last called on this input stream
 void setExitCode(int exitcode)
          Sets the exit code returned from the process or session that returned this Moab input stream.
 long skip(long n)
          Skips over and discards n bytes of data from this input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MoabInputStream

public MoabInputStream()
creates an empty moab input stream


MoabInputStream

public MoabInputStream(java.io.InputStream inStream,
                       java.io.InputStream errStream,
                       java.lang.String cmd)
Creates a new instance

Parameters:
inStream - the standard out stream (or ssh stream or demo jar stream)
errStream -
Method Detail

read

public int read()
         throws java.io.IOException
reads a byte from the inputStream, which comes from the standard out of the moab client command. (If running over SSH or a demo jar, the error stream an the input stream from the moab client command are combined)

Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

getErrorStream

public java.io.InputStream getErrorStream()
returns the error stream from running the moab client command if the command was run on the local host


getCommand

public java.lang.String getCommand()
The moab command that was run to create this input stream


closeAll

public void closeAll()
Closes both the input and error stream

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes the input stream

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.

Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

mark

public void mark(int readlimit)
Marks the current position in this input stream.

Overrides:
mark in class java.io.InputStream

markSupported

public boolean markSupported()
Tests if this input stream supports the mark and reset methods.

Overrides:
markSupported in class java.io.InputStream

read

public int read(byte[] b)
         throws java.io.IOException
Reads some number of bytes from the input stream and stores them into the buffer array b

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from the input stream into an array of bytes.

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

reset

public void reset()
           throws java.io.IOException
Repositions this stream to the position at the time the mark method was last called on this input stream

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Skips over and discards n bytes of data from this input stream.

Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

getExitCode

public int getExitCode()
Returns the exit code returned from the process or session that returned this Moab input stream.

Returns:
the exit code returned from the process or session that returned this Moab input stream.

setExitCode

public void setExitCode(int exitcode)
Sets the exit code returned from the process or session that returned this Moab input stream.

Parameters:
exitcode - the exit code returned from the process or session that returned this Moab input stream.


Copyright © 2001-2009 Cluster Resources, Inc. All Rights Reserved.