Search in sources :

Example 6 with ConfiguredObjectRecordImpl

use of org.apache.qpid.server.store.ConfiguredObjectRecordImpl in project qpid-broker-j by apache.

the class BDBHAVirtualHostNodeTestHelper method recoverHaVHN.

public BDBHAVirtualHostNode<?> recoverHaVHN(UUID id, Map<String, Object> attributes) {
    Map<String, UUID> parents = new HashMap<>();
    parents.put(Broker.class.getSimpleName(), _broker.getId());
    ConfiguredObjectRecordImpl record = new ConfiguredObjectRecordImpl(id, VirtualHostNode.class.getSimpleName(), attributes, parents);
    @SuppressWarnings("unchecked") UnresolvedConfiguredObject<BDBHAVirtualHostNodeImpl> unresolved = _objectFactory.recover(record, _broker);
    BDBHAVirtualHostNode<?> node = unresolved.resolve();
    node.open();
    _nodes.add(node);
    return node;
}
Also used : ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) Broker(org.apache.qpid.server.model.Broker) HashMap(java.util.HashMap) UUID(java.util.UUID) AbstractVirtualHostNode(org.apache.qpid.server.virtualhostnode.AbstractVirtualHostNode) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode)

Example 7 with ConfiguredObjectRecordImpl

use of org.apache.qpid.server.store.ConfiguredObjectRecordImpl in project qpid-broker-j by apache.

the class TestBrokerConfiguration method setObjectAttribute.

private boolean setObjectAttribute(ConfiguredObjectRecord entry, String attributeName, Object value) {
    Map<String, Object> attributes = new HashMap<String, Object>(entry.getAttributes());
    attributes.put(attributeName, value);
    ConfiguredObjectRecord newEntry = new ConfiguredObjectRecordImpl(entry.getId(), entry.getType(), attributes, entry.getParents());
    _store.update(false, newEntry);
    return true;
}
Also used : ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord)

Example 8 with ConfiguredObjectRecordImpl

use of org.apache.qpid.server.store.ConfiguredObjectRecordImpl in project qpid-broker-j by apache.

the class TestBrokerConfiguration method addObjectConfiguration.

public UUID addObjectConfiguration(final Class<? extends ConfiguredObject> parentCategory, final String parentName, Class<? extends ConfiguredObject> type, Map<String, Object> attributes) {
    UUID id = UUIDGenerator.generateRandomUUID();
    ConfiguredObjectRecord entry = new ConfiguredObjectRecordImpl(id, type.getSimpleName(), attributes, Collections.singletonMap(parentCategory.getSimpleName(), findObject(parentCategory, parentName).getId()));
    _store.update(true, entry);
    return id;
}
Also used : ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) UUID(java.util.UUID)

Example 9 with ConfiguredObjectRecordImpl

use of org.apache.qpid.server.store.ConfiguredObjectRecordImpl in project qpid-broker-j by apache.

the class ManagementModeStoreHandler method recoverRecords.

public void recoverRecords(final List<ConfiguredObjectRecord> records) {
    boolean b = _systemConfig.getManagementModeHttpPortOverride() > 0;
    for (ConfiguredObjectRecord object : records) {
        String entryType = object.getType();
        Map<String, Object> attributes = object.getAttributes();
        boolean quiesce = false;
        if (VIRTUAL_HOST_TYPE.equals(entryType) && _systemConfig.isManagementModeQuiesceVirtualHosts()) {
            quiesce = true;
        } else if (PORT_TYPE.equals(entryType)) {
            if (attributes == null) {
                throw new IllegalConfigurationException("Port attributes are not set in " + object);
            }
            Set<Protocol> protocols = getPortProtocolsAttribute(attributes);
            if (protocols == null) {
                quiesce = true;
            } else {
                for (Protocol protocol : protocols) {
                    switch(protocol) {
                        case HTTP:
                            quiesce = b;
                            break;
                        default:
                            quiesce = true;
                    }
                }
            }
        }
        if (quiesce) {
            LOGGER.debug("Management mode quiescing entry {}", object);
            // save original state
            _quiescedEntriesOriginalState.put(object.getId(), attributes.get(ATTRIBUTE_STATE));
            Map<String, Object> modifiedAttributes = new HashMap<String, Object>(attributes);
            modifiedAttributes.put(ATTRIBUTE_STATE, State.QUIESCED);
            ConfiguredObjectRecord record = new ConfiguredObjectRecordImpl(object.getId(), object.getType(), modifiedAttributes, object.getParents());
            _records.put(record.getId(), record);
        } else {
            _records.put(object.getId(), object);
        }
    }
}
Also used : ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) Set(java.util.Set) HashMap(java.util.HashMap) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) Protocol(org.apache.qpid.server.model.Protocol)

Example 10 with ConfiguredObjectRecordImpl

use of org.apache.qpid.server.store.ConfiguredObjectRecordImpl in project qpid-broker-j by apache.

the class ManagementModeStoreHandler method createCLIPortEntry.

private ConfiguredObjectRecord createCLIPortEntry(int port, Protocol protocol) {
    ConfiguredObjectRecord parent = findBroker();
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put(Port.PORT, port);
    attributes.put(Port.PROTOCOLS, Collections.singleton(protocol));
    attributes.put(Port.NAME, MANAGEMENT_MODE_PORT_PREFIX + protocol.name());
    attributes.put(Port.AUTHENTICATION_PROVIDER, BrokerImpl.MANAGEMENT_MODE_AUTHENTICATION);
    ConfiguredObjectRecord portEntry = new ConfiguredObjectRecordImpl(UUID.randomUUID(), PORT_TYPE, attributes, Collections.singletonMap(parent.getType(), parent.getId()));
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Add management mode port configuration " + portEntry + " for port " + port + " and protocol " + protocol);
    }
    return portEntry;
}
Also used : ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord)

Aggregations

ConfiguredObjectRecordImpl (org.apache.qpid.server.store.ConfiguredObjectRecordImpl)16 ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)14 HashMap (java.util.HashMap)11 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)11 UUID (java.util.UUID)4 Broker (org.apache.qpid.server.model.Broker)3 Port (org.apache.qpid.server.model.Port)3 LinkedHashMap (java.util.LinkedHashMap)2 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)2 VirtualHost (org.apache.qpid.server.model.VirtualHost)2 ConfiguredObjectRecordHandler (org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler)2 Mockito.doAnswer (org.mockito.Mockito.doAnswer)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Set (java.util.Set)1 CurrentThreadTaskExecutor (org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor)1 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)1 AbstractSystemConfig (org.apache.qpid.server.model.AbstractSystemConfig)1