Package org.libvirt
Class Stream
- java.lang.Object
-
- org.libvirt.Stream
-
public class Stream extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected LibvirtlibvirtThe libvirt connection from the hypervisorstatic intVIR_STREAM_NONBLOCK
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intabort()Request that the in progress data transfer be cancelled abnormally before the end of the stream has been reachedintaddCallback(int events, Libvirt.VirStreamEventCallback cb)Register a callback to be notified when a stream becomes writable, or readable.voidfinalize()intfinish()Indicate that there is no further data is to be transmitted on the stream.intfree()Decrement the reference count on a stream, releasing the stream object if the reference count has hit zero.protected voidprocessError()Error handling logic to throw errors.intreceive(byte[] data)Receieves data from teh stream into the buffer provided.intreceiveAll(Libvirt.VirStreamSinkFunc handler)Batch receive methodintremoveCallback()Remove an event callback from the streamintsend(java.lang.String data)Write a series of bytes to the stream.intsendAll(Libvirt.VirStreamSourceFunc handler)Batch send methodintupdateCallback(int events)Changes the set of events to monitor for a stream.
-
-
-
Field Detail
-
VIR_STREAM_NONBLOCK
public static int VIR_STREAM_NONBLOCK
-
libvirt
protected Libvirt libvirt
The libvirt connection from the hypervisor
-
-
Method Detail
-
abort
public int abort() throws LibvirtExceptionRequest that the in progress data transfer be cancelled abnormally before the end of the stream has been reached- Throws:
LibvirtException
-
addCallback
public int addCallback(int events, Libvirt.VirStreamEventCallback cb) throws LibvirtExceptionRegister a callback to be notified when a stream becomes writable, or readable.- Parameters:
events- the events to monitorcb- the callback method- Returns:
- 0 for success, -1 for failure
- Throws:
LibvirtException- See Also:
- Libvirt Docs
-
finalize
public void finalize() throws LibvirtException- Overrides:
finalizein classjava.lang.Object- Throws:
LibvirtException
-
finish
public int finish() throws LibvirtExceptionIndicate that there is no further data is to be transmitted on the stream.- Returns:
- 0 if success, -1 if failure
- Throws:
LibvirtException
-
free
public int free() throws LibvirtExceptionDecrement the reference count on a stream, releasing the stream object if the reference count has hit zero.- Returns:
- 0 on success, or -1 on error.
- Throws:
LibvirtException
-
processError
protected void processError() throws LibvirtExceptionError handling logic to throw errors. Must be called after every libvirt call.- Throws:
LibvirtException
-
receive
public int receive(byte[] data) throws LibvirtExceptionReceieves data from teh stream into the buffer provided.- Parameters:
data- the put the sata into- Returns:
- the number of bytes read, -1 on error, -2 if the buffer is empty
- Throws:
LibvirtException
-
receiveAll
public int receiveAll(Libvirt.VirStreamSinkFunc handler) throws LibvirtException
Batch receive method- Parameters:
handler- the callback handler- Returns:
- 0 if successfule, -1 otherwise
- Throws:
LibvirtException- See Also:
- virStreamRecvAll
-
removeCallback
public int removeCallback() throws LibvirtExceptionRemove an event callback from the stream- Returns:
- 0 for success, -1 for failure
- Throws:
LibvirtException- See Also:
- Libvirt Docs
-
send
public int send(java.lang.String data) throws LibvirtExceptionWrite a series of bytes to the stream.- Parameters:
data- the data to write- Returns:
- the number of bytes written, -1 on error, -2 if the buffer is full
- Throws:
LibvirtException
-
sendAll
public int sendAll(Libvirt.VirStreamSourceFunc handler) throws LibvirtException
Batch send method- Parameters:
handler- the callback handler- Returns:
- 0 if successfule, -1 otherwise
- Throws:
LibvirtException- See Also:
- Libvirt Documentation
-
updateCallback
public int updateCallback(int events) throws LibvirtExceptionChanges the set of events to monitor for a stream.- Parameters:
events- the events to monitor- Returns:
- 0 for success, -1 for failure
- Throws:
LibvirtException- See Also:
- Libvirt Docs
-
-