Search in sources :

Example 61 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class BrokerStoreUpgraderAndRecoverer method upgradeAndRecover.

@Override
public Broker<?> upgradeAndRecover(List<ConfiguredObjectRecord> records) {
    final DurableConfigurationStore store = _systemConfig.getConfigurationStore();
    List<ConfiguredObjectRecord> upgradedRecords = upgrade(store, records);
    new GenericRecoverer(_systemConfig).recover(upgradedRecords, false);
    final StoreConfigurationChangeListener configChangeListener = new StoreConfigurationChangeListener(store);
    applyRecursively(_systemConfig.getContainer(Broker.class), new RecursiveAction<ConfiguredObject<?>>() {

        @Override
        public void performAction(final ConfiguredObject<?> object) {
            object.addChangeListener(configChangeListener);
        }

        @Override
        public boolean applyToChildren(ConfiguredObject<?> object) {
            return !object.managesChildStorage();
        }
    });
    return _systemConfig.getContainer(Broker.class);
}
Also used : Broker(org.apache.qpid.server.model.Broker) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) StoreConfigurationChangeListener(org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener)

Example 62 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class VirtualHostStoreUpgraderAndRecoverer method recover.

private void recover(final ConfiguredObject<?> recoveryRoot, final DurableConfigurationStore durableConfigurationStore, final List<ConfiguredObjectRecord> records, final boolean isNew) {
    new GenericRecoverer(recoveryRoot).recover(records, isNew);
    final StoreConfigurationChangeListener configChangeListener = new StoreConfigurationChangeListener(durableConfigurationStore);
    if (_virtualHostNode.getVirtualHost() != null) {
        applyRecursively(_virtualHostNode.getVirtualHost(), new RecursiveAction<ConfiguredObject<?>>() {

            @Override
            public boolean applyToChildren(final ConfiguredObject<?> object) {
                return object.isDurable();
            }

            @Override
            public void performAction(final ConfiguredObject<?> object) {
                object.addChangeListener(configChangeListener);
            }
        });
    }
    if (recoveryRoot instanceof VirtualHostNode) {
        _virtualHostNode.addChangeListener(new AbstractConfigurationChangeListener() {

            @Override
            public void childAdded(final ConfiguredObject<?> object, final ConfiguredObject<?> child) {
                if (child instanceof VirtualHost) {
                    applyRecursively(child, new RecursiveAction<ConfiguredObject<?>>() {

                        @Override
                        public boolean applyToChildren(final ConfiguredObject<?> object) {
                            return object.isDurable();
                        }

                        @Override
                        public void performAction(final ConfiguredObject<?> object) {
                            if (object.isDurable()) {
                                durableConfigurationStore.update(true, object.asObjectRecord());
                                object.addChangeListener(configChangeListener);
                            }
                        }
                    });
                }
            }

            @Override
            public void childRemoved(final ConfiguredObject<?> object, final ConfiguredObject<?> child) {
                if (child instanceof VirtualHost) {
                    child.removeChangeListener(configChangeListener);
                }
            }
        });
        if (isNew) {
            if (_virtualHostNode instanceof AbstractConfiguredObject) {
                ((AbstractConfiguredObject) _virtualHostNode).forceUpdateAllSecureAttributes();
            }
        }
    }
}
Also used : AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) VirtualHost(org.apache.qpid.server.model.VirtualHost) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) StoreConfigurationChangeListener(org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener) AbstractConfigurationChangeListener(org.apache.qpid.server.model.AbstractConfigurationChangeListener)

Example 63 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class JsonFilePreferenceStoreFactoryService method createInstance.

@Override
public PreferenceStore createInstance(final ConfiguredObject<?> parent, final Map<String, Object> preferenceStoreAttributes) {
    final Object path = preferenceStoreAttributes.get(PATH);
    if (path == null || !(path instanceof String)) {
        throw new IllegalConfigurationException("JsonFilePreferenceStore requires path");
    }
    final String posixFilePermissions = parent.getContextValue(String.class, SystemConfig.POSIX_FILE_PERMISSIONS);
    return new JsonFilePreferenceStore((String) path, posixFilePermissions);
}
Also used : IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Example 64 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class ConfiguredObjectRecordConverter method loadChild.

private Collection<NameToIdResolver> loadChild(final Class<? extends ConfiguredObject> clazz, final Map<String, Object> data, final Class<? extends ConfiguredObject> parentClass, final UUID parentId, final Map<UUID, ConfiguredObjectRecord> records) {
    String idStr = (String) data.remove("id");
    final UUID id = idStr == null ? UUID.randomUUID() : UUID.fromString(idStr);
    final String type = clazz.getSimpleName();
    Map<String, UUID> parentMap = new HashMap<>();
    Collection<Class<? extends ConfiguredObject>> childClasses = _model.getChildTypes(clazz);
    List<NameToIdResolver> requiringResolution = new ArrayList<>();
    for (Class<? extends ConfiguredObject> childClass : childClasses) {
        final String childType = childClass.getSimpleName();
        String singularName = childType.toLowerCase();
        String attrName = singularName + (singularName.endsWith("s") ? "es" : "s");
        Object children = data.remove(attrName);
        if (children != null) {
            if (children instanceof Collection) {
                for (Object child : (Collection) children) {
                    if (child instanceof Map) {
                        requiringResolution.addAll(loadChild(childClass, (Map) child, clazz, id, records));
                    }
                }
            }
        }
    }
    if (parentId != null) {
        parentMap.put(parentClass.getSimpleName(), parentId);
    }
    records.put(id, new ConfiguredObjectRecordImpl(id, type, data, parentMap));
    return requiringResolution;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Collection(java.util.Collection) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map)

Example 65 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class AncestorAttributeResolverTest method testResolveAncestorAttributeOfTypeConfiguredObject.

@Test
public void testResolveAncestorAttributeOfTypeConfiguredObject() throws Exception {
    Map<String, Object> carAttributes = new HashMap<>();
    carAttributes.put(ConfiguredObject.NAME, CAR_NAME);
    carAttributes.put(ConfiguredObject.TYPE, TestKitCarImpl.TEST_KITCAR_TYPE);
    carAttributes.put("alternateEngine", _engine);
    _car = _model.getObjectFactory().create(TestCar.class, carAttributes, null);
    _ancestorAttributeResolver = new AncestorAttributeResolver(_car);
    String actual = _ancestorAttributeResolver.resolve("ancestor:testcar:alternateEngine", null);
    assertEquals("Unexpected resolved ancestor attribute of type ConfiguredObject", _engine.getId().toString(), actual);
}
Also used : HashMap(java.util.HashMap) AncestorAttributeResolver(org.apache.qpid.server.model.AncestorAttributeResolver) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) Test(org.junit.Test)

Aggregations

ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)117 ArrayList (java.util.ArrayList)43 HashMap (java.util.HashMap)35 Test (org.junit.Test)33 Map (java.util.Map)29 List (java.util.List)27 LinkedHashMap (java.util.LinkedHashMap)25 UUID (java.util.UUID)21 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)21 AbstractConfigurationChangeListener (org.apache.qpid.server.model.AbstractConfigurationChangeListener)15 Collection (java.util.Collection)12 LegacyConfiguredObject (org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject)12 ConfiguredObjectFinder (org.apache.qpid.server.model.ConfiguredObjectFinder)12 ManagedObject (org.apache.qpid.server.model.ManagedObject)11 State (org.apache.qpid.server.model.State)10 Date (java.util.Date)7 TreeMap (java.util.TreeMap)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 GenericLegacyConfiguredObject (org.apache.qpid.server.management.plugin.controller.GenericLegacyConfiguredObject)6 InternalMessageHeader (org.apache.qpid.server.message.internal.InternalMessageHeader)6