Search in sources :

Example 6 with UAVHttpMessage

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

the class LineNumberWriter method testSystemInvoker.

private void testSystemInvoker() {
    Thread thd = new Thread(new Runnable() {

        @Override
        public void run() {
            ThreadHelper.suspend(5000);
            // AgentFeatureComponent afc = (AgentFeatureComponent) getConfigManager().getComponent("hbclientagent",
            // "HeartBeatClientAgent");
            // 
            // if (afc == null) {
            // return;
            // }
            // 
            // String[] urls = (String[]) afc.exchange("hbclientagent.service.discovery",
            // "healthmanager-HealthMangerServerWorker-/hm/cache/q");
            // 
            // log.info(this, ">>" + urls);
            AbstractSystemInvoker invoker = getSystemInvokerMgr().getSystemInvoker(InvokerType.HTTP);
            for (int i = 0; i < 5; i++) {
                UAVHttpMessage msg = new UAVHttpMessage();
                msg.setIntent("services");
                msg.putRequest("service", "hbserveragent-HeartBeatQueryListenWorker-/hb/query");
                String res = (String) invoker.invoke("hbserveragent-HeartBeatQueryListenWorker-/hb/query", msg, String.class);
                log.info(this, ">>" + res);
            // invoker.invoke("hbserveragent-HeartBeatQueryListenWorker-/hb/query", msg, new
            // HttpClientCallback() {
            // 
            // @Override
            // public void completed(HttpClientCallbackResult result) {
            // 
            // log.info(this, ">>" + result.getReplyDataAsString());
            // }
            // 
            // @Override
            // public void failed(HttpClientCallbackResult result) {
            // 
            // }
            // 
            // });
            }
            log.info(this, ">>>>");
        }
    });
    thd.start();
}
Also used : UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) AbstractSystemInvoker(com.creditease.agent.spi.AbstractSystemInvoker)

Example 7 with UAVHttpMessage

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

the class HeartBeatQueryListenWorker method adaptRequest.

@Override
protected UAVHttpMessage adaptRequest(HttpMessage message) {
    String messageBody = message.getRequestBodyAsString("UTF-8");
    if (log.isDebugEnable()) {
        log.debug(this, "HeartBeatQueryListenWorker Request: " + messageBody);
    }
    UAVHttpMessage msg = new UAVHttpMessage(messageBody);
    return msg;
}
Also used : UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage)

Example 8 with UAVHttpMessage

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

the class NodeOperHttpServer method adaptRequest.

@Override
protected UAVHttpMessage adaptRequest(HttpMessage message) {
    String messageBody = message.getRequestBodyAsString("UTF-8");
    if (log.isTraceEnable()) {
        log.info(this, "NodeOperHttpServer Request: " + messageBody);
    }
    UAVHttpMessage msg = new UAVHttpMessage(messageBody);
    return msg;
}
Also used : UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage)

Example 9 with UAVHttpMessage

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

the class CollectNodeOperAction method doAction.

@Override
public void doAction(ActionContext context) throws Exception {
    AgentFeatureComponent afc = (AgentFeatureComponent) getConfigManager().getComponent("collectclient", "CollectDataAgent");
    if (afc == null) {
        return;
    }
    UAVHttpMessage data = (UAVHttpMessage) context.getParam("msg");
    String cmd = data.getRequest().get("cmd");
    if ("add".equals(cmd)) {
        afc.exchange("collectdata.add", data.getRequest().get("task"));
    } else if ("del".equals(cmd)) {
        afc.exchange("collectdata.del", data.getRequest().get("task"));
    } else if ("status".equals(cmd)) {
        String status = (String) afc.exchange("collectdata.status", cmd);
        data.putResponse(UAVHttpMessage.RESULT, status);
    }
}
Also used : UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) AgentFeatureComponent(com.creditease.agent.spi.AgentFeatureComponent)

Example 10 with UAVHttpMessage

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

the class GUIService method createGroupInfoCache.

private void createGroupInfoCache() {
    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.group");
    dbInfo.put("conllectionName", "uav_groupinfo");
    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 createGroupInfoCache \n" + e.getMessage());
        throw new ApphubException(e);
    }
    logger.info(this, "GUIService createGroupInfoCache");
    GroupCacheCallBack groupCacheCb = new GroupCacheCallBack();
    doHttpPost("uav.app.manage.apphubmanager.http.addr", "/ah/group", datab, "application/json", "utf-8", groupCacheCb);
}
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)

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