public class ZLogstream
extends java.lang.Object
Refer to "z/OS MVS Programming: Assembler Services Guide" - SA22-7605 for more information on defining and using z/OS Logstreams, aka "the z/OS System Logger".
Note:If a Java security manager is active, it is used to check permissions for writing to a resource path name generated from the logstream name. For a logstream named "XXX.YYY.ZZZ", a pathname of "/LOGSTREAM/XXX/YYY/XXX" is used.
ZLogstreamException
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_RETRY_SLEEP_MS
The time, in milliseconds to sleep between retries
|
static int |
DEFAULT_WRITE_RETRY_COUNT
The count for retries certain write errors
|
Constructor and Description |
---|
ZLogstream(java.lang.String name)
Constructor that creates a ZLogstream instance wrapper and connects
to the named z/OS Logstream.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this ZLogstream by disconnecting from the z/OS Logstream.
|
java.lang.String |
getName()
Answers the name of the logstream
|
long |
getRetrySleepTimeMs()
Answers the time to sleep in ms between retries
|
byte[] |
getToken()
Answers the 16-byte logstream token
|
int |
getWriteRetryCount()
Answers the default retry count for certain kinds of write errors
|
void |
setRetrySleepTimeMs(long retryTimeMs)
Sets the time to sleep in ms between retries
|
void |
setWriteRetryCount(int writeRetryCount)
Sets the default retry count for certain kinds of write errors
|
java.lang.String |
toString()
Answer a String representation of the receiver
|
void |
write(byte[] bytes,
int offset,
int len,
boolean sync)
Writes bytes to the ZLogstream by disconnecting from the z/OS Logstream.
|
public static final int DEFAULT_WRITE_RETRY_COUNT
public static final long DEFAULT_RETRY_SLEEP_MS
public ZLogstream(java.lang.String name) throws ZLogstreamException
This method calls the IXGCONN macro to create a connection to the named logstream.
name
- the name of the z/OS logstream to open, length <= 26 charactersZLogstreamException
- if the logstream could not be connectedjava.lang.SecurityException
- if a SecurityManager is active and the required
permission is not granted based on the policy
in effect. Thepublic void close() throws ZLogstreamException
This method calls the IXGCONN macro to disconnect from the logstream. This method does nothing if the ZLogstream has already been closed.
ZLogstreamException
- if there was an error disconnecting.public void write(byte[] bytes, int offset, int len, boolean sync) throws ZLogstreamException
This method calls the IXGWRITE macro to write bytes to the logstream. If a RC=8/082D error occurs (Invalid Token), then try to reconnect to the logstream and retry. If a RC=8/0868 occurs (Stage Formatting not Finished), sleep a little (retryTimeMs) and retry for up to writeRetryCount times.
bytes
- the byte array containing the raw block to write via IXGWRITEoffset
- the offset in bytes to beginning of block to writelen
- the length of the block to writesync
- if true, use IXGWRITE MODE=SYNC, otherwise MODE=ASYNCNORESPONSEZLogstreamException
- if there was an error from IXGWRITE, or possibly IXGCONN on a reconnectsetWriteRetryCount(int)
,
setRetrySleepTimeMs(long)
public java.lang.String getName()
public byte[] getToken()
public int getWriteRetryCount()
public void setWriteRetryCount(int writeRetryCount)
public long getRetrySleepTimeMs()
public void setRetrySleepTimeMs(long retryTimeMs)
public java.lang.String toString()
toString
in class java.lang.Object