Package org.apache.qpid.server.virtualhost

Examples of org.apache.qpid.server.virtualhost.VirtualHostImpl


        {
            _logger.debug("RECV[" + _channelId + "] ExchangeDelete[" +" exchange: " + exchangeStr + " ifUnused: " + ifUnused + " nowait: " + nowait + " ]");
        }


        VirtualHostImpl virtualHost = _connection.getVirtualHost();
        sync();
        try
        {

            if (isDefaultExchange(exchangeStr))
            {
                _connection.closeConnection(AMQConstant.NOT_ALLOWED,
                                            "Default Exchange cannot be deleted", getChannelId());

            }

            else
            {
                final String exchangeName = exchangeStr.toString();

                final ExchangeImpl exchange = virtualHost.getExchange(exchangeName);
                if (exchange == null)
                {
                    closeChannel(AMQConstant.NOT_FOUND, "No such exchange: " + exchangeStr);
                }
                else
                {
                    virtualHost.removeExchange(exchange, !ifUnused);

                    ExchangeDeleteOkBody responseBody = _connection.getMethodRegistry().createExchangeDeleteOkBody();

                    _connection.writeFrame(responseBody.generateFrame(getChannelId()));
                }
View Full Code Here


                    exception(session, method, ExecutionErrorCode.PRECONDITION_FAILED, "Queue " + queueName + " in use");

                }
                else
                {
                    VirtualHostImpl virtualHost = getVirtualHost(session);

                    try
                    {
                        virtualHost.removeQueue(queue);
                    }
                    catch (AccessControlException e)
                    {
                        exception(session, method, ExecutionErrorCode.UNAUTHORIZED_ACCESS, e.getMessage());
                    }
View Full Code Here

                          " exchange: " + exchange +
                          " bindingKey: " + routingKey +
                          " nowait: " + nowait + " arguments: " + argumentsTable + " ]");
        }

        VirtualHostImpl virtualHost = _connection.getVirtualHost();
        AMQQueue<?> queue;
        if (queueName == null)
        {

            queue = getDefaultQueue();

            if (queue != null)
            {
                if (routingKey == null)
                {
                    routingKey = AMQShortString.valueOf(queue.getName());
                }
                else
                {
                    routingKey = routingKey.intern();
                }
            }
        }
        else
        {
            queue = virtualHost.getQueue(queueName.toString());
            routingKey = routingKey == null ? AMQShortString.EMPTY_STRING : routingKey.intern();
        }

        if (queue == null)
        {
            String message = queueName == null
                    ? "No default queue defined on channel and queue was null"
                    : "Queue " + queueName + " does not exist.";
                closeChannel(AMQConstant.NOT_FOUND, message);
        }
        else if (isDefaultExchange(exchange))
        {
            _connection.closeConnection(AMQConstant.NOT_ALLOWED,
                                        "Cannot bind the queue " + queueName + " to the default exchange", getChannelId());

        }
        else
        {

            final String exchangeName = exchange.toString();

            final ExchangeImpl exch = virtualHost.getExchange(exchangeName);
            if (exch == null)
            {
                closeChannel(AMQConstant.NOT_FOUND,
                             "Exchange " + exchangeName + " does not exist.");
            }
View Full Code Here

                          " durable: " + durable +
                          " exclusive: " + exclusive +
                          " autoDelete: " + autoDelete + " nowait: " + nowait + " arguments: " + arguments + " ]");
        }

        VirtualHostImpl virtualHost = _connection.getVirtualHost();

        final AMQShortString queueName;

        // if we aren't given a queue name, we create one which we return to the client
        if ((queueStr == null) || (queueStr.length() == 0))
        {
            queueName = new AMQShortString("tmp_" + UUID.randomUUID());
        }
        else
        {
            queueName = queueStr.intern();
        }

        AMQQueue queue;

        //TODO: do we need to check that the queue already exists with exactly the same "configuration"?


        if (passive)
        {
            queue = virtualHost.getQueue(queueName.toString());
            if (queue == null)
            {
                closeChannel(AMQConstant.NOT_FOUND,
                                                     "Queue: "
                                                     + queueName
                                                     + " not found on VirtualHost("
                                                     + virtualHost
                                                     + ").");
            }
            else
            {
                if (!queue.verifySessionAccess(this))
                {
                    _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Queue "
                                                + queue.getName()
                                                + " is exclusive, but not created on this Connection.", getChannelId());
                }
                else
                {
                    //set this as the default queue on the channel:
                    setDefaultQueue(queue);
                    if (!nowait)
                    {
                        sync();
                        MethodRegistry methodRegistry = _connection.getMethodRegistry();
                        QueueDeclareOkBody responseBody =
                                methodRegistry.createQueueDeclareOkBody(queueName,
                                                                        queue.getQueueDepthMessages(),
                                                                        queue.getConsumerCount());
                        _connection.writeFrame(responseBody.generateFrame(getChannelId()));

                        _logger.info("Queue " + queueName + " declared successfully");
                    }
                }
            }
        }
        else
        {

            try
            {
                Map<String, Object> attributes =
                        QueueArgumentsConverter.convertWireArgsToModel(FieldTable.convertToMap(arguments));
                final String queueNameString = AMQShortString.toString(queueName);
                attributes.put(Queue.NAME, queueNameString);
                attributes.put(Queue.ID, UUID.randomUUID());
                attributes.put(Queue.DURABLE, durable);

                LifetimePolicy lifetimePolicy;
                ExclusivityPolicy exclusivityPolicy;

                if (exclusive)
                {
                    lifetimePolicy = autoDelete
                            ? LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS
                            : durable ? LifetimePolicy.PERMANENT : LifetimePolicy.DELETE_ON_CONNECTION_CLOSE;
                    exclusivityPolicy = durable ? ExclusivityPolicy.CONTAINER : ExclusivityPolicy.CONNECTION;
                }
                else
                {
                    lifetimePolicy = autoDelete ? LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS : LifetimePolicy.PERMANENT;
                    exclusivityPolicy = ExclusivityPolicy.NONE;
                }

                attributes.put(Queue.EXCLUSIVE, exclusivityPolicy);
                attributes.put(Queue.LIFETIME_POLICY, lifetimePolicy);


                queue = virtualHost.createQueue(attributes);

                setDefaultQueue(queue);

                if (!nowait)
                {
View Full Code Here

        if(_logger.isDebugEnabled())
        {
            _logger.debug("RECV[" + _channelId + "] QueueDelete[" +" queue: " + queueName + " ifUnused: " + ifUnused + " ifEmpty: " + ifEmpty + " nowait: " + nowait + " ]");
        }

        VirtualHostImpl virtualHost = _connection.getVirtualHost();
        sync();
        AMQQueue queue;
        if (queueName == null)
        {

            //get the default queue on the channel:
            queue = getDefaultQueue();
        }
        else
        {
            queue = virtualHost.getQueue(queueName.toString());
        }

        if (queue == null)
        {
            closeChannel(AMQConstant.NOT_FOUND, "Queue " + queueName + " does not exist.");

        }
        else
        {
            if (ifEmpty && !queue.isEmpty())
            {
                closeChannel(AMQConstant.IN_USE, "Queue: " + queueName + " is not empty.");
            }
            else if (ifUnused && !queue.isUnused())
            {
                // TODO - Error code
                closeChannel(AMQConstant.IN_USE, "Queue: " + queueName + " is still used.");
            }
            else
            {
                if (!queue.verifySessionAccess(this))
                {
                    _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Queue "
                                                + queue.getName()
                                                + " is exclusive, but not created on this Connection.", getChannelId());

                }
                else
                {
                    try
                    {
                        int purged = virtualHost.removeQueue(queue);

                        MethodRegistry methodRegistry = _connection.getMethodRegistry();
                        QueueDeleteOkBody responseBody = methodRegistry.createQueueDeleteOkBody(purged);
                        _connection.writeFrame(responseBody.generateFrame(getChannelId()));
                    }
View Full Code Here

        if(_logger.isDebugEnabled())
        {
            _logger.debug("RECV[" + _channelId + "] QueuePurge[" +" queue: " + queueName + " nowait: " + nowait + " ]");
        }

        VirtualHostImpl virtualHost = _connection.getVirtualHost();
        AMQQueue queue = null;
        if (queueName == null && (queue = getDefaultQueue()) == null)
        {

            _connection.closeConnection(AMQConstant.NOT_ALLOWED, "No queue specified.", getChannelId());
        }
        else if ((queueName != null) && (queue = virtualHost.getQueue(queueName.toString())) == null)
        {
            closeChannel(AMQConstant.NOT_FOUND, "Queue " + queueName + " does not exist.");
        }
        else if (!queue.verifySessionAccess(this))
        {
View Full Code Here

                          " exchange: " + exchange +
                          " bindingKey: " + routingKey +
                          " arguments: " + arguments + " ]");
        }

        VirtualHostImpl virtualHost = _connection.getVirtualHost();


        final boolean useDefaultQueue = queueName == null;
        final AMQQueue queue = useDefaultQueue
                ? getDefaultQueue()
                : virtualHost.getQueue(queueName.toString());


        if (queue == null)
        {
            String message = useDefaultQueue
                    ? "No default queue defined on channel and queue was null"
                    : "Queue " + queueName + " does not exist.";
            closeChannel(AMQConstant.NOT_FOUND, message);
        }
        else if (isDefaultExchange(exchange))
        {
            _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Cannot unbind the queue "
                                                         + queue.getName()
                                                         + " from the default exchange", getChannelId());

        }
        else
        {

            final ExchangeImpl exch = virtualHost.getExchange(exchange.toString());

            if (exch == null)
            {
                closeChannel(AMQConstant.NOT_FOUND, "Exchange " + exchange + " does not exist.");
            }
View Full Code Here

        when(queue.getAlternateExchange()).thenReturn(alternateExchange);
        when(queue.getCategoryClass()).thenReturn((Class)Queue.class);
        when(queue.isDurable()).thenReturn(true);
        when(queue.getTaskExecutor()).thenReturn(CurrentThreadTaskExecutor.newStartedInstance());

        final VirtualHostImpl vh = mock(VirtualHostImpl.class);
        when(vh.getSecurityManager()).thenReturn(mock(SecurityManager.class));
        when(queue.getVirtualHost()).thenReturn(vh);
        final Map<String,Object> attributes = arguments == null ? new LinkedHashMap<String, Object>() : new LinkedHashMap<String, Object>(arguments);
        attributes.put(Queue.NAME, queueName);
        attributes.put(Queue.TYPE, STANDARD);
        if(alternateExchange != null)
View Full Code Here

    public void setUp() throws Exception
    {
        super.setUp();
        BrokerTestHelper.setUp();
        _channel = BrokerTestHelper_0_8.createChannel();
        VirtualHostImpl virtualHost = _channel.getVirtualHost();
        _queueName = getTestName();
        _queue = BrokerTestHelper.createQueue(_queueName, virtualHost);
        _messageStore = virtualHost.getMessageStore();
    }
View Full Code Here

    public void setUp() throws Exception
    {
        super.setUp();
        BrokerTestHelper.setUp();
        _channel = BrokerTestHelper_0_8.createChannel();
        VirtualHostImpl virtualHost = _channel.getVirtualHost();
        _queueName = getTestName();
        _queue = BrokerTestHelper.createQueue(_queueName, virtualHost);
        _messageStore = virtualHost.getMessageStore();
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.virtualhost.VirtualHostImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.