@Override public Object readResponse(Schema schema, Decoder in) throws IOException { return getDatumReader(schema).read(null, in); }
@Override public void writeRequest(Schema schema, Object request, Encoder out) throws IOException { Object[] args = (Object[])request; int i = 0; for (Schema.Field param : schema.getFields()) getDatumWriter(param.schema()).write(args[i++], out); }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return request(method.getName(), args); }
/** Create a proxy instance whose methods invoke RPCs. */ public static Object getClient(Class<?> iface, Transceiver transciever) throws IOException { return getClient(iface, transciever, SpecificData.get()); }
/** Create a proxy instance whose methods invoke RPCs. */ public static Object getClient(Class<?> iface, Transceiver transciever, SpecificData specificData) throws IOException { Protocol protocol = specificData.getProtocol(iface); return Proxy.newProxyInstance(iface.getClassLoader(), new Class[] { iface }, new SpecificRequestor(protocol, transciever)); }
/** Create a proxy instance whose methods invoke RPCs. */ public static Object getClient(Class<?> iface, Transceiver transciever) throws IOException { return getClient(iface, transciever, SpecificData.get()); }
/** Create a proxy instance whose methods invoke RPCs. */ public static Object getClient(Class<?> iface, Transceiver transciever, SpecificData specificData) throws IOException { Protocol protocol = specificData.getProtocol(iface); return Proxy.newProxyInstance(iface.getClassLoader(), new Class[] { iface }, new SpecificRequestor(protocol, transciever)); }
protected List<Span> collectAllSpans(List<URL> hosts) { List<Span> out = new ArrayList<Span>(); for (URL url: hosts) { HttpTransceiver trans = new HttpTransceiver(url); try { AvroTrace client = (AvroTrace) SpecificRequestor.getClient(AvroTrace.class, trans); for (Span s: client.getAllSpans()) { out.add(s); } } catch (IOException e) { continue; } } return out; }
@Override public Object readResponse(Schema schema, Decoder in) throws IOException { return getDatumReader(schema).read(null, in); }
@Override public void writeRequest(Schema schema, Object request, Encoder out) throws IOException { Object[] args = (Object[])request; int i = 0; for (Schema.Field param : schema.getFields()) getDatumWriter(param.schema()).write(args[i++], out); }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return request(method.getName(), args); }
protected List<Span> collectRangedSpans(List<URL> hosts, long start, long end) { List<Span> out = new ArrayList<Span>(); for (URL url: hosts) { HttpTransceiver trans = new HttpTransceiver(url); try { AvroTrace client = (AvroTrace) SpecificRequestor.getClient(AvroTrace.class, trans); for (Span s: client.getSpansInRange(start, end)) { out.add(s); } } catch (IOException e) { continue; } } return out; }
@Override public Exception readError(Schema schema, Decoder in) throws IOException { Object value = getDatumReader(schema).read(null, in); if (value instanceof Exception) return (Exception)value; return new AvroRuntimeException(value.toString()); }
public TetheredProcess(JobConf job, OutputCollector<TetherData, NullWritable> collector, Reporter reporter) throws Exception { try { // start server this.outputService = new TetherOutputService(collector, reporter); this.outputServer = new SocketServer (new SpecificResponder(OutputProtocol.class, outputService), new InetSocketAddress(0)); outputServer.start(); // start sub-process, connecting back to server this.subprocess = startSubprocess(job); // open client, connecting to sub-process this.clientTransceiver = new SocketTransceiver(new InetSocketAddress(outputService.inputPort())); this.inputClient = (InputProtocol) SpecificRequestor.getClient(InputProtocol.class, clientTransceiver); } catch (Exception t) { close(); throw t; } }
@Override public Exception readError(Schema schema, Decoder in) throws IOException { Object value = getDatumReader(schema).read(null, in); if (value instanceof Exception) return (Exception)value; return new AvroRemoteException(value); }