Search in sources :

Example 1 with FieldTable

use of org.apache.qpid.server.protocol.v0_8.FieldTable in project qpid-broker-j by apache.

the class BasicContentHeaderProperties method decode.

private void decode(QpidByteBuffer buffer) throws AMQFrameDecodingException {
    if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0) {
        _contentType = AMQShortString.readAMQShortString(buffer);
    }
    if ((_propertyFlags & ENCODING_MASK) != 0) {
        _encoding = AMQShortString.readAMQShortString(buffer);
    }
    if ((_propertyFlags & HEADERS_MASK) != 0) {
        long length = buffer.getUnsignedInt();
        try (QpidByteBuffer buf = buffer.view(0, (int) length)) {
            _headers = new FieldTable(buf);
        }
        buffer.position(buffer.position() + (int) length);
    }
    if ((_propertyFlags & DELIVERY_MODE_MASK) != 0) {
        _deliveryMode = buffer.get();
    }
    if ((_propertyFlags & PRIORITY_MASK) != 0) {
        _priority = buffer.get();
    }
    if ((_propertyFlags & CORRELATION_ID_MASK) != 0) {
        _correlationId = AMQShortString.readAMQShortString(buffer);
    }
    if ((_propertyFlags & REPLY_TO_MASK) != 0) {
        _replyTo = AMQShortString.readAMQShortString(buffer);
    }
    if ((_propertyFlags & EXPIRATION_MASK) != 0) {
        _expiration = EncodingUtils.readLongAsShortString(buffer);
    }
    if ((_propertyFlags & MESSAGE_ID_MASK) != 0) {
        _messageId = AMQShortString.readAMQShortString(buffer);
    }
    if ((_propertyFlags & TIMESTAMP_MASK) != 0) {
        _timestamp = buffer.getLong();
    }
    if ((_propertyFlags & TYPE_MASK) != 0) {
        _type = AMQShortString.readAMQShortString(buffer);
    }
    if ((_propertyFlags & USER_ID_MASK) != 0) {
        _userId = AMQShortString.readAMQShortString(buffer);
    }
    if ((_propertyFlags & APPLICATION_ID_MASK) != 0) {
        _appId = AMQShortString.readAMQShortString(buffer);
    }
    if ((_propertyFlags & CLUSTER_ID_MASK) != 0) {
        _clusterId = AMQShortString.readAMQShortString(buffer);
    }
}
Also used : FieldTable(org.apache.qpid.server.protocol.v0_8.FieldTable) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 2 with FieldTable

use of org.apache.qpid.server.protocol.v0_8.FieldTable in project qpid-broker-j by apache.

the class UpgradeFrom5To6 method createQueueConfiguredObjectRecord.

private UpgradeConfiguredObjectRecord createQueueConfiguredObjectRecord(String queueName, String owner, boolean exclusive, FieldTable arguments) {
    Map<String, Object> attributesMap = buildQueueArgumentMap(queueName, owner, exclusive, arguments);
    String json = serialiseMap(attributesMap);
    UpgradeConfiguredObjectRecord configuredObject = new UpgradeConfiguredObjectRecord(Queue.class.getName(), json);
    return configuredObject;
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) Queue(org.apache.qpid.server.model.Queue)

Example 3 with FieldTable

use of org.apache.qpid.server.protocol.v0_8.FieldTable in project qpid-broker-j by apache.

the class UpgradeFrom5To6 method upgradeQueues.

private List<String> upgradeQueues(Environment environment, Transaction transaction, final String virtualHostName) {
    final List<String> queueNames = new ArrayList<String>();
    LOGGER.info("Queues");
    if (environment.getDatabaseNames().contains(OLD_QUEUE_DB_NAME)) {
        final UpgradeQueueBinding queueBinding = new UpgradeQueueBinding();
        CursorOperation queueCursor = new CursorOperation() {

            @Override
            public void processEntry(Database queueDatabase, Database configuredObjectsDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
                OldQueueRecord queueRecord = queueBinding.entryToObject(value);
                String queueName = queueRecord.getNameShortString().toString();
                queueNames.add(queueName);
                String owner = queueRecord.getOwner() == null ? null : queueRecord.getOwner().toString();
                boolean exclusive = queueRecord.isExclusive();
                FieldTable arguments = queueRecord.getArguments();
                UUID queueId = UUIDGenerator.generateQueueUUID(queueName, virtualHostName);
                UpgradeConfiguredObjectRecord configuredObject = createQueueConfiguredObjectRecord(queueName, owner, exclusive, arguments);
                storeConfiguredObjectEntry(configuredObjectsDatabase, queueId, configuredObject, transaction);
            }
        };
        new DatabaseTemplate(environment, OLD_QUEUE_DB_NAME, CONFIGURED_OBJECTS_DB_NAME, transaction).run(queueCursor);
        environment.removeDatabase(transaction, OLD_QUEUE_DB_NAME);
        LOGGER.info(queueCursor.getRowCount() + " Queue Entries");
    }
    return queueNames;
}
Also used : FieldTable(org.apache.qpid.server.protocol.v0_8.FieldTable) ArrayList(java.util.ArrayList) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) DatabaseEntry(com.sleepycat.je.DatabaseEntry) Transaction(com.sleepycat.je.Transaction) Database(com.sleepycat.je.Database) UUID(java.util.UUID)

Example 4 with FieldTable

use of org.apache.qpid.server.protocol.v0_8.FieldTable in project qpid-broker-j by apache.

the class UpgradeFrom4To5 method createQueue.

protected void createQueue(final Environment environment, Transaction transaction, final String queueName) {
    final QueueRecordBinding binding = new QueueRecordBinding(null);
    final BindingTuple bindingTuple = new BindingTuple();
    DatabaseRunnable queueCreateOperation = new DatabaseRunnable() {

        @Override
        public void run(Database newQueueDatabase, Database newBindingsDatabase, Transaction transaction) {
            AMQShortString queueNameAMQ = AMQShortString.createAMQShortString(queueName);
            QueueRecord record = new QueueRecord(queueNameAMQ, null, false, null);
            DatabaseEntry key = new DatabaseEntry();
            TupleOutput output = new TupleOutput();
            AMQShortStringEncoding.writeShortString(record.getNameShortString(), output);
            TupleBase.outputToEntry(output, key);
            DatabaseEntry newValue = new DatabaseEntry();
            binding.objectToEntry(record, newValue);
            newQueueDatabase.put(transaction, key, newValue);
            FieldTable emptyArguments = FieldTableFactory.createFieldTable(Collections.emptyMap());
            addBindingToDatabase(bindingTuple, newBindingsDatabase, transaction, queueNameAMQ, AMQShortString.valueOf(ExchangeDefaults.DIRECT_EXCHANGE_NAME), queueNameAMQ, emptyArguments);
            // TODO QPID-3490 we should not persist a default exchange binding
            addBindingToDatabase(bindingTuple, newBindingsDatabase, transaction, queueNameAMQ, AMQShortString.valueOf(ExchangeDefaults.DEFAULT_EXCHANGE_NAME), queueNameAMQ, emptyArguments);
        }
    };
    new DatabaseTemplate(environment, NEW_QUEUE_DB_NAME, NEW_BINDINGS_DB_NAME, transaction).run(queueCreateOperation);
}
Also used : AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) Transaction(com.sleepycat.je.Transaction) FieldTable(org.apache.qpid.server.protocol.v0_8.FieldTable) Database(com.sleepycat.je.Database) DatabaseEntry(com.sleepycat.je.DatabaseEntry) TupleOutput(com.sleepycat.bind.tuple.TupleOutput)

Example 5 with FieldTable

use of org.apache.qpid.server.protocol.v0_8.FieldTable in project qpid-broker-j by apache.

the class UpgradeFrom4To5 method upgradeQueueBindings.

private void upgradeQueueBindings(Environment environment, UpgradeInteractionHandler handler, final List<AMQShortString> potentialDurableSubs, Transaction transaction) {
    if (environment.getDatabaseNames().contains(OLD_BINDINGS_DB_NAME)) {
        LOGGER.info("Queue Bindings");
        final BindingTuple bindingTuple = new BindingTuple();
        CursorOperation databaseOperation = new CursorOperation() {

            @Override
            public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
                // All the information required in binding entries is actually in the *key* not value.
                BindingRecord oldBindingRecord = bindingTuple.entryToObject(key);
                AMQShortString queueName = oldBindingRecord.getQueueName();
                AMQShortString exchangeName = oldBindingRecord.getExchangeName();
                AMQShortString routingKey = oldBindingRecord.getRoutingKey();
                FieldTable arguments = oldBindingRecord.getArguments();
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug(String.format("Processing binding for queue %s, exchange %s, routingKey %s arguments %s", queueName, exchangeName, routingKey, arguments));
                }
                // only topic exchange should have a JMS selector key in binding
                if (potentialDurableSubs.contains(queueName) && exchangeName.equals(AMQShortString.valueOf(ExchangeDefaults.TOPIC_EXCHANGE_NAME))) {
                    Map<String, Object> argumentsMap = new HashMap<>();
                    if (arguments != null) {
                        argumentsMap.putAll(FieldTable.convertToMap(arguments));
                    }
                    String selectorFilterKey = AMQPFilterTypes.JMS_SELECTOR.getValue();
                    if (!argumentsMap.containsKey(selectorFilterKey)) {
                        if (LOGGER.isDebugEnabled()) {
                            LOGGER.info("adding the empty string (i.e. 'no selector') value for " + queueName + " and exchange " + exchangeName);
                        }
                        argumentsMap.put(selectorFilterKey, "");
                    }
                    arguments = FieldTable.convertToFieldTable(argumentsMap);
                }
                addBindingToDatabase(bindingTuple, targetDatabase, transaction, queueName, exchangeName, routingKey, arguments);
            }
        };
        new DatabaseTemplate(environment, OLD_BINDINGS_DB_NAME, NEW_BINDINGS_DB_NAME, transaction).run(databaseOperation);
        environment.removeDatabase(transaction, OLD_BINDINGS_DB_NAME);
        LOGGER.info(databaseOperation.getRowCount() + " Queue Binding entries");
    }
}
Also used : AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) FieldTable(org.apache.qpid.server.protocol.v0_8.FieldTable) HashMap(java.util.HashMap) DatabaseEntry(com.sleepycat.je.DatabaseEntry) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) Transaction(com.sleepycat.je.Transaction) Database(com.sleepycat.je.Database) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Aggregations

FieldTable (org.apache.qpid.server.protocol.v0_8.FieldTable)26 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)20 Test (org.junit.Test)7 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)6 Database (com.sleepycat.je.Database)5 DatabaseEntry (com.sleepycat.je.DatabaseEntry)5 Transaction (com.sleepycat.je.Transaction)5 HashMap (java.util.HashMap)5 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)5 FrameTransport (org.apache.qpid.tests.protocol.v0_8.FrameTransport)5 Interaction (org.apache.qpid.tests.protocol.v0_8.Interaction)5 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)4 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)3 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)3 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 UUID (java.util.UUID)2 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)2 AMQPInvalidClassException (org.apache.qpid.server.protocol.v0_8.AMQPInvalidClassException)2 LongBinding (com.sleepycat.bind.tuple.LongBinding)1