use of org.apache.qpid.server.store.ConfiguredObjectRecord in project qpid-broker-j by apache.
the class ManagementModeStoreHandlerTest method openAndGetRecords.
private Collection<ConfiguredObjectRecord> openAndGetRecords() {
final Collection<ConfiguredObjectRecord> records = new ArrayList<>();
_handler.openConfigurationStore(new ConfiguredObjectRecordHandler() {
@Override
public void handle(final ConfiguredObjectRecord record) {
records.add(record);
}
});
return records;
}
use of org.apache.qpid.server.store.ConfiguredObjectRecord in project qpid-broker-j by apache.
the class StoreConfigurationChangeListenerTest method testStateChanged.
public void testStateChanged() {
notifyBrokerStarted();
UUID id = UUID.randomUUID();
ConfiguredObject object = mock(VirtualHost.class);
when(object.isDurable()).thenReturn(true);
when(object.getId()).thenReturn(id);
ConfiguredObjectRecord record = mock(ConfiguredObjectRecord.class);
when(object.asObjectRecord()).thenReturn(record);
_listener.stateChanged(object, State.ACTIVE, State.DELETED);
verify(_store).remove(record);
}
use of org.apache.qpid.server.store.ConfiguredObjectRecord in project qpid-broker-j by apache.
the class ManagementModeStoreHandler method openConfigurationStore.
@Override
public boolean openConfigurationStore(final ConfiguredObjectRecordHandler recoveryHandler, final ConfiguredObjectRecord... initialRecords) throws StoreException {
changeState(StoreState.CONFIGURED, StoreState.OPEN);
_records = new HashMap<UUID, ConfiguredObjectRecord>();
UnderlyingStoreRecoveringObjectRecordHandler underlyingHandler = new UnderlyingStoreRecoveringObjectRecordHandler();
boolean isNew = _store.openConfigurationStore(underlyingHandler, initialRecords);
_quiescedEntriesOriginalState = quiesceEntries(_systemConfig, underlyingHandler.getRecoveredRecords());
recoverRecords(underlyingHandler.getRecoveredRecords());
_cliEntries = createPortsFromCommandLineOptions(_systemConfig);
for (ConfiguredObjectRecord entry : _cliEntries.values()) {
_records.put(entry.getId(), entry);
}
for (ConfiguredObjectRecord record : _records.values()) {
recoveryHandler.handle(record);
}
return isNew;
}
use of org.apache.qpid.server.store.ConfiguredObjectRecord in project qpid-broker-j by apache.
the class ManagementModeStoreHandler method remove.
@Override
public synchronized UUID[] remove(final ConfiguredObjectRecord... records) {
assertState(StoreState.OPEN);
synchronized (_store) {
UUID[] idsToRemove = new UUID[records.length];
for (int i = 0; i < records.length; i++) {
idsToRemove[i] = records[i].getId();
}
for (UUID id : idsToRemove) {
if (_cliEntries.containsKey(id)) {
throw new IllegalConfigurationException("Cannot change configuration for command line entry:" + _cliEntries.get(id));
}
}
UUID[] result = _store.remove(records);
for (UUID id : idsToRemove) {
if (_quiescedEntriesOriginalState.containsKey(id)) {
_quiescedEntriesOriginalState.remove(id);
}
}
for (ConfiguredObjectRecord record : records) {
_records.remove(record.getId());
}
return result;
}
}
use of org.apache.qpid.server.store.ConfiguredObjectRecord in project qpid-broker-j by apache.
the class ManagementModeStoreHandler method update.
@Override
public void update(final boolean createIfNecessary, final ConfiguredObjectRecord... records) throws StoreException {
assertState(StoreState.OPEN);
synchronized (_store) {
Collection<ConfiguredObjectRecord> actualUpdates = new ArrayList<ConfiguredObjectRecord>();
for (ConfiguredObjectRecord record : records) {
if (_cliEntries.containsKey(record.getId())) {
throw new IllegalConfigurationException("Cannot save configuration provided as command line argument:" + record);
} else if (_quiescedEntriesOriginalState.containsKey(record.getId())) {
// save entry with the original state
record = createEntryWithState(record, _quiescedEntriesOriginalState.get(record.getId()));
}
actualUpdates.add(record);
}
_store.update(createIfNecessary, actualUpdates.toArray(new ConfiguredObjectRecord[actualUpdates.size()]));
}
for (ConfiguredObjectRecord record : records) {
_records.put(record.getId(), record);
}
}
Aggregations