|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.InputStream | +--ninja.activeproxy.path.io.PathInputStream
The PathInputStream is a wrapper for a standard java InputStream which handles failure detection and recovery for Ninja paths. The general process for doing this is as follows: When an exception occurs on input or output, notify the operator passed into the constructor by calling the operator.pathFailed exception. This operator is considered to be the "path master" and is responsible for rebuilding part or all of the path when it is notified of an error.
Field Summary | |
java.io.InputStream |
inputStream
|
Operator |
operator
|
java.lang.Object |
pathID
|
boolean |
rebuildFlag
|
Fields inherited from class java.io.InputStream |
SKIP_BUFFER_SIZE,
skipBuffer |
Constructor Summary | |
PathInputStream()
Default constructor |
|
PathInputStream(Operator operator,
java.lang.Object pathID,
java.io.InputStream inputStream)
Create a new PathInputStream from the provided input stream. |
Method Summary | |
int |
available()
|
void |
close()
Same as default InputStream close method |
void |
mark(int readlimit)
Same as default InputStream mark method |
boolean |
markSupported()
Same as default InputStream markSupported method |
int |
read()
The read method -- called too handle data input on this stream. |
int |
read(byte[] b)
Try to fill array b with data. |
void |
reset()
Same as default InputStream reset method |
long |
skip(long n)
fill b with data, starting at offset off and for len bytes |
Methods inherited from class java.io.InputStream |
read |
Methods inherited from class java.lang.Object |
|
Field Detail |
public Operator operator
public java.lang.Object pathID
public java.io.InputStream inputStream
public boolean rebuildFlag
Constructor Detail |
public PathInputStream()
public PathInputStream(Operator operator, java.lang.Object pathID, java.io.InputStream inputStream)
operator
- The master operator for this path; should be notified on path failurepathID
- The pathID which this stream belongs to -- needs to be kept so the
appropriate message can be passed to the pathFailed method of the path owner.inputStream
- The stream which we're wrappingMethod Detail |
public int read() throws java.io.IOException
Basically works as follows:
1) call inputStream.read() to block for incoming data
2) if an exception occurs, call the pathFailed method of the path master
3) if the path was rebuilt, throw a "PathInterruptedException" to the stream owner
4) if the path was unable to be rebuilt, thrown a "NoPathFoundException"
PathInterruptedException: The stream owner is being notified that the path had to be rebuilt and some data may have been lost. It is currently the responsibility of the path owner to hand end-to-end delivery constraints
NoPathFoundException: The stream could not be or was not rebuilt, but isn't allowing data to flow properly. The stream owner is basically SOL, but should attept to clean up and fail gracefully.
public int read(byte[] b) throws java.io.IOException
b
- An array of bytes to fill with datapublic long skip(long n) throws java.io.IOException
b
- The array to put data intooff
- The offset to being writing data atlen
- The number of bytes to readpublic int available() throws java.io.IOException
public void close() throws java.io.IOException
public void mark(int readlimit)
public void reset() throws java.io.IOException
public boolean markSupported()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |