Package org.hobbit.core.components.test
Class InMemoryEvaluationStore
- java.lang.Object
-
- org.hobbit.core.components.AbstractComponent
-
- org.hobbit.core.components.AbstractCommandReceivingComponent
-
- org.hobbit.core.components.AbstractPlatformConnectorComponent
-
- org.hobbit.core.components.AbstractEvaluationStorage
-
- org.hobbit.core.components.test.InMemoryEvaluationStore
-
- All Implemented Interfaces:
Closeable,AutoCloseable,CommandReceivingComponent,Component,ExpectedResponseReceivingComponent,PlatformConnector,ResponseReceivingComponent
public class InMemoryEvaluationStore extends AbstractEvaluationStorage
Simple in-memory implementation of an evaluation storage that can be used for testing purposes.- Author:
- Michael Röder (roeder@informatik.uni-leipzig.de)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInMemoryEvaluationStore.ResultImplA simple structure implementing theResultinterfacestatic classInMemoryEvaluationStore.ResultPairImplA simple structure implementing theResultPairinterface.
-
Field Summary
Fields Modifier and Type Field Description private Map<String,ResultPair>resultsMap containing a mapping from task Ids to result pairs.-
Fields inherited from class org.hobbit.core.components.AbstractEvaluationStorage
ackChannel, evalModule2EvalStoreQueue, NEW_ITERATOR_ID, RECEIVE_TIMESTAMP_FOR_SYSTEM_RESULTS_KEY, resultPairIterators, systemResultReceiver, taskResultReceiver
-
Fields inherited from class org.hobbit.core.components.AbstractCommandReceivingComponent
cmdChannel, cmdQueueFactory, cmdResponseTimeout, DEFAULT_CMD_RESPONSE_TIMEOUT, defaultContainerType
-
Fields inherited from class org.hobbit.core.components.AbstractComponent
connectionFactory, incomingDataQueueFactory, NUMBER_OF_RETRIES_TO_CONNECT_TO_RABBIT_MQ, outgoingDataQueuefactory, rabbitMQHostName, START_WAITING_TIME_BEFORE_RETRY
-
-
Constructor Summary
Constructors Constructor Description InMemoryEvaluationStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Iterator<ResultPair>createIterator()Creates a new iterator that iterates over the response pairs.voidputResult(boolean isExpectedResult, String taskId, long timestamp, byte[] data)Adds the given result to the map of results.voidreceiveExpectedResponseData(String taskId, long timestamp, byte[] data)This method is called if an expected response is received from a task generator component.voidreceiveResponseData(String taskId, long timestamp, byte[] data)This method is called if a response is received from the system.-
Methods inherited from class org.hobbit.core.components.AbstractEvaluationStorage
close, init, receiveCommand, run
-
Methods inherited from class org.hobbit.core.components.AbstractPlatformConnectorComponent
addContainerObserver, createContainer, getFactoryForIncomingCmdQueues, getFactoryForIncomingDataQueues, getFactoryForOutgoingCmdQueues, getFactoryForOutgoingDataQueues, stopContainer
-
Methods inherited from class org.hobbit.core.components.AbstractCommandReceivingComponent
addCommandHeaderId, createContainer, createContainer, getCmdResponseTimeout, handleCmd, sendToCmdQueue, sendToCmdQueue, sendToCmdQueue, setCmdResponseTimeout
-
Methods inherited from class org.hobbit.core.components.AbstractComponent
createConnection, generateSessionQueueName, getHobbitSessionId
-
-
-
-
Field Detail
-
results
private Map<String,ResultPair> results
Map containing a mapping from task Ids to result pairs.
-
-
Method Detail
-
receiveResponseData
public void receiveResponseData(String taskId, long timestamp, byte[] data)
Description copied from interface:ResponseReceivingComponentThis method is called if a response is received from the system.- Parameters:
taskId- the id of the tasktimestamp- the time at which the response has been received from the systemdata- the data received from a data generator
-
receiveExpectedResponseData
public void receiveExpectedResponseData(String taskId, long timestamp, byte[] data)
Description copied from interface:ExpectedResponseReceivingComponentThis method is called if an expected response is received from a task generator component.- Parameters:
taskId- the id of the tasktimestamp- the time at which the task has been sent to the systemdata- the data received from a task generator
-
putResult
public void putResult(boolean isExpectedResult, String taskId, long timestamp, byte[] data)Adds the given result to the map of results.- Parameters:
isExpectedResult- true if the result has been received from a task generator, i.e., is the expected result for a tasktaskId- id of the tasktimestamp- time stamp for the task resultdata- the result
-
createIterator
protected Iterator<ResultPair> createIterator()
Description copied from class:AbstractEvaluationStorageCreates a new iterator that iterates over the response pairs.- Specified by:
createIteratorin classAbstractEvaluationStorage- Returns:
- a new iterator or null if an error occurred
-
-