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

com.aoindustries.aoserv.client.MasterServerStat Maven / Gradle / Ivy

There is a newer version: 1.92.0
Show newest version
/*
 * aoserv-client - Java client for the AOServ platform.
 * Copyright (C) 2001-2013, 2015, 2016  AO Industries, Inc.
 *     [email protected]
 *     7262 Bull Pen Cir
 *     Mobile, AL 36695
 *
 * This file is part of aoserv-client.
 *
 * aoserv-client is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * aoserv-client is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with aoserv-client.  If not, see .
 */
package com.aoindustries.aoserv.client;

import com.aoindustries.io.CompressedDataInputStream;
import com.aoindustries.io.CompressedDataOutputStream;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * To aid in system reliability, scalability, and debugging, many server
 * runtime statistics are maintained.  MasterServerStat
 * provides table-like access to this data.
 *
 * @author  AO Industries, Inc.
 */
final public class MasterServerStat extends AOServObject implements SingleTableObject {

	public static final String
		BYTE_ARRAY_CACHE_CREATES="byte_array_cache_creates",
		BYTE_ARRAY_CACHE_USES="byte_array_cache_uses",
		CHAR_ARRAY_CACHE_CREATES="char_array_cache_creates",
		CHAR_ARRAY_CACHE_USES="char_array_cache_uses",
		DAEMON_CONCURRENCY="daemon_concurrency",
		DAEMON_CONNECTIONS="daemon_connections",
		DAEMON_CONNECTS="daemon_connects",
		DAEMON_COUNT="daemon_count",
		DAEMON_DOWN_COUNT="daemon_down_count",
		DAEMON_MAX_CONCURRENCY="daemon_max_concurrency",
		DAEMON_POOL_SIZE="daemon_pool_size",
		DAEMON_TOTAL_TIME="daemon_total_time",
		DAEMON_TRANSACTIONS="daemon_transactions",
		DB_CONCURRENCY="db_concurrency",
		DB_CONNECTIONS="db_connections",
		DB_CONNECTS="db_connects",
		DB_MAX_CONCURRENCY="db_max_concurrency",
		DB_POOL_SIZE="db_pool_size",
		DB_TOTAL_TIME="db_total_time",
		DB_TRANSACTIONS="db_transactions",
		ENTROPY_AVAIL="entropy_avail",
		ENTROPY_POOLSIZE="entropy_poolsize",
		ENTROPY_READ_BYTES="entropy_read_bytes",
		ENTROPY_READ_COUNT="entropy_read_count",
		ENTROPY_WRITE_BYTES="entropy_write_bytes",
		ENTROPY_WRITE_COUNT="entropy_write_count",
		MEMORY_FREE="memory_free",
		MEMORY_TOTAL="memory_total",
		PROTOCOL_VERSION="protocol_version",
		REQUEST_CONCURRENCY="request_concurrency",
		REQUEST_CONNECTIONS="request_connections",
		REQUEST_MAX_CONCURRENCY="request_max_concurrency",
		REQUEST_TOTAL_TIME="request_total_time",
		REQUEST_TRANSACTIONS="request_transactions",
		THREAD_COUNT="thread_count",
		UPTIME="uptime"
	;

	String name;
	private String value;
	private String description;
	protected AOServTable table;

	public MasterServerStat() {
	}

	public MasterServerStat(String name, String value, String description) {
		this.name=name;
		this.value=value;
		this.description=description;
	}

	@Override
	Object getColumnImpl(int i) {
		if(i==0) return name;
		if(i==1) return value;
		if(i==2) return description;
		throw new IllegalArgumentException("Invalid index: "+i);
	}

	public String getDescription() {
		return description;
	}

	public String getName() {
		return name;
	}

	@Override
	public String getKey() {
		return name;
	}

	/**
	 * Gets the AOServTable that contains this AOServObject.
	 *
	 * @return  the AOServTable.
	 */
	@Override
	public AOServTable getTable() {
		return table;
	}

	@Override
	public SchemaTable.TableID getTableID() {
		return SchemaTable.TableID.MASTER_SERVER_STATS;
	}

	public String getValue() {
		return value;
	}

	@Override
	public void init(ResultSet result) throws SQLException {
		throw new SQLException("Should not be read from the database, should be generated.");
	}

	@Override
	public void read(CompressedDataInputStream in) throws IOException {
		name=in.readUTF().intern();
		value=in.readNullUTF();
		description=in.readUTF();
	}

	@Override
	public void setTable(AOServTable table) {
		if(this.table!=null) throw new IllegalStateException("table already set");
		this.table=table;
	}

	@Override
	public void write(CompressedDataOutputStream out, AOServProtocol.Version version) throws IOException {
		out.writeUTF(name);
		out.writeNullUTF(value);
		out.writeUTF(description);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy