use of org.apache.ignite.internal.configuration.storage.Data 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.internal.configuration.storage.Data in project ignite-3 by apache.
the class ConfigurationChangerTest method testFailedToWrite.
/**
* Test that change fails with right exception if storage is inaccessible.
*/
@Test
public void testFailedToWrite() {
ConfigurationChanger changer = createChanger(KEY);
storage.fail(true);
assertThrows(ConfigurationChangeException.class, changer::start);
storage.fail(false);
changer.start();
storage.fail(true);
assertThrows(ExecutionException.class, () -> changer.change(source(KEY, (FirstChange parent) -> parent.changeChild(child -> child.changeIntCfg(1).changeStrCfg("1")))).get(1, SECONDS));
storage.fail(false);
Data dataFromStorage = storage.readAll();
Map<String, ? extends Serializable> dataMap = dataFromStorage.values();
assertEquals(0, dataMap.size());
FirstView newRoot = (FirstView) changer.getRootNode(KEY);
assertNotNull(newRoot.child());
assertNull(newRoot.child().strCfg());
}
Aggregations