/** * The purpose of this test is to make sure that: When a TimedOutException is thrown out from * invoke method, the CassandraProxyClient will try at least maxAttempts times before throwing the * exception to the client. * * <p>A counter from the ThriftServer in BriskErrorDaemon tracks how many times the method has * been called. * * @throws Exception */ @Test public void testReconnect() throws Exception { EmbeddedBriskErrorServer.startBrisk(); Brisk.Iface client = CassandraProxyClient.newProxyConnection( "localhost", DatabaseDescriptor.getRpcPort(), true, ConnectionStrategy.STICKY); List<KsDef> ks = client.describe_keyspaces(); assertTrue(ks.size() > 0); try { client.get(ByteBufferUtil.EMPTY_BYTE_BUFFER, new ColumnPath("test"), ConsistencyLevel.ALL); fail("Expect a TimedoutException"); } catch (TimedOutException e) { // This is expected. } assertEquals( 11, client.get_count( ByteBufferUtil.EMPTY_BYTE_BUFFER, new ColumnParent("test"), new SlicePredicate(), ConsistencyLevel.ALL)); }
/** * When a cassandra server is not up, we expect that an IOException is thrown out from the method. */ @Test public void testNodeDown() { Brisk.Iface client = null; try { client = CassandraProxyClient.newProxyConnection( "localhost", DatabaseDescriptor.getRpcPort(), true, ConnectionStrategy.STICKY); fail("This should error"); } catch (IOException e) { } }