use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.
the class TestPutRpc method executeHBaseErrorHandler.
@SuppressWarnings("unchecked")
@Test
public void executeHBaseErrorHandler() throws Exception {
when(tsdb.addPoint(anyString(), anyLong(), anyLong(), (HashMap<String, String>) any())).thenReturn(Deferred.fromError(new RuntimeException("Wotcher!")));
final PutDataPointRpc put = new PutDataPointRpc();
final Channel chan = NettyMocks.fakeChannel();
assertNull(put.execute(tsdb, chan, new String[] { "put", "sys.cpu.nice", "1365465600", "42", "host=web01" }).joinUninterruptibly());
assertEquals(1, requests.get());
assertEquals(0, invalid_values.get());
assertEquals(1, hbase_errors.get());
verify(chan, times(1)).write(any());
verify(chan, times(1)).isConnected();
verify(tsdb, times(1)).getStorageExceptionHandler();
verify(handler, times(1)).handleError((IncomingDataPoint) any(), (Exception) any());
}
use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.
the class TestPutRpc method executeHBaseErrorNotWriteable.
@SuppressWarnings("unchecked")
@Test
public void executeHBaseErrorNotWriteable() throws Exception {
when(tsdb.addPoint(anyString(), anyLong(), anyLong(), (HashMap<String, String>) any())).thenReturn(Deferred.fromError(new RuntimeException("Wotcher!")));
final PutDataPointRpc put = new PutDataPointRpc();
final Channel chan = NettyMocks.fakeChannel();
when(chan.isWritable()).thenReturn(false);
assertNull(put.execute(tsdb, chan, new String[] { "put", "sys.cpu.nice", "1365465600", "42", "host=web01" }).joinUninterruptibly());
assertEquals(1, requests.get());
assertEquals(0, invalid_values.get());
assertEquals(1, hbase_errors.get());
assertEquals(1, writes_blocked.get());
verify(chan, never()).write(any());
verify(chan, times(1)).isConnected();
verify(tsdb, times(1)).getStorageExceptionHandler();
}
use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.
the class TestPutRpc method executeNullArray.
@Test(expected = NullPointerException.class)
public void executeNullArray() throws Exception {
final PutDataPointRpc put = new PutDataPointRpc();
final Channel chan = NettyMocks.fakeChannel();
put.execute(tsdb, chan, null);
}
use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.
the class TestRpcHandler method emptyPathIsBadRequest.
@Test
public void emptyPathIsBadRequest() throws Exception {
final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "");
final Channel mockChan = handleHttpRpc(req, new Answer<ChannelFuture>() {
public ChannelFuture answer(final InvocationOnMock args) throws Throwable {
DefaultHttpResponse response = (DefaultHttpResponse) args.getArguments()[0];
assertEquals(HttpResponseStatus.BAD_REQUEST, response.getStatus());
return new SucceededChannelFuture((Channel) args.getMock());
}
});
final RpcHandler rpc = new RpcHandler(tsdb, rpc_manager);
Whitebox.invokeMethod(rpc, "handleHttpQuery", tsdb, mockChan, req);
}
use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.
the class TestRpcHandler method createQueryInstanceEmptyRequestInvalid.
@Test(expected = BadRequestException.class)
public void createQueryInstanceEmptyRequestInvalid() throws Exception {
final RpcHandler rpc = new RpcHandler(tsdb, rpc_manager);
final Channel mockChan = NettyMocks.fakeChannel();
final Method meth = Whitebox.getMethod(RpcHandler.class, "createQueryInstance", TSDB.class, HttpRequest.class, Channel.class);
meth.invoke(rpc, tsdb, new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, ""), mockChan);
}
Aggregations