use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class ManagementModeStoreHandlerTest method createManagementModeStoreHandler.
private ManagementModeStoreHandler createManagementModeStoreHandler() {
_systemConfig.close();
Map<String, Object> attributes = new HashMap<>(_systemConfigAttributes);
attributes.put(ConfiguredObject.DESIRED_STATE, State.QUIESCED);
attributes.remove(ConfiguredObject.TYPE);
_systemConfig = new AbstractSystemConfig(_taskExecutor, mock(EventLogger.class), mock(Principal.class), attributes) {
@Override
protected void onOpen() {
}
@Override
protected DurableConfigurationStore createStoreObject() {
return _store;
}
@Override
protected ListenableFuture<Void> onClose() {
return Futures.immediateFuture(null);
}
@Override
@StateTransition(currentState = State.UNINITIALIZED, desiredState = State.QUIESCED)
protected ListenableFuture<Void> startQuiesced() {
return Futures.immediateFuture(null);
}
};
_systemConfig.open();
return new ManagementModeStoreHandler(_store, _systemConfig);
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class BrokerTestHelper method createVirtualHostNodeMock.
public static VirtualHostNode createVirtualHostNodeMock(final String virtualHostNodeName, final boolean defaultVHN, final AccessControl accessControl, final Broker<?> broker) {
ConfiguredObjectFactory objectFactory = broker.getObjectFactory();
VirtualHostNode virtualHostNode = mockWithSystemPrincipalAndAccessControl(VirtualHostNode.class, SYSTEM_PRINCIPAL, accessControl);
when(virtualHostNode.getName()).thenReturn(virtualHostNodeName);
when(virtualHostNode.getTaskExecutor()).thenReturn(TASK_EXECUTOR);
when(virtualHostNode.getChildExecutor()).thenReturn(TASK_EXECUTOR);
when(virtualHostNode.isDefaultVirtualHostNode()).thenReturn(defaultVHN);
when(virtualHostNode.getParent()).thenReturn(broker);
Collection<VirtualHostNode<?>> nodes = broker.getVirtualHostNodes();
nodes = new ArrayList<>(nodes != null ? nodes : Collections.<VirtualHostNode<?>>emptyList());
nodes.add(virtualHostNode);
when(broker.getVirtualHostNodes()).thenReturn(nodes);
DurableConfigurationStore dcs = mock(DurableConfigurationStore.class);
when(virtualHostNode.getConfigurationStore()).thenReturn(dcs);
when(virtualHostNode.getModel()).thenReturn(objectFactory.getModel());
when(virtualHostNode.getObjectFactory()).thenReturn(objectFactory);
when(virtualHostNode.getCategoryClass()).thenReturn(VirtualHostNode.class);
when(virtualHostNode.getTaskExecutor()).thenReturn(TASK_EXECUTOR);
when(virtualHostNode.getChildExecutor()).thenReturn(TASK_EXECUTOR);
when(virtualHostNode.createPreferenceStore()).thenReturn(mock(PreferenceStore.class));
return virtualHostNode;
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class BrokerImplTest method createVhnWithVh.
private void createVhnWithVh(final BrokerImpl brokerImpl, int nameSuffix, final long totalQueueSize) {
final Map<String, Object> vhnAttributes = new HashMap<>();
vhnAttributes.put(VirtualHostNode.TYPE, TestVirtualHostNode.VIRTUAL_HOST_NODE_TYPE);
vhnAttributes.put(VirtualHostNode.NAME, "testVhn" + nameSuffix);
final DurableConfigurationStore store = mock(DurableConfigurationStore.class);
TestVirtualHostNode vhn = new TestVirtualHostNode(brokerImpl, vhnAttributes, store);
vhn.create();
final Map<String, Object> vhAttributes = new HashMap<>();
vhAttributes.put(VirtualHost.TYPE, TestMemoryVirtualHost.VIRTUAL_HOST_TYPE);
vhAttributes.put(VirtualHost.NAME, "testVh" + nameSuffix);
TestMemoryVirtualHost vh = new TestMemoryVirtualHost(vhAttributes, vhn) {
@Override
public long getTotalDepthOfQueuesBytes() {
return totalQueueSize;
}
};
vh.create();
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNode method onDelete.
@Override
protected ListenableFuture<Void> onDelete() {
final VirtualHost<?> virtualHost = getVirtualHost();
final MessageStore messageStore = virtualHost == null ? null : virtualHost.getMessageStore();
return doAfterAlways(closeVirtualHostIfExists(), () -> {
if (messageStore != null) {
messageStore.closeMessageStore();
messageStore.onDelete(virtualHost);
}
if (AbstractStandardVirtualHostNode.this instanceof PreferenceStoreProvider) {
PreferenceStore preferenceStore = ((PreferenceStoreProvider) AbstractStandardVirtualHostNode.this).getPreferenceStore();
if (preferenceStore != null) {
preferenceStore.onDelete();
}
}
DurableConfigurationStore configurationStore = getConfigurationStore();
if (configurationStore != null) {
configurationStore.closeConfigurationStore();
configurationStore.onDelete(AbstractStandardVirtualHostNode.this);
}
onCloseOrDelete();
});
}
use of org.apache.qpid.server.store.DurableConfigurationStore in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testValidateOnCreateFails_ExistingDefaultVHN.
@Test
public void testValidateOnCreateFails_ExistingDefaultVHN() throws Exception {
String nodeName = getTestName();
Map<String, Object> attributes = new HashMap<>();
attributes.put(TestVirtualHostNode.NAME, nodeName);
attributes.put(TestVirtualHostNode.DEFAULT_VIRTUAL_HOST_NODE, Boolean.TRUE);
VirtualHostNode existingDefault = mock(VirtualHostNode.class);
when(existingDefault.getName()).thenReturn("existingDefault");
when(_broker.findDefautVirtualHostNode()).thenReturn(existingDefault);
final DurableConfigurationStore store = mock(DurableConfigurationStore.class);
AbstractStandardVirtualHostNode node = createTestStandardVirtualHostNode(attributes, store);
try {
node.create();
fail("Exception not thrown");
} catch (IllegalConfigurationException e) {
assertTrue("Unexpected exception " + e.getMessage(), e.getMessage().startsWith("The existing virtual host node 'existingDefault' is already the default for the Broker"));
}
}
Aggregations