All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scouter.server.core.ServerStat Maven / Gradle / Ivy

There is a newer version: 2.20.0
Show newest version
package scouter.server.core;

import scouter.util.SortUtil;
import scouter.util.StringKeyLinkedMap;
import scouter.util.StringUtil;

public class ServerStat {
	private static StringKeyLinkedMap stat = new StringKeyLinkedMap().setMax(1000);

	public static void put(String id, int value) {
		stat.put(id, value);
	}

	public static void put(String id, float value) {
		stat.put(id, value);
	}

	public static void put(String id, long value) {
		stat.put(id, value);
	}

	public static String toString(String key, String prefix) {
		if(prefix==null)
			prefix="";
		boolean emptyKey = StringUtil.isEmpty(key);
		StringBuffer sb = new StringBuffer();
		String[] keys = SortUtil.sort(stat.keyArray());
		for (int i = 0; i < keys.length; i++) {
			if (emptyKey || keys[i].indexOf(key) >= 0) {
				sb.append(prefix).append(keys[i]).append("=").append(stat.get(keys[i])).append("\n");
			}
		}
		return sb.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy