<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\section{ActionPrepareDistributedCommitedTransferAnswer}
After an answer from a client reached the server, the server tries to
find the corresponding request. If the answer was a acknowlegement, the
request will get another positive answer. When the same amount of
positive answers equals the count of known neighbors received on the
server, all client will be informed to commit the change and the
request will be deleted. If the answer was an abort, all clients will be
informed to abort the transaction.
\\
\begin{lstlisting}
protected void onAction(ActorRef sender, ActorRef self, UntypedActorContext context,
                        SuperVisor superVisor) {
  log(""+superVisor.getKnownNeighbors());
  log("granted?"+granted);
  DistributedCommitedTransferRequest request = superVisor.getRequest(id);
  if(granted){
    if(request==null)	//unknown DistributedCommitedTransferRequest ignore
       return;
    int newCount = request.addPositiveAnswer(sender);
    if(newCount == superVisor.getKnownNeighbors().size()){
      ActionCommitDistributedCommitedTransfer acdct =
        new ActionCommitDistributedCommitedTransfer(source, target, amount, true,
                                                    timestamp, id);
      for(ActorRef neighbor : request.getAnswers()){
        neighbor.tell(acdct, self);
      }
      superVisor.deleteRequest(request);
    }
  }else{
    // A client wants to rollback
    if(request!=null){
      ActionCommitDistributedCommitedTransfer acdct =
        new ActionCommitDistributedCommitedTransfer(source, target, amount, false,
                                                    timestamp, id);
      for(ActorRef neighbor : request.getAnswers()){
        neighbor.tell(acdct, self);
      }
    }
  }
}
\end{lstlisting}
</pre></body></html>