Package org.hobbit.core.components.utils
Class SystemResourceUsageRequester
- java.lang.Object
-
- org.hobbit.core.components.utils.SystemResourceUsageRequester
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class SystemResourceUsageRequester extends Object implements Closeable
-
-
Field Summary
Fields Modifier and Type Field Description protected com.rabbitmq.client.ChannelcmdChannelChannel that is used for the command queue but not owned by this class (i.e., it won't be closed).protected com.google.gson.Gsongsonprotected com.rabbitmq.client.ChannelincomingChannelprivate static org.slf4j.LoggerLOGGERprivate com.rabbitmq.client.QueueingConsumerresponseConsumerConsumer of the queue that is used to receive responses for messages that are sent via the command queue and for which an answer is expected.private StringresponseQueueNameName of the queue that is used to receive responses for messages that are sent via the command queue and for which an answer is expected.protected byte[]sessionIdBytes
-
Constructor Summary
Constructors Modifier Constructor Description protectedSystemResourceUsageRequester(com.rabbitmq.client.Channel cmdChannel, com.rabbitmq.client.Channel incomingChannel, String responseQueueName, com.rabbitmq.client.QueueingConsumer responseConsumer, String sessionId)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static SystemResourceUsageRequestercreate(PlatformConnector connector, String sessionId)ResourceUsageInformationgetSystemResourceUsage()protected voidsendToCmdQueue(byte command, byte[] data, com.rabbitmq.client.AMQP.BasicProperties props)Sends the given command to the command queue with the given data appended and using the given properties.
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
responseQueueName
private String responseQueueName
Name of the queue that is used to receive responses for messages that are sent via the command queue and for which an answer is expected.
-
responseConsumer
private com.rabbitmq.client.QueueingConsumer responseConsumer
Consumer of the queue that is used to receive responses for messages that are sent via the command queue and for which an answer is expected.
-
cmdChannel
protected com.rabbitmq.client.Channel cmdChannel
Channel that is used for the command queue but not owned by this class (i.e., it won't be closed).
-
incomingChannel
protected com.rabbitmq.client.Channel incomingChannel
-
sessionIdBytes
protected byte[] sessionIdBytes
-
gson
protected com.google.gson.Gson gson
-
-
Method Detail
-
create
public static SystemResourceUsageRequester create(PlatformConnector connector, String sessionId)
-
getSystemResourceUsage
public ResourceUsageInformation getSystemResourceUsage()
-
sendToCmdQueue
protected void sendToCmdQueue(byte command, byte[] data, com.rabbitmq.client.AMQP.BasicProperties props) throws IOExceptionSends the given command to the command queue with the given data appended and using the given properties.- Parameters:
command- the command that should be sentdata- data that should be appended to the commandprops- properties that should be used for the message- Throws:
IOException- if a communication problem occurs
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-