private RestClient mockClientResponses(RestClient.BulkActionResponse... responses) { RestClient mockClient = Mockito.mock(RestClient.class); OngoingStubbing<RestClient.BulkActionResponse> stubb = Mockito.when( mockClient.bulk(Mockito.eq(resource), Mockito.any(TrackingBytesArray.class)) ); for (RestClient.BulkActionResponse response : responses) { stubb = stubb.thenReturn(response); } stubb.thenThrow(new AssertionError("Exhausted all given test responses.")); return mockClient; }
RestClient.BulkActionResponse bar = restClient.bulk(resource, data); debugLog(bulkLoggingID, "Response received"); totalAttempts++;
public BitSet tryFlush() { BitSet bulkResult = EMPTY; try { // double check data - it might be a false flush (called on clean-up) if (data.length() > 0) { if (log.isDebugEnabled()) { log.debug(String.format("Sending batch of [%d] bytes/[%s] entries", data.length(), dataEntries)); } bulkResult = client.bulk(resourceW, data); executedBulkWrite = true; } } catch (EsHadoopException ex) { hadWriteErrors = true; throw ex; } // discard the data buffer, only if it was properly sent/processed //if (bulkResult.isEmpty()) { // always discard data since there's no code path that uses the in flight data discard(); //} return bulkResult; }
RestClient.BulkActionResponse bar = restClient.bulk(resource, data); debugLog(bulkLoggingID, "Response received"); totalAttempts++;
RestClient.BulkActionResponse bar = restClient.bulk(resource, data); debugLog(bulkLoggingID, "Response received"); totalAttempts++;
RestClient.BulkActionResponse bar = restClient.bulk(resource, data); debugLog(bulkLoggingID, "Response received"); totalAttempts++;