/** * Handle user abort. **/ public void handleAbort() { if (!conn.cancelReply(this)) { return; } timeoutTask.kill(); req.setError(ErrorCode.ABORT, "Aborted by user"); reqWaiter.handleRequestDone(req); }
/** * Add a connection to the set of connections handled by this * Transport. Invoked by the {@link Connector} class. * * @param conn the connection to add **/ void addConnection(Connection conn) { if (!postCommand(new AddConnectionCmd(conn))) { perform(new CloseConnectionCmd(conn)); } }
/** * Handle connection down. **/ public void handleConnectionDown() { timeoutTask.kill(); req.setError(ErrorCode.CONNECTION, "Connection error"); reqWaiter.handleRequestDone(req); }
public RegisterCallback(Request req, String name, String spec) { req.detach(); registerReq = req; this.name = name; this.spec = spec; target = orb.connect(new Spec(spec)); Request cbReq = new Request("slobrok.callback.listNamesServed"); target.invokeAsync(cbReq, 5.0, this); }
public void invokeAsync(Request req, double timeout, RequestWaiter waiter) { // TODO: Consider replacing this by a watcher on the target synchronized(this) { // ensure we have exactly 1 valid connection across threads if (target == null || ! target.isValid()) target = supervisor.connect(new Spec(hostname, port)); } target.invokeAsync(req, timeout, waiter); }
public void invoke() { if (!conn.postPacket(new RequestPacket(0, replyKey.intValue(), req.methodName(), req.parameters()), this)) { req.setError(ErrorCode.CONNECTION, "Connection error"); reqWaiter.handleRequestDone(req); return; } timeoutTask.schedule(timeout); }
public RequestPacket(int flags, int reqId, ByteBuffer src) { super(flags, reqId); methodName = new StringValue(src); parameters = new Values(src); }
private void handleAddConnection(Connection conn) { if (conn.isClosed()) { if (conn.hasSocket()) { closer.closeLater(conn); } return; } if (!conn.init(selector)) { handleCloseConnection(conn); } }
/** * Handle timeout. **/ public void run() { if (!conn.cancelReply(this)) { return; } req.setError(ErrorCode.TIMEOUT, "Request timed out after " + timeout + " seconds."); reqWaiter.handleRequestDone(req); } }
@Override public int write(ByteBuffer src) throws IOException { verifyHandshakeCompleted(); if (flush() == FlushResult.NEED_WRITE) return 0; int totalBytesWrapped = 0; int bytesWrapped; do { bytesWrapped = applicationDataWrap(src); totalBytesWrapped += bytesWrapped; } while (bytesWrapped > 0 && wrapBuffer.bytes() < sessionPacketBufferSize); return totalBytesWrapped; }
/** * Request an asynchronous close of a connection. * * @param conn the connection to close **/ void closeConnection(Connection conn) { postCommand(new CloseConnectionCmd(conn)); }
public Connection(Transport parent, Supervisor owner, SocketChannel channel) { this.parent = parent; this.owner = owner; this.socket = parent.createCryptoSocket(channel, true); server = true; owner.sessionInit(this); }
public void closeLater(Connection c) { if (!closeQueue.enqueue(c)) { c.closeSocket(); } }