Search in sources :

Example 6 with PersistenceConfig

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

the class TestPersistenceEncryptionVaultApplicationContext method testPersistence.

@Test
public void testPersistence() {
    File dir = new File("/mnt/persistence/");
    File hotBackupDir = new File("/mnt/persistence-backup/");
    PersistenceConfig persistenceConfig = config.getPersistenceConfig();
    assertFalse(persistenceConfig.isEnabled());
    assertEquals(dir.getAbsolutePath(), persistenceConfig.getBaseDir().getAbsolutePath());
    assertEquals(hotBackupDir.getAbsolutePath(), persistenceConfig.getBackupDir().getAbsolutePath());
    assertEquals(1111, persistenceConfig.getValidationTimeoutSeconds());
    assertEquals(2222, persistenceConfig.getDataLoadTimeoutSeconds());
    assertEquals(PARTIAL_RECOVERY_MOST_COMPLETE, persistenceConfig.getClusterDataRecoveryPolicy());
    assertFalse(persistenceConfig.isAutoRemoveStaleData());
    EncryptionAtRestConfig encryptionAtRestConfig = persistenceConfig.getEncryptionAtRestConfig();
    assertNotNull(encryptionAtRestConfig);
    assertTrue(encryptionAtRestConfig.isEnabled());
    assertEquals("AES/CBC/PKCS5Padding", encryptionAtRestConfig.getAlgorithm());
    assertEquals("sugar", encryptionAtRestConfig.getSalt());
    assertEquals(16, encryptionAtRestConfig.getKeySize());
    assertTrue(encryptionAtRestConfig.getSecureStoreConfig() instanceof VaultSecureStoreConfig);
    VaultSecureStoreConfig vaultConfig = (VaultSecureStoreConfig) encryptionAtRestConfig.getSecureStoreConfig();
    assertEquals("http://localhost:1234", vaultConfig.getAddress());
    assertEquals("secret/path", vaultConfig.getSecretPath());
    assertEquals("token", vaultConfig.getToken());
    SSLConfig sslConfig = vaultConfig.getSSLConfig();
    assertNotNull(sslConfig);
    assertTrue(sslConfig.isEnabled());
    assertEquals(sslContextFactory, sslConfig.getFactoryImplementation());
    assertEquals(60, vaultConfig.getPollingInterval());
}
Also used : SSLConfig(com.hazelcast.config.SSLConfig) EncryptionAtRestConfig(com.hazelcast.config.EncryptionAtRestConfig) PersistenceConfig(com.hazelcast.config.PersistenceConfig) VaultSecureStoreConfig(com.hazelcast.config.VaultSecureStoreConfig) File(java.io.File) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with PersistenceConfig

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

the class MemberDomConfigProcessor method handlePersistence.

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

Aggregations

PersistenceConfig (com.hazelcast.config.PersistenceConfig)7 File (java.io.File)5 EncryptionAtRestConfig (com.hazelcast.config.EncryptionAtRestConfig)4 SSLConfig (com.hazelcast.config.SSLConfig)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 HotRestartPersistenceConfig (com.hazelcast.config.HotRestartPersistenceConfig)2 VaultSecureStoreConfig (com.hazelcast.config.VaultSecureStoreConfig)2 AdvancedNetworkConfig (com.hazelcast.config.AdvancedNetworkConfig)1 AuditlogConfig (com.hazelcast.config.AuditlogConfig)1 Config (com.hazelcast.config.Config)1 DataPersistenceConfig (com.hazelcast.config.DataPersistenceConfig)1 EndpointConfig (com.hazelcast.config.EndpointConfig)1 JavaKeyStoreSecureStoreConfig (com.hazelcast.config.JavaKeyStoreSecureStoreConfig)1 SecurityConfig (com.hazelcast.config.SecurityConfig)1 CPSubsystemConfig (com.hazelcast.config.cp.CPSubsystemConfig)1 EndpointQualifier (com.hazelcast.instance.EndpointQualifier)1 Map (java.util.Map)1 Node (org.w3c.dom.Node)1