@Override public void mutateRows(List<Mutation> mutations) throws IOException { // get the coprocessor environment RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) getEnvironment(); // set of rows to lock, sorted to avoid deadlocks SortedSet<byte[]> rowsToLock = new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR); HRegionInfo regionInfo = env.getRegion().getRegionInfo(); for (Mutation m : mutations) { // check whether rows are in range for this region if (!HRegion.rowIsInRange(regionInfo, m.getRow())) { String msg = "Requested row out of range '" + Bytes.toStringBinary(m.getRow()) + "'"; if (rowsToLock.isEmpty()) { // if this is the first row, region might have moved, // allow client to retry throw new WrongRegionException(msg); } else { // rows are split between regions, do not retry throw new DoNotRetryIOException(msg); } } rowsToLock.add(m.getRow()); } // call utility method on region env.getRegion().mutateRowsWithLocks(mutations, rowsToLock); }