Search in sources :

Example 41 with ConfiguredObjectRecord

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

the class AbstractVirtualHostNode method enrichWithAuditInformation.

private void enrichWithAuditInformation(final Collection<ConfiguredObjectRecord> records) {
    List<ConfiguredObjectRecord> replacements = new ArrayList<>(records.size());
    for (ConfiguredObjectRecord record : records) {
        replacements.add(new ConfiguredObjectRecordImpl(record.getId(), record.getType(), enrichAttributesWithAuditInformation(record.getAttributes()), record.getParents()));
    }
    records.clear();
    records.addAll(replacements);
}
Also used : ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) ArrayList(java.util.ArrayList) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord)

Example 42 with ConfiguredObjectRecord

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

the class ManagementModeStoreHandlerTest method testGetEntryByRootId.

public void testGetEntryByRootId() {
    Collection<ConfiguredObjectRecord> records = openAndGetRecords();
    ConfiguredObjectRecord root = getEntry(records, _rootId);
    assertEquals("Unexpected root id", _rootId, root.getId());
    assertEquals("Unexpected children", Collections.singleton(_portEntryId), getChildrenIds(records, root));
}
Also used : ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord)

Example 43 with ConfiguredObjectRecord

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

the class ManagementModeStoreHandlerTest method testGetEntryByCLIHttpPortId.

public void testGetEntryByCLIHttpPortId() {
    _systemConfigAttributes.put(SystemConfig.MANAGEMENT_MODE_HTTP_PORT_OVERRIDE, 9090);
    _handler = createManagementModeStoreHandler();
    _handler.init(_systemConfig);
    Collection<ConfiguredObjectRecord> records = openAndGetRecords();
    UUID optionsPort = getOptionsPortId(records);
    ConfiguredObjectRecord portEntry = getEntry(records, optionsPort);
    assertCLIPortEntry(records, portEntry, optionsPort, Protocol.HTTP);
}
Also used : ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) UUID(java.util.UUID)

Example 44 with ConfiguredObjectRecord

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

the class ManagementModeStoreHandlerTest method testSavePort.

public void testSavePort() {
    _systemConfigAttributes.put(SystemConfig.MANAGEMENT_MODE_HTTP_PORT_OVERRIDE, 1000);
    _handler = createManagementModeStoreHandler();
    _handler.init(_systemConfig);
    Collection<ConfiguredObjectRecord> records = openAndGetRecords();
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put(Port.NAME, "TEST");
    ConfiguredObjectRecord configurationEntry = new ConfiguredObjectRecordImpl(_portEntryId, Port.class.getSimpleName(), attributes, Collections.singletonMap(Broker.class.getSimpleName(), getRootEntry(records).getId()));
    _handler.create(configurationEntry);
    verify(_store).create(any(ConfiguredObjectRecord.class));
}
Also used : ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) HashMap(java.util.HashMap) Port(org.apache.qpid.server.model.Port) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord)

Example 45 with ConfiguredObjectRecord

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

the class ManagementModeStoreHandlerTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    _rootId = UUID.randomUUID();
    _portEntryId = UUID.randomUUID();
    _store = mock(DurableConfigurationStore.class);
    _taskExecutor = new CurrentThreadTaskExecutor();
    _taskExecutor.start();
    _systemConfig = new JsonSystemConfigImpl(_taskExecutor, mock(EventLogger.class), null, new HashMap<String, Object>());
    ConfiguredObjectRecord systemContextRecord = _systemConfig.asObjectRecord();
    _root = new ConfiguredObjectRecordImpl(_rootId, Broker.class.getSimpleName(), Collections.singletonMap(Broker.NAME, (Object) "broker"), Collections.singletonMap(SystemConfig.class.getSimpleName(), systemContextRecord.getId()));
    _portEntry = mock(ConfiguredObjectRecord.class);
    when(_portEntry.getId()).thenReturn(_portEntryId);
    when(_portEntry.getParents()).thenReturn(Collections.singletonMap(Broker.class.getSimpleName(), _root.getId()));
    when(_portEntry.getType()).thenReturn(Port.class.getSimpleName());
    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);
            return false;
        }
    }).when(_store).openConfigurationStore(recovererArgumentCaptor.capture());
    _systemConfigAttributes = new HashMap<>();
    _handler = new ManagementModeStoreHandler(_store, _systemConfig);
    ;
    _handler.init(_systemConfig);
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) AbstractSystemConfig(org.apache.qpid.server.model.AbstractSystemConfig) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) HashMap(java.util.HashMap) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) Port(org.apache.qpid.server.model.Port) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) JsonSystemConfigImpl(org.apache.qpid.server.model.JsonSystemConfigImpl) ConfiguredObjectRecordHandler(org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler)

Aggregations

ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)58 HashMap (java.util.HashMap)27 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)25 UUID (java.util.UUID)24 ConfiguredObjectRecordImpl (org.apache.qpid.server.store.ConfiguredObjectRecordImpl)14 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)13 ArrayList (java.util.ArrayList)12 ConfiguredObjectRecordHandler (org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler)8 LinkedHashMap (java.util.LinkedHashMap)6 IOException (java.io.IOException)5 Transaction (com.sleepycat.je.Transaction)4 Map (java.util.Map)4 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)4 StoreException (org.apache.qpid.server.store.StoreException)4 Mockito.doAnswer (org.mockito.Mockito.doAnswer)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 Answer (org.mockito.stubbing.Answer)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3