/** * Creates client worker. * * @param idx Worker index for worker thread naming. * @param endpoint Connected client endpoint. * @throws GridException If endpoint output stream cannot be obtained. */ protected ClientWorker(GridIpcEndpoint endpoint, int idx) throws GridException { super(ggfsCtx.kernalContext().gridName(), "ggfs-client-worker-" + idx, log); this.endpoint = endpoint; ses = new GridGgfsClientSession(); out = new GridGgfsDataOutputStream(new BufferedOutputStream(endpoint.outputStream())); }
@Override public void applyx(GridFuture<GridGgfsMessage> fut) { GridGgfsMessage res; try { res = fut.get(); } catch (GridException e) { res = new GridGgfsControlResponse(); ((GridGgfsControlResponse)res).error(e); } try { synchronized (out) { byte[] hdr = GridGgfsMarshaller.createHeader(reqId, res.command()); marsh.marshall(res, hdr, out); out.flush(); } } catch (IOException | GridException e) { shutdown0(e); } } });
@Override public void applyx(GridFuture<GridGgfsMessage> fut) { GridGgfsMessage res; try { res = fut.get(); } catch (GridException e) { res = new GridGgfsControlResponse(); ((GridGgfsControlResponse)res).error(e); } try { synchronized (out) { byte[] hdr = GridGgfsMarshaller.createHeader(reqId, res.command()); marsh.marshall(res, hdr, out); out.flush(); } } catch (IOException | GridException e) { shutdown0(e); } } });
/** * Creates client worker. * * @param idx Worker index for worker thread naming. * @param endpoint Connected client endpoint. * @throws GridException If endpoint output stream cannot be obtained. */ protected ClientWorker(GridIpcEndpoint endpoint, int idx) throws GridException { super(ggfsCtx.kernalContext().gridName(), "ggfs-client-worker-" + idx, log); this.endpoint = endpoint; ses = new GridGgfsClientSession(); out = new GridGgfsDataOutputStream(new BufferedOutputStream(endpoint.outputStream())); }