@Test public void testFailedHttpGet() throws Exception { LOG.info("STARTING HTTP GET (FAIL) TEST..."); Map<String, Object> conf = getConf(0, 0, 0); try (DRPCServer server = new DRPCServer(conf, new StormMetricsRegistry())) { server.start(); //TODO need a better way to do this Thread.sleep(2000); try (DRPCInvocationsClient invoke = new DRPCInvocationsClient(conf, "localhost", server.getDrpcInvokePort())) { Future<String> found = exec.submit(() -> doGet(server.getHttpServerPort(), "testing", "test")); DRPCRequest request = getNextAvailableRequest(invoke, "testing"); assertNotNull(request); assertEquals("test", request.get_func_args()); assertNotNull(request.get_request_id()); invoke.getClient().failRequest(request.get_request_id()); try { found.get(1000, TimeUnit.MILLISECONDS); fail("exec did not throw an exception"); } catch (ExecutionException e) { LOG.warn("Got Expected Exception", e); //Getting the exact response code is a bit more complex. //TODO should use a better client } } } } }
public void reconnectClient() throws TException { if (client.get() == null) { reconnect(); client.set(new DistributedRPCInvocations.Client(_protocol)); } }
public DRPCRequest fetchRequest(String func) throws TException, AuthorizationException { DistributedRPCInvocations.Client c = client.get(); try { if (c == null) { throw new TException("Client is not connected..."); } return c.fetchRequest(func); } catch (AuthorizationException aze) { throw aze; } catch (TException e) { client.compareAndSet(c, null); throw e; } }
public void failRequest(String id) throws TException, AuthorizationException { DistributedRPCInvocations.Client c = client.get(); try { if (c == null) { throw new TException("Client is not connected..."); } c.failRequest(id); } catch(AuthorizationException aze) { throw aze; } catch(TException e) { client.compareAndSet(c, null); throw e; } }
public DRPCRequest fetchRequest(String func) throws TException, AuthorizationException { DistributedRPCInvocations.Client c = client.get(); try { if (c == null) { throw new TException("Client is not connected..."); } return c.fetchRequest(func); } catch(AuthorizationException aze) { throw aze; } catch(TException e) { client.compareAndSet(c, null); throw e; } }
public void result(String id, String result) throws TException, AuthorizationException { DistributedRPCInvocations.Client c = client.get(); try { if (c == null) { throw new TException("Client is not connected..."); } c.result(id, result); } catch(AuthorizationException aze) { throw aze; } catch(TException e) { client.compareAndSet(c, null); throw e; } }
public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { return new Client(iprot, oprot); } }
public Client getClient(org.apache.thrift.protocol.TProtocol prot) { return new Client(prot); } public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
public DRPCInvocationsClient(Map conf, String host, int port) throws TTransportException { super(conf, ThriftConnectionType.DRPC_INVOCATIONS, host, port, null); this.host = host; this.port = port; client.set(new DistributedRPCInvocations.Client(_protocol)); }
public void recv_failRequest() throws AuthorizationException, org.apache.thrift.TException { failRequest_result result = new failRequest_result(); receiveBase(result, "failRequest"); if (result.aze != null) { throw result.aze; } return; }
public void getResult() throws AuthorizationException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); (new Client(prot)).recv_failRequest(); } }
public void failRequest(String id) throws AuthorizationException, org.apache.thrift.TException { send_failRequest(id); recv_failRequest(); }
public void reconnectClient() throws TException { if (client.get() == null) { reconnect(); client.set(new DistributedRPCInvocations.Client(_protocol)); } }
public void send_failRequest(String id) throws org.apache.thrift.TException { failRequest_args args = new failRequest_args(); args.set_id(id); sendBase("failRequest", args); }
public void getResult() throws AuthorizationException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); (new Client(prot)).recv_result(); } }
public DRPCRequest recv_fetchRequest() throws AuthorizationException, org.apache.thrift.TException { fetchRequest_result result = new fetchRequest_result(); receiveBase(result, "fetchRequest"); if (result.is_set_success()) { return result.success; } if (result.aze != null) { throw result.aze; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "fetchRequest failed: unknown result"); }
public void result(String id, String result) throws AuthorizationException, org.apache.thrift.TException { send_result(id, result); recv_result(); }
public DRPCRequest getResult() throws AuthorizationException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_fetchRequest(); } }
public void send_fetchRequest(String functionName) throws org.apache.thrift.TException { fetchRequest_args args = new fetchRequest_args(); args.set_functionName(functionName); sendBase("fetchRequest", args); }
public void send_result(String id, String result) throws org.apache.thrift.TException { result_args args = new result_args(); args.set_id(id); args.set_result(result); sendBase("result", args); }