private RMResult processAtomicCustomerRequest(String requestString) { // Process the given request by first checking that the given customer // exists, and if yes creating it at the relevant RM as necessary. Integer cid = getCustomerId(requestString); RMResult existenceCheck = processAtomicRequest(Command.SERVER_CHECK_CUSTOMER_EXISTS + ",1," + cid); if (existenceCheck.IsError()) { return existenceCheck; } if (!existenceCheck.AsBool()) { RMResult failure = new RMResult(new Exception("Customer " + cid + " does not exist.")); return failure; } // Create the customer on the given RM (no side-effects if customer already exists. int rmId = getRMIndexForRequest(requestString); processAtomicRequest("newcustomerid,1," + cid, _rmIps[rmId], _rmPorts[rmId]); // Actually execute the request return processAtomicRequest(requestString, _rmIps[rmId], _rmPorts[rmId]); }