(final HBaseClient client, String[] args)
| 337 | |
| 338 | private static final class cas implements Cmd { |
| 339 | public void execute(final HBaseClient client, String[] args) throws Exception { |
| 340 | ensureArguments(args, 8, 8); |
| 341 | RowLock lock = null; |
| 342 | if (args[1].charAt(0) == 'l') { // locked version of the command |
| 343 | final RowLockRequest rlr = new RowLockRequest(args[2], args[3]); |
| 344 | lock = client.lockRow(rlr).joinUninterruptibly(); |
| 345 | LOG.info("Acquired explicit row lock: " + lock); |
| 346 | } |
| 347 | final PutRequest put = lock == null |
| 348 | ? new PutRequest(args[2], args[3], args[4], args[5], args[7]) |
| 349 | : new PutRequest(args[2], args[3], args[4], args[5], args[7], lock); |
| 350 | final String expected = args[6]; |
| 351 | args = null; |
| 352 | try { |
| 353 | final boolean ok = client.compareAndSet(put, expected).joinUninterruptibly(); |
| 354 | LOG.info("CAS " |
| 355 | + (ok ? "succeeded" : "failed: value wasn't " + expected)); |
| 356 | } catch (Exception e) { |
| 357 | LOG.error("CAS failed", e); |
| 358 | } finally { |
| 359 | if (lock != null) { |
| 360 | client.unlockRow(lock).joinUninterruptibly(); |
| 361 | LOG.info("Released explicit row lock: " + lock); |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | } |
nothing calls this directly
no test coverage detected