Search in sources :

Example 1 with RequestIndexRename

use of com.pamirs.attach.plugin.es.common.RequestIndexRename in project LinkAgent by shulieTech.

the class RestClientTraceInterceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    Object target = advice.getTarget();
    SpanRecord record = new SpanRecord();
    RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(args[0]);
    if (requestIndexRename == null) {
        LOGGER.error("elasticsearch {} is not supported", args[0].getClass().getName());
        return null;
    }
    final Set<String> indexes = new HashSet<String>(requestIndexRename.getIndex(args[0]));
    if (CollectionUtils.isEmpty(indexes)) {
        return null;
    }
    record.setService(toString(indexes));
    record.setMethod(advice.getBehaviorName());
    String remoteIp = getRemoteIp(target);
    record.setRemoteIp(remoteIp);
    if (!Pradar.isClusterTest()) {
        record.setPassedCheck(true);
    }
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) RequestIndexRename(com.pamirs.attach.plugin.es.common.RequestIndexRename) HashSet(java.util.HashSet)

Example 2 with RequestIndexRename

use of com.pamirs.attach.plugin.es.common.RequestIndexRename in project LinkAgent by shulieTech.

the class RestHighLevelClientInterceptor method beforeFirst.

@Override
public void beforeFirst(Advice advice) {
    Object[] args = advice.getParameterArray();
    ClusterTestUtils.validateClusterTest();
    if (!Pradar.isClusterTest()) {
        return;
    }
    if (GlobalConfig.getInstance().isShadowEsServer()) {
        return;
    }
    RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(args[0]);
    if (requestIndexRename == null) {
        throw new PressureMeasureError("elasticsearch " + args[0].getClass().getName() + " is not supported!");
    }
    if (requestIndexRename.supportedDirectReindex(args[0])) {
        requestIndexRename.reindex(args[0]);
    } else {
        Object index = requestIndexRename.indirectIndex(args[0]);
        advice.changeParameter(0, index);
    }
}
Also used : PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) RequestIndexRename(com.pamirs.attach.plugin.es.common.RequestIndexRename)

Example 3 with RequestIndexRename

use of com.pamirs.attach.plugin.es.common.RequestIndexRename in project LinkAgent by shulieTech.

the class TransportClientTraceInterceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    Object target = advice.getTarget();
    SpanRecord record = new SpanRecord();
    RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(args[1]);
    if (requestIndexRename == null) {
        LOGGER.error("elasticsearch {} is not supported", args[1].getClass().getName());
        return null;
    }
    if (!Pradar.isClusterTest()) {
        record.setPassedCheck(true);
    }
    AbstractClient client = (AbstractClient) target;
    record.setService(toString(new HashSet<String>(requestIndexRename.getIndex(args[1]))));
    record.setMethod(advice.getBehaviorName());
    record.setRemoteIp(parseAddressAndPort(client));
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) AbstractClient(org.elasticsearch.client.support.AbstractClient) RequestIndexRename(com.pamirs.attach.plugin.es.common.RequestIndexRename) HashSet(java.util.HashSet)

Example 4 with RequestIndexRename

use of com.pamirs.attach.plugin.es.common.RequestIndexRename in project LinkAgent by shulieTech.

the class BulkRequestAddInterceptor method beforeFirst.

@Override
public void beforeFirst(Advice advice) {
    ClusterTestUtils.validateClusterTest();
    if (!Pradar.isClusterTest()) {
        return;
    }
    Object[] args = advice.getParameterArray();
    RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(args[0]);
    if (requestIndexRename == null) {
        throw new PressureMeasureError("elasticsearch " + args[0].getClass().getName() + " is not supported!");
    }
    if (requestIndexRename.supportedDirectReindex(args[0])) {
        requestIndexRename.reindex(args[0]);
    } else {
        Object index = requestIndexRename.indirectIndex(args[0]);
        advice.changeParameter(0, index);
    }
}
Also used : PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) RequestIndexRename(com.pamirs.attach.plugin.es.common.RequestIndexRename)

Example 5 with RequestIndexRename

use of com.pamirs.attach.plugin.es.common.RequestIndexRename in project LinkAgent by shulieTech.

the class BulkRequestIndexRename method getIndex0.

@Override
public List<String> getIndex0(Object target) {
    BulkRequest req = (BulkRequest) target;
    List reqs = req.requests();
    List<String> list = new ArrayList<String>();
    for (Object r : reqs) {
        if (r == null) {
            continue;
        }
        RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(r);
        if (requestIndexRename != null) {
            list.addAll(requestIndexRename.getIndex(r));
        }
    }
    return list;
}
Also used : BulkRequest(org.elasticsearch.action.bulk.BulkRequest) ArrayList(java.util.ArrayList) RequestIndexRename(com.pamirs.attach.plugin.es.common.RequestIndexRename) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

RequestIndexRename (com.pamirs.attach.plugin.es.common.RequestIndexRename)13 PressureMeasureError (com.pamirs.pradar.exception.PressureMeasureError)7 ArrayList (java.util.ArrayList)5 List (java.util.List)5 HashSet (java.util.HashSet)4 SpanRecord (com.pamirs.pradar.interceptor.SpanRecord)3 MultiPercolateRequest (org.elasticsearch.action.percolate.MultiPercolateRequest)2 MultiTermVectorsRequest (org.elasticsearch.action.termvectors.MultiTermVectorsRequest)2 BulkRequest (org.elasticsearch.action.bulk.BulkRequest)1 AbstractClient (org.elasticsearch.client.support.AbstractClient)1