binding.bindAddress() + "\n***via candidate:\n" + candidate + return binding.bindAddress();
@Override public IoHandler getHandler(ResourceAddress address) { Binding binding = bindings.getBinding(address); if (binding != null) { return binding.handler(); } System.out.println(String.format("ERROR in getHandler: bindings: %s\naddress: %s", bindings, address)); return null; }
boolean needsAcceptorBind = (nextBinding == null); Binding newBinding = new Binding(address, handler, initializer); Binding binding = bindings.addBinding(newBinding); if (binding != null) {
final ResourceAddress sseBindAddress = binding.bindAddress(); final IoHandler sseHandler = binding.handler();
ResourceAddress localAddress = (binding != null) ? binding.bindAddress() : null; if (localAddress != null) { httpRequest.setExternalURI(candidateAddress.getExternalURI());
ResourceAddress transport = currentAddress.getTransport(); if (transport != null) { // Udp over Socks over Tcp might get us here Binding newBinding = new Binding(currentAddress, handler, initializer); Binding binding = bindings.addBinding(newBinding); if (binding != null) { Binding newBinding = new Binding(currentAddress, handler, initializer); Binding binding = bindings.addBinding(newBinding); if (binding != null) {
binding.bindAddress() + "\n***via candidate:\n" + candidate + return binding.bindAddress();
boolean removed = bindings.removeBinding(address, binding); if (removed) { ResourceAddress bindAddress = binding.bindAddress(); T socketAddress = socketAddressFactory.createSocketAddress(bindAddress); acceptor.unbind(socketAddress);
Binding newBinding = new Binding(address, handler, initializer); Binding oldBinding = bindings.addBinding(newBinding); + " because it collides with an already bound address " + oldBinding.bindAddress());
tcpBridgeProcessor, acceptor.getSessionDataStructureFactory()); newTcpBridgeSession.setLocalAddress(binding.bindAddress()); newTcpBridgeSession.setRemoteAddress(resourceAddressFactory.newResourceAddress(binding.bindAddress(), REMOTE_ADDRESS.get(session))); newTcpBridgeSession.setHandler(binding.handler()); if (binding.initializer() != null) { binding.initializer().initializeSession(newTcpBridgeSession, null);
IoHandler handler = binding.handler(); DELEGATE_KEY.set(session, handler); ResourceAddress localAddress = binding.bindAddress(); LOCAL_ADDRESS.set(session, localAddress); REMOTE_ADDRESS.set(session, remoteAddress); BridgeSessionInitializer<? extends IoFuture> initializer = binding.initializer(); if (initializer != null) { initializer.initializeSession(session, null);
IoHandler handler = binding.handler(); DELEGATE_KEY.set(session, handler); ResourceAddress localAddress = binding.bindAddress(); LOCAL_ADDRESS.set(session, localAddress); REMOTE_ADDRESS.set(session, remoteAddress); BridgeSessionInitializer<? extends IoFuture> initializer = binding.initializer(); if (initializer != null) { initializer.initializeSession(session, null);
boolean removed = bindings.removeBinding(address, nioBinding); if (removed) { ResourceAddress bindAddress = nioBinding.bindAddress(); InetSocketAddress socketAddress = asSocketAddress(bindAddress); acceptor.unbind(socketAddress);
@Override public final UnbindFuture unbind(ResourceAddress address) { UnbindFuture future = null; boolean unbindAlternate; do { //System.out.println(getClass().getSimpleName()+"@"+hashCode()+" unbinding: "+address.getExternalURI()+" -- "+address.getOption(NEXT_PROTOCOL)); unbindAlternate = address.getOption(BIND_ALTERNATE); Binding binding = bindings.getBinding(address); bindings.removeBinding(address, binding); // Using address (instead of binding.bindAddress()) as two different addresses may have the same binding // due to alternates. For example: sse (with http transport) has alternate sse(with httpxe transport) // Say, they are A and its alternate B. A and B share the same binding as alternates comparator consider // A and B are equal. Unbinding A happens fine. While unbinding B, the binding.bindAddress() would be A // with alternate B and this would cause problems(as A is already used for unbinding). UnbindFuture newFuture = unbindInternal(address, binding.handler(), binding.initializer()); if (future != null) { future = DefaultUnbindFuture.combineFutures(future, newFuture); } else { future = newFuture; } address = address.getOption(ALTERNATE); } while (address != null && unbindAlternate); return future; }
binding.bindAddress() + "\n***via candidate:\n" + candidate + return binding.bindAddress();
public Binding addBinding(Binding newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); String nextProtocol = bindAddress.getOption(NEXT_PROTOCOL); if (nextProtocol == null) { if (nullNextProtocol.compareAndSet(null, newBinding)) { newBinding.incrementReferenceCount(); return null; } Binding oldBinding = nullNextProtocol.get(); if (equivalent(newBinding, oldBinding)) { oldBinding.incrementReferenceCount(); return null; } return oldBinding; } Binding oldBinding = nextProtocols.putIfAbsent(nextProtocol, newBinding); if (oldBinding == null) { newBinding.incrementReferenceCount(); } else if (equivalent(newBinding, oldBinding)) { oldBinding.incrementReferenceCount(); oldBinding = null; } return oldBinding; }
@Override public Binding addBinding(Binding newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); HttpBinding httpBinding = getBinding0(bindAddress); if (httpBinding == null) { HttpBinding newHttpBinding = new HttpBinding(bindAddress); httpBinding = bindAdditionalAddressesIfNecessary(newHttpBinding); if (httpBinding == null) { httpBinding = newHttpBinding; } } URI location = bindAddress.getResource(); String path = location.getPath(); Binding binding = httpBinding.put(path, newBinding); if (binding != null) { if (equivalent(newBinding, binding)) { binding.incrementReferenceCount(); binding = null; } } else { newBinding.incrementReferenceCount(); } return binding; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); int mark = sb.length(); Binding nullNextProtocolSnapshot = nullNextProtocol.get(); if (nullNextProtocolSnapshot != null) { sb.append("null: "); ResourceAddress bindAddress = nullNextProtocolSnapshot.bindAddress(); sb.append(bindAddress); sb.append(", "); } for (Binding binding : nextProtocols.values()) { ResourceAddress bindAddress = binding.bindAddress(); sb.append(bindAddress); sb.append(", "); } if (sb.length() > mark) { // rewind last ", " sb.setLength(sb.length() - 2); } sb.append('}'); return sb.toString(); }
protected final B addBinding0(B newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); B oldBinding = bindings.get(bindAddress); if (oldBinding != null) { IoHandler newHandler = newBinding.handler(); IoHandler oldHandler = oldBinding.handler(); if (oldHandler != null && newHandler != oldHandler) { throw new RuntimeException("Tried to bind address "+bindAddress+" to a different handler (old,new) = ("+oldHandler+","+newHandler+")"); } oldBinding.incrementReferenceCount(); return null; } // bind address to handler B binding = bindings.putIfAbsent(bindAddress, newBinding); if (binding != null) { if (equivalent(newBinding, binding)) { binding.incrementReferenceCount(); binding = null; } } else { newBinding.incrementReferenceCount(); } return binding; }
public boolean removeBinding(ResourceAddress address, Binding binding) { ResourceAddress bindAddress = binding.bindAddress(); String nextProtocol = bindAddress.getOption(NEXT_PROTOCOL); if (nextProtocol == null) { Binding oldBinding = nullNextProtocol.get(); if (equivalent(oldBinding, binding)) { binding = oldBinding; } if (binding.decrementReferenceCount() == 0) { return nullNextProtocol.compareAndSet(binding, null); } return false; } Binding oldBinding = nextProtocols.get(nextProtocol); if (equivalent(oldBinding, binding)) { binding = oldBinding; } if (binding.decrementReferenceCount() == 0) { return nextProtocols.remove(nextProtocol, binding); } return false; }