use of org.apache.ignite.configuration.ConfigurationChangeException 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);
}
use of org.apache.ignite.configuration.ConfigurationChangeException in project ignite-3 by apache.
the class ConfigurationChanger method initializeDefaults.
/**
* Initializes the configuration storage - reads data and sets default values for missing configuration properties.
*
* @throws ConfigurationValidationException If configuration validation failed.
* @throws ConfigurationChangeException If configuration framework failed to add default values and save them to storage.
*/
public void initializeDefaults() throws ConfigurationValidationException, ConfigurationChangeException {
try {
ConfigurationSource defaultsCfgSource = new ConfigurationSource() {
/**
* {@inheritDoc}
*/
@Override
public void descend(ConstructableTreeNode node) {
addDefaults((InnerNode) node);
}
};
changeInternally(defaultsCfgSource).get(5, TimeUnit.SECONDS);
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof ConfigurationValidationException) {
throw (ConfigurationValidationException) cause;
}
if (cause instanceof ConfigurationChangeException) {
throw (ConfigurationChangeException) cause;
}
throw new ConfigurationChangeException("Failed to write default configuration values into the storage " + storage.getClass(), e);
} catch (InterruptedException | TimeoutException e) {
throw new ConfigurationChangeException("Failed to initialize configuration storage " + storage.getClass(), e);
}
}
Aggregations