Search in sources :

Example 6 with JsonRPCResponseBase

use of ngse.org.JsonRPCResponseBase in project MSEC by Tencent.

the class QueryBusinessLog method exec.

public JsonRPCResponseBase exec(BusinessLog request) {
    try {
        /*
            getHttpResponse().setContentType("text/html");
            getHttpResponse().setCharacterEncoding("UTF-8");
            ServletOutputStream out = getHttpResponse().getOutputStream();

            out.println("<html>");
            out.println("<head>");
            out.println("<title>log result</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<pre>");//这个标签用于原样输出

            String result = doQueryLog(out, request);
            if (result == null || !result.equals("success"))
            {
                out.println(result);
            }

            out.println("</pre>");
            out.println("</body>");
            out.println("</html>");


            out.close();
            return null;
            */
        JsonRPCResponseBase response = new JsonRPCResponseBase();
        String result = checkIdentity();
        if (!result.equals("success")) {
            response.setStatus(99);
            response.setMessage(result);
            return response;
        }
        result = doQueryLog(request);
        if (!result.equals("success")) {
            response.setMessage(result);
            response.setStatus(100);
            return response;
        }
        String ReqID = request.getRequest_id();
        if (ReqID != null && ReqID.length() > 0) {
            result = doGetCallRelationGraph(request);
            if (!result.equals("success")) {
                response.setMessage(result);
                response.setStatus(100);
                return response;
            }
        }
        response.setMessage("success");
        response.setStatus(0);
        return response;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : JsonRPCResponseBase(ngse.org.JsonRPCResponseBase)

Example 7 with JsonRPCResponseBase

use of ngse.org.JsonRPCResponseBase in project MSEC by Tencent.

the class RefreshCapacity method exec.

public JsonRPCResponseBase exec(CapacityRequest request) {
    JsonRPCResponseBase response = new JsonRPCResponseBase();
    String result = checkIdentity();
    if (!result.equals("success")) {
        response.setStatus(99);
        response.setMessage(result);
        return response;
    }
    Logger logger = Logger.getLogger(RefreshCapacity.class);
    //把ip列表刷新到LB的服务器里并下发给各个客户端
    AccessZooKeeper azk = new AccessZooKeeper();
    DBUtil util = new DBUtil();
    if (util.getConnection() == null) {
        response.setStatus(100);
        response.setMessage("db connect failed");
        return response;
    }
    try {
        //step2: 获得该服务下所有enabled的IP,写入LB系统
        ArrayList<IPPortPair> ips = LoadBalance.getIPPortInfoByServiceName(request.getFirst_level_service_name(), request.getSecond_level_service_name(), util);
        if (ips == null) {
            response.setStatus(100);
            response.setMessage("get ip info from db failed");
            return response;
        }
        logger.info("get enabled IP, they will be write to LB server, number:" + ips.size());
        result = LoadBalance.writeOneServiceConfigInfo(azk, request.getFirst_level_service_name() + "/" + request.getSecond_level_service_name(), true, ips);
        if (result == null || !result.equals("success")) {
            response.setStatus(100);
            response.setMessage(result);
            return response;
        }
        logger.info("write into LB server successfully.");
        //step3: 更新涉及到的IP为key的配置信息
        ArrayList<String> whiteNameList = new ArrayList<>();
        for (int i = 0; i < ips.size(); i++) {
            whiteNameList.add(ips.get(i).getIp());
        }
        logger.info("update the IP-key information in LB server");
        result = LoadBalance.writeIPConfigInfo(azk, whiteNameList);
        if (result == null || !result.equals("success")) {
            response.setStatus(100);
            response.setMessage(result);
            return response;
        }
        response.setStatus(0);
        response.setMessage("success");
        return response;
    } catch (Exception e) {
        e.printStackTrace();
        response.setStatus(100);
        response.setMessage(e.getMessage());
        return response;
    } finally {
        azk.disconnect();
        util.releaseConn();
    }
}
Also used : DBUtil(ngse.org.DBUtil) JsonRPCResponseBase(ngse.org.JsonRPCResponseBase) IPPortPair(beans.request.IPPortPair) ArrayList(java.util.ArrayList) Logger(org.apache.log4j.Logger) AccessZooKeeper(ngse.org.AccessZooKeeper)

Example 8 with JsonRPCResponseBase

use of ngse.org.JsonRPCResponseBase in project MSEC by Tencent.

the class ChangeCapacity method exec.

public JsonRPCResponseBase exec(ChangeCapacityRequest request) {
    JsonRPCResponseBase response = new JsonRPCResponseBase();
    String result = checkIdentity();
    if (!result.equals("success")) {
        response.setStatus(99);
        response.setMessage(result);
        return response;
    }
    Logger logger = Logger.getLogger(ChangeCapacity.class);
    //把ip列表刷新到LB的服务器里并下发给各个客户端
    AccessZooKeeper azk = new AccessZooKeeper();
    DBUtil util = new DBUtil();
    if (util.getConnection() == null) {
        response.setStatus(100);
        response.setMessage("db connect failed");
        return response;
    }
    try {
        //step1:更新扩缩容的IP的状态
        if (//扩容
        request.getAction_type().equals("expand")) {
            updateIPStatus(request, true, util);
        } else // 缩容
        {
            updateIPStatus(request, false, util);
        }
        logger.info("update matchine's status OK, matchine Numbers:" + request.getIp_list().size());
        //step2: 获得该服务下所有enabled的IP,写入LB系统
        ArrayList<IPPortPair> ips = LoadBalance.getIPPortInfoByServiceName(request.getFirst_level_service_name(), request.getSecond_level_service_name(), util);
        if (ips == null) {
            response.setStatus(100);
            response.setMessage("get ip info from db failed");
            return response;
        }
        logger.info("get enabled IP, they will be write to LB server, number:" + ips.size());
        result = LoadBalance.writeOneServiceConfigInfo(azk, request.getFirst_level_service_name() + "/" + request.getSecond_level_service_name(), true, ips);
        if (result == null || !result.equals("success")) {
            response.setStatus(100);
            response.setMessage(result);
            return response;
        }
        logger.info("write into LB server successfully.");
        //step3: 更新涉及到的IP为key的配置信息
        ArrayList<String> whiteNameList = new ArrayList<>();
        for (int i = 0; i < request.getIp_list().size(); i++) {
            whiteNameList.add(request.getIp_list().get(i).getIp());
        }
        logger.info("update the IP-key information in LB server");
        result = LoadBalance.writeIPConfigInfo(azk, whiteNameList);
        if (result == null || !result.equals("success")) {
            response.setStatus(100);
            response.setMessage(result);
            return response;
        }
        response.setStatus(0);
        response.setMessage("success");
        return response;
    } catch (Exception e) {
        e.printStackTrace();
        response.setStatus(100);
        response.setMessage(e.getMessage());
        return response;
    } finally {
        azk.disconnect();
        util.releaseConn();
    }
}
Also used : DBUtil(ngse.org.DBUtil) JsonRPCResponseBase(ngse.org.JsonRPCResponseBase) IPPortPair(beans.request.IPPortPair) ArrayList(java.util.ArrayList) Logger(org.apache.log4j.Logger) AccessZooKeeper(ngse.org.AccessZooKeeper)

Example 9 with JsonRPCResponseBase

use of ngse.org.JsonRPCResponseBase in project MSEC by Tencent.

the class RefreshOddCapacity method exec.

public JsonRPCResponseBase exec(CapacityRequest request) {
    JsonRPCResponseBase response = new JsonRPCResponseBase();
    String result = checkIdentity();
    if (!result.equals("success")) {
        response.setStatus(99);
        response.setMessage(result);
        return response;
    }
    Logger logger = Logger.getLogger(RefreshOddCapacity.class);
    //把ip列表刷新到LB的服务器里并下发给各个客户端
    AccessZooKeeper azk = new AccessZooKeeper();
    DBUtil util = new DBUtil();
    if (util.getConnection() == null) {
        response.setStatus(100);
        response.setMessage("db connect failed");
        return response;
    }
    try {
        //step2: 获得该服务下所有enabled的IP,写入LB系统
        ArrayList<IPPortPair> ips = LoadBalance.getIPPortInfoByServiceName(request.getFirst_level_service_name(), request.getSecond_level_service_name(), util);
        if (ips == null) {
            response.setStatus(100);
            response.setMessage("get ip info from db failed");
            return response;
        }
        logger.info("get enabled IP, they will be write to LB server, number:" + ips.size());
        result = LoadBalance.writeOneServiceConfigInfo(azk, request.getFirst_level_service_name() + "/" + request.getSecond_level_service_name(), false, ips);
        if (result == null || !result.equals("success")) {
            response.setStatus(100);
            response.setMessage(result);
            return response;
        }
        logger.info("write into LB server successfully.");
        response.setStatus(0);
        response.setMessage("success");
        return response;
    } catch (Exception e) {
        e.printStackTrace();
        response.setStatus(100);
        response.setMessage(e.getMessage());
        return response;
    } finally {
        azk.disconnect();
        util.releaseConn();
    }
}
Also used : DBUtil(ngse.org.DBUtil) JsonRPCResponseBase(ngse.org.JsonRPCResponseBase) IPPortPair(beans.request.IPPortPair) Logger(org.apache.log4j.Logger) AccessZooKeeper(ngse.org.AccessZooKeeper)

Aggregations

JsonRPCResponseBase (ngse.org.JsonRPCResponseBase)9 DBUtil (ngse.org.DBUtil)6 Logger (org.apache.log4j.Logger)5 IPPortPair (beans.request.IPPortPair)4 ArrayList (java.util.ArrayList)4 AccessZooKeeper (ngse.org.AccessZooKeeper)4 IOException (java.io.IOException)2 HttpSession (javax.servlet.http.HttpSession)2 DevPackage (beans.request.DevPackage)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 SQLException (java.sql.SQLException)1 ServletOutputStream (javax.servlet.ServletOutputStream)1