Search in sources :

Example 11 with UAVHttpMessage

use of com.creditease.agent.http.api.UAVHttpMessage in project uavstack by uavorg.

the class GUIService method createAppInfoCache.

private void createAppInfoCache() {
    Map<String, Object> where = new HashMap<String, Object>();
    where.put("state", 1);
    Map<String, Object> data = new HashMap<String, Object>();
    data.put("where", where);
    String dataStr = JSONHelper.toString(data);
    Map<String, Object> jsonRequest = new HashMap<String, Object>();
    jsonRequest.put("type", "query");
    jsonRequest.put("data", dataStr);
    HashMap<String, String> dbInfo = new HashMap<String, String>();
    dbInfo.put("dataStoreName", "AppHub.app");
    dbInfo.put("conllectionName", "uav_appinfo");
    UAVHttpMessage request = new UAVHttpMessage();
    request.putRequest("mrd.data", JSONHelper.toString(jsonRequest));
    request.putRequest("datastore.name", dbInfo.get("dataStoreName"));
    request.putRequest("mgo.coll.name", dbInfo.get("conllectionName"));
    String jsonStr = JSONHelper.toString(request);
    byte[] datab = null;
    try {
        datab = jsonStr.getBytes("utf-8");
    } catch (Exception e) {
        logger.err(this, "GUIService createAppInfoCache \n" + e.getMessage());
        throw new ApphubException(e);
    }
    logger.info(this, "GUIService createAppInfoCache");
    AppCacheCallBack appCacheCb = new AppCacheCallBack();
    doHttpPost("uav.app.manage.apphubmanager.http.addr", "/ah/app", datab, "application/json", "utf-8", appCacheCb);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ApphubException(com.creditease.uav.exception.ApphubException) UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) ApphubException(com.creditease.uav.exception.ApphubException) IOException(java.io.IOException)

Example 12 with UAVHttpMessage

use of com.creditease.agent.http.api.UAVHttpMessage in project uavstack by uavorg.

the class APMRestService method queryIVC.

@POST
@Path("ivc/q")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void queryIVC(String data, @Suspended AsyncResponse response) {
    UAVHttpMessage msg = new UAVHttpMessage(data);
    this.doHttpPost("uav.app.apm.ivc.http.addr", "/ivc/q", msg, new IVCCallback(response));
}
Also used : UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 13 with UAVHttpMessage

use of com.creditease.agent.http.api.UAVHttpMessage in project uavstack by uavorg.

the class GodEyeRestService method loadAppProfileDetail.

/**
 * 读取profile的某个lazy模式加载的数据
 *
 * @param data
 * @param response
 */
@POST
@Path("profile/q/detail")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void loadAppProfileDetail(String data, @Suspended AsyncResponse response) {
    UAVHttpMessage message = new UAVHttpMessage(data);
    loadAppProfileListFromHttp(message, response);
}
Also used : UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 14 with UAVHttpMessage

use of com.creditease.agent.http.api.UAVHttpMessage in project uavstack by uavorg.

the class GodEyeRestService method noitifyView.

@POST
@Path("notify/view/hm")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void noitifyView(String data, @Suspended AsyncResponse response) throws Exception {
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    @SuppressWarnings("unchecked") Map<String, String> jsonParam = JSONHelper.toObject(data, Map.class);
    String url = jsonParam.get("url");
    String time;
    if ("link".equals(jsonParam.get("type"))) {
        byte[] d = new BASE64DecoderUrl().decodeBuffer(url);
        url = new String(d, "utf-8");
        time = url.substring(url.lastIndexOf("&") + 1);
    } else {
        String timeStr = url.substring(url.lastIndexOf("&") + 1);
        time = String.valueOf(simpleDateFormat.parse(timeStr).getTime());
    }
    String ntfkey = url.substring(0, url.lastIndexOf("&"));
    String loginUser = "";
    HttpSession session = request.getSession(false);
    if (null != session) {
        loginUser = String.valueOf(session.getAttribute("apphub.gui.session.login.user.id"));
    }
    String log = "loginUser=[" + loginUser + "],type=[" + jsonParam.get("type") + "],ntfkey=[" + ntfkey + "],time=[" + time + "]";
    if (!"".equals(ntfkey) && !"undefined".equals(ntfkey)) {
        UAVHttpMessage message = new UAVHttpMessage();
        message.putRequest("ncevent", ntfkey);
        message.putRequest("time", time);
        NoitifyViewCB callback = new NoitifyViewCB();
        callback.setResponse(response);
        callback.setLog(log);
        doHttpPost("uav.app.godeye.notify.view.http.addr", "/nc/update", message, callback);
    }
}
Also used : BASE64DecoderUrl(com.creditease.uav.helpers.url.BASE64DecoderUrl) HttpSession(javax.servlet.http.HttpSession) UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) SimpleDateFormat(java.text.SimpleDateFormat) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 15 with UAVHttpMessage

use of com.creditease.agent.http.api.UAVHttpMessage in project uavstack by uavorg.

the class GodEyeRestService method loadMonitorDataFromOpenTSDB.

private void loadMonitorDataFromOpenTSDB(String data, final AsyncResponse response) {
    UAVHttpMessage message = new UAVHttpMessage();
    message.putRequest("opentsdb.query.json", data);
    message.putRequest("datastore.name", MonitorDataFrame.MessageType.Monitor.toString());
    LoadMonitorDataFromOpenTSDBCB callback = new LoadMonitorDataFromOpenTSDBCB();
    callback.setResponse(response);
    this.doHttpPost("uav.app.godeye.healthmanager.http.addr", "/hm/query", message, callback);
}
Also used : UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage)

Aggregations

UAVHttpMessage (com.creditease.agent.http.api.UAVHttpMessage)58 Path (javax.ws.rs.Path)25 Produces (javax.ws.rs.Produces)25 POST (javax.ws.rs.POST)22 HashMap (java.util.HashMap)14 HttpClientCallback (com.creditease.uav.httpasync.HttpClientCallback)5 HttpClientCallbackResult (com.creditease.uav.httpasync.HttpClientCallbackResult)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 ApphubException (com.creditease.uav.exception.ApphubException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 IOException (java.io.IOException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 GET (javax.ws.rs.GET)3 AbstractSystemInvoker (com.creditease.agent.spi.AbstractSystemInvoker)2 AgentFeatureComponent (com.creditease.agent.spi.AgentFeatureComponent)2 BASE64DecoderUrl (com.creditease.uav.helpers.url.BASE64DecoderUrl)2 Date (java.util.Date)2