Search in sources :

Example 21 with Symbol

use of org.apache.qpid.server.protocol.v1_0.type.Symbol in project qpid-broker-j by apache.

the class AMQPConnection_1_0Impl method receiveOpen.

@Override
public void receiveOpen(final int channel, final Open open) {
    assertState(ConnectionState.AWAIT_OPEN);
    int channelMax = getPort().getSessionCountLimit() - 1;
    _channelMax = open.getChannelMax() == null ? channelMax : open.getChannelMax().intValue() < channelMax ? open.getChannelMax().intValue() : channelMax;
    if (_receivingSessions == null) {
        _receivingSessions = new Session_1_0[_channelMax + 1];
        _sendingSessions = new Session_1_0[_channelMax + 1];
    }
    _maxFrameSize = open.getMaxFrameSize() == null || open.getMaxFrameSize().longValue() > getBroker().getNetworkBufferSize() ? getBroker().getNetworkBufferSize() : open.getMaxFrameSize().intValue();
    _remoteContainerId = open.getContainerId();
    if (open.getHostname() != null && !"".equals(open.getHostname().trim())) {
        _localHostname = open.getHostname();
    }
    if (_localHostname == null || "".equals(_localHostname.trim()) && getNetwork().getSelectedHost() != null) {
        _localHostname = getNetwork().getSelectedHost();
    }
    if (open.getIdleTimeOut() != null) {
        _outgoingIdleTimeout = open.getIdleTimeOut().longValue();
    }
    final Map<Symbol, Object> remoteProperties = open.getProperties() == null ? Collections.emptyMap() : Collections.unmodifiableMap(new LinkedHashMap<>(open.getProperties()));
    _remoteDesiredCapabilities = open.getDesiredCapabilities() == null ? Collections.emptySet() : Sets.newHashSet(open.getDesiredCapabilities());
    if (remoteProperties.containsKey(Symbol.valueOf("product"))) {
        setClientProduct(remoteProperties.get(Symbol.valueOf("product")).toString());
    }
    if (remoteProperties.containsKey(Symbol.valueOf("version"))) {
        setClientVersion(remoteProperties.get(Symbol.valueOf("version")).toString());
    }
    setClientId(_remoteContainerId);
    if (_remoteDesiredCapabilities.contains(SoleConnectionConnectionProperties.SOLE_CONNECTION_FOR_CONTAINER)) {
        if (remoteProperties != null && remoteProperties.containsKey(SOLE_CONNECTION_ENFORCEMENT_POLICY)) {
            try {
                _soleConnectionEnforcementPolicy = SoleConnectionEnforcementPolicy.valueOf(remoteProperties.get(SOLE_CONNECTION_ENFORCEMENT_POLICY));
            } catch (IllegalArgumentException e) {
                closeConnection(AmqpError.INVALID_FIELD, e.getMessage());
                return;
            }
        } else {
            _soleConnectionEnforcementPolicy = SoleConnectionEnforcementPolicy.REFUSE_CONNECTION;
        }
    }
    if (_outgoingIdleTimeout != 0L && _outgoingIdleTimeout < MINIMUM_SUPPORTED_IDLE_TIMEOUT) {
        closeConnection(ConnectionError.CONNECTION_FORCED, "Requested idle timeout of " + _outgoingIdleTimeout + " is too low. The minimum supported timeout is" + MINIMUM_SUPPORTED_IDLE_TIMEOUT);
    } else {
        initialiseHeartbeating(_outgoingIdleTimeout / 2L, _incomingIdleTimeout);
        final NamedAddressSpace addressSpace = getPort().getAddressSpace(_localHostname);
        if (addressSpace == null) {
            closeConnection(AmqpError.NOT_FOUND, "Unknown hostname in connection open: '" + _localHostname + "'");
        } else {
            receiveOpenInternal(addressSpace);
        }
    }
}
Also used : Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) LinkedHashMap(java.util.LinkedHashMap)

Example 22 with Symbol

use of org.apache.qpid.server.protocol.v1_0.type.Symbol in project qpid-broker-j by apache.

the class AMQPConnection_1_0Impl method receiveClose.

@Override
public void receiveClose(final int channel, final Close close) {
    switch(_connectionState) {
        case AWAIT_AMQP_OR_SASL_HEADER:
        case AWAIT_SASL_INIT:
        case AWAIT_SASL_RESPONSE:
        case AWAIT_AMQP_HEADER:
            throw new ConnectionScopedRuntimeException("Received unexpected close when AMQP connection has not been established.");
        case AWAIT_OPEN:
            closeReceived();
            closeConnection(ConnectionError.CONNECTION_FORCED, "Connection close sent before connection was opened");
            break;
        case OPENED:
            _connectionState = ConnectionState.CLOSE_RECEIVED;
            closeReceived();
            if (close.getError() != null) {
                final Error error = close.getError();
                ErrorCondition condition = error.getCondition();
                Symbol errorCondition = condition == null ? null : condition.getValue();
                LOGGER.info("{} : Connection closed with error : {} - {}", getLogSubject(), errorCondition, close.getError().getDescription());
            }
            sendClose(new Close());
            _connectionState = ConnectionState.CLOSED;
            _orderlyClose.set(true);
            addCloseTicker();
            break;
        case CLOSE_SENT:
            closeReceived();
            _connectionState = ConnectionState.CLOSED;
            _orderlyClose.set(true);
            break;
        case CLOSE_RECEIVED:
        case CLOSED:
            break;
        default:
            throw new ServerScopedRuntimeException("Unknown state: " + _connectionState);
    }
}
Also used : ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) ErrorCondition(org.apache.qpid.server.protocol.v1_0.type.ErrorCondition) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) ConnectionError(org.apache.qpid.server.protocol.v1_0.type.transport.ConnectionError) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) ServerScopedRuntimeException(org.apache.qpid.server.util.ServerScopedRuntimeException)

Example 23 with Symbol

use of org.apache.qpid.server.protocol.v1_0.type.Symbol in project qpid-broker-j by apache.

the class MessageConverter_from_1_0 method getContentEncoding.

static Symbol getContentEncoding(final Message_1_0 serverMsg) {
    Symbol contentEncoding = null;
    final PropertiesSection propertiesSection = serverMsg.getPropertiesSection();
    if (propertiesSection != null) {
        final Properties properties = propertiesSection.getValue();
        propertiesSection.dispose();
        if (properties != null) {
            contentEncoding = properties.getContentEncoding();
        }
    }
    return contentEncoding;
}
Also used : PropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.PropertiesSection) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Example 24 with Symbol

use of org.apache.qpid.server.protocol.v1_0.type.Symbol in project qpid-broker-j by apache.

the class Session_1_0Test method createAttach.

private Attach createAttach(final boolean durable, final String linkName, final String address, final Symbol destinationTypeCapability, final boolean isGlobal, final boolean isShared) {
    Attach attach = new Attach();
    Source source = new Source();
    List<Symbol> capabilities = new ArrayList<>();
    if (isGlobal) {
        capabilities.add(Symbol.getSymbol("global"));
    }
    if (isShared) {
        capabilities.add(Symbol.getSymbol("shared"));
    }
    capabilities.add(destinationTypeCapability);
    source.setCapabilities(capabilities.toArray(new Symbol[capabilities.size()]));
    if (durable) {
        source.setDurable(TerminusDurability.CONFIGURATION);
        source.setExpiryPolicy(TerminusExpiryPolicy.NEVER);
    } else {
        source.setDurable(TerminusDurability.NONE);
        source.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
    }
    attach.setSource(source);
    Target target = new Target();
    attach.setTarget(target);
    attach.setHandle(new UnsignedInteger(_handle++));
    attach.setIncompleteUnsettled(false);
    attach.setName(linkName);
    attach.setRole(Role.RECEIVER);
    source.setAddress(address);
    return attach;
}
Also used : Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) ArrayList(java.util.ArrayList) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Example 25 with Symbol

use of org.apache.qpid.server.protocol.v1_0.type.Symbol in project qpid-broker-j by apache.

the class LinkStoreTestCase method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    _linkStore = createLinkStore();
    _source = new Source();
    _target = new Target();
    _source.setAddress(ADDRESS);
    _source.setCapabilities(new Symbol[] { Symbol.getSymbol(CAPABILITY) });
    _source.setDefaultOutcome(new Rejected());
    _source.setDistributionMode(StdDistMode.COPY);
    _source.setDurable(TerminusDurability.UNSETTLED_STATE);
    _source.setDynamic(Boolean.TRUE);
    _source.setExpiryPolicy(TerminusExpiryPolicy.CONNECTION_CLOSE);
    _source.setFilter(Collections.singletonMap(Symbol.valueOf("foo"), NoLocalFilter.INSTANCE));
    _source.setOutcomes(new Accepted().getSymbol());
    _source.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("dynamicProperty"), "dynamicPropertyValue"));
    _source.setTimeout(new UnsignedInteger(1));
    _target.setTimeout(new UnsignedInteger(2));
    _target.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("targetDynamicProperty"), "targetDynamicPropertyValue"));
    _target.setDynamic(Boolean.TRUE);
    _target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
    _target.setAddress("bar");
    _target.setCapabilities(new Symbol[] { Symbol.getSymbol(CAPABILITY) });
    _target.setDurable(TerminusDurability.CONFIGURATION);
}
Also used : Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) Rejected(org.apache.qpid.server.protocol.v1_0.type.messaging.Rejected) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)

Aggregations

Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)27 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)11 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)7 Map (java.util.Map)6 BaseSource (org.apache.qpid.server.protocol.v1_0.type.BaseSource)6 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)6 Target (org.apache.qpid.server.protocol.v1_0.type.messaging.Target)6 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)5 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)5 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)5 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)4 TokenMgrError (org.apache.qpid.server.filter.selector.TokenMgrError)4 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)4 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)4 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3