/*
  * (non-Javadoc)
  * @see project3.RMIServerInterface#ASK(java.lang.String, java.lang.String, java.lang.String)
  * ASK method checks with the replica that the command being requested with the key and value is legitimate and acceptable to the server.
  * If the value is not being modified for the key passed in, then reject.
  * Similarly, if the key doesn't exist in the replica, then ASK would reject for this replica.
  * Enforces consistency of data in the absence of failures.
  */
 @Override
 public String ASK(String command, String key, String value) {
   if (hash.containsKey(key)) {
     String existingVal = hash.get(key);
     if (command.toUpperCase().equals("PUT"))
       if (!existingVal.equals(value)) return "ACCEPT";
       else return "REJECT";
     else return "ACCEPT";
   } else {
     if (command.toUpperCase().equals("PUT")) return "ACCEPT";
     else return "REJECT";
   }
 }
  public String GET(String clientId, String key) {
    log.info(
        "Server at "
            + hostname
            + ":"
            + port
            + " "
            + "received [GET "
            + key
            + "] from client "
            + clientId);
    String response = "";

    if (hash.containsKey(key)) response = hash.get(key);
    else {
      response = "No key " + key + " matches db ";
      log.error(response);
    }
    return response;
  }
 public String DELETE(boolean go, String clientId, String key) {
   // synchronize delete function on hash
   if (go) {
     log.info(
         "Server at "
             + hostname
             + ":"
             + port
             + " "
             + "received [DELETE "
             + key
             + "] from client "
             + clientId);
     String response = "";
     if (hash.containsKey(key)) {
       hash.remove(key);
       response = ACK;
     } else {
       response = "No such key - " + key + " exists";
       log.error(response);
     }
     return response;
   } else return TwoPCommit("DELETE", key, "") ? ACK : NACK;
 }