// 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/CuratorLockAcquire.java
// public class CuratorLockAcquire  {
//     private static final Logger LOGGER = LoggerFactory.getLogger(CuratorLockAcquire.class);
// 
//     private CuratorFramework client = null;
// 
//     public CuratorLockAcquire() {}
// 
//     public synchronized CuratorFramework getCuratorClient() {
//         if (client == null) {
//             try {
//                 String zkHostPort = ConfigPropertieUtil.getInstance().getString("curator.lock.zk.connect");
//                 RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
//                 client = CuratorFrameworkFactory.newClient(zkHostPort, retryPolicy);
//                 client.start();
//             } catch (Exception e) {
//                 LOGGER.error("Get curatorClient error.", e);
//             }
//         }
// 
//         return client;
//     }
// }


import com.alibaba.fastjson.JSONObject;
import com.fksm.common.util.Constants;
import com.fksm.utils.CuratorLockAcquire;
import com.netflix.curator.framework.recipes.locks.InterProcessMutex;
import org.apache.storm.task.OutputCollector;
import org.apache.storm.task.TopologyContext;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Tuple;
import org.apache.storm.tuple.Values;
import org.apache.storm.windowing.TupleWindow;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
package com.fksm.storm.bolt;



/**
 * Created by root on 16-4-23.
 */
public class ServerServiceWindowBolt extends BaseRedisWindowBolt {

    private static final Logger logger = LoggerFactory.getLogger(ServerServiceWindowBolt.class);

    private OutputCollector collector;
    //分布式锁
// 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/CuratorLockAcquire.java
// public class CuratorLockAcquire  {
//     private static final Logger LOGGER = LoggerFactory.getLogger(CuratorLockAcquire.class);
// 
//     private CuratorFramework client = null;
// 
//     public CuratorLockAcquire() {}
// 
//     public synchronized CuratorFramework getCuratorClient() {
//         if (client == null) {
//             try {
//                 String zkHostPort = ConfigPropertieUtil.getInstance().getString("curator.lock.zk.connect");
//                 RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
//                 client = CuratorFrameworkFactory.newClient(zkHostPort, retryPolicy);
//                 client.start();
//             } catch (Exception e) {
//                 LOGGER.error("Get curatorClient error.", e);
//             }
//         }
// 
//         return client;
//     }
// }


// Path: storm/src/main/java/com/fksm/storm/bolt/ServerServiceWindowBolt.java
import com.alibaba.fastjson.JSONObject;
import com.fksm.common.util.Constants;
import com.fksm.utils.CuratorLockAcquire;
import com.netflix.curator.framework.recipes.locks.InterProcessMutex;
import org.apache.storm.task.OutputCollector;
import org.apache.storm.task.TopologyContext;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Tuple;
import org.apache.storm.tuple.Values;
import org.apache.storm.windowing.TupleWindow;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;

package com.fksm.storm.bolt;



/**
 * Created by root on 16-4-23.
 */
public class ServerServiceWindowBolt extends BaseRedisWindowBolt {

    private static final Logger logger = LoggerFactory.getLogger(ServerServiceWindowBolt.class);

    private OutputCollector collector;
    //分布式锁
    private CuratorLockAcquire curatorLockAcquire;