Class QemuConnector
java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jdrupes.vmoperator.runner.qemu.QemuConnector
- All Implemented Interfaces:
Iterable<ComponentType>
,Channel
,ComponentType
,Eligible
,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
Channel.Default
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final com.fasterxml.jackson.databind.ObjectMapper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
As the initial configuration of this component depends on the configuration of theRunner
, it doesn’t have a handler for theConfigurationUpdate
event.void
onClientConnected
(ClientConnected event, 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.void
onClosed
(Closed<?> event, SocketIOChannel channel) On closed.void
onConnectError
(ConnectError event, SocketIOChannel channel) Called when a connection attempt fails.void
onFileChanged
(FileChanged event) Watch for the creation of the swtpm socket and start the qemu process if it has been created.void
onInput
(Input<?> event, SocketIOChannel channel) Handle data from the socket connection.void
Note the runner’s event processor and delete the socket.protected abstract void
processInput
(String line) Process agent input.protected Optional
<SocketIOChannel> Return the QEMU channel if the connection has been established.protected EventPipeline
rep()
Return the runner’s event pipeline.protected boolean
sendCommand
(String command) Send the given command to QEMU.protected void
Called when the connector has been connected to the socket.writer()
Return theWriter
for the connection if the connection has been established.Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setName
Methods 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, unregisterAsGenerator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
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
-
configure
As the initial configuration of this component depends on the configuration of theRunner
, it doesn’t have a handler for theConfigurationUpdate
event.The values are forwarded from the
Runner
instead.- Parameters:
socketPath
- the socket path
-
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
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 theWriter
for 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 eventchannel
- the channel
-
onInput
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
On closed.- Parameters:
event
- the eventchannel
- the channel
-