List<ClientProtos.WriteResultProto> writeResultProtos = new ArrayList<ClientProtos.WriteResultProto>();
List<InsertAction> actions = plan.getActions();
InsertAction action = actions.get(0);
EntityGroupInfo entityGroupInfo = action.getEntityGroupLocation()
.getEntityGroupInfo();
ServerName serverName = new ServerName(action.getEntityGroupLocation()
.getHostname(), action.getEntityGroupLocation().getPort(),
ServerName.NON_STARTCODE);
// if actions > 1. will commit by 2pc
if (actions.size() == 1) {
try {
if (workingOnLocalServer(server, serverName)) {
ClientProtos.InsertResponse response = server.insert(
entityGroupInfo.getEntityGroupName(), action);
writeResultProtos.add(response.getResult());
} else {
ClientProtocol clientProtocol = connection.getClient(
serverName.getHostname(), serverName.getPort());
ClientProtos.InsertResponse response = clientProtocol.insert(null,
RequestConverter.buildInsertRequest(action));
writeResultProtos.add(response.getResult());
}
} catch (ServiceException e) {
if (e.getCause() != null && e.getCause() instanceof IOException) {
connection.clearCaches(serverName.getHostAndPort());
}
throw e;
} catch (Exception e) {
if (e instanceof IOException) {
connection.clearCaches(serverName.getHostAndPort());
}
throw new ServiceException(e);
}
} else if (actions.size() > 1) {
Map<EntityGroupInfo, List<Action>> actionMap = getActionMap(plan