-
Notifications
You must be signed in to change notification settings - Fork 353
Thread Safety
opuneet edited this page Feb 24, 2014
·
1 revision
This should be done only once before all threads start processing. The init code creates a keyspace object that is thread safe and hence the same instances can be given to all processing threads, once it is inited safely.
As mentioned above, keyspace is thread safe and hence can be shared among multiple threads. Similarly ColumnFamily is also thread safe.
The impls for ColumnFamilyQuery and MutationBatch maintain intermittent state for supporting features like mixed write batches, merging batches, pagination, host pinning, timers, tracers etc and hence SHOULD NOT be used by multiple threads and are NOT thread safe.
- Initialize the AstyanaxContext object once safely and get the Keyspace object before any threads start processing.
- Then handoff the Keyspace and ColumnFamily objects to the worker threads.
- Each worker thread must create it's own read and write object by calling keyspace.prepareQuery() and keyspace.prepareMutationBatch() separately. These method calls do not need to be synchronized, but the objects that they return MUST NOT be shared by the worker threads. Hence each worker thread should have it's own read and write object.
A Netflix Original Production
Tech Blog | Twitter @NetflixOSS | Jobs
- Getting-Started
- Configuration
- Features
- Monitoring
- Thread Safety
- Timeouts
- Recipes
- Examples
- Javadoc
- Utilities
- Cassandra-Compatibility
- FAQ
- End-to-End Examples
- Astyanax Integration with Java Driver