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