Search in sources :

Example 21 with UAVHttpMessage

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

the class AppHubInit method getRequestData.

protected 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("utf8");
    } catch (Exception e) {
        logger.err(this, "ManageBaseRestService getRequestData " + 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 22 with UAVHttpMessage

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

the class AppHubManagerServerWorker method adaptRequest.

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

Example 23 with UAVHttpMessage

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

the class HealthManagerServerWorker method adaptRequest.

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

Example 24 with UAVHttpMessage

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

the class DoTestOpenTSDBQuery method main.

@SuppressWarnings("resource")
public static void main(String[] args) throws ClientProtocolException, IOException {
    String queryurl = "http://localhost:8765/hm/query";
    HttpPost post = new HttpPost(queryurl);
    HttpClient client = new DefaultHttpClient();
    UAVHttpMessage request = new UAVHttpMessage();
    request.putRequest("start", "146234606");
    request.putRequest("end", "1462346020");
    request.putRequest("metric", "urlResp.tmax");
    request.putRequest("aggregator", "sum");
    request.putRequest("downsample", "1ms-avg");
    LinkedHashMap<String, String> tags = new LinkedHashMap<String, String>();
    tags.put("ip", "127.0.0.1");
    request.putRequest("tags", JSONHelper.toString(tags));
    request.putRequest(DataStoreProtocol.DATASTORE_NAME, HealthManagerConstants.DataStore_Monitor);
    String queryJson = JSONHelper.toString(request);
    // String queryJson = "{\"request\":"
    // +"{\"start\":\"1461908927\",\"end\":\"1461908932\","
    // +"\"datastore.name\":\"monitorDataStore\","
    // +"\"queries\":[{"
    // +"\"aggregator\":\"sum\","
    // +"\"metric\":\"urlResp.tmax\","
    // +"\"downsample\":\"1ms-avg\","
    // +"\"tags\":{\"ip\":\"127.0.0.1\"}"
    // +"}]"
    // +"},"
    // +"\"responseAsJsonString\":\"{}\"}";
    StringEntity entity = new StringEntity(queryJson);
    post.setEntity(entity);
    HttpResponse response = client.execute(post);
    if (response != null) {
        HttpEntity resEntity = response.getEntity();
        if (resEntity != null) {
            String result = EntityUtils.toString(resEntity);
            LOG.info(result);
        }
    }
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) HttpEntity(org.apache.http.HttpEntity) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpClient(org.apache.http.client.HttpClient) HttpResponse(org.apache.http.HttpResponse) UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) LinkedHashMap(java.util.LinkedHashMap)

Example 25 with UAVHttpMessage

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

the class HttpTestQuery method executeQuery.

public static void executeQuery(dataType4Test type) {
    System.out.println("################### TEST CASE::  " + jsonQuery + " ####### \n");
    HttpAsyncClient.build(1000, 1000, 100000, 100000, 100000);
    String url = "http://localhost:8765/hm/query";
    UAVHttpMessage request = new UAVHttpMessage();
    String content = null;
    switch(type) {
        case profile:
            // content = prepareMongoProfileDBdata(request);
            // executeHttpCommand(url, content);
            loopTest();
            break;
        case notfication:
            content = prepareNotifcationData(request);
            executeHttpCommand("NotifcationData", url, content);
            break;
        case monitor:
            // executeHttpCommand("InfluxDBdata",url, content);
            break;
        case log:
            content = prepareLogData(request);
            executeHttpCommand("HBaseLogdata", url, content);
            break;
        default:
            System.out.println("not support data type");
            break;
    }
}
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