Search in sources :

Example 1 with NamedAddressSpace

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();
    }
}
Also used : NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace)

Example 2 with NamedAddressSpace

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);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) AccessControlContext(java.security.AccessControlContext) SocketAddress(java.net.SocketAddress) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) SaslSettings(org.apache.qpid.server.security.auth.sasl.SaslSettings) SettableFuture(com.google.common.util.concurrent.SettableFuture) ConnectionMessages(org.apache.qpid.server.logging.messages.ConnectionMessages) ContextProvider(org.apache.qpid.server.model.ContextProvider) TransactionObserver(org.apache.qpid.server.txn.TransactionObserver) AmqpPort(org.apache.qpid.server.model.port.AmqpPort) Map(java.util.Map) Port(org.apache.qpid.server.model.Port) LocalTransaction(org.apache.qpid.server.txn.LocalTransaction) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) PrivilegedAction(java.security.PrivilegedAction) InetSocketAddress(java.net.InetSocketAddress) List(java.util.List) Principal(java.security.Principal) Transport(org.apache.qpid.server.model.Transport) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) AccessControlException(java.security.AccessControlException) ConnectionLogSubject(org.apache.qpid.server.logging.subjects.ConnectionLogSubject) AccessController(java.security.AccessController) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) StatisticsGatherer(org.apache.qpid.server.stats.StatisticsGatherer) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) FlowToDiskTransactionObserver(org.apache.qpid.server.txn.FlowToDiskTransactionObserver) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) HashMap(java.util.HashMap) EventLogger(org.apache.qpid.server.logging.EventLogger) LogSubject(org.apache.qpid.server.logging.LogSubject) ConnectionPrincipal(org.apache.qpid.server.connection.ConnectionPrincipal) AuthenticatedPrincipal(org.apache.qpid.server.security.auth.AuthenticatedPrincipal) FixedKeyMapCreator(org.apache.qpid.server.util.FixedKeyMapCreator) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) TaskExecutorProvider(org.apache.qpid.server.model.TaskExecutorProvider) EventLoggerProvider(org.apache.qpid.server.logging.EventLoggerProvider) NetworkConnection(org.apache.qpid.server.transport.network.NetworkConnection) LinkedHashSet(java.util.LinkedHashSet) Session(org.apache.qpid.server.model.Session) Ticker(org.apache.qpid.server.transport.network.Ticker) ServerTransaction(org.apache.qpid.server.txn.ServerTransaction) Logger(org.slf4j.Logger) Action(org.apache.qpid.server.util.Action) Iterator(java.util.Iterator) Broker(org.apache.qpid.server.model.Broker) State(org.apache.qpid.server.model.State) SubjectDomainCombiner(javax.security.auth.SubjectDomainCombiner) Protocol(org.apache.qpid.server.model.Protocol) Connection(org.apache.qpid.server.model.Connection) Subject(javax.security.auth.Subject) AtomicLong(java.util.concurrent.atomic.AtomicLong) Futures(com.google.common.util.concurrent.Futures) QueueManagingVirtualHost(org.apache.qpid.server.virtualhost.QueueManagingVirtualHost) QueueManagingVirtualHost(org.apache.qpid.server.virtualhost.QueueManagingVirtualHost) EventLogger(org.apache.qpid.server.logging.EventLogger) Ticker(org.apache.qpid.server.transport.network.Ticker) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace)

Example 3 with NamedAddressSpace

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;
}
Also used : NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace)

Example 4 with NamedAddressSpace

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());
            }
        }
    }
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) AccessControlException(java.security.AccessControlException) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with NamedAddressSpace

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()));
}
Also used : MessageDestination(org.apache.qpid.server.message.MessageDestination) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) MessageSource(org.apache.qpid.server.message.MessageSource) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Queue(org.apache.qpid.server.model.Queue)

Aggregations

NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)42 AccessControlException (java.security.AccessControlException)22 HashMap (java.util.HashMap)12 MessageSource (org.apache.qpid.server.message.MessageSource)8 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)8 Queue (org.apache.qpid.server.model.Queue)6 Collection (java.util.Collection)5 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)5 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)5 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)4 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)4 MessageDestination (org.apache.qpid.server.message.MessageDestination)4 AmqpPort (org.apache.qpid.server.model.port.AmqpPort)4 ArrayList (java.util.ArrayList)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 Exchange (org.apache.qpid.server.model.Exchange)3 BaseSource (org.apache.qpid.server.protocol.v1_0.type.BaseSource)3 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)3 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)3