use of org.apache.qpid.server.model.NamedAddressSpace in project qpid-broker-j by apache.
the class AbstractServlet method getManagedObject.
private ConfiguredObject<?> getManagedObject(final HttpServletRequest request, final HttpServletResponse resp) {
HttpPort<?> port = HttpManagementUtil.getPort(request);
final NamedAddressSpace addressSpace = port.getAddressSpace(request.getServerName());
if (addressSpace == null) {
if (port.isManageBrokerOnNoAliasMatch()) {
return getBroker();
}
LOGGER.info("No HTTP Management alias mapping found for host '{}' on port {}", request.getServerName(), port);
sendError(resp, HttpServletResponse.SC_NOT_FOUND);
return null;
} else if (addressSpace instanceof VirtualHost<?>) {
return (VirtualHost<?>) addressSpace;
} else {
return getBroker();
}
}
use of org.apache.qpid.server.model.NamedAddressSpace in project qpid-broker-j by apache.
the class AbstractAMQPConnection method registerTransactionTickers.
@Override
public void registerTransactionTickers(final ServerTransaction serverTransaction, final Action<String> closeAction, final long notificationRepeatPeriod) {
NamedAddressSpace addressSpace = getAddressSpace();
if (addressSpace instanceof QueueManagingVirtualHost) {
final QueueManagingVirtualHost<?> virtualhost = (QueueManagingVirtualHost<?>) addressSpace;
EventLogger eventLogger = virtualhost.getEventLogger();
final Set<Ticker> tickers = new LinkedHashSet<>(4);
if (virtualhost.getStoreTransactionOpenTimeoutWarn() > 0) {
tickers.add(new TransactionTimeoutTicker(virtualhost.getStoreTransactionOpenTimeoutWarn(), notificationRepeatPeriod, serverTransaction::getTransactionStartTime, age -> eventLogger.message(getLogSubject(), ConnectionMessages.OPEN_TXN(age))));
}
if (virtualhost.getStoreTransactionOpenTimeoutClose() > 0) {
tickers.add(new TransactionTimeoutTicker(virtualhost.getStoreTransactionOpenTimeoutClose(), notificationRepeatPeriod, serverTransaction::getTransactionStartTime, age -> closeAction.performAction(OPEN_TRANSACTION_TIMEOUT_ERROR)));
}
if (virtualhost.getStoreTransactionIdleTimeoutWarn() > 0) {
tickers.add(new TransactionTimeoutTicker(virtualhost.getStoreTransactionIdleTimeoutWarn(), notificationRepeatPeriod, serverTransaction::getTransactionUpdateTime, age -> eventLogger.message(getLogSubject(), ConnectionMessages.IDLE_TXN(age))));
}
if (virtualhost.getStoreTransactionIdleTimeoutClose() > 0) {
tickers.add(new TransactionTimeoutTicker(virtualhost.getStoreTransactionIdleTimeoutClose(), notificationRepeatPeriod, serverTransaction::getTransactionUpdateTime, age -> closeAction.performAction(IDLE_TRANSACTION_TIMEOUT_ERROR)));
}
if (!tickers.isEmpty()) {
for (Ticker ticker : tickers) {
getAggregateTicker().addTicker(ticker);
}
notifyWork();
}
_transactionTickers.put(serverTransaction, tickers);
}
}
use of org.apache.qpid.server.model.NamedAddressSpace in project qpid-broker-j by apache.
the class VirtualHostNameAliasImpl method getAddressSpace.
@Override
public NamedAddressSpace getAddressSpace(final String name) {
Broker<?> broker = getAncestor(Broker.class);
NamedAddressSpace addressSpace = broker.getSystemAddressSpace(name);
if (addressSpace == null) {
for (VirtualHostNode<?> vhn : broker.getVirtualHostNodes()) {
VirtualHost<?> vh = vhn.getVirtualHost();
if (vh != null && vh.getName().equals(name)) {
addressSpace = vh;
break;
}
}
}
return addressSpace;
}
use of org.apache.qpid.server.model.NamedAddressSpace in project qpid-broker-j by apache.
the class AMQChannel method receiveQueueBind.
@Override
public void receiveQueueBind(final AMQShortString queueName, final AMQShortString exchange, AMQShortString bindingKey, final boolean nowait, final FieldTable argumentsTable) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("RECV[" + _channelId + "] QueueBind[" + " queue: " + queueName + " exchange: " + exchange + " bindingKey: " + bindingKey + " nowait: " + nowait + " arguments: " + argumentsTable + " ]");
}
NamedAddressSpace virtualHost = _connection.getAddressSpace();
Queue<?> queue;
if (queueName == null) {
queue = getDefaultQueue();
if (queue != null) {
if (bindingKey == null) {
bindingKey = AMQShortString.valueOf(queue.getName());
}
}
} else {
queue = getQueue(queueName.toString());
}
if (queue == null) {
String message = queueName == null ? "No default queue defined on channel and queue was null" : "Queue " + queueName + " does not exist.";
closeChannel(ErrorCodes.NOT_FOUND, message);
} else if (isDefaultExchange(exchange)) {
_connection.sendConnectionClose(ErrorCodes.NOT_ALLOWED, "Cannot bind the queue '" + queueName + "' to the default exchange", getChannelId());
} else {
final String exchangeName = exchange.toString();
final Exchange<?> exch = getExchange(exchangeName);
if (exch == null) {
closeChannel(ErrorCodes.NOT_FOUND, "Exchange '" + exchangeName + "' does not exist.");
} else {
try {
Map<String, Object> arguments = FieldTable.convertToMap(argumentsTable);
String bindingKeyStr = AMQShortString.toString(bindingKey);
if (!exch.isBound(bindingKeyStr, arguments, queue)) {
if (!exch.addBinding(bindingKeyStr, queue, arguments) && ExchangeDefaults.TOPIC_EXCHANGE_CLASS.equals(exch.getType())) {
exch.replaceBinding(bindingKeyStr, queue, arguments);
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Binding queue " + queue + " to exchange " + exch + " with routing key " + bindingKeyStr);
}
if (!nowait) {
sync();
MethodRegistry methodRegistry = _connection.getMethodRegistry();
AMQMethodBody responseBody = methodRegistry.createQueueBindOkBody();
_connection.writeFrame(responseBody.generateFrame(getChannelId()));
}
} catch (AccessControlException e) {
_connection.sendConnectionClose(ErrorCodes.ACCESS_REFUSED, e.getMessage(), getChannelId());
}
}
}
}
use of org.apache.qpid.server.model.NamedAddressSpace in project qpid-broker-j by apache.
the class AMQChannel method receiveExchangeBound.
@Override
public void receiveExchangeBound(final AMQShortString exchangeName, final AMQShortString routingKey, final AMQShortString queueName) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("RECV[" + _channelId + "] ExchangeBound[" + " exchange: " + exchangeName + " routingKey: " + routingKey + " queue: " + queueName + " ]");
}
NamedAddressSpace virtualHost = _connection.getAddressSpace();
MethodRegistry methodRegistry = _connection.getMethodRegistry();
sync();
int replyCode;
String replyText;
if (isDefaultExchange(exchangeName)) {
if (routingKey == null) {
if (queueName == null) {
replyCode = virtualHost.hasMessageSources() ? ExchangeBoundOkBody.OK : ExchangeBoundOkBody.NO_BINDINGS;
replyText = null;
} else {
MessageSource queue = virtualHost.getAttainedMessageSource(queueName.toString());
if (queue == null) {
replyCode = ExchangeBoundOkBody.QUEUE_NOT_FOUND;
replyText = "Queue '" + queueName + "' not found";
} else {
replyCode = ExchangeBoundOkBody.OK;
replyText = null;
}
}
} else {
if (queueName == null) {
replyCode = virtualHost.getAttainedMessageDestination(routingKey.toString()) instanceof Queue ? ExchangeBoundOkBody.OK : ExchangeBoundOkBody.NO_QUEUE_BOUND_WITH_RK;
replyText = null;
} else {
MessageDestination destination = virtualHost.getAttainedMessageDestination(queueName.toString());
Queue<?> queue = destination instanceof Queue ? (Queue) destination : null;
if (queue == null) {
replyCode = ExchangeBoundOkBody.QUEUE_NOT_FOUND;
replyText = "Queue '" + queueName + "' not found";
} else {
replyCode = queueName.equals(routingKey) ? ExchangeBoundOkBody.OK : ExchangeBoundOkBody.SPECIFIC_QUEUE_NOT_BOUND_WITH_RK;
replyText = null;
}
}
}
} else {
Exchange<?> exchange = getExchange(exchangeName.toString());
if (exchange == null) {
replyCode = ExchangeBoundOkBody.EXCHANGE_NOT_FOUND;
replyText = "Exchange '" + exchangeName + "' not found";
} else if (routingKey == null) {
if (queueName == null) {
if (exchange.hasBindings()) {
replyCode = ExchangeBoundOkBody.OK;
replyText = null;
} else {
replyCode = ExchangeBoundOkBody.NO_BINDINGS;
replyText = null;
}
} else {
Queue<?> queue = getQueue(queueName.toString());
if (queue == null) {
replyCode = ExchangeBoundOkBody.QUEUE_NOT_FOUND;
replyText = "Queue '" + queueName + "' not found";
} else {
if (exchange.isBound(queue)) {
replyCode = ExchangeBoundOkBody.OK;
replyText = null;
} else {
replyCode = ExchangeBoundOkBody.QUEUE_NOT_BOUND;
replyText = "Queue '" + queueName + "' not bound to exchange '" + exchangeName + "'";
}
}
}
} else if (queueName != null) {
Queue<?> queue = getQueue(queueName.toString());
if (queue == null) {
replyCode = ExchangeBoundOkBody.QUEUE_NOT_FOUND;
replyText = "Queue '" + queueName + "' not found";
} else {
String bindingKey = routingKey == null ? null : routingKey.toString();
if (exchange.isBound(bindingKey, queue)) {
replyCode = ExchangeBoundOkBody.OK;
replyText = null;
} else {
replyCode = ExchangeBoundOkBody.SPECIFIC_QUEUE_NOT_BOUND_WITH_RK;
replyText = "Queue '" + queueName + "' not bound with routing key '" + routingKey + "' to exchange '" + exchangeName + "'";
}
}
} else {
if (exchange.isBound(routingKey == null ? "" : routingKey.toString())) {
replyCode = ExchangeBoundOkBody.OK;
replyText = null;
} else {
replyCode = ExchangeBoundOkBody.NO_QUEUE_BOUND_WITH_RK;
replyText = "No queue bound with routing key '" + routingKey + "' to exchange '" + exchangeName + "'";
}
}
}
ExchangeBoundOkBody exchangeBoundOkBody = methodRegistry.createExchangeBoundOkBody(replyCode, AMQShortString.validValueOf(replyText));
_connection.writeFrame(exchangeBoundOkBody.generateFrame(getChannelId()));
}
Aggregations