private void verifyResult(AsyncRequestFuture ars, boolean... expected) throws Exception { Object[] actual = ars.getResults(); Assert.assertEquals(expected.length, actual.length); for (int i = 0; i < expected.length; ++i) { Assert.assertEquals(expected[i], !(actual[i] instanceof Throwable)); } }
private void verifyReplicaResult(AsyncRequestFuture ars, RR... expecteds) throws Exception { Object[] actuals = ars.getResults(); Assert.assertEquals(expecteds.length, actuals.length); for (int i = 0; i < expecteds.length; ++i) { Object actual = actuals[i]; RR expected = expecteds[i]; Assert.assertEquals(actual.toString(), expected == RR.FAILED, actual instanceof Throwable); if (expected != RR.FAILED && expected != RR.DONT_CARE) { Assert.assertEquals(expected == RR.TRUE, ((Result)actual).isStale()); } } }
@Test public void testSuccessivePut() throws Exception { MyAsyncProcess ap = new MyAsyncProcess(createHConnection(), CONF); List<Put> puts = new ArrayList<>(1); puts.add(new Put(GOOD_ROW).addColumn(FAMILY, FAMILY, FAMILY)); final int expectedSize = puts.size(); AsyncRequestFuture arf = ap.submit(DUMMY_TABLE, puts); arf.waitUntilDone(); Object[] result = arf.getResults(); assertEquals(expectedSize, result.length); for (Object r : result) { assertEquals(Result.class, r.getClass()); } assertTrue(puts.isEmpty()); assertActionsInProgress(arf); }
@Test public void testFailedPut() throws Exception { MyAsyncProcess ap = new MyAsyncProcess(createHConnection(), CONF); List<Put> puts = new ArrayList<>(2); puts.add(new Put(GOOD_ROW).addColumn(FAMILY, FAMILY, FAMILY)); // this put should fail puts.add(new Put(BAD_ROW).addColumn(FAMILY, FAMILY, FAMILY)); final int expectedSize = puts.size(); AsyncRequestFuture arf = ap.submit(DUMMY_TABLE, puts); arf.waitUntilDone(); // There is a failed puts assertError(arf, 1); Object[] result = arf.getResults(); assertEquals(expectedSize, result.length); assertEquals(Result.class, result[0].getClass()); assertTrue(result[1] instanceof IOException); assertTrue(puts.isEmpty()); assertActionsInProgress(arf); }
@Test public void testFailedPutWithoutActionException() throws Exception { MyAsyncProcess ap = new MyAsyncProcess(createHConnection(), CONF); List<Put> puts = new ArrayList<>(3); puts.add(new Put(GOOD_ROW).addColumn(FAMILY, FAMILY, FAMILY)); // this put should fail puts.add(new Put(BAD_ROW).addColumn(FAMILY, FAMILY, FAMILY)); // this put should fail, and it won't have action exception puts.add(new Put(BAD_ROW_WITHOUT_ACTION_EXCEPTION).addColumn(FAMILY, FAMILY, FAMILY)); final int expectedSize = puts.size(); AsyncRequestFuture arf = ap.submit(DUMMY_TABLE, puts); arf.waitUntilDone(); // There are two failed puts assertError(arf, 2); Object[] result = arf.getResults(); assertEquals(expectedSize, result.length); assertEquals(Result.class, result[0].getClass()); assertTrue(result[1] instanceof IOException); assertTrue(result[2] instanceof IOException); assertTrue(puts.isEmpty()); assertActionsInProgress(arf); }
private void verifyResult(AsyncRequestFuture ars, boolean... expected) throws Exception { Object[] actual = ars.getResults(); Assert.assertEquals(expected.length, actual.length); for (int i = 0; i < expected.length; ++i) { Assert.assertEquals(expected[i], !(actual[i] instanceof Throwable)); } }
private void verifyReplicaResult(AsyncRequestFuture ars, RR... expecteds) throws Exception { Object[] actuals = ars.getResults(); Assert.assertEquals(expecteds.length, actuals.length); for (int i = 0; i < expecteds.length; ++i) { Object actual = actuals[i]; RR expected = expecteds[i]; Assert.assertEquals(actual.toString(), expected == RR.FAILED, actual instanceof Throwable); if (expected != RR.FAILED && expected != RR.DONT_CARE) { Assert.assertEquals(expected == RR.TRUE, ((Result)actual).isStale()); } } }
@Test public void testSuccessivePut() throws Exception { MyAsyncProcess ap = new MyAsyncProcess(createHConnection(), CONF); List<Put> puts = new ArrayList<>(1); puts.add(new Put(GOOD_ROW).addColumn(FAMILY, FAMILY, FAMILY)); final int expectedSize = puts.size(); AsyncRequestFuture arf = ap.submit(DUMMY_TABLE, puts); arf.waitUntilDone(); Object[] result = arf.getResults(); assertEquals(expectedSize, result.length); for (Object r : result) { assertEquals(Result.class, r.getClass()); } assertTrue(puts.isEmpty()); assertActionsInProgress(arf); }
@Test public void testFailedPutWithoutActionException() throws Exception { MyAsyncProcess ap = new MyAsyncProcess(createHConnection(), CONF); List<Put> puts = new ArrayList<>(3); puts.add(new Put(GOOD_ROW).addColumn(FAMILY, FAMILY, FAMILY)); // this put should fail puts.add(new Put(BAD_ROW).addColumn(FAMILY, FAMILY, FAMILY)); // this put should fail, and it won't have action exception puts.add(new Put(BAD_ROW_WITHOUT_ACTION_EXCEPTION).addColumn(FAMILY, FAMILY, FAMILY)); final int expectedSize = puts.size(); AsyncRequestFuture arf = ap.submit(DUMMY_TABLE, puts); arf.waitUntilDone(); // There are two failed puts assertError(arf, 2); Object[] result = arf.getResults(); assertEquals(expectedSize, result.length); assertEquals(Result.class, result[0].getClass()); assertTrue(result[1] instanceof IOException); assertTrue(result[2] instanceof IOException); assertTrue(puts.isEmpty()); assertActionsInProgress(arf); }
@Test public void testFailedPut() throws Exception { MyAsyncProcess ap = new MyAsyncProcess(createHConnection(), CONF); List<Put> puts = new ArrayList<>(2); puts.add(new Put(GOOD_ROW).addColumn(FAMILY, FAMILY, FAMILY)); // this put should fail puts.add(new Put(BAD_ROW).addColumn(FAMILY, FAMILY, FAMILY)); final int expectedSize = puts.size(); AsyncRequestFuture arf = ap.submit(DUMMY_TABLE, puts); arf.waitUntilDone(); // There is a failed puts assertError(arf, 1); Object[] result = arf.getResults(); assertEquals(expectedSize, result.length); assertEquals(Result.class, result[0].getClass()); assertTrue(result[1] instanceof IOException); assertTrue(puts.isEmpty()); assertActionsInProgress(arf); }