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

com.github.ltsopensource.monitor.access.mysql.MysqlJVMGCAccess Maven / Gradle / Ivy

There is a newer version: 1.7.0
Show newest version
package com.github.ltsopensource.monitor.access.mysql;

import com.github.ltsopensource.core.cluster.Config;
import com.github.ltsopensource.core.commons.utils.CollectionUtils;
import com.github.ltsopensource.monitor.access.domain.JVMGCDataPo;
import com.github.ltsopensource.monitor.access.face.JVMGCAccess;
import com.github.ltsopensource.store.jdbc.builder.InsertSql;

import java.util.List;

/**
 * @author Robert HG ([email protected]) on 3/10/16.
 */
public class MysqlJVMGCAccess extends MysqlAbstractJdbcAccess implements JVMGCAccess {

    public MysqlJVMGCAccess(Config config) {
        super(config);
    }

    @Override
    public void insert(List jvmGCDataPos) {
        if (CollectionUtils.isEmpty(jvmGCDataPos)) {
            return;
        }

        InsertSql insertSql = new InsertSql(getSqlTemplate())
                .insert(getTableName())
                .columns("gmt_created",
                        "identity",
                        "timestamp",
                        "node_type",
                        "node_group",
                        "young_gc_collection_count",
                        "young_gc_collection_time",
                        "full_gc_collection_count",
                        "full_gc_collection_time",
                        "span_young_gc_collection_count",
                        "span_young_gc_collection_time",
                        "span_full_gc_collection_count",
                        "span_full_gc_collection_time");

        for (JVMGCDataPo po : jvmGCDataPos) {
            insertSql.values(
                    po.getGmtCreated(),
                    po.getIdentity(),
                    po.getTimestamp(),
                    po.getNodeType().name(),
                    po.getNodeGroup(),
                    po.getYoungGCCollectionCount(),
                    po.getYoungGCCollectionTime(),
                    po.getFullGCCollectionCount(),
                    po.getFullGCCollectionTime(),
                    po.getSpanYoungGCCollectionCount(),
                    po.getSpanYoungGCCollectionTime(),
                    po.getSpanFullGCCollectionCount(),
                    po.getSpanFullGCCollectionTime()
            );
        }

        insertSql.doBatchInsert();

    }

    @Override
    protected String getTableName() {
        return "lts_admin_jvm_gc";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy