Example usage for java.lang.management MemoryUsage getMax

List of usage examples for java.lang.management MemoryUsage getMax

Introduction

In this page you can find the example usage for java.lang.management MemoryUsage getMax.

Prototype

public long getMax() 

Source Link

Document

Returns the maximum amount of memory in bytes that can be used for memory management.

Usage

From source file:org.wso2.carbon.cassandra.cluster.mgt.query.ClusterMBeanServiceHandler.java

public NodeInformation getNodeInfo() throws ClusterDataAdminException {
    clusterStorageMBeanService = ClusterMBeanProxy.getClusterStorageMBeanService();
    clusterEndpointSnitchMBeanService = ClusterMBeanProxy.getClusterEndpointSnitchMBeanService();
    clusterCacheMBeanService = ClusterMBeanProxy.getClusterCacheMBeanService();
    clusterRuntimeMXBeanService = ClusterMBeanProxy.getRuntimeMXBeanService();
    clusterMemoryMXBeanService = ClusterMBeanProxy.getClusterMemoryMXBeanService();
    NodeInformation nodeInformation = new NodeInformation();
    boolean gossipInitialized = clusterStorageMBeanService.isInitialized();
    nodeInformation.setToken(clusterStorageMBeanService.getToken());
    nodeInformation.setGossipState(gossipInitialized);
    nodeInformation.setThriftState(clusterStorageMBeanService.getRPCServerStatus());
    nodeInformation.setLoad(clusterStorageMBeanService.getLoadString());
    if (gossipInitialized)
        nodeInformation.setGenerationNo(clusterStorageMBeanService.getCurrentGenerationNumber());
    else//from   w w  w. j a  v  a  2s  .c o  m
        nodeInformation.setGenerationNo(0);

    // Uptime
    long secondsUp = clusterRuntimeMXBeanService.getUptime() / 1000;
    nodeInformation.setUptime(secondsUp);

    // Memory usage
    MemoryUsage heapUsage = clusterMemoryMXBeanService.getHeapMemoryUsage();
    HeapMemory heapMemory = new HeapMemory();
    double memUsed = (double) heapUsage.getUsed() / (1024 * 1024);
    double memMax = (double) heapUsage.getMax() / (1024 * 1024);
    heapMemory.setMaxMemory(memMax);
    heapMemory.setUseMemory(memUsed);
    nodeInformation.setHeapMemory(heapMemory);

    // Data Center/Rack
    try {
        nodeInformation.setDataCenter(
                clusterEndpointSnitchMBeanService.getDataCenter(clusterStorageMBeanService.getEndpoint()));
        nodeInformation
                .setRack(clusterEndpointSnitchMBeanService.getRack(clusterStorageMBeanService.getEndpoint()));
    } catch (UnknownHostException e) {
        throw new ClusterDataAdminException("Host is unknown when retrieving node info", e, log);
    }
    // Exceptions
    nodeInformation.setExceptions(clusterStorageMBeanService.getExceptionCount());
    CacheProperties keyCacheProperties = new CacheProperties();
    CacheProperties rowCacheProperties = new CacheProperties();

    // Key Cache: Hits, Requests, RecentHitRate, SavePeriodInSeconds
    keyCacheProperties.setCacheSize(clusterCacheMBeanService.getKeyCacheSize());
    keyCacheProperties.setCacheCapacity(clusterCacheMBeanService.getKeyCacheCapacityInBytes());
    keyCacheProperties.setCacheHits(clusterCacheMBeanService.getKeyCacheHits());
    keyCacheProperties.setCacheRequests(clusterCacheMBeanService.getKeyCacheRequests());
    keyCacheProperties.setCacheRecentHitRate(clusterCacheMBeanService.getKeyCacheRecentHitRate());
    keyCacheProperties.setCacheSavePeriodInSeconds(clusterCacheMBeanService.getKeyCacheSavePeriodInSeconds());

    // Row Cache: Hits, Requests, RecentHitRate, SavePeriodInSeconds

    rowCacheProperties.setCacheSize(clusterCacheMBeanService.getRowCacheSize());
    rowCacheProperties.setCacheCapacity(clusterCacheMBeanService.getRowCacheCapacityInBytes());
    rowCacheProperties.setCacheHits(clusterCacheMBeanService.getRowCacheHits());
    rowCacheProperties.setCacheRequests(clusterCacheMBeanService.getRowCacheRequests());
    rowCacheProperties.setCacheRecentHitRate(clusterCacheMBeanService.getRowCacheRecentHitRate());
    rowCacheProperties.setCacheSavePeriodInSeconds(clusterCacheMBeanService.getRowCacheSavePeriodInSeconds());
    nodeInformation.setRowCacheProperties(rowCacheProperties);
    nodeInformation.setKeyCacheProperties(keyCacheProperties);
    return nodeInformation;
}

From source file:com.bigdata.dastor.tools.DastorAdminCli.java

/**
 * Write node information./*from  w  w w . j a va 2 s  .  c  o  m*/
 * 
 * @param outs the stream to write to
 */
public void printInfo(PrintStream outs) {
    outs.println(String.format("%-17s: %s", "Who", host + ":" + port));
    outs.println(String.format("%-17s: %s", "Status", probe.getOperationMode()));
    outs.println(String.format("%-17s: %s", "PositionCode", probe.getToken()));
    outs.println(String.format("%-17s: %s", "Generation", probe.getCurrentGenerationNumber()));

    // Uptime
    long secondsUp = probe.getUptime() / 1000;
    outs.println(String.format("%-17s: %d", "Uptime (seconds)", secondsUp));

    // Memory usage
    MemoryUsage heapUsage = probe.getHeapMemoryUsage();
    double memUsed = (double) heapUsage.getUsed() / (1024 * 1024);
    double memMax = (double) heapUsage.getMax() / (1024 * 1024);
    outs.println(String.format("%-17s: %.2f / %.2f", "Heap Memory (MB)", memUsed, memMax));

    // Disk space
    outs.println(String.format("%-17s: %s / %s", "Load", probe.getLoadString(),
            probe.getStorageServiceMBean().getGrossLoadString()));
    Map<String, DiskSpaceLoad> loadMap = probe.getStorageServiceMBean().getTablesDiskSpaceLoad();
    for (Entry<String, DiskSpaceLoad> entry : loadMap.entrySet()) {
        outs.println(String.format("%-17s : %s / %s", "Load of " + entry.getKey(),
                FileUtils.stringifyFileSize(entry.getValue().net),
                FileUtils.stringifyFileSize(entry.getValue().gross)));
    }
}

From source file:com.knowbout.cc2nlp.server.CCEventServiceImpl.java

private void checkStats() {
    long timestamp = new Date().getTime();
    String day = getFileDate(timestamp);
    if (!day.equals(currentDay)) {
        if (statsFile != null) {
            statsFile.println("</table></body></html>");
            statsFile.close();//from  ww w  .  j  av  a  2  s.c  o  m
            statsFile = null;
        }
        currentDay = day;
    }
    if (hostname == null) {
        try {
            hostname = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            hostname = "UnknownHost";
        }
    }
    String dirname = documentRoot + "/stats/" + currentDay + "/" + hostname;
    String statsFileName = dirname + "/nlpprocstats.html";
    int interval = 5; // minutes
    try {
        if (statsFile == null) {
            File dir = new File(dirname);
            if ((!dir.exists()) && (!dir.mkdirs())) {
                throw new IOException("Error creating directory " + dirname);
            }
            File file = new File(statsFileName);
            if (file.exists()) {
                statsFile = new PrintStream(new FileOutputStream(statsFileName, true));
                statsFile.println("<tr><td colspan='5'>Restart</td></tr>");
            } else {
                statsFile = new PrintStream(new FileOutputStream(statsFileName));
                String title = "NLP Process (tomcat) status for " + currentDay;
                statsFile.println("<html><head><title>" + title + "</title></head>");
                statsFile.println("<body><h1>" + title + "</h1>");
                statsFile.println("<table border='1'>");
                statsFile.println("<tr>");
                statsFile.println(
                        "<th colspan='2'>" + interval + " Minute Intervals</th><th colspan='3'>Memory</th>");
                statsFile.println("</tr>");
                statsFile.println("<tr>");
                statsFile.println("<th>Timestamp</th>");
                statsFile.println("<th>Time</th>");
                statsFile.println("<th>Used</th>");
                statsFile.println("<th>Committed</th>");
                statsFile.println("<th>Max<th>");
                statsFile.println("</tr>");
            }
        }
        if ((timestamp - lastWrite) > (interval * 60 * 1000)) {
            lastWrite = timestamp;
            Calendar cal = Calendar.getInstance();
            cal.setTimeZone(TimeZone.getTimeZone("GMT"));
            cal.setTimeInMillis(timestamp);
            String time = String.format("%1$tH:%1$tM:%1$tS", cal);
            MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
            MemoryUsage memory = memoryBean.getHeapMemoryUsage();
            statsFile.print("<tr>");
            statsFile.print("<td>" + timestamp + "</td>");
            statsFile.print("<td>" + time + "</td>");
            statsFile.format("<td>%,d</td>", memory.getUsed());
            statsFile.format("<td>%,d</td>", memory.getCommitted());
            statsFile.format("<td>%,d</td>", memory.getMax());
            statsFile.println("</tr>");
        }
    } catch (IOException e) {
        log.error("Error opening or writing to " + statsFileName, e);
    }
}

From source file:net.centro.rtb.monitoringcenter.metrics.system.jvm.JvmMemoryUsageMetricSet.java

JvmMemoryUsageMetricSet(final MemoryUsageProvider memoryUsageProvider) {
    Preconditions.checkNotNull(memoryUsageProvider);

    final MemoryUsage memoryUsage = memoryUsageProvider.get();
    Preconditions.checkNotNull(memoryUsage);

    Map<String, Metric> metricsByNames = new HashMap<>();

    if (memoryUsage.getInit() >= 0) {
        this.initialSizeInBytesGauge = new Gauge<Long>() {
            @Override//  w  w w.  j a  v  a2  s  .  c o m
            public Long getValue() {
                return memoryUsageProvider.get().getInit();
            }
        };
        metricsByNames.put("initialInBytes", initialSizeInBytesGauge);
    }

    this.usedMemoryInBytesGauge = new Gauge<Long>() {
        @Override
        public Long getValue() {
            return memoryUsageProvider.get().getUsed();
        }
    };
    metricsByNames.put("usedInBytes", usedMemoryInBytesGauge);

    if (memoryUsage.getMax() >= 0) {
        this.maxAvailableMemoryInBytesGauge = new Gauge<Long>() {
            @Override
            public Long getValue() {
                return memoryUsageProvider.get().getMax();
            }
        };
        metricsByNames.put("maxAvailableInBytes", maxAvailableMemoryInBytesGauge);
    }

    this.committedMemoryInBytesGauge = new Gauge<Long>() {
        @Override
        public Long getValue() {
            return memoryUsageProvider.get().getCommitted();
        }
    };
    metricsByNames.put("committedInBytes", committedMemoryInBytesGauge);

    this.usedMemoryPercentageGauge = new Gauge<Double>() {
        @Override
        public Double getValue() {
            MemoryUsage memoryUsage = memoryUsageProvider.get();
            long max = memoryUsage.getMax() > 0 ? memoryUsage.getMax() : memoryUsage.getCommitted();
            return Double.valueOf(memoryUsage.getUsed()) / max * 100;
        }
    };
    metricsByNames.put("usedPercentage", usedMemoryPercentageGauge);

    this.metricsByNames = metricsByNames;
}

From source file:org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL.java

private int calculateMaxLogFiles(float memstoreSizeRatio, long logRollSize) {
    MemoryUsage mu = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    return Math.round(mu.getMax() * memstoreSizeRatio * 2 / logRollSize);
}

From source file:com.adeptj.runtime.servlet.ToolsServlet.java

/**
 * Renders tools page./*from   ww  w . ja  v  a 2s .  c  o  m*/
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
    Bundle[] bundles = BundleContextHolder.getInstance().getBundleContext().getBundles();
    long startTime = ManagementFactory.getRuntimeMXBean().getStartTime();
    MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    TemplateEngine.getInstance()
            .render(TemplateContext.builder().request(req).response(resp).template(TOOLS_TEMPLATE)
                    .locale(req.getLocale())
                    .templateData(TemplateData.newTemplateData().put("username", req.getRemoteUser())
                            .put("sysProps", System.getProperties().entrySet())
                            .put("totalBundles", bundles.length).put("bundles", bundles)
                            .put("runtime", JAVA_RUNTIME_NAME + "(build " + JAVA_RUNTIME_VERSION + ")")
                            .put("jvm", JAVA_VM_NAME + "(build " + JAVA_VM_VERSION + ", " + JAVA_VM_INFO + ")")
                            .put("startTime", Date.from(Instant.ofEpochMilli(startTime)))
                            .put("upTime", Times.format(startTime))
                            .put("maxMemory", FileUtils.byteCountToDisplaySize(memoryUsage.getMax()))
                            .put("usedMemory", FileUtils.byteCountToDisplaySize(memoryUsage.getUsed()))
                            .put("processors", Runtime.getRuntime().availableProcessors()))
                    .build());
}

From source file:com.chinamobile.bcbsp.graph.GraphDataForDisk.java

/**
 * Initialize the graph data disk manager with job and partitionID. Get the
 * parameter of graph on disk./*from   ww w .ja  v  a 2s . co m*/
 * @param job
 * @param partitionID
 */
public void initialize(BSPJob job, int partitionID) {
    vertexClass = job.getVertexClass();
    edgeClass = job.getEdgeClass();
    LOG.info("========== Initializing Graph Data For Disk ==========");
    this.dataPercent = job.getMemoryDataPercent(); // Default 0.8
    this.jobID = job.getJobID();
    this.partitionID = partitionID;
    this.beta = job.getBeta();
    this.hashBucketNumber = job.getHashBucketNumber();
    LOG.info("[beta] = " + this.beta);
    LOG.info("[hashBucketNumber] = " + this.hashBucketNumber);
    this.hashBuckets = new ArrayList<ArrayList<Vertex>>(hashBucketNumber);
    // So the bitmaps's length decides the maximum nodes of a bucket is
    // 320*32.
    this.bitmaps = new ArrayList<ArrayList<Integer>>(hashBucketNumber);
    this.metaTable = new ArrayList<BucketMeta>(hashBucketNumber);
    // Initialize the meta table and bitmaps.
    for (int i = 0; i < hashBucketNumber; i++) {
        this.hashBuckets.add(null);
        // init the meta table.
        BucketMeta meta = new BucketMeta();
        meta.superStepCount = -1;
        meta.onDiskFlag = false;
        meta.length = 0;
        meta.lengthInMemory = 0;
        meta.count = 0;
        meta.activeCount = 0;
        metaTable.add(meta);
        // init the bitmapsCache.
        ArrayList<Integer> bitmap = new ArrayList<Integer>(Constants.GRAPH_BITMAP_BUCKET_NUM_BYTES);
        for (int j = 0; j < Constants.GRAPH_BITMAP_BUCKET_NUM_BYTES; j++) {
            bitmap.add(0);
        }
        this.bitmaps.add(bitmap);
    }
    // Initialize the size of objects and data structures.
    //int sizeOfMetaBucket = sizer.sizeOf(new BucketMeta());
    //this.sizeOfMetaTable = (sizeOfMetaBucket + sizeOfRef) * hashBucketNumber;
    int sizeOfBitmap = sizer.sizeOf(new ArrayList<Integer>());
    this.sizeOfBitmapsInMem = (sizeOfBitmap + sizeOfRef) * hashBucketNumber;
    Vertex<?, ?, ?> tmpVertex = null;
    Edge<?, ?> tmpEdge = null;
    try {
        tmpVertex = this.vertexClass.newInstance();
        tmpEdge = this.edgeClass.newInstance();
    } catch (InstantiationException e) {
        throw new RuntimeException("[GraphDataForDisk] caught:", e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException("[GraphDataForDisk] caught:", e);
    }
    this.sizeOfVertex = sizer.sizeOf(tmpVertex);
    this.sizeOfEdge = sizer.sizeOf(tmpEdge);
    LOG.info("[Default initial size of Vertex] = " + this.sizeOfVertex + "B");
    LOG.info("[Default initial size of Edge] = " + this.sizeOfEdge + "B");
    // Get the memory mxBean.
    MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
    // Get the heap memory usage.
    MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage();
    long maxHeapSize = memoryUsage.getMax();
    LOG.info("[JVM max Heap size] = " + maxHeapSize / MB_SIZE + "MB");
    this.sizeOfGraphSpace = (long) (maxHeapSize * dataPercent * beta);
    this.sizeThreshold = (sizeOfGraphSpace);
    this.sizeOfGraphDataInMem = 0;
    this.sizeForAll = 0;
    this.totalSizeOfVertex = 0;
    this.totalCountOfVertex = 0;
    this.totalSizeOfEdge = 0;
    this.totalCountOfEdge = 0;
    this.sortedBucketIndexList = new int[hashBucketNumber];
    this.fileRoot = new File("/tmp/bcbsp/" + this.jobID.toString() + "/" + "partition-" + this.partitionID);
    this.graphDataFile = new File(this.fileRoot + "/" + "GraphData");
    LOG.info("[size of Graph Data Space] = " + this.sizeOfGraphSpace / MB_SIZE + "MB");
    LOG.info("[threshold of Graph Data] = " + this.sizeThreshold / MB_SIZE + "MB");
    LOG.info("======================================================");
}

From source file:com.eurelis.opencms.admin.systeminformation.CmsMemoryOverviewDialog.java

/**
 * Initializes the infos object.<p>
 *//*from   w ww. j  a v a  2s .  co m*/
protected void initInfosObject() {

    com.sun.management.OperatingSystemMXBean sunOsBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory
            .getOperatingSystemMXBean();
    java.lang.management.OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
    java.lang.management.ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
    java.lang.management.RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
    java.lang.management.ClassLoadingMXBean classesBean = ManagementFactory.getClassLoadingMXBean();

    for (java.lang.management.MemoryPoolMXBean item : ManagementFactory.getMemoryPoolMXBeans()) {
        java.lang.management.MemoryUsage mu = item.getUsage();
        String name = item.getName();

        if (name.toLowerCase().contains("perm")) {
            setMemPermMax("" + mu.getMax());
            setMemPermTotal("" + mu.getCommitted());
            setMemPermUsed("" + mu.getUsed());
        } else if (name.toLowerCase().contains("old")) {
            setMemOldMax("" + mu.getMax());
            setMemOldTotal("" + mu.getCommitted());
            setMemOldUsed("" + mu.getUsed());
        } else if (name.toLowerCase().contains("eden")) {
            setMemEdenMax("" + mu.getMax());
            setMemEdenTotal("" + mu.getCommitted());
            setMemEdenUsed("" + mu.getUsed());
        } else if (name.toLowerCase().contains("survivor")) {
            setMemSurvivorMax("" + mu.getMax());
            setMemSurvivorTotal("" + mu.getCommitted());
            setMemSurvivorUsed("" + mu.getUsed());
        } else {
            //LOG.debug("MemoryPoolMXBean name = " + name.toLowerCase());
        }
    }

    Object o;
    if (CmsStringUtil.isEmpty(getParamAction())) {
        o = new CmsAdminSettings(getSession());
    } else {
        // this is not the initial call, get the job object from session
        o = getDialogObject();
    }
    if (!(o instanceof CmsAdminSettings)) {
        // create a new history settings handler object
        m_adminSettings = new CmsAdminSettings(getSession());
    } else {
        // reuse html import handler object stored in session
        m_adminSettings = (CmsAdminSettings) o;
    }

    setParamCloseLink(getJsp()
            .link("/system/workplace/views/admin/admin-main.jsp?path=/eurelis_system_information/memory.jsp"));
}

From source file:com.koda.integ.hbase.blockcache.OffHeapBlockCache.java

/**
 * Calculate on heap cache size./*  ww w .j a  v a 2 s .c  o  m*/
 *
 * @param conf the conf
 * @return the long
 */
private long calculateOnHeapCacheSize(Configuration conf) {
    float cachePercentage = conf.getFloat(HEAP_BLOCK_CACHE_MEMORY_RATIO, DEFAULT_HEAP_BLOCK_CACHE_MEMORY_RATIO);
    if (cachePercentage == 0L) {
        // block cache disabled on heap
        return 0L;
    }
    if (cachePercentage > 1.0) {
        throw new IllegalArgumentException(
                HEAP_BLOCK_CACHE_MEMORY_RATIO + " must be between 0.0 and 1.0, and not > 1.0");
    }

    // Calculate the amount of heap to give the heap.
    MemoryUsage mu = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    long cacheSize = (long) (mu.getMax() * cachePercentage);
    return cacheSize;
}

From source file:com.chinamobile.bcbsp.comm.MessageQueuesForDisk.java

/**
 * Constructor.//from  ww  w . ja va2s  .com
 * @param job
 * @param partitionID
 */
public MessageQueuesForDisk(BSPJob job, int partitionID) {
    LOG.info("========== Initializing Message Queues Data For Disk ==========");
    this.dataPercent = job.getMemoryDataPercent(); // Default 0.8
    this.jobID = job.getJobID();
    this.partitionID = partitionID;
    // ratio of graph data
    this.beta = job.getBeta();
    this.hashBucketNumber = job.getHashBucketNumber();
    LOG.info("[beta] = " + this.beta);
    LOG.info("[hashBucketNumber] = " + this.hashBucketNumber);
    // the structure of three kinds message queues
    this.outgoingQueues = new ConcurrentHashMap<String, ConcurrentLinkedQueue<IMessage>>();
    this.incomingQueues = new ArrayList<BucketMeta>(this.hashBucketNumber);
    this.incomedQueues = new ArrayList<BucketMeta>(this.hashBucketNumber);
    for (int i = 0; i < this.hashBucketNumber; i++) {
        BucketMeta meta = new BucketMeta();
        meta.onDiskFlag = false;
        meta.length = 0;
        meta.lengthInMemory = 0;
        meta.count = 0;
        meta.countInMemory = 0;
        meta.queueMap = new ConcurrentHashMap<String, ConcurrentLinkedQueue<IMessage>>();
        this.incomingQueues.add(meta);
        meta = new BucketMeta();
        meta.onDiskFlag = false;
        meta.length = 0;
        meta.lengthInMemory = 0;
        meta.count = 0;
        meta.countInMemory = 0;
        meta.queueMap = new ConcurrentHashMap<String, ConcurrentLinkedQueue<IMessage>>();
        this.incomedQueues.add(meta);
    }
    // Initialize the bucket file locks
    this.incomedFileLocks = new ReentrantLock[this.hashBucketNumber];
    this.incomingFileLocks = new ReentrantLock[this.hashBucketNumber];
    for (int i = 0; i < this.hashBucketNumber; i++) {
        this.incomedFileLocks[i] = new ReentrantLock();
        this.incomingFileLocks[i] = new ReentrantLock();
    }
    // Initialize the size of objects.
    BSPConfiguration conf = new BSPConfiguration();
    if (conf.getInt(Constants.BC_BSP_JVM_VERSION, 32) == 64) {
        sizer = ObjectSizer.forSun64BitsVM();
    } else {
        sizer = ObjectSizer.forSun32BitsVM();
    }
    this.sizeOfRef = sizer.sizeOfRef();
    this.sizeOfInteger = sizer.sizeOf(new Integer(0));
    this.sizeOfChar = sizer.sizeOfChar();
    this.sizeOfEmptyMessageQueue = sizer.sizeOf(new ConcurrentLinkedQueue<IMessage>());
    // Size will be evaluted later based on first m received messages.
    this.sizeOfMessage = MESSAGE_SIZE; // Default
    // Get the memory mxBean.
    MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
    // Get the heap memory usage.
    MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage();
    long maxHeapSize = memoryUsage.getMax();
    LOG.info("[JVM max Heap size] = " + maxHeapSize / MB_SIZE + "MB");
    this.sizeOfMessagesSpace = (long) (maxHeapSize * dataPercent * (1.0f - beta));
    this.sizeThreshold = (long) (sizeOfMessagesSpace);
    this.countThreshold = (long) (sizeThreshold / sizeOfMessage);
    this.countThresholdForBucket = this.countThreshold / (3 * this.hashBucketNumber);
    LOG.info("[size of Messages Space Threshold] = " + this.sizeThreshold / MB_SIZE + "MB");
    LOG.info("[count of Messages In Memory Threshold] = " + this.countThreshold / KB_SIZE + "K");
    this.sizeOfMessagesDataInMem = 0;
    this.countOfMessagesDataInMem = 0;
    this.totalSizeOfMessages = 0;
    this.totalCount = 0;
    this.sizeOfHashMapsInMem = 0;
    this.fileRoot = new File("/tmp/bcbsp/" + this.jobID.toString() + "/" + "partition-" + this.partitionID);
    this.messagesDataFile = new File(this.fileRoot + "/" + "MessagesData");
    // If the root dir does not exit, create it.
    if (!this.fileRoot.exists()) {
        this.fileRoot.mkdirs();
    }
    // If the messages data dir does not exit, create it.
    if (!this.messagesDataFile.exists()) {
        this.messagesDataFile.mkdir();
    }
    // Initialize the current accessed bucket index.
    this.currentBucket = -1;
    LOG.info("===============================================================");
}