// Path: common/src/main/java/com/fksm/common/util/Constants.java
// public class Constants {
//     /** The Constant REGEX. */
//     public static final String REGEX_UUID = "regex.uuid";
//     public static final String REGEX_IP = "regex.ip";
//     public static final String REGEX_TIME = "regex.time";
// 
//     public static final int TYPE_CALLER_INFO = 1;
//     public static final int TYPE_RESP_PARAM = 2;
//     public static final int TYPE_REQ_PARAM = 3;
//     public static final int TYPE_RESP_TIME = 4;
//     public static final int TYPE_SERVICE_INFO = 5;
// 
//     public static final String REDIS_SERVER_KEY = "SERVER";
// 
//     public static final String REDIS_SERVER_SERVICE_PREFIX = "SERVER_SERVICE_";
//     public static final String REDIS_SERVICE_REQUEST_PREFIX = "SERVICE_REQUEST_";
//     public static final String REDIS_TIME_REQUESTS_PREFIX = "TIME_REQUESTS_";
//     //server->service->requests
//     public static final String REDIS_SERVER_SERVICE_REQUEST_PREFIX = "SERVER_SERVICE_REQUEST_";
// 
//     public static final String REDIS_SERVICE_COSTS_PREFIX = "SERVICE_COSTS_";
//     public static final String REDIS_SERVICE_CALLERS_PREFIX = "SERVICE_CALLERS_";
//     public static final String REDIS_SERVICE_CODES_PREFIX = "SERVICE_CODES_";
// 
//     public static final String REDIS_SERVICE_REQUEST_CALLER_PREFIX = "SERVICE_REQUEST_CALLER_";
//     public static final String REDIS_SERVER_SERVICE_COST_PREFIX = "SERVER_SERVICE_COST_";
//     public static final String REDIS_SERVICE_REQUEST_CODE_PREFIX = "SERVICE_REQUEST_CODE_";
// 
//     public static final String REDIS_SERVER_PREFIX = "S_SERVER_SERVICE_REQUEST_";
//     public static final String REDIS_SERVER_COSTS_PREFIX = "S_SERVER_SERVICE_COSTS_";
//     public static final String REDIS_SERVER_CALLER_PREFIX = "S_SERVER_SERVICE_CALLER_";
//     public static final String REDIS_SERVER_CODE_PREFIX = "S_SERVER_SERVICE_CODE_";
// 
//     public static final String REDIS_TIMELINE_KEY = "TIMELINE_KEY";
// 
//     public static final Integer CODE_SUCESS = 100;
// }


import com.alibaba.fastjson.JSON;
import com.fksm.common.util.Constants;
import com.typesafe.config.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;

    public void putServiceRequestsCache(String service_id, String request_id){
        ArrayList<String> requests = service_requests.get(service_id);
        if(requests == null){
            ArrayList<String> d = new ArrayList<>();
            d.add(request_id);
            service_requests.put(service_id, d);
        }else{
            requests.add(request_id);
        }
    }

    public Map<String, HashMap<String, String>> getServiceCallersCache(){
        return service_callers;
    }

    public void putServiceCallersCache(String service_id, String request_id, String caller_ip){
        HashMap<String, String> requests = service_callers.get(service_id);
        if(requests == null){
            HashMap<String, String> d = new HashMap<String, String>();
            d.put(request_id, caller_ip);
            service_callers.put(service_id, d);
        }else{
            requests.put(request_id, caller_ip);
        }
    }

    private void saveServiceCallers(){
        if(service_callers.size() > 0) {
            for (String service:service_callers.keySet()){
// Path: common/src/main/java/com/fksm/common/util/Constants.java
// public class Constants {
//     /** The Constant REGEX. */
//     public static final String REGEX_UUID = "regex.uuid";
//     public static final String REGEX_IP = "regex.ip";
//     public static final String REGEX_TIME = "regex.time";
// 
//     public static final int TYPE_CALLER_INFO = 1;
//     public static final int TYPE_RESP_PARAM = 2;
//     public static final int TYPE_REQ_PARAM = 3;
//     public static final int TYPE_RESP_TIME = 4;
//     public static final int TYPE_SERVICE_INFO = 5;
// 
//     public static final String REDIS_SERVER_KEY = "SERVER";
// 
//     public static final String REDIS_SERVER_SERVICE_PREFIX = "SERVER_SERVICE_";
//     public static final String REDIS_SERVICE_REQUEST_PREFIX = "SERVICE_REQUEST_";
//     public static final String REDIS_TIME_REQUESTS_PREFIX = "TIME_REQUESTS_";
//     //server->service->requests
//     public static final String REDIS_SERVER_SERVICE_REQUEST_PREFIX = "SERVER_SERVICE_REQUEST_";
// 
//     public static final String REDIS_SERVICE_COSTS_PREFIX = "SERVICE_COSTS_";
//     public static final String REDIS_SERVICE_CALLERS_PREFIX = "SERVICE_CALLERS_";
//     public static final String REDIS_SERVICE_CODES_PREFIX = "SERVICE_CODES_";
// 
//     public static final String REDIS_SERVICE_REQUEST_CALLER_PREFIX = "SERVICE_REQUEST_CALLER_";
//     public static final String REDIS_SERVER_SERVICE_COST_PREFIX = "SERVER_SERVICE_COST_";
//     public static final String REDIS_SERVICE_REQUEST_CODE_PREFIX = "SERVICE_REQUEST_CODE_";
// 
//     public static final String REDIS_SERVER_PREFIX = "S_SERVER_SERVICE_REQUEST_";
//     public static final String REDIS_SERVER_COSTS_PREFIX = "S_SERVER_SERVICE_COSTS_";
//     public static final String REDIS_SERVER_CALLER_PREFIX = "S_SERVER_SERVICE_CALLER_";
//     public static final String REDIS_SERVER_CODE_PREFIX = "S_SERVER_SERVICE_CODE_";
// 
//     public static final String REDIS_TIMELINE_KEY = "TIMELINE_KEY";
// 
//     public static final Integer CODE_SUCESS = 100;
// }


// Path: storm/src/main/java/com/fksm/utils/CacheManager.java
import com.alibaba.fastjson.JSON;
import com.fksm.common.util.Constants;
import com.typesafe.config.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;


    public void putServiceRequestsCache(String service_id, String request_id){
        ArrayList<String> requests = service_requests.get(service_id);
        if(requests == null){
            ArrayList<String> d = new ArrayList<>();
            d.add(request_id);
            service_requests.put(service_id, d);
        }else{
            requests.add(request_id);
        }
    }

    public Map<String, HashMap<String, String>> getServiceCallersCache(){
        return service_callers;
    }

    public void putServiceCallersCache(String service_id, String request_id, String caller_ip){
        HashMap<String, String> requests = service_callers.get(service_id);
        if(requests == null){
            HashMap<String, String> d = new HashMap<String, String>();
            d.put(request_id, caller_ip);
            service_callers.put(service_id, d);
        }else{
            requests.put(request_id, caller_ip);
        }
    }

    private void saveServiceCallers(){
        if(service_callers.size() > 0) {
            for (String service:service_callers.keySet()){
                String key = Constants.REDIS_SERVICE_CODES_PREFIX + service;