private void reportNoMoreHosts(SpeculativeExecution execution) { runningExecutions.remove(execution); if (runningExecutions.isEmpty()) setFinalException( execution, null, new NoHostAvailableException( errors == null ? Collections.<InetSocketAddress, Throwable>emptyMap() : errors)); }
@Override public NoHostAvailableException copy() { return new NoHostAvailableException(getMessage(), this, errors); }
@Test(groups = "unit") public void should_build_formatted_message_with_stack_traces() { NoHostAvailableException e = new NoHostAvailableException(buildMockErrors(3)); String message = e.getCustomMessage(3, true, true); assertThat(message).startsWith("All host(s) tried for query failed (tried:\n"); assertThat(message).contains("/127.0.0.1:9042\nmock stack trace 1\n"); assertThat(message).contains("/127.0.0.3:9042\nmock stack trace 3\n"); assertThat(message).contains("/127.0.0.2:9042\nmock stack trace 2\n"); }
@Test(groups = "unit") public void should_build_formatted_message_without_stack_traces() { NoHostAvailableException e = new NoHostAvailableException(buildMockErrors(3)); String message = e.getCustomMessage(3, true, false); assertThat(message).startsWith("All host(s) tried for query failed (tried:\n"); assertThat(message) .contains( "/127.0.0.1:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 1)\n"); assertThat(message) .contains( "/127.0.0.2:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 2)\n"); assertThat(message) .contains( "/127.0.0.3:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 3)\n"); }
@Test(groups = "unit") public void should_build_default_message_when_less_than_3_errors() { NoHostAvailableException e = new NoHostAvailableException(buildMockErrors(3)); String message = e.getMessage(); assertThat(message).startsWith("All host(s) tried for query failed"); assertThat(message) .contains( "/127.0.0.1:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 1)"); assertThat(message) .contains( "/127.0.0.2:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 2)"); assertThat(message) .contains( "/127.0.0.3:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 3)"); }
@Test(groups = "unit") public void should_build_default_message_when_more_than_3_errors() { NoHostAvailableException e = new NoHostAvailableException(buildMockErrors(4)); String message = e.getMessage(); assertThat(message).startsWith("All host(s) tried for query failed"); assertThat(message) .contains( "/127.0.0.1:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 1)"); assertThat(message) .contains( "/127.0.0.2:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 2)"); assertThat(message) .contains( "/127.0.0.3:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 3)"); assertThat(message) .contains("only showing errors of first 3 hosts, use getErrors() for more details"); }
iter.next(), new DriverException("Connection thread interrupted"), errors, iter); throw new NoHostAvailableException( errors == null ? Collections.<InetSocketAddress, Throwable>emptyMap() : errors);
private void reportNoMoreHosts(SpeculativeExecution execution) { runningExecutions.remove(execution); if (runningExecutions.isEmpty()) setFinalException(execution, null, new NoHostAvailableException( errors == null ? Collections.<InetSocketAddress, Throwable>emptyMap() : errors)); }
@Override public DriverException copy() { return new NoHostAvailableException(getMessage(), this, errors); }
private void reportNoMoreHosts(SpeculativeExecution execution) { runningExecutions.remove(execution); if (runningExecutions.isEmpty()) setFinalException(execution, null, new NoHostAvailableException( errors == null ? Collections.<InetSocketAddress, Throwable>emptyMap() : errors)); }
private void reportNoMoreHosts(SpeculativeExecution execution) { runningExecutions.remove(execution); if (runningExecutions.isEmpty()) setFinalException(execution, null, new NoHostAvailableException( errors == null ? Collections.<InetSocketAddress, Throwable>emptyMap() : errors)); }
@Override public NoHostAvailableException copy() { return new NoHostAvailableException(getMessage(), this, errors); }
@Override public NoHostAvailableException copy() { return new NoHostAvailableException(getMessage(), this, errors); }
@Override public NoHostAvailableException copy() { return new NoHostAvailableException(getMessage(), this, errors); }
public void sendRequest() { try { while (queryPlan.hasNext() && !isCanceled) { Host host = queryPlan.next(); logger.trace("Querying node {}", host); if (query(host)) return; } setFinalException(null, new NoHostAvailableException(errors == null ? Collections.<InetSocketAddress, Throwable>emptyMap() : errors)); } catch (Exception e) { // Shouldn't happen really, but if ever the loadbalancing policy returned iterator throws, we don't want to block. setFinalException(null, new DriverInternalError("An unexpected error happened while sending requests", e)); } }
@Test(groups = "unit") public void should_build_formatted_message_with_stack_traces() { NoHostAvailableException e = new NoHostAvailableException(buildMockErrors(3)); String message = e.getCustomMessage(3, true, true); assertThat(message).startsWith("All host(s) tried for query failed (tried:\n"); assertThat(message).contains("/127.0.0.1:9042\nmock stack trace 1\n"); assertThat(message).contains("/127.0.0.3:9042\nmock stack trace 3\n"); assertThat(message).contains("/127.0.0.2:9042\nmock stack trace 2\n"); }
@Test(groups = "unit") public void should_build_default_message_when_less_than_3_errors() { NoHostAvailableException e = new NoHostAvailableException(buildMockErrors(3)); String message = e.getMessage(); assertThat(message).startsWith("All host(s) tried for query failed"); assertThat(message) .contains( "/127.0.0.1:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 1)"); assertThat(message) .contains( "/127.0.0.2:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 2)"); assertThat(message) .contains( "/127.0.0.3:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 3)"); }
@Test(groups = "unit") public void should_build_formatted_message_without_stack_traces() { NoHostAvailableException e = new NoHostAvailableException(buildMockErrors(3)); String message = e.getCustomMessage(3, true, false); assertThat(message).startsWith("All host(s) tried for query failed (tried:\n"); assertThat(message) .contains( "/127.0.0.1:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 1)\n"); assertThat(message) .contains( "/127.0.0.2:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 2)\n"); assertThat(message) .contains( "/127.0.0.3:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 3)\n"); }
@Test(groups = "unit") public void should_build_default_message_when_more_than_3_errors() { NoHostAvailableException e = new NoHostAvailableException(buildMockErrors(4)); String message = e.getMessage(); assertThat(message).startsWith("All host(s) tried for query failed"); assertThat(message) .contains( "/127.0.0.1:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 1)"); assertThat(message) .contains( "/127.0.0.2:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 2)"); assertThat(message) .contains( "/127.0.0.3:9042 (com.datastax.driver.core.exceptions.NoHostAvailableExceptionTest$MockError: mock error 3)"); assertThat(message) .contains("only showing errors of first 3 hosts, use getErrors() for more details"); }
errors = logError(iter.next(), new DriverException("Connection thread interrupted"), errors, iter); throw new NoHostAvailableException(errors == null ? Collections.<InetSocketAddress, Throwable>emptyMap() : errors);