Search in sources :

Example 1 with ConfiguredObjectRecordImpl

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

the class AbstractStandardVirtualHostNode method enrichInitialVirtualHostRootRecord.

@Override
protected ConfiguredObjectRecord enrichInitialVirtualHostRootRecord(final ConfiguredObjectRecord vhostRecord) {
    ConfiguredObjectRecord replacementRecord;
    if (vhostRecord.getAttributes().get(ConfiguredObject.NAME) == null) {
        Map<String, Object> updatedAttributes = new LinkedHashMap<>(vhostRecord.getAttributes());
        updatedAttributes.put(ConfiguredObject.NAME, getName());
        if (!updatedAttributes.containsKey(VirtualHost.MODEL_VERSION)) {
            updatedAttributes.put(VirtualHost.MODEL_VERSION, getBroker().getModelVersion());
        }
        replacementRecord = new ConfiguredObjectRecordImpl(vhostRecord.getId(), vhostRecord.getType(), updatedAttributes, vhostRecord.getParents());
    } else if (vhostRecord.getAttributes().get(VirtualHost.MODEL_VERSION) == null) {
        Map<String, Object> updatedAttributes = new LinkedHashMap<>(vhostRecord.getAttributes());
        updatedAttributes.put(VirtualHost.MODEL_VERSION, getBroker().getModelVersion());
        replacementRecord = new ConfiguredObjectRecordImpl(vhostRecord.getId(), vhostRecord.getType(), updatedAttributes, vhostRecord.getParents());
    } else {
        replacementRecord = vhostRecord;
    }
    return replacementRecord;
}
Also used : ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with ConfiguredObjectRecordImpl

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

the class AbstractVirtualHostNode method addExchangeIfNecessary.

private void addExchangeIfNecessary(final String exchangeClass, final String exchangeName, final Collection<ConfiguredObjectRecord> records, final ConfiguredObjectRecord vhostRecord) {
    boolean found = false;
    for (ConfiguredObjectRecord record : records) {
        if (Exchange.class.getSimpleName().equals(record.getType()) && exchangeName.equals(record.getAttributes().get(ConfiguredObject.NAME))) {
            found = true;
            break;
        }
    }
    if (!found) {
        final Map<String, Object> exchangeAttributes = new HashMap<>();
        exchangeAttributes.put(ConfiguredObject.NAME, exchangeName);
        exchangeAttributes.put(ConfiguredObject.TYPE, exchangeClass);
        records.add(new ConfiguredObjectRecordImpl(UUID.randomUUID(), Exchange.class.getSimpleName(), exchangeAttributes, Collections.singletonMap(VirtualHost.class.getSimpleName(), vhostRecord.getId())));
    }
}
Also used : ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ManagedObject(org.apache.qpid.server.model.ManagedObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) VirtualHost(org.apache.qpid.server.model.VirtualHost) NonStandardVirtualHost(org.apache.qpid.server.virtualhost.NonStandardVirtualHost)

Example 3 with ConfiguredObjectRecordImpl

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

the class ManagementModeStoreHandlerTest method testSaveRoot.

public void testSaveRoot() {
    _systemConfigAttributes.put(SystemConfig.MANAGEMENT_MODE_HTTP_PORT_OVERRIDE, 1000);
    _handler = createManagementModeStoreHandler();
    _handler.init(_systemConfig);
    Collection<ConfiguredObjectRecord> records = openAndGetRecords();
    ConfiguredObjectRecord root = getRootEntry(records);
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put(Broker.NAME, "TEST");
    ConfiguredObjectRecord configurationEntry = new ConfiguredObjectRecordImpl(_rootId, Broker.class.getSimpleName(), attributes, root.getParents());
    _handler.update(false, configurationEntry);
    verify(_store).update(anyBoolean(), any(ConfiguredObjectRecord.class));
}
Also used : ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) Broker(org.apache.qpid.server.model.Broker) HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord)

Example 4 with ConfiguredObjectRecordImpl

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

the class ManagementModeStoreHandlerTest method testSaveCLIHttpPort.

public void testSaveCLIHttpPort() {
    _systemConfigAttributes.put(SystemConfig.MANAGEMENT_MODE_HTTP_PORT_OVERRIDE, 1000);
    _handler = createManagementModeStoreHandler();
    _handler.init(_systemConfig);
    Collection<ConfiguredObjectRecord> records = openAndGetRecords();
    UUID portId = getOptionsPortId(records);
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put(Port.NAME, "TEST");
    ConfiguredObjectRecord configurationEntry = new ConfiguredObjectRecordImpl(portId, Port.class.getSimpleName(), attributes, Collections.singletonMap(Broker.class.getSimpleName(), getRootEntry(records).getId()));
    try {
        _handler.update(false, configurationEntry);
        fail("Exception should be thrown on trying to save CLI port");
    } catch (IllegalConfigurationException e) {
    // pass
    }
}
Also used : ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) HashMap(java.util.HashMap) Port(org.apache.qpid.server.model.Port) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) UUID(java.util.UUID)

Example 5 with ConfiguredObjectRecordImpl

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

the class ManagementModeStoreHandlerTest method virtualHostEntryQuiescedStatusTestImpl.

private void virtualHostEntryQuiescedStatusTestImpl(boolean mmQuiesceVhosts) {
    UUID virtualHostId = UUID.randomUUID();
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put(VirtualHost.TYPE, "STANDARD");
    final ConfiguredObjectRecord virtualHost = new ConfiguredObjectRecordImpl(virtualHostId, VirtualHost.class.getSimpleName(), attributes, Collections.singletonMap(Broker.class.getSimpleName(), _root.getId()));
    final ArgumentCaptor<ConfiguredObjectRecordHandler> recovererArgumentCaptor = ArgumentCaptor.forClass(ConfiguredObjectRecordHandler.class);
    doAnswer(new Answer() {

        @Override
        public Object answer(final InvocationOnMock invocation) throws Throwable {
            ConfiguredObjectRecordHandler recoverer = recovererArgumentCaptor.getValue();
            recoverer.handle(_root);
            recoverer.handle(_portEntry);
            recoverer.handle(virtualHost);
            return false;
        }
    }).when(_store).openConfigurationStore(recovererArgumentCaptor.capture());
    State expectedState = mmQuiesceVhosts ? State.QUIESCED : null;
    if (mmQuiesceVhosts) {
        _systemConfigAttributes.put(SystemConfig.MANAGEMENT_MODE_QUIESCE_VIRTUAL_HOSTS, mmQuiesceVhosts);
    }
    _handler = createManagementModeStoreHandler();
    _handler.init(_systemConfig);
    Collection<ConfiguredObjectRecord> records = openAndGetRecords();
    ConfiguredObjectRecord hostEntry = getEntry(records, virtualHostId);
    Map<String, Object> hostAttributes = new HashMap<String, Object>(hostEntry.getAttributes());
    assertEquals("Unexpected state", expectedState, hostAttributes.get(VirtualHost.STATE));
    hostAttributes.remove(VirtualHost.STATE);
    assertEquals("Unexpected attributes", attributes, hostAttributes);
}
Also used : HashMap(java.util.HashMap) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) InvocationOnMock(org.mockito.invocation.InvocationOnMock) State(org.apache.qpid.server.model.State) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) VirtualHost(org.apache.qpid.server.model.VirtualHost) UUID(java.util.UUID) ConfiguredObjectRecordHandler(org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler)

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