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);
}
}
}
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);
}
}
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;
}
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;
}
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);
}
Aggregations