Search in sources :

Example 6 with MemorySize

use of com.hazelcast.memory.MemorySize in project hazelcast by hazelcast.

the class AbstractDomConfigProcessor method createMemorySize.

protected MemorySize createMemorySize(Node node) {
    final String value = getTextContent(getNamedItemNode(node, "value"));
    final MemoryUnit unit = MemoryUnit.valueOf(getTextContent(getNamedItemNode(node, "unit")));
    return new MemorySize(Long.parseLong(value), unit);
}
Also used : MemoryUnit(com.hazelcast.memory.MemoryUnit) MemorySize(com.hazelcast.memory.MemorySize)

Example 7 with MemorySize

use of com.hazelcast.memory.MemorySize in project hazelcast by hazelcast.

the class ClientConfigXmlGeneratorTest method nativeMemoryWithPersistentMemory.

@Test
public void nativeMemoryWithPersistentMemory() {
    NativeMemoryConfig expected = new NativeMemoryConfig();
    expected.setEnabled(true).setAllocatorType(MemoryAllocatorType.STANDARD).setMetadataSpacePercentage(70).setMinBlockSize(randomInt()).setPageSize(randomInt()).setSize(new MemorySize(randomInt(), MemoryUnit.BYTES)).getPersistentMemoryConfig().setEnabled(true).addDirectoryConfig(new PersistentMemoryDirectoryConfig("/mnt/pmem0", 0)).addDirectoryConfig(new PersistentMemoryDirectoryConfig("/mnt/pmem1", 1));
    clientConfig.setNativeMemoryConfig(expected);
    NativeMemoryConfig actual = newConfigViaGenerator().getNativeMemoryConfig();
    assertEquals(clientConfig.getNativeMemoryConfig(), actual);
}
Also used : NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) MemorySize(com.hazelcast.memory.MemorySize) PersistentMemoryDirectoryConfig(com.hazelcast.config.PersistentMemoryDirectoryConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with MemorySize

use of com.hazelcast.memory.MemorySize in project hazelcast by hazelcast.

the class ClientConfigXmlGeneratorTest method nativeMemory.

@Test
public void nativeMemory() {
    NativeMemoryConfig expected = new NativeMemoryConfig();
    expected.setEnabled(true).setAllocatorType(MemoryAllocatorType.STANDARD).setMetadataSpacePercentage(70).setMinBlockSize(randomInt()).setPageSize(randomInt()).setSize(new MemorySize(randomInt(), MemoryUnit.BYTES));
    clientConfig.setNativeMemoryConfig(expected);
    NativeMemoryConfig actual = newConfigViaGenerator().getNativeMemoryConfig();
    assertEquals(clientConfig.getNativeMemoryConfig(), actual);
}
Also used : NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) MemorySize(com.hazelcast.memory.MemorySize) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with MemorySize

use of com.hazelcast.memory.MemorySize in project hazelcast by hazelcast.

the class ClientConfigXmlGeneratorTest method nativeMemoryWithPersistentMemory_SystemMemoryMode.

@Test
public void nativeMemoryWithPersistentMemory_SystemMemoryMode() {
    NativeMemoryConfig expected = new NativeMemoryConfig();
    expected.setEnabled(true).setAllocatorType(MemoryAllocatorType.STANDARD).setMetadataSpacePercentage(70).setMinBlockSize(randomInt()).setPageSize(randomInt()).setSize(new MemorySize(randomInt(), MemoryUnit.BYTES)).getPersistentMemoryConfig().setMode(PersistentMemoryMode.SYSTEM_MEMORY);
    clientConfig.setNativeMemoryConfig(expected);
    NativeMemoryConfig actual = newConfigViaGenerator().getNativeMemoryConfig();
    assertEquals(clientConfig.getNativeMemoryConfig(), actual);
}
Also used : NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) MemorySize(com.hazelcast.memory.MemorySize) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with MemorySize

use of com.hazelcast.memory.MemorySize in project hazelcast by hazelcast.

the class AbstractXmlConfigHelper method fillNativeMemoryConfig.

@SuppressFBWarnings("DM_BOXED_PRIMITIVE_FOR_PARSING")
protected void fillNativeMemoryConfig(Node node, NativeMemoryConfig nativeMemoryConfig) {
    final NamedNodeMap atts = node.getAttributes();
    final Node enabledNode = atts.getNamedItem("enabled");
    final boolean enabled = enabledNode != null && getBooleanValue(getTextContent(enabledNode).trim());
    nativeMemoryConfig.setEnabled(enabled);
    final Node allocTypeNode = atts.getNamedItem("allocator-type");
    final String allocType = getTextContent(allocTypeNode);
    if (allocType != null && !"".equals(allocType)) {
        nativeMemoryConfig.setAllocatorType(NativeMemoryConfig.MemoryAllocatorType.valueOf(upperCaseInternal(allocType)));
    }
    for (Node n : childElements(node)) {
        final String nodeName = cleanNodeName(n);
        if ("size".equals(nodeName)) {
            final NamedNodeMap attrs = n.getAttributes();
            final String value = getTextContent(attrs.getNamedItem("value"));
            final MemoryUnit unit = MemoryUnit.valueOf(getTextContent(attrs.getNamedItem("unit")));
            MemorySize memorySize = new MemorySize(Long.valueOf(value), unit);
            nativeMemoryConfig.setSize(memorySize);
        } else if ("min-block-size".equals(nodeName)) {
            String value = getTextContent(n);
            nativeMemoryConfig.setMinBlockSize(Integer.parseInt(value));
        } else if ("page-size".equals(nodeName)) {
            String value = getTextContent(n);
            nativeMemoryConfig.setPageSize(Integer.parseInt(value));
        } else if ("metadata-space-percentage".equals(nodeName)) {
            String value = getTextContent(n);
            try {
                Number percentage = new DecimalFormat("##.#").parse(value);
                nativeMemoryConfig.setMetadataSpacePercentage(percentage.floatValue());
            } catch (ParseException e) {
                LOGGER.info("Metadata space percentage, [" + value + "], is not a proper value. Default value will be used!");
            }
        }
    }
}
Also used : MemoryUnit(com.hazelcast.memory.MemoryUnit) MemorySize(com.hazelcast.memory.MemorySize) NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) DecimalFormat(java.text.DecimalFormat) ParseException(java.text.ParseException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

MemorySize (com.hazelcast.memory.MemorySize)12 QuickTest (com.hazelcast.test.annotation.QuickTest)10 Test (org.junit.Test)10 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)9 CPSubsystemConfig (com.hazelcast.config.cp.CPSubsystemConfig)5 FencedLockConfig (com.hazelcast.config.cp.FencedLockConfig)5 SemaphoreConfig (com.hazelcast.config.cp.SemaphoreConfig)5 KerberosAuthenticationConfig (com.hazelcast.config.security.KerberosAuthenticationConfig)5 KerberosIdentityConfig (com.hazelcast.config.security.KerberosIdentityConfig)5 LdapAuthenticationConfig (com.hazelcast.config.security.LdapAuthenticationConfig)5 RealmConfig (com.hazelcast.config.security.RealmConfig)5 SimpleAuthenticationConfig (com.hazelcast.config.security.SimpleAuthenticationConfig)5 NativeMemoryConfig (com.hazelcast.config.NativeMemoryConfig)4 TokenIdentityConfig (com.hazelcast.config.security.TokenIdentityConfig)4 JetConfig (com.hazelcast.jet.config.JetConfig)4 JaasAuthenticationConfig (com.hazelcast.config.security.JaasAuthenticationConfig)3 TlsAuthenticationConfig (com.hazelcast.config.security.TlsAuthenticationConfig)3 File (java.io.File)3 RaftAlgorithmConfig (com.hazelcast.config.cp.RaftAlgorithmConfig)2 MemoryUnit (com.hazelcast.memory.MemoryUnit)2