I've a use case where I build a graph from data retrieved from multiple data stores. Each of those data stores has its own client library that builds the sub-graph representing that particular data stores data.
Current implementation Since, I didn't have any concurrency requirements, I build a single Graph object in the service layer and pass it to each of those client libraries and they will use the same Graph instance
New implementation - to meet the SLA
To meet the SLA, i want to pull the data from these data stores concurrently.
EDIT
How the object being used
com.tinkerpop.blueprints.impls.tg.TinkerGraph
and shares it among 3 different threads retreiving the data from 3 different store simultaneously on 3 different threads. Each thread also responsible for adding the data pulled to the shared Graph instance.It depends on the Graph
interface implementation. For example, if you are using TinkerGraph
it makes no guarantees of thread-safety. Neo4jGraph
uses a ThreadLocal
variable to manage transactions which means that you can share the same Neo4jGraph
instance with multiple threads without any trouble. Blueprints also allows for multi-threaded transactions via ThreadedTransactionalGraph
:
but you have to find a Graph
that supports that function.