Search in sources :

Example 1 with HotRestartPersistenceConfig

use of com.hazelcast.config.HotRestartPersistenceConfig in project hazelcast by hazelcast.

the class TestFullApplicationContext method testHotRestart.

@Test
public void testHotRestart() {
    File dir = new File("/mnt/hot-restart/");
    File hotBackupDir = new File("/mnt/hot-backup/");
    HotRestartPersistenceConfig hotRestartPersistenceConfig = config.getHotRestartPersistenceConfig();
    assertTrue(hotRestartPersistenceConfig.isEnabled());
    assertEquals(dir.getAbsolutePath(), hotRestartPersistenceConfig.getBaseDir().getAbsolutePath());
    assertEquals(hotBackupDir.getAbsolutePath(), hotRestartPersistenceConfig.getBackupDir().getAbsolutePath());
    assertEquals(1111, hotRestartPersistenceConfig.getValidationTimeoutSeconds());
    assertEquals(2222, hotRestartPersistenceConfig.getDataLoadTimeoutSeconds());
    assertEquals(PARTIAL_RECOVERY_MOST_COMPLETE, hotRestartPersistenceConfig.getClusterDataRecoveryPolicy());
}
Also used : HotRestartPersistenceConfig(com.hazelcast.config.HotRestartPersistenceConfig) File(java.io.File) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 2 with HotRestartPersistenceConfig

use of com.hazelcast.config.HotRestartPersistenceConfig in project hazelcast by hazelcast.

the class PersistenceAndHotRestartPersistenceMergerTest method test.

private void test(String template) {
    String xml = String.format(template, persistenceEnabled, directory, parallelism, hotRestartPersistenceEnabled, directory + "a", max(parallelism - 1, parallelism + 1));
    Config cfg = Config.loadFromString(xml);
    HotRestartPersistenceConfig hotRestartPersistenceConfig = cfg.getHotRestartPersistenceConfig();
    PersistenceConfig persistenceConfig = cfg.getPersistenceConfig();
    assertEquals(persistenceEnabled || hotRestartPersistenceEnabled, persistenceConfig.isEnabled());
    assertEquals(new File(expectedDirectory).getAbsolutePath(), persistenceConfig.getBaseDir().getAbsolutePath());
    assertEquals(expectedParallelism, persistenceConfig.getParallelism());
    assertEquals(persistenceEnabled || hotRestartPersistenceEnabled, hotRestartPersistenceConfig.isEnabled());
    assertEquals(new File(expectedDirectory).getAbsolutePath(), hotRestartPersistenceConfig.getBaseDir().getAbsolutePath());
    assertEquals(expectedParallelism, hotRestartPersistenceConfig.getParallelism());
}
Also used : HotRestartPersistenceConfig(com.hazelcast.config.HotRestartPersistenceConfig) PersistenceConfig(com.hazelcast.config.PersistenceConfig) HotRestartPersistenceConfig(com.hazelcast.config.HotRestartPersistenceConfig) Config(com.hazelcast.config.Config) PersistenceConfig(com.hazelcast.config.PersistenceConfig) HotRestartPersistenceConfig(com.hazelcast.config.HotRestartPersistenceConfig) File(java.io.File)

Example 3 with HotRestartPersistenceConfig

use of com.hazelcast.config.HotRestartPersistenceConfig in project hazelcast by hazelcast.

the class MemberDomConfigProcessor method handleHotRestartPersistence.

private void handleHotRestartPersistence(Node hrRoot) throws Exception {
    HotRestartPersistenceConfig hrConfig = config.getHotRestartPersistenceConfig().setEnabled(getBooleanValue(getAttribute(hrRoot, "enabled")));
    String parallelismName = "parallelism";
    String validationTimeoutName = "validation-timeout-seconds";
    String dataLoadTimeoutName = "data-load-timeout-seconds";
    for (Node n : childElements(hrRoot)) {
        String name = cleanNodeName(n);
        if (matches("encryption-at-rest", name)) {
            handleEncryptionAtRest(n, hrConfig);
        } else {
            if (matches("base-dir", name)) {
                hrConfig.setBaseDir(new File(getTextContent(n)).getAbsoluteFile());
            } else if (matches("backup-dir", name)) {
                hrConfig.setBackupDir(new File(getTextContent(n)).getAbsoluteFile());
            } else if (matches(parallelismName, name)) {
                hrConfig.setParallelism(getIntegerValue(parallelismName, getTextContent(n)));
            } else if (matches(validationTimeoutName, name)) {
                hrConfig.setValidationTimeoutSeconds(getIntegerValue(validationTimeoutName, getTextContent(n)));
            } else if (matches(dataLoadTimeoutName, name)) {
                hrConfig.setDataLoadTimeoutSeconds(getIntegerValue(dataLoadTimeoutName, getTextContent(n)));
            } else if (matches("cluster-data-recovery-policy", name)) {
                hrConfig.setClusterDataRecoveryPolicy(HotRestartClusterDataRecoveryPolicy.valueOf(upperCaseInternal(getTextContent(n))));
            } else if (matches("auto-remove-stale-data", name)) {
                hrConfig.setAutoRemoveStaleData(getBooleanValue(getTextContent(n)));
            }
        }
    }
    config.setHotRestartPersistenceConfig(hrConfig);
}
Also used : HotRestartPersistenceConfig(com.hazelcast.config.HotRestartPersistenceConfig) Node(org.w3c.dom.Node) File(java.io.File)

Aggregations

HotRestartPersistenceConfig (com.hazelcast.config.HotRestartPersistenceConfig)3 File (java.io.File)3 Config (com.hazelcast.config.Config)1 PersistenceConfig (com.hazelcast.config.PersistenceConfig)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Test (org.junit.Test)1 Node (org.w3c.dom.Node)1