Search in sources :

Example 1 with NativeMemoryConfig

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

the class TestFullApplicationContext method testNativeMemoryConfig.

@Test
public void testNativeMemoryConfig() {
    NativeMemoryConfig nativeMemoryConfig = config.getNativeMemoryConfig();
    assertFalse(nativeMemoryConfig.isEnabled());
    assertEquals(MemoryUnit.MEGABYTES, nativeMemoryConfig.getSize().getUnit());
    assertEquals(256, nativeMemoryConfig.getSize().getValue());
    assertEquals(20, nativeMemoryConfig.getPageSize());
    assertEquals(NativeMemoryConfig.MemoryAllocatorType.POOLED, nativeMemoryConfig.getAllocatorType());
    assertEquals(10.2, nativeMemoryConfig.getMetadataSpacePercentage(), 0.1);
    assertEquals(10, nativeMemoryConfig.getMinBlockSize());
}
Also used : NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 2 with NativeMemoryConfig

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

the class PhoneHome method phoneHome.

public Map<String, String> phoneHome(Node hazelcastNode, String version, boolean isEnterprise) {
    String downloadId = "source";
    InputStream is = null;
    try {
        is = getClass().getClassLoader().getResourceAsStream("hazelcast-download.properties");
        if (is != null) {
            final Properties properties = new Properties();
            properties.load(is);
            downloadId = properties.getProperty("hazelcastDownloadId");
        }
    } catch (IOException ignored) {
        EmptyStatement.ignore(ignored);
    } finally {
        IOUtil.closeResource(is);
    }
    //Calculate native memory usage from native memory config
    NativeMemoryConfig memoryConfig = hazelcastNode.getConfig().getNativeMemoryConfig();
    final ClusterServiceImpl clusterService = hazelcastNode.getClusterService();
    long totalNativeMemorySize = clusterService.getSize(DATA_MEMBER_SELECTOR) * memoryConfig.getSize().bytes();
    String nativeMemoryParameter = (isEnterprise) ? Long.toString(MemoryUnit.BYTES.toGigaBytes(totalNativeMemorySize)) : "0";
    //Calculate connected clients to the cluster.
    Map<ClientType, Integer> clusterClientStats = hazelcastNode.clientEngine.getConnectedClientStats();
    RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
    OperatingSystemMXBean osMxBean = ManagementFactory.getOperatingSystemMXBean();
    Long clusterUpTime = clusterService.getClusterClock().getClusterUpTime();
    PhoneHomeParameterCreator parameterCreator = new PhoneHomeParameterCreator();
    parameterCreator.addParam("version", version);
    parameterCreator.addParam("m", hazelcastNode.getThisUuid());
    parameterCreator.addParam("e", Boolean.toString(isEnterprise));
    parameterCreator.addParam("l", MD5Util.toMD5String(hazelcastNode.getConfig().getLicenseKey()));
    parameterCreator.addParam("p", downloadId);
    parameterCreator.addParam("c", clusterService.getClusterId());
    parameterCreator.addParam("crsz", convertToLetter(clusterService.getMembers().size()));
    parameterCreator.addParam("cssz", convertToLetter(hazelcastNode.clientEngine.getClientEndpointCount()));
    parameterCreator.addParam("hdgb", nativeMemoryParameter);
    parameterCreator.addParam("ccpp", Integer.toString(clusterClientStats.get(ClientType.CPP)));
    parameterCreator.addParam("cdn", Integer.toString(clusterClientStats.get(ClientType.CSHARP)));
    parameterCreator.addParam("cjv", Integer.toString(clusterClientStats.get(ClientType.JAVA)));
    parameterCreator.addParam("cnjs", Integer.toString(clusterClientStats.get(ClientType.NODEJS)));
    parameterCreator.addParam("cpy", Integer.toString(clusterClientStats.get(ClientType.PYTHON)));
    parameterCreator.addParam("cuptm", Long.toString(clusterUpTime));
    parameterCreator.addParam("nuptm", Long.toString(runtimeMxBean.getUptime()));
    parameterCreator.addParam("jvmn", runtimeMxBean.getVmName());
    parameterCreator.addParam("jvmv", System.getProperty("java.version"));
    JetBuildInfo jetBuildInfo = hazelcastNode.getBuildInfo().getJetBuildInfo();
    parameterCreator.addParam("jetv", jetBuildInfo == null ? "" : jetBuildInfo.getVersion());
    try {
        parameterCreator.addParam("osn", osMxBean.getName());
        parameterCreator.addParam("osa", osMxBean.getArch());
        parameterCreator.addParam("osv", osMxBean.getVersion());
    } catch (SecurityException e) {
        parameterCreator.addParam("osn", "N/A");
        parameterCreator.addParam("osa", "N/A");
        parameterCreator.addParam("osv", "N/A");
    }
    String urlStr = BASE_PHONE_HOME_URL + parameterCreator.build();
    fetchWebService(urlStr);
    return parameterCreator.getParameters();
}
Also used : ClientType(com.hazelcast.core.ClientType) JetBuildInfo(com.hazelcast.instance.JetBuildInfo) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) IOException(java.io.IOException) RuntimeMXBean(java.lang.management.RuntimeMXBean) Properties(java.util.Properties) NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) OperatingSystemMXBean(java.lang.management.OperatingSystemMXBean)

Example 3 with NativeMemoryConfig

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

the class DefaultRecordStore method clearPartition.

@Override
public void clearPartition(boolean onShutdown) {
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService != null) {
        final DefaultObjectNamespace namespace = new DefaultObjectNamespace(MapService.SERVICE_NAME, name);
        lockService.clearLockStore(partitionId, namespace);
    }
    Indexes indexes = mapContainer.getIndexes();
    if (indexes.hasIndex()) {
        for (Record record : storage.values()) {
            Data key = record.getKey();
            Object value = Records.getValueOrCachedValue(record, serializationService);
            indexes.removeEntryIndex(key, value);
        }
    }
    mapDataStore.reset();
    if (onShutdown) {
        NativeMemoryConfig nativeMemoryConfig = nodeEngine.getConfig().getNativeMemoryConfig();
        boolean shouldClear = (nativeMemoryConfig != null && nativeMemoryConfig.getAllocatorType() != POOLED);
        if (shouldClear) {
            storage.clear(true);
        }
        storage.destroy(true);
    } else {
        storage.clear(false);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) DefaultObjectNamespace(com.hazelcast.spi.DefaultObjectNamespace) LockService(com.hazelcast.concurrent.lock.LockService) Record(com.hazelcast.map.impl.record.Record) EntryEventData(com.hazelcast.map.impl.event.EntryEventData) Data(com.hazelcast.nio.serialization.Data) Indexes(com.hazelcast.query.impl.Indexes)

Aggregations

NativeMemoryConfig (com.hazelcast.config.NativeMemoryConfig)3 LockService (com.hazelcast.concurrent.lock.LockService)1 ClientType (com.hazelcast.core.ClientType)1 JetBuildInfo (com.hazelcast.instance.JetBuildInfo)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)1 Record (com.hazelcast.map.impl.record.Record)1 Data (com.hazelcast.nio.serialization.Data)1 Indexes (com.hazelcast.query.impl.Indexes)1 DefaultObjectNamespace (com.hazelcast.spi.DefaultObjectNamespace)1 NodeEngine (com.hazelcast.spi.NodeEngine)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 BufferedInputStream (java.io.BufferedInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)1 RuntimeMXBean (java.lang.management.RuntimeMXBean)1 Properties (java.util.Properties)1 Test (org.junit.Test)1