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

com.aliyun.openservices.ons.api.exactlyonce.manager.util.MetricsUtil Maven / Gradle / Ivy

There is a newer version: 1.9.4.Final
Show newest version
package com.aliyun.openservices.ons.api.exactlyonce.manager.util;

import com.aliyun.openservices.ons.api.exactlyonce.aop.model.MQTxContext;

/**
 * @author gongshi
 */
public class MetricsUtil {

    public static void recordStart(MQTxContext context) {
        if (context != null) {
            context.setStartTimestamp(System.currentTimeMillis());
        }
    }

    public static void recordProcessTimeStamp(MQTxContext context) {
        if (context != null) {
            context.setProcessTimestamp(System.currentTimeMillis());
        }
    }

    public static void recordPersistenceTimestamp(MQTxContext context) {
        if (context != null) {
            context.setPersistenceTimestamp(System.currentTimeMillis());
        }
    }

    public static void recordAfterPersistenceTimestamp(MQTxContext context) {
        if (context != null) {
            context.setAftePersistenceTimestamp(System.currentTimeMillis());
        }
    }

    public static void recordFinishConsumeTimestamp(MQTxContext context) {
        if (context != null) {
            context.setFinishTimestamp(System.currentTimeMillis());
        }
    }

    public static long getProcessTime(MQTxContext context) {
        return context == null ? 0 : context.getPersistenceTimestamp() - context.getProcessTimestamp();
    }

    public static long getPersistenceTime(MQTxContext context) {
        return context == null ? 0 : context.getAftePersistenceTimestamp() - context.getPersistenceTimestamp();
    }

    public static long getConsumeTime(MQTxContext context) {
        return context == null ? 0 : context.getFinishTimestamp() - context.getStartTimestamp();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy