Package be.cylab.mark.datastore
Class RequestHandler
- java.lang.Object
-
- be.cylab.mark.datastore.RequestHandler
-
- All Implemented Interfaces:
ServerInterface
public final class RequestHandler extends Object implements ServerInterface
- Author:
- Thibault Debatty
-
-
Constructor Summary
Constructors Constructor Description RequestHandler(com.mongodb.client.MongoDatabase mongodb, ActivationControllerInterface activation_controller, DataSourcesController sources, MongoParser parser)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DetectionAgentProfile[]
activation()
void
addEvidence(Evidence evidence)
org.bson.types.ObjectId
addFile(byte[] bytes, String filename)
void
addRawData(RawData data)
boolean
compareAndSwapInCache(String key, Object new_value, Object old_value)
synchronized block because multiple agents can acces to the cache at the same time.Evidence[]
findEvidence(String label)
Evidence[]
findEvidence(String label, int page)
Keep only one evidence per subject: the most recent one.Evidence[]
findEvidence(String label, Map<String,String> subject)
Evidence
findEvidenceById(String id)
Get a single evidence by id, or throw an exception if id is not valid.Evidence[]
findEvidenceSince(String label, Map<String,String> subject, long time)
byte[]
findFile(org.bson.types.ObjectId file_id)
Evidence[]
findLastEvidences()
Evidence[]
findLastEvidences(String label, Map<String,String> subject)
RawData[]
findLastRawData()
RawData[]
findRawData(String label, Map<String,String> subject, long from, long till)
Object
getFromCache(String key)
URL
getURL()
List<Map>
history()
void
pause()
void
reload()
void
resume()
void
setAgentProfile(DetectionAgentProfile profile)
DataAgentProfile[]
sources()
Map<String,Object>
status()
void
storeInCache(String key, Object value)
String
test()
Should return the string 1.void
testString(String data)
Test RPC method that accepts a single string parameter.
-
-
-
Constructor Detail
-
RequestHandler
@Inject public RequestHandler(com.mongodb.client.MongoDatabase mongodb, ActivationControllerInterface activation_controller, DataSourcesController sources, MongoParser parser)
- Parameters:
mongodb
-activation_controller
-sources
-parser
-
-
-
Method Detail
-
test
public String test()
Should return the string 1.- Specified by:
test
in interfaceServerInterface
- Returns:
-
testString
public void testString(String data)
Test RPC method that accepts a single string parameter. Do nothing but print string on screen.- Specified by:
testString
in interfaceServerInterface
- Parameters:
data
-
-
addRawData
public void addRawData(RawData data)
- Specified by:
addRawData
in interfaceServerInterface
- Parameters:
data
-
-
findRawData
public RawData[] findRawData(String label, Map<String,String> subject, long from, long till)
- Specified by:
findRawData
in interfaceServerInterface
- Parameters:
label
-subject
-- Returns:
-
addEvidence
public void addEvidence(Evidence evidence)
- Specified by:
addEvidence
in interfaceServerInterface
- Parameters:
evidence
-
-
addFile
public org.bson.types.ObjectId addFile(byte[] bytes, String filename) throws Throwable
- Specified by:
addFile
in interfaceServerInterface
- Throws:
Throwable
-
findFile
public byte[] findFile(org.bson.types.ObjectId file_id) throws Throwable
- Specified by:
findFile
in interfaceServerInterface
- Throws:
Throwable
-
activation
public DetectionAgentProfile[] activation()
- Specified by:
activation
in interfaceServerInterface
-
setAgentProfile
public void setAgentProfile(DetectionAgentProfile profile) throws Throwable
- Specified by:
setAgentProfile
in interfaceServerInterface
- Throws:
Throwable
-
findEvidence
public Evidence[] findEvidence(String label, Map<String,String> subject) throws Throwable
- Specified by:
findEvidence
in interfaceServerInterface
- Parameters:
label
-subject
-- Returns:
- Throws:
Throwable
- if request fails
-
findEvidence
public Evidence[] findEvidence(String label) throws Throwable
- Specified by:
findEvidence
in interfaceServerInterface
- Parameters:
label
-- Returns:
- Throws:
Throwable
-
findEvidence
public Evidence[] findEvidence(String label, int page) throws Throwable
Keep only one evidence per subject: the most recent one.- Specified by:
findEvidence
in interfaceServerInterface
- Parameters:
label
-- Returns:
- Throws:
Throwable
- if request fails
-
findEvidenceById
public Evidence findEvidenceById(String id)
Get a single evidence by id, or throw an exception if id is not valid.- Specified by:
findEvidenceById
in interfaceServerInterface
- Parameters:
id
-- Returns:
-
getURL
public URL getURL()
- Specified by:
getURL
in interfaceServerInterface
- Returns:
-
findLastEvidences
public Evidence[] findLastEvidences(String label, Map<String,String> subject)
- Specified by:
findLastEvidences
in interfaceServerInterface
- Parameters:
label
-subject
-- Returns:
-
getFromCache
public Object getFromCache(String key) throws Throwable
- Specified by:
getFromCache
in interfaceServerInterface
- Parameters:
key
-- Returns:
- Throws:
Throwable
-
storeInCache
public void storeInCache(String key, Object value) throws Throwable
- Specified by:
storeInCache
in interfaceServerInterface
- Parameters:
key
-value
-- Throws:
Throwable
-
compareAndSwapInCache
public boolean compareAndSwapInCache(String key, Object new_value, Object old_value) throws Throwable
synchronized block because multiple agents can acces to the cache at the same time.- Specified by:
compareAndSwapInCache
in interfaceServerInterface
- Parameters:
key
-new_value
-old_value
-- Returns:
- Throws:
Throwable
-
findEvidenceSince
public Evidence[] findEvidenceSince(String label, Map<String,String> subject, long time) throws Throwable
- Specified by:
findEvidenceSince
in interfaceServerInterface
- Throws:
Throwable
-
pause
public void pause() throws Throwable
- Specified by:
pause
in interfaceServerInterface
- Throws:
Throwable
-
resume
public void resume() throws Throwable
- Specified by:
resume
in interfaceServerInterface
- Throws:
Throwable
-
reload
public void reload()
- Specified by:
reload
in interfaceServerInterface
-
status
public Map<String,Object> status() throws Throwable
- Specified by:
status
in interfaceServerInterface
- Throws:
Throwable
-
history
public List<Map> history() throws Throwable
- Specified by:
history
in interfaceServerInterface
- Throws:
Throwable
-
findLastRawData
public RawData[] findLastRawData() throws Throwable
- Specified by:
findLastRawData
in interfaceServerInterface
- Throws:
Throwable
-
findLastEvidences
public Evidence[] findLastEvidences() throws Throwable
- Specified by:
findLastEvidences
in interfaceServerInterface
- Throws:
Throwable
-
sources
public DataAgentProfile[] sources() throws Throwable
- Specified by:
sources
in interfaceServerInterface
- Throws:
Throwable
-
-