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

com.datastax.insight.core.service.PersistService Maven / Gradle / Ivy

package com.datastax.insight.core.service;

import com.datastax.insight.core.entity.Cache;
import com.datastax.insight.core.handler.InsightHandler;

/**
 * Created by huangping on 17-1-19.
 */
public class PersistService {

    private static InsightHandler insightHandler;
//    private static ModelAction modelAction;
//    private static MetricsHandler metricsHandler;

    public static void setInsightHandler(InsightHandler handler) {
        insightHandler = handler;
    }

//    public static void setModelAction(ModelAction action) {
//        modelAction = action;
//    }

//    public static void setMetricsHandler(MetricsHandler handler) {
//        metricsHandler = handler;
//    }

    public static Object invoke(String className, String methodName, String[] parametersType, Object[] parameters) {

        if(insightHandler == null) {
            return null;
        }

        return insightHandler.handler(className, methodName, parametersType, parameters);
    }

//    public static Model getModel(String modelId) {
//        if(modelAction == null) {
//            return null;
//        }
//
//        int flowId = getFlowId();
//
//        return modelAction.getModel(modelId);
//    }

//    public static int saveModel(String modelName, String path) {
//        if(modelAction == null) {
//            return -1;
//        }
//
//        int flowId = getFlowId();
//
//        return modelAction.handle(flowId, modelName, path);
//    }

//    public static int saveMetrics(Metrics metrics) {
//        if(metricsHandler == null) {
//            return -1;
//        }
//
//        int flowId = getFlowId();
//
//        return metricsHandler.handle(flowId, JSON.toJSONString(metrics));
//    }

    public static Long getFlowId() {
        Object obj = Cache.getCache("flowId");
        return Long.parseLong(obj.toString());
    }

    public static long getBatchId() {
        Object obj = Cache.getCache("batchId");
        return Long.parseLong(obj.toString());
    }

    public static long getFlowVersionId() {
        Object obj = Cache.getCache("flowVersionId");
        return Long.parseLong(obj.toString());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy