+ private void writeData(DOMStoreWriteTransaction transaction, WriteData message,
+ boolean returnSerialized) {
+ LOG.debug("writeData at path : {}", message.getPath());
+
+ modification.addModification(
+ new WriteModification(message.getPath(), message.getData()));
+ try {
+ transaction.write(message.getPath(), message.getData());
+ WriteDataReply writeDataReply = WriteDataReply.INSTANCE;
+ getSender().tell(returnSerialized ? writeDataReply.toSerializable(message.getVersion()) :
+ writeDataReply, getSelf());
+ }catch(Exception e){
+ getSender().tell(new akka.actor.Status.Failure(e), getSelf());
+ }
+ }
+
+ private void mergeData(DOMStoreWriteTransaction transaction, MergeData message,
+ boolean returnSerialized) {
+ LOG.debug("mergeData at path : {}", message.getPath());
+
+ modification.addModification(
+ new MergeModification(message.getPath(), message.getData()));
+
+ try {
+ transaction.merge(message.getPath(), message.getData());
+ MergeDataReply mergeDataReply = MergeDataReply.INSTANCE;
+ getSender().tell(returnSerialized ? mergeDataReply.toSerializable(message.getVersion()) :
+ mergeDataReply, getSelf());
+ }catch(Exception e){
+ getSender().tell(new akka.actor.Status.Failure(e), getSelf());
+ }
+ }
+
+ private void deleteData(DOMStoreWriteTransaction transaction, DeleteData message,
+ boolean returnSerialized) {
+ LOG.debug("deleteData at path : {}", message.getPath());
+
+ modification.addModification(new DeleteModification(message.getPath()));
+ try {
+ transaction.delete(message.getPath());
+ DeleteDataReply deleteDataReply = DeleteDataReply.INSTANCE;
+ getSender().tell(returnSerialized ? deleteDataReply.toSerializable(message.getVersion()) :
+ deleteDataReply, getSelf());
+ }catch(Exception e){
+ getSender().tell(new akka.actor.Status.Failure(e), getSelf());
+ }
+ }
+
+ private void readyTransaction(DOMStoreWriteTransaction transaction, boolean returnSerialized) {
+ String transactionID = getTransactionID();
+
+ LOG.debug("readyTransaction : {}", transactionID);
+
+ DOMStoreThreePhaseCommitCohort cohort = transaction.ready();
+
+ getShardActor().forward(new ForwardedReadyTransaction(transactionID, getClientTxVersion(),
+ cohort, modification, returnSerialized), getContext());
+
+ // The shard will handle the commit from here so we're no longer needed - self-destruct.
+ getSelf().tell(PoisonPill.getInstance(), 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;
+ }
+
+ public CompositeModification getModification() {
+ return modification;
+ }