public class OFMStorageManager extends OFModule implements IStorageService
Modifier and Type | Field and Description |
---|---|
private com.mongodb.DB |
db |
private com.mongodb.MongoClient |
mongoClient |
private org.codehaus.jackson.map.ObjectMapper |
om |
private Storage |
storage |
controller
Constructor and Description |
---|
OFMStorageManager() |
Modifier and Type | Method and Description |
---|---|
boolean |
delete(java.lang.String dbName,
java.lang.String collection,
java.util.Map<java.lang.String,java.lang.Object> query)
deletes data that matches the JSON style query from the persistent storage.
|
boolean |
delete(java.lang.String dbName,
java.lang.String collection,
java.lang.String r)
deletes data that matches the JSON style query from the persistent storage.
|
void |
dropDB(java.lang.String dbName)
drops DBs in the persistent storage.
|
void |
dropIndex(java.lang.String dbName,
java.lang.String collection,
java.util.Map<java.lang.String,java.lang.Object> key)
drops a key-value pair as an index to ensure the uniqueness in the persistent storage.
|
void |
ensureIndex(java.lang.String dbName,
java.lang.String collection,
java.util.Map<java.lang.String,java.lang.Object> key)
assigns a key-value pair to ensure the uniqueness of the key-value pair in the persistent storage.
|
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
getIndex(java.lang.String dbName,
java.lang.String collection)
retrieves all assigned key-value pairs in the persistent storage.
|
OFModel[] |
getModels()
returns the array of all
OFModel objects associated with this module. |
protected boolean |
handleDisconnect(Connection conn)
Process the disconnection event from a switch.
|
protected boolean |
handleHandshakedEvent(Connection conn,
MessageContext context)
An abstract method that all subclasses should implement.
|
protected boolean |
handleMessage(Connection conn,
MessageContext context,
org.openflow.protocol.OFMessage msg,
java.util.List<org.openflow.protocol.OFMessage> outgoing)
Handle incoming messages that pass the test of filters.
|
protected void |
initialize()
method that initializes this module.
|
boolean |
insert(java.lang.String dbName,
java.lang.String collection,
java.util.Map<java.lang.String,java.lang.Object> query)
inserts a Map
|
boolean |
insert(java.lang.String dbName,
java.lang.String collection,
java.lang.String r)
inserts a JSON style String object into a persistent storage.
|
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
retrieve(java.lang.String dbName,
java.lang.String collection,
java.util.Map<java.lang.String,java.lang.Object> query)
retrieves data that matches the JSON style query from the persistent storage,
and returns data as List of Map
|
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
retrieveAll(java.lang.String dbName,
java.lang.String collection)
retrieves all data from the persistent storage,
and returns data as List of Map
|
java.util.List<java.lang.String> |
retrieveAsString(java.lang.String dbName,
java.lang.String collection,
java.lang.String query)
retrieves data that matches the JSON style query from the persistent storage.
|
java.util.List<java.lang.String> |
retrieveAsStringAll(java.lang.String dbName,
java.lang.String collection)
retrieves all data from the persistent storage in the specific collection,
and returns data as List of String.
|
java.util.List<java.lang.String> |
retrieveDBs()
retrieves names of DBs in the persistent storage.
|
boolean |
update(java.lang.String dbName,
java.lang.String collection,
java.util.Map<java.lang.String,java.lang.Object> key,
java.util.Map<java.lang.String,java.lang.Object> query)
updates data that matches the JSON style key from the persistent storage.
|
boolean |
update(java.lang.String dbName,
java.lang.String collection,
java.lang.String key,
java.lang.String query)
updates data that matches the JSON style key from the persistent storage.
|
boolean |
upsert(java.lang.String dbName,
java.lang.String collection,
java.util.Map<java.lang.String,java.lang.Object> key,
java.util.Map<java.lang.String,java.lang.Object> query)
upserts data that matches the JSON style key from the persistent storage.
|
boolean |
upsert(java.lang.String dbName,
java.lang.String collection,
java.lang.String key,
java.lang.String query)
upserts data that matches the JSON style key from the persistent storage.
|
getController, getModule, init, processDisconnect, processHandshakeFinished, processMessage, registerFilter, registerModule
private com.mongodb.MongoClient mongoClient
private com.mongodb.DB db
private org.codehaus.jackson.map.ObjectMapper om
private Storage storage
protected void initialize()
OFModule
OFMLinkDiscovery.initialize()
.initialize
in class OFModule
public boolean insert(java.lang.String dbName, java.lang.String collection, java.util.Map<java.lang.String,java.lang.Object> query) throws StorageException
insert
in interface IStorageService
dbName
- name of the database.collection
- name of collection for the database.query
- MapStorageException
public boolean insert(java.lang.String dbName, java.lang.String collection, java.lang.String r) throws StorageException
insert
in interface IStorageService
dbName
- name of the database.collection
- name of collection for the database.r
- JSON style String data to be inserted.StorageException
public boolean delete(java.lang.String dbName, java.lang.String collection, java.util.Map<java.lang.String,java.lang.Object> query) throws StorageException
delete
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.query
- MapStorageException
public boolean delete(java.lang.String dbName, java.lang.String collection, java.lang.String r) throws StorageException
delete
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.r
- JSON style String query to delete the matching data from the persistent storage.StorageException
public boolean update(java.lang.String dbName, java.lang.String collection, java.util.Map<java.lang.String,java.lang.Object> key, java.util.Map<java.lang.String,java.lang.Object> query) throws StorageException
update
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.key
- Mapquery
- MapStorageException
public boolean update(java.lang.String dbName, java.lang.String collection, java.lang.String key, java.lang.String query) throws StorageException
update
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.key
- JSON style String key to update the matching data from the persistent storage.query
- JSON style String query to update the matching data from the persistent storage.
In case of matching data, the matching data is replaced with the query and original key and value pairs are lost,
and if you want to keep the original key-value pairs while updating the data,
then you should use "$set" as key and the query as value.StorageException
public boolean upsert(java.lang.String dbName, java.lang.String collection, java.util.Map<java.lang.String,java.lang.Object> key, java.util.Map<java.lang.String,java.lang.Object> query) throws StorageException
upsert
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.key
- Mapquery
- MapStorageException
public boolean upsert(java.lang.String dbName, java.lang.String collection, java.lang.String key, java.lang.String query) throws StorageException
upsert
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.key
- JSON style String key to upsert the matching data from the persistent storage.query
- JSON style String query to upsert the matching data from the persistent storage.
In case of matching data, the matching data is replaced with the query and some original key and value pairs can be lost,
and if you want to keep all of the original key-value pairs while upserting the data,
then you should use "$set" as key and the query as value.StorageException
public java.util.List<java.lang.String> retrieveAsStringAll(java.lang.String dbName, java.lang.String collection) throws StorageException
retrieveAsStringAll
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.StorageException
public java.util.List<java.lang.String> retrieveAsString(java.lang.String dbName, java.lang.String collection, java.lang.String query) throws StorageException
retrieveAsString
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.query
- JSON style String query to retrieve the matching data from the persistent storage.StorageException
public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> retrieve(java.lang.String dbName, java.lang.String collection, java.util.Map<java.lang.String,java.lang.Object> query) throws StorageException
retrieve
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.query
- MapStorageException
public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> retrieveAll(java.lang.String dbName, java.lang.String collection) throws StorageException
retrieveAll
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.StorageException
public void ensureIndex(java.lang.String dbName, java.lang.String collection, java.util.Map<java.lang.String,java.lang.Object> key) throws StorageException
ensureIndex
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.key
- key-value pair to be unique in the persistent storage.
This key-value pair should have follow pattern {"key": 1} or {"key": -1}
1 means ascending order and -1 means descending order.StorageException
public void dropIndex(java.lang.String dbName, java.lang.String collection, java.util.Map<java.lang.String,java.lang.Object> key) throws StorageException
dropIndex
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.key
- key-value pair to be dropped as an index in the persistent storage.StorageException
public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> getIndex(java.lang.String dbName, java.lang.String collection) throws StorageException
getIndex
in interface IStorageService
dbName
- name of the persistent storage.collection
- name of collection for the persistent storage.StorageException
public java.util.List<java.lang.String> retrieveDBs() throws StorageException
retrieveDBs
in interface IStorageService
StorageException
public void dropDB(java.lang.String dbName) throws StorageException
dropDB
in interface IStorageService
dbName
- name of the persistent storage.StorageException
protected boolean handleHandshakedEvent(Connection conn, MessageContext context)
OFModule
OFModule.processHandshakeFinished(Connection, MessageContext)
.
Normally, most of modules have very simple implementation for this method,
only returning true.handleHandshakedEvent
in class OFModule
conn
- connection that the event has occurredcontext
- message context for the handshaking messagesprotected boolean handleMessage(Connection conn, MessageContext context, org.openflow.protocol.OFMessage msg, java.util.List<org.openflow.protocol.OFMessage> outgoing)
OFModule
OFModule.processMessage(Connection, MessageContext, OFMessage, List)
.handleMessage
in class OFModule
conn
- connection that the message has arrivedcontext
- message context for the messagemsg
- the actual message objectoutgoing
- responses for the message arrived, which is filled by the handleMessage implementationprotected boolean handleDisconnect(Connection conn)
OFModule
OFModule.processDisconnect(Connection)
.
All subclasses of OFModule should implement this method.handleDisconnect
in class OFModule
conn
- connection that the event has occurred