Class QemuConnector
java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jdrupes.vmoperator.runner.qemu.QemuConnector
- All Implemented Interfaces:
Iterable<org.jgrapes.core.ComponentType>,org.jgrapes.core.Channel,org.jgrapes.core.ComponentType,org.jgrapes.core.Eligible,org.jgrapes.core.Manager
- Direct Known Subclasses:
AgentConnector,QemuMonitor
A component that handles the communication with QEMU over a socket.
Derived classes should log the messages exchanged on the socket if the log level is set to fine.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
org.jgrapes.core.Channel.Default -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final com.fasterxml.jackson.databind.ObjectMapperFields inherited from class org.jgrapes.core.Component
loggerFields inherited from interface org.jgrapes.core.Channel
BROADCAST, SELF -
Constructor Summary
ConstructorsConstructorDescriptionQemuConnector(org.jgrapes.core.Channel componentChannel) Instantiates a new QEMU connector. -
Method Summary
Modifier and TypeMethodDescriptionvoidonClientConnected(org.jgrapes.net.events.ClientConnected event, org.jgrapes.net.SocketIOChannel channel) Check if this is from opening the agent socket and if true, save the socket in the context and associate the channel with the context.voidonClosed(org.jgrapes.io.events.Closed<?> event, org.jgrapes.net.SocketIOChannel channel) On closed.voidonConnectError(org.jgrapes.io.events.ConnectError event) Called when a connection attempt fails.voidonFileChanged(org.jgrapes.util.events.FileChanged event) Watch for the creation of the swtpm socket and start the qemu process if it has been created.voidonInput(org.jgrapes.io.events.Input<?> event, org.jgrapes.net.SocketIOChannel channel) Handle data from the socket connection.voidonStart(org.jgrapes.core.events.Start event) Note the runner’s event processor and delete the socket.protected abstract voidprocessInput(String line) Process agent input.protected Optional<org.jgrapes.net.SocketIOChannel> Return the QEMU channel if the connection has been established.protected org.jgrapes.core.EventPipelinerep()Return the runner’s event pipeline.protected booleansendCommand(String command) Send the given command to QEMU.protected voidCalled when the connector has been connected to the socket.writer()Return theWriterfor the connection if the connection has been established.Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setNameMethods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGeneratorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.jgrapes.core.Manager
stream
-
Field Details
-
mapper
-
-
Constructor Details
-
QemuConnector
Instantiates a new QEMU connector.- Parameters:
componentChannel- the component channel- Throws:
IOException- Signals that an I/O exception has occurred.
-
-
Method Details
-
onStart
Note the runner’s event processor and delete the socket.- Parameters:
event- the event- Throws:
IOException- Signals that an I/O exception has occurred.
-
rep
Return the runner’s event pipeline.- Returns:
- the event pipeline
-
onFileChanged
Watch for the creation of the swtpm socket and start the qemu process if it has been created.- Parameters:
event- the event
-
onClientConnected
@Handler public void onClientConnected(org.jgrapes.net.events.ClientConnected event, org.jgrapes.net.SocketIOChannel channel) Check if this is from opening the agent socket and if true, save the socket in the context and associate the channel with the context.- Parameters:
event- the eventchannel- the channel
-
qemuChannel
Return the QEMU channel if the connection has been established.- Returns:
- the socket IO channel
-
writer
Return theWriterfor the connection if the connection has been established.- Returns:
- the optional
-
sendCommand
Send the given command to QEMU.A newline is appended to the command automatically.
- Parameters:
command- the command- Returns:
- true, if successful
- Throws:
IOException- Signals that an I/O exception has occurred.
-
socketConnected
Called when the connector has been connected to the socket. -
onConnectError
Called when a connection attempt fails.- Parameters:
event- the event
-
onInput
@Handler public void onInput(org.jgrapes.io.events.Input<?> event, org.jgrapes.net.SocketIOChannel channel) Handle data from the socket connection.- Parameters:
event- the eventchannel- the channel
-
processInput
Process agent input.- Parameters:
line- the line- Throws:
IOException- Signals that an I/O exception has occurred.
-
onClosed
@Handler public void onClosed(org.jgrapes.io.events.Closed<?> event, org.jgrapes.net.SocketIOChannel channel) On closed.- Parameters:
event- the eventchannel- the channel
-