+ private void createSnapshot() {
+
+ // This is a special message sent by the shard to send back a serialized snapshot of the whole
+ // data store tree. This transaction was created for that purpose only so we can
+ // self-destruct after sending the reply.
+
+ final ActorRef sender = getSender();
+ final ActorRef self = getSelf();
+ final Optional<NormalizedNode<?, ?>> result = transaction.getSnapshot().readNode(DATASTORE_ROOT);
+
+ byte[] serialized = SerializationUtils.serializeNormalizedNode(result.get());
+ sender.tell(new CaptureSnapshotReply(serialized), self);
+
+ self.tell(PoisonPill.getInstance(), self);
+ }
+