/** * Create a copy of this exception with a nicer stack trace, and including the coordinator address * that caused this exception to be raised. * * <p>This method is mainly intended for internal use by the driver and exists mainly because: * * <ol> * <li>the original exception was decoded from a response frame and at that time, the * coordinator address was not available; and * <li>the newly-created exception will refer to the current thread in its stack trace, which * generally yields a more user-friendly stack trace that the original one. * </ol> * * @param address The full address of the host that caused this exception to be thrown. * @return a copy/clone of this exception, but with the given host address instead of the original * one. */ public UnavailableException copy(InetSocketAddress address) { return new UnavailableException(address, getMessage(), this, consistency, required, alive); } }
@Override public UnavailableException copy() { return new UnavailableException(getAddress(), getMessage(), this, consistency, required, alive); }
@Test(groups = "unit") public void should_create_proper_unavailable_exception() { UnavailableException e = new UnavailableException(address1, LOCAL_QUORUM, 3, 2); assertThat(e.getMessage()) .isEqualTo( "Not enough replicas available for query at consistency LOCAL_QUORUM (3 required but only 2 alive)"); assertThat(e.getConsistencyLevel()).isEqualTo(LOCAL_QUORUM); assertThat(e.getAliveReplicas()).isEqualTo(2); assertThat(e.getRequiredReplicas()).isEqualTo(3); assertThat(e.getAddress()).isEqualTo(address1); assertThat(e.getHost()).isEqualTo(address1.getAddress()); e = e.copy(address2); assertThat(e.getMessage()) .isEqualTo( "Not enough replicas available for query at consistency LOCAL_QUORUM (3 required but only 2 alive)"); assertThat(e.getConsistencyLevel()).isEqualTo(LOCAL_QUORUM); assertThat(e.getAliveReplicas()).isEqualTo(2); assertThat(e.getRequiredReplicas()).isEqualTo(3); assertThat(e.getAddress()).isEqualTo(address2); assertThat(e.getHost()).isEqualTo(address2.getAddress()); }
new UnavailableException(ConsistencyLevel.ANY, 0, 0), new OverloadedException(null, "Overloaded"), new BootstrappingException(null, "Bootstrapping"),
@Override public DriverException copy() { return new UnavailableException(getMessage(), this, consistency, required, alive); } }
/** * Create a copy of this exception with a nicer stack trace, and including the coordinator * address that caused this exception to be raised. * <p/> * This method is mainly intended for internal use by the driver and exists mainly because: * <ol> * <li>the original exception was decoded from a response frame * and at that time, the coordinator address was not available; and</li> * <li>the newly-created exception will refer to the current thread in its stack trace, * which generally yields a more user-friendly stack trace that the original one.</li> * </ol> * * @param address The full address of the host that caused this exception to be thrown. * @return a copy/clone of this exception, but with the given host address instead of the original one. */ public UnavailableException copy(InetSocketAddress address) { return new UnavailableException(address, getMessage(), this, consistency, required, alive); } }
/** * Create a copy of this exception with a nicer stack trace, and including the coordinator * address that caused this exception to be raised. * <p/> * This method is mainly intended for internal use by the driver and exists mainly because: * <ol> * <li>the original exception was decoded from a response frame * and at that time, the coordinator address was not available; and</li> * <li>the newly-created exception will refer to the current thread in its stack trace, * which generally yields a more user-friendly stack trace that the original one.</li> * </ol> * * @param address The full address of the host that caused this exception to be thrown. * @return a copy/clone of this exception, but with the given host address instead of the original one. */ public UnavailableException copy(InetSocketAddress address) { return new UnavailableException(address, getMessage(), this, consistency, required, alive); } }
/** * Create a copy of this exception with a nicer stack trace, and including the coordinator * address that caused this exception to be raised. * <p/> * This method is mainly intended for internal use by the driver and exists mainly because: * <ol> * <li>the original exception was decoded from a response frame * and at that time, the coordinator address was not available; and</li> * <li>the newly-created exception will refer to the current thread in its stack trace, * which generally yields a more user-friendly stack trace that the original one.</li> * </ol> * * @param address The full address of the host that caused this exception to be thrown. * @return a copy/clone of this exception, but with the given host address instead of the original one. */ public UnavailableException copy(InetSocketAddress address) { return new UnavailableException(address, getMessage(), this, consistency, required, alive); } }
@Override public UnavailableException copy() { return new UnavailableException(getAddress(), getMessage(), this, consistency, required, alive); }
@Override public UnavailableException copy() { return new UnavailableException(getAddress(), getMessage(), this, consistency, required, alive); }
@Override public UnavailableException copy() { return new UnavailableException(getAddress(), getMessage(), this, consistency, required, alive); }
@Test(groups = "unit") public void should_create_proper_unavailable_exception() { UnavailableException e = new UnavailableException(address1, LOCAL_QUORUM, 3, 2); assertThat(e.getMessage()) .isEqualTo( "Not enough replicas available for query at consistency LOCAL_QUORUM (3 required but only 2 alive)"); assertThat(e.getConsistencyLevel()).isEqualTo(LOCAL_QUORUM); assertThat(e.getAliveReplicas()).isEqualTo(2); assertThat(e.getRequiredReplicas()).isEqualTo(3); assertThat(e.getAddress()).isEqualTo(address1); assertThat(e.getHost()).isEqualTo(address1.getAddress()); e = e.copy(address2); assertThat(e.getMessage()) .isEqualTo( "Not enough replicas available for query at consistency LOCAL_QUORUM (3 required but only 2 alive)"); assertThat(e.getConsistencyLevel()).isEqualTo(LOCAL_QUORUM); assertThat(e.getAliveReplicas()).isEqualTo(2); assertThat(e.getRequiredReplicas()).isEqualTo(3); assertThat(e.getAddress()).isEqualTo(address2); assertThat(e.getHost()).isEqualTo(address2.getAddress()); }
new UnavailableException(ConsistencyLevel.ANY, 0, 0), new OverloadedException(null, "Overloaded"), new BootstrappingException(null, "Bootstrapping"),