- protected void writeData(DOMStoreWriteTransaction transaction, WriteData message) {
- modification.addModification(
- new WriteModification(message.getPath(), message.getData(),schemaContext));
- LOG.debug("writeData at path : " + message.getPath().toString());
-
- try {
- transaction.write(message.getPath(), message.getData());
- getSender().tell(new WriteDataReply().toSerializable(), getSelf());
- }catch(Exception e){
- getSender().tell(new akka.actor.Status.Failure(e), getSelf());
- }
- }
-
- protected void mergeData(DOMStoreWriteTransaction transaction, MergeData message) {
- modification.addModification(
- new MergeModification(message.getPath(), message.getData(), schemaContext));
- LOG.debug("mergeData at path : " + message.getPath().toString());
- try {
- transaction.merge(message.getPath(), message.getData());
- getSender().tell(new MergeDataReply().toSerializable(), getSelf());
- }catch(Exception e){
- getSender().tell(new akka.actor.Status.Failure(e), getSelf());
- }
- }
-
- protected void deleteData(DOMStoreWriteTransaction transaction, DeleteData message) {
- LOG.debug("deleteData at path : " + message.getPath().toString());
- modification.addModification(new DeleteModification(message.getPath()));
- try {
- transaction.delete(message.getPath());
- getSender().tell(new DeleteDataReply().toSerializable(), getSelf());
- }catch(Exception e){
- getSender().tell(new akka.actor.Status.Failure(e), getSelf());
- }
- }
-
- protected void readyTransaction(DOMStoreWriteTransaction transaction, ReadyTransaction message) {
- DOMStoreThreePhaseCommitCohort cohort = transaction.ready();
- ActorRef cohortActor = getContext().actorOf(
- ThreePhaseCommitCohort.props(cohort, shardActor, modification), "cohort");
- getSender()
- .tell(new ReadyTransactionReply(cohortActor.path()).toSerializable(), getSelf());
-
- }
-
-
- // These classes are in here for test purposes only
-
-
- static class GetCompositedModification {
-
- }
-
-
- static class GetCompositeModificationReply {
- private final CompositeModification modification;
-
-
- GetCompositeModificationReply(CompositeModification modification) {
- this.modification = modification;
- }
-
+ private static class ShardTransactionCreator implements Creator<ShardTransaction> {
+
+ private static final long serialVersionUID = 1L;
+
+ final DOMStoreTransaction transaction;
+ final ActorRef shardActor;
+ final SchemaContext schemaContext;
+ final DatastoreContext datastoreContext;
+ final ShardStats shardStats;
+ final String transactionID;
+ final short txnClientVersion;
+
+ ShardTransactionCreator(DOMStoreTransaction transaction, ActorRef shardActor,
+ SchemaContext schemaContext, DatastoreContext datastoreContext,
+ ShardStats shardStats, String transactionID, short txnClientVersion) {
+ this.transaction = transaction;
+ this.shardActor = shardActor;
+ this.shardStats = shardStats;
+ this.schemaContext = schemaContext;
+ this.datastoreContext = datastoreContext;
+ this.transactionID = transactionID;
+ this.txnClientVersion = txnClientVersion;
+ }