|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.OutputStream | +--ninja.activeproxy.path.io.PathOutputStream
The PathOutputStream 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 | |
Operator |
operator
|
java.io.OutputStream |
outputStream
|
java.lang.Object |
pathID
|
boolean |
rebuildFlag
|
Constructor Summary | |
PathOutputStream()
Default constructor |
|
PathOutputStream(Operator operator,
java.lang.Object pathID,
java.io.OutputStream outputStream)
Create a new PathOutputStream from the provided output stream. |
Method Summary | |
void |
close()
|
void |
flush()
|
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
The write method -- called too handle data output on this stream. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public Operator operator
public java.lang.Object pathID
public java.io.OutputStream outputStream
public boolean rebuildFlag
Constructor Detail |
public PathOutputStream()
public PathOutputStream(Operator operator, java.lang.Object pathID, java.io.OutputStream outputStream)
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.outputStream
- The stream which we're wrappingMethod Detail |
public void write(int b) throws java.io.IOException
Basically works as follows:
1) call outputStream.write() to push the specified byte onto the stream
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"
b
- A byte of data to writePathInterruptedException: 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 void write(byte[] b) throws java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
public void flush() throws java.io.IOException
public void close() throws java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |