Search in sources :

Example 16 with UAVHttpMessage

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

the class GodEyeRestService method noitifyEvent.

@POST
@Path("notify/q/event/hm")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void noitifyEvent(@Suspended AsyncResponse response) throws Exception {
    HashMap<String, Object> requestParam = new HashMap<String, Object>();
    HashMap<String, Object> data = new HashMap<String, Object>();
    data.put("distinct", "eventid");
    requestParam.put("group", data);
    List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
    // 过滤数据,只查询最近的指定数据 begin
    HashMap<String, Object> sortMap = new HashMap<String, Object>();
    HashMap<String, Object> sort = new HashMap<String, Object>();
    sort.put("values", "time");
    sort.put("sortorder", "-1");
    sortMap.put("sort", sort);
    list.add(sortMap);
    // modify start : 只返回firstrecord为true的事件id
    HashMap<String, Object> firstRecord = new HashMap<String, Object>();
    HashMap<String, Object> firstRecordMatch = new HashMap<String, Object>();
    firstRecord.put("firstrecord", "true");
    firstRecordMatch.put("match", firstRecord);
    list.add(firstRecordMatch);
    // modify end
    HashMap<String, Object> skipMap = new HashMap<String, Object>();
    skipMap.put("skip", mongodbQueryRangeMap.get("skip"));
    list.add(skipMap);
    HashMap<String, Object> limitMap = new HashMap<String, Object>();
    limitMap.put("limit", mongodbQueryRangeMap.get("limit"));
    list.add(limitMap);
    // 过滤数据,只查询最近的指定数据 end
    list.add(requestParam);
    // 封装http请求数据
    UAVHttpMessage message = new UAVHttpMessage();
    message.putRequest("mgo.sql", JSONHelper.toString(list));
    message.putRequest("datastore.name", "MT_Notify");
    message.putRequest("mgo.coll.name", "uav_notify");
    NoitifyEventCB callback = new NoitifyEventCB();
    callback.setResponse(response);
    doHttpPost("uav.app.godeye.healthmanager.http.addr", "/hm/query", message, callback);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 17 with UAVHttpMessage

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

the class GodEyeRestService method queryAppLog.

@Deprecated
protected void queryAppLog(String data, AsyncResponse response) {
    UAVHttpMessage message = new UAVHttpMessage();
    message.putRequest("hbase.query.json", data);
    message.putRequest("datastore.name", MonitorDataFrame.MessageType.Log.toString());
    QueryAppLogCB callback = new QueryAppLogCB();
    callback.setResponse(response);
    this.doHttpPost("uav.app.godeye.healthmanager.http.addr", "/hm/query", message, callback);
}
Also used : UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage)

Example 18 with UAVHttpMessage

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

the class GodEyeRestService method searchNewLog.

// ---------------------------------------新日志服务接口 START-----------------------------------
/**
 * searchNewLog
 *
 * @param data
 * @param resp
 */
@POST
@Path("/newlog/q")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void searchNewLog(String data, @Suspended AsyncResponse resp) {
    UAVHttpMessage msg = new UAVHttpMessage(data);
    doHttpPost("uav.app.hm.newlog.http.addr", "/newlog/q", msg, new SearchNewLogCallback(resp));
}
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 19 with UAVHttpMessage

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

the class ManageRestService method getRequestData.

// tools begin---------------------------------------------------------->
/**
 * 打包请求数据
 *
 * @param type
 * @param mapParam
 * @return
 */
private byte[] getRequestData(String type, Map<String, Object> mapParam) {
    Map<String, String> dbInfo = getDBInfo(type);
    UAVHttpMessage request = new UAVHttpMessage();
    request.putRequest("mrd.data", JSONHelper.toString(mapParam));
    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, "ManageBaseRestService getRequestData \n" + e.getMessage());
        throw new ApphubException(e);
    }
    return datab;
}
Also used : ApphubException(com.creditease.uav.exception.ApphubException) UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) ApphubException(com.creditease.uav.exception.ApphubException)

Example 20 with UAVHttpMessage

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

the class XRobotRestService method doCommand.

@POST
@Path("command")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void doCommand(String data, @Suspended AsyncResponse response) {
    UAVHttpMessage msg = new UAVHttpMessage(data);
    this.doHttpPost("uav.app.xrobot.http.addr", "/hit/xrobot", msg, new CmdCallback(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)

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