public class RabbitMQListener extends Object implements Runnable, org.hobbit.core.rabbit.DataHandler
SquirrelWebObjects and the VisualisationGraphs| Modifier and Type | Field and Description |
|---|---|
private com.rabbitmq.client.Channel |
channel |
private com.rabbitmq.client.Connection |
connection |
private List<com.SquirrelWebObject> |
dataQueue |
private org.slf4j.Logger |
logger |
private static int |
MAXLENGTHOFHISTORY |
private static String |
QUEUE_INPUT_GENERAL_NAME |
private static String |
QUEUE_OUTPUT_URI_NAME |
private org.dice_research.squirrel.data.uri.serialize.Serializer |
serializer |
private Semaphore |
terminationMutex |
| Constructor and Description |
|---|
RabbitMQListener() |
| Modifier and Type | Method and Description |
|---|---|
private <T> void |
addElementToLimitedList(@NotNull List<T> list,
T insertedElement)
Adds a element to a
List, but checks in addition before, if a certain size limit (MAXLENGTHOFHISTORY) is reached. |
void |
close() |
int |
countSquirrelWebObjects()
Counts the number of
SquirrelWebObject |
com.graph.VisualisationGraph |
getCrawledGraph()
Gets the fected crawled graph from Frontier.
|
com.graph.VisualisationGraph |
getCrawledGraph(int index)
Gets the fetched crawled graph from Frontier.
|
private <T> T |
getObject(List<T> list,
int index) |
com.SquirrelWebObject |
getSquirrel()
Gets the fetched data from the Frontier.
|
com.SquirrelWebObject |
getSquirrel(int index)
Gets the fetched data from the Frontier.
|
void |
handleData(byte[] bytes) |
(package private) boolean |
publishURI(String uri)
Just publishes a URI to the queue (connected with the Frontier): for serialising, a
Serializer is used. |
private boolean |
queueDeclare(String queueName) |
private boolean |
rabbitConnect(int triesLeft)
recursive function, that tries to connect with the rabbit container
|
void |
run() |
private List<com.SquirrelWebObject> dataQueue
private static final String QUEUE_INPUT_GENERAL_NAME
private static final String QUEUE_OUTPUT_URI_NAME
private com.rabbitmq.client.Connection connection
private com.rabbitmq.client.Channel channel
private Semaphore terminationMutex
private org.dice_research.squirrel.data.uri.serialize.Serializer serializer
private org.slf4j.Logger logger
private static final int MAXLENGTHOFHISTORY
private boolean queueDeclare(String queueName)
private boolean rabbitConnect(int triesLeft)
triesLeft - the number of left tries. 5s are in between 2 triestrue, if the connection to the RabbitMQ was established, otherwise falsepublic void close()
throws IOException,
TimeoutException
IOExceptionTimeoutExceptionpublic com.SquirrelWebObject getSquirrel()
SquirrelWebObjectpublic com.SquirrelWebObject getSquirrel(int index)
index - All received SquirrelWebObject are stored in a list. Index 0 is the oldest entry, Index size-1 is the latest oneSquirrelWebObjectpublic com.graph.VisualisationGraph getCrawledGraph()
VisualisationGraphpublic com.graph.VisualisationGraph getCrawledGraph(int index)
index - All received VisualisationGraph are stored in a list. Index 0 is the oldest entry, Index size-1 is the latest oneVisualisationGraphprivate <T> T getObject(List<T> list, int index)
public int countSquirrelWebObjects()
SquirrelWebObjectSquirrelWebObject-objects, that were received from the WebServiceprivate <T> void addElementToLimitedList(@NotNull
@NotNull List<T> list,
@NotNull
T insertedElement)
List, but checks in addition before, if a certain size limit (MAXLENGTHOFHISTORY) is reached. If yes, the method truncates every second element from the list.
Attention: if the list is bigger than MAXLENGTHOFHISTORY*2, then the truncate procedure will execute multiple times.T - this method is genericlist - the List, in that the element should be added. Must not be null.insertedElement - the element, that should be added Must not be null.boolean publishURI(String uri)
Serializer is used.
Until yet, it's common to use as the Serializer implementation the GzipJavaUriSerializer. If it changes, you should adpat this method!uri - the URItrue if and only if the publish to the Channel succeeded!public void handleData(byte[] bytes)
handleData in interface org.hobbit.core.rabbit.DataHandlerCopyright © 2017–2020. All rights reserved.