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