Search in sources :

Example 1 with StorageException

use of org.apache.ignite.internal.configuration.storage.StorageException in project ignite-3 by apache.

the class ConfigurationChanger method start.

/**
 * Start component.
 */
// ConfigurationChangeException, really?
public void start() throws ConfigurationChangeException {
    Data data;
    try {
        data = storage.readAll();
    } catch (StorageException e) {
        throw new ConfigurationChangeException("Failed to initialize configuration: " + e.getMessage(), e);
    }
    SuperRoot superRoot = new SuperRoot(rootCreator());
    Map<String, ?> dataValuesPrefixMap = toPrefixMap(data.values());
    for (RootKey<?, ?> rootKey : rootKeys.values()) {
        Map<String, ?> rootPrefixMap = (Map<String, ?>) dataValuesPrefixMap.get(rootKey.key());
        InnerNode rootNode = createRootNode(rootKey);
        if (rootPrefixMap != null) {
            fillFromPrefixMap(rootNode, rootPrefixMap);
        }
        superRoot.addRoot(rootKey, rootNode);
    }
    // Workaround for distributed configuration.
    addDefaults(superRoot);
    storageRoots = new StorageRoots(superRoot, data.changeId());
    storage.registerConfigurationListener(this::updateFromListener);
}
Also used : ConfigurationChangeException(org.apache.ignite.configuration.ConfigurationChangeException) Data(org.apache.ignite.internal.configuration.storage.Data) StorageException(org.apache.ignite.internal.configuration.storage.StorageException) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConfigurationUtil.fillFromPrefixMap(org.apache.ignite.internal.configuration.util.ConfigurationUtil.fillFromPrefixMap) ConfigurationFlattener.createFlattenedUpdatesMap(org.apache.ignite.internal.configuration.util.ConfigurationFlattener.createFlattenedUpdatesMap) HashMap(java.util.HashMap) ConfigurationUtil.toPrefixMap(org.apache.ignite.internal.configuration.util.ConfigurationUtil.toPrefixMap) InnerNode(org.apache.ignite.internal.configuration.tree.InnerNode)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 ConfigurationChangeException (org.apache.ignite.configuration.ConfigurationChangeException)1 Data (org.apache.ignite.internal.configuration.storage.Data)1 StorageException (org.apache.ignite.internal.configuration.storage.StorageException)1 InnerNode (org.apache.ignite.internal.configuration.tree.InnerNode)1 ConfigurationFlattener.createFlattenedUpdatesMap (org.apache.ignite.internal.configuration.util.ConfigurationFlattener.createFlattenedUpdatesMap)1 ConfigurationUtil.fillFromPrefixMap (org.apache.ignite.internal.configuration.util.ConfigurationUtil.fillFromPrefixMap)1 ConfigurationUtil.toPrefixMap (org.apache.ignite.internal.configuration.util.ConfigurationUtil.toPrefixMap)1