public final class Library
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static long |
getVersion()
Returns the version of the native libvirt library.
|
static void |
initEventLoop()
Initialize the event loop.
|
static void |
processEvent()
Run one iteration of the event loop.
|
static void |
runEventLoop()
Runs the event loop.
|
static void |
stopEventLoop()
Stops the event loop.
|
public static long getVersion() throws LibvirtException
LibvirtException
public static void initEventLoop() throws LibvirtException
Once registered, the application has to invoke
processEvent()
in a loop or call runEventLoop()
in another thread.
Note: You must call this function before connecting to the hypervisor.
LibvirtException
- on failureprocessEvent()
,
runLoop
public static void processEvent() throws LibvirtException
Applications will generally want to have a thread which invokes this method in an infinite loop:
while (true) connection.processEvent();
Failure to do so may result in connections being closed unexpectedly as a result of keepalive timeout.
LibvirtException
- on failureinitEventLoop()
public static void runEventLoop() throws LibvirtException, java.lang.InterruptedException
stopEventLoop()
is called or an
exception is thrown.
Usually, this method is run in another thread.
LibvirtException
- if there was an error during the call of a
native libvirt functionjava.lang.InterruptedException
- if this thread was interrupted by a call to
Thread.interrupt()
public static void stopEventLoop() throws LibvirtException
LibvirtException
runEventLoop()