private void close(Endpoint endpoint) { if (endpoint.getLocalState() != EndpointState.CLOSED) { endpoint.close(); } }
private void open(Endpoint endpoint) { if (endpoint.getLocalState() == EndpointState.UNINITIALIZED) { endpoint.open(); } }
@Override public void remotelyClosed(AmqpConnection connection) { Exception error = AmqpSupport.convertToException(getEndpoint().getRemoteCondition()); if (endpoint != null) { // TODO: if this is a producer/consumer link then we may only be detached, // rather than fully closed, and should respond appropriately. endpoint.close(); } LOG.info("Resource {} was remotely closed", this); connection.fireClientException(error); }
public EndpointContext context(Endpoint endpoint) { EndpointContext context = (EndpointContext) endpoint.getContext(); if( context == null ) { context = new EndpointContext(this, endpoint); endpoint.setContext(context); } return context; }
if (getEndpoint().getLocalState() == EndpointState.CLOSED || getEndpoint().getRemoteState() == EndpointState.CLOSED) { if (getEndpoint().getLocalState() != EndpointState.CLOSED) { getEndpoint().close(); getEndpoint().free(); getEndpoint().setContext(null);
protected final void handleClosed(AmqpProvider provider, Throwable cause) { // If the resource being built is closed during the creation process // then this is always an error. resourceInfo.setState(ResourceState.REMOTELY_CLOSED); // Perform any post processing relating to closure during creation attempt afterClosed(getResource(), getResourceInfo()); Throwable openError; if (hasRemoteError()) { openError = AmqpSupport.convertToException(parent.getProvider(), getEndpoint(), getEndpoint().getRemoteCondition()); } else if (cause != null) { openError = cause; } else { openError = getOpenAbortException(); } if (requestTimeoutTask != null) { requestTimeoutTask.cancel(false); } LOG.warn("Open of resource:({}) failed: {}", resourceInfo, openError.getMessage()); // This resource is now terminated. getEndpoint().close(); getEndpoint().free(); getEndpoint().setContext(null); getRequest().onFailure(openError); }
@Override public void close(AsyncResult request) { // If already closed signal success or else the caller might never get notified. if (getEndpoint().getLocalState() == EndpointState.CLOSED || getEndpoint().getRemoteState() == EndpointState.CLOSED) { if (getEndpoint().getLocalState() != EndpointState.CLOSED) { doClose(); getEndpoint().free(); } request.onSuccess(); } else { this.closeRequest = request; doClose(); } }
endpoint.setContext(this); endpoint.open(); if (endpoint.getRemoteState() != EndpointState.UNINITIALIZED) { provider.scheduleExecuteAndPump(new Runnable() { @Override
/** * Perform the close operation on the managed endpoint. A subclass may override this method * to provide additional close actions or alter the standard close path such as endpoint * detach etc. */ protected void doClose() { getEndpoint().close(); }
@Override public boolean isClosed() { return getEndpoint().getLocalState() == EndpointState.CLOSED; }
public void fireListenerEvents(AmqpListener listener) { if( listener!=null && !listenerProcessing ) { if( endpoint.getLocalState() == EndpointState.UNINITIALIZED && endpoint.getRemoteState() != EndpointState.UNINITIALIZED ) { listenerProcessing = true; listener.processRemoteOpen(endpoint, new ProcessedTask()); } else if( endpoint.getLocalState() == EndpointState.ACTIVE && endpoint.getRemoteState() == EndpointState.CLOSED ) { listenerProcessing = true; listener.processRemoteClose(endpoint, new ProcessedTask()); } } if( attachment !=null && attachment instanceof Task ) { ((Task) attachment).run(); } }
@Override public boolean isOpen() { return getEndpoint().getRemoteState() == EndpointState.ACTIVE; }
public ErrorCondition getRemoteError() { return getEndpoint().getRemoteCondition(); }
@Override public boolean execute() { if (getEndpoint().getRemoteState() == EndpointState.CLOSED) { cb.onSuccess(getEndpoint().getRemoteCondition()); return true; } return false; } });
public void processRemoteOpen(Endpoint endpoint, Task onComplete) { ErrorCondition condition = endpoint.getCondition(); condition.setCondition(Symbol.valueOf("error")); condition.setDescription("Not supported"); endpoint.close(); onComplete.run(); }
getEndpoint().free(); getEndpoint().setContext(null);
/** * Perform the open operation on the managed endpoint. A subclass may override this method to * provide additional open actions or configuration updates. */ protected void doOpen() { getEndpoint().open(); }
@Override public void open(AsyncResult request) { this.openRequest = request; doOpen(); getEndpoint().setContext(this); }
if (getEndpoint().getLocalState() == EndpointState.CLOSED || getEndpoint().getRemoteState() == EndpointState.CLOSED) { if (getEndpoint().getLocalState() != EndpointState.CLOSED) { getEndpoint().close(); getEndpoint().free(); getEndpoint().setContext(null);