1 /***************************************************************** 2 * Licensed to the Apache Software Foundation (ASF) under one * 3 * or more contributor license agreements. See the NOTICE file * 4 * distributed with this work for additional information * 5 * regarding copyright ownership. The ASF licenses this file * 6 * to you under the Apache License, Version 2.0 (the * 7 * "License"); you may not use this file except in compliance * 8 * with the License. You may obtain a copy of the License at * 9 * * 10 * http://www.apache.org/licenses/LICENSE-2.0 * 11 * * 12 * Unless required by applicable law or agreed to in writing, * 13 * software distributed under the License is distributed on an * 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * 15 * KIND, either express or implied. See the License for the * 16 * specific language governing permissions and limitations * 17 * under the License. * 18 ****************************************************************/ 19 20 21 package org.apache.james.postage.result; 22 23 /*** 24 * records data of fundamental resource consumption of James' JVM 25 */ 26 public class JVMResourcesRecord { 27 private static String SEPARATOR = ","; 28 29 private final long m_timestamp = System.currentTimeMillis(); 30 private String m_errorMessage = null; 31 32 private long m_memoryCommitted = -1; 33 private long m_memoryInit = -1; 34 private long m_memoryMax = -1; 35 private long m_memoryUsed = -1; 36 private long m_threadCountPeak = -1; 37 private long m_threadCountCurrent = -1; 38 private long m_threadCountTotalStarted = -1; 39 40 public String getErrorMessage() { 41 return m_errorMessage; 42 } 43 44 public void setErrorMessage(String errorMessage) { 45 m_errorMessage = errorMessage; 46 } 47 48 public long getMemoryCommitted() { 49 return m_memoryCommitted; 50 } 51 52 public void setMemoryCommitted(long memoryCommitted) { 53 this.m_memoryCommitted = memoryCommitted; 54 } 55 56 public long getMemoryInit() { 57 return m_memoryInit; 58 } 59 60 public void setMemoryInit(long memoryInit) { 61 this.m_memoryInit = memoryInit; 62 } 63 64 public long getMemoryMax() { 65 return m_memoryMax; 66 } 67 68 public void setMemoryMax(long memoryMax) { 69 this.m_memoryMax = memoryMax; 70 } 71 72 public long getMemoryUsed() { 73 return m_memoryUsed; 74 } 75 76 public void setMemoryUsed(long memoryUsed) { 77 this.m_memoryUsed = memoryUsed; 78 } 79 80 public long getThreadCountPeak() { 81 return m_threadCountPeak; 82 } 83 84 public void setThreadCountPeak(long threadCountPeak) { 85 this.m_threadCountPeak = threadCountPeak; 86 } 87 88 public long getThreadCountCurrent() { 89 return m_threadCountCurrent; 90 } 91 92 public void setThreadCountCurrent(long threadCountCurrent) { 93 this.m_threadCountCurrent = threadCountCurrent; 94 } 95 96 public long getThreadCountTotalStarted() { 97 return m_threadCountTotalStarted; 98 } 99 100 public void setThreadCountTotalStarted(long threadCountTotalStarted) { 101 this.m_threadCountTotalStarted = threadCountTotalStarted; 102 } 103 104 public static StringBuffer writeHeader() { 105 StringBuffer stringBuffer = new StringBuffer(); 106 stringBuffer.append("timestamp").append(SEPARATOR); 107 stringBuffer.append("errorMessage").append(SEPARATOR); 108 stringBuffer.append("memoryMin").append(SEPARATOR); 109 stringBuffer.append("memoryMax").append(SEPARATOR); 110 stringBuffer.append("memoryCommitted").append(SEPARATOR); 111 stringBuffer.append("memoryUsed").append(SEPARATOR); 112 stringBuffer.append("threadCountPeak").append(SEPARATOR); 113 stringBuffer.append("threadCountCurrent").append(SEPARATOR); 114 stringBuffer.append("threadCountTotalStarted").append(SEPARATOR); 115 stringBuffer.append("\r\n"); 116 117 return stringBuffer; 118 } 119 120 public StringBuffer writeData() { 121 StringBuffer stringBuffer = new StringBuffer(); 122 stringBuffer.append(m_timestamp).append(SEPARATOR); 123 stringBuffer.append(m_errorMessage).append(SEPARATOR); 124 stringBuffer.append(m_memoryInit).append(SEPARATOR); 125 stringBuffer.append(m_memoryMax).append(SEPARATOR); 126 stringBuffer.append(m_memoryCommitted).append(SEPARATOR); 127 stringBuffer.append(m_memoryUsed).append(SEPARATOR); 128 stringBuffer.append(m_threadCountPeak).append(SEPARATOR); 129 stringBuffer.append(m_threadCountCurrent).append(SEPARATOR); 130 stringBuffer.append(m_threadCountTotalStarted).append(SEPARATOR); 131 stringBuffer.append("\r\n"); 132 133 return stringBuffer; 134 } 135 136 }