Search in sources :

Example 6 with RequestIndexRename

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

the class MultiPercolateRequestIndexRename method reindex0.

@Override
public List<String> reindex0(Object target) {
    MultiPercolateRequest mReq = (MultiPercolateRequest) target;
    List list = mReq.requests();
    List<String> indexes = new ArrayList<String>();
    for (Object req : list) {
        if (req == null) {
            continue;
        }
        RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(req);
        if (requestIndexRename != null) {
            indexes.addAll(requestIndexRename.reindex(req));
        } else {
            throw new PressureMeasureError("elasticsearch " + req.getClass().getName() + " is not supported!");
        }
    }
    String[] indices = mReq.indices();
    for (int i = 0, len = indices.length; i < len; i++) {
        String index = indices[i];
        /**
         * 如果在白名单中则不允许写
         */
        if (GlobalConfig.getInstance().getSearchWhiteList().contains(index)) {
            throw new PressureMeasureError("Cluster Test request can't refresh business index ! " + index);
        }
        if (!Pradar.isClusterTestPrefix(index)) {
            index = Pradar.addClusterTestPrefixLower(index);
            indices[i] = index;
        }
    }
    return indexes;
}
Also used : MultiPercolateRequest(org.elasticsearch.action.percolate.MultiPercolateRequest) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) ArrayList(java.util.ArrayList) RequestIndexRename(com.pamirs.attach.plugin.es.common.RequestIndexRename) List(java.util.List) ArrayList(java.util.ArrayList)

Example 7 with RequestIndexRename

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

the class RestHighLevelClientInterceptor 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;
    }
    if (!Pradar.isClusterTest()) {
        record.setPassedCheck(true);
    }
    record.setService(toString(new HashSet<String>(requestIndexRename.getIndex(args[0]))));
    record.setMethod(advice.getBehaviorName());
    String remoteIp = getRemoteIp(target);
    record.setRemoteIp(remoteIp);
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) RequestIndexRename(com.pamirs.attach.plugin.es.common.RequestIndexRename) HashSet(java.util.HashSet)

Example 8 with RequestIndexRename

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

the class TransportClientExecuteInterceptor method doShadowIndexInterceptor.

private CutOffResult doShadowIndexInterceptor(Advice advice) {
    Object[] args = advice.getParameterArray();
    if (args[1] == null) {
        return CutOffResult.PASSED;
    }
    RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(args[1]);
    if (requestIndexRename == null) {
        throw new PressureMeasureError("elasticsearch " + args[1].getClass().getName() + " is not supported");
    }
    requestIndexRename.reindex(args[1]);
    return CutOffResult.PASSED;
}
Also used : PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) RequestIndexRename(com.pamirs.attach.plugin.es.common.RequestIndexRename)

Example 9 with RequestIndexRename

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

the class TransportClientTraceInterceptor method check.

private void check(Object target, String methodName, Object[] args) {
    if (GlobalConfig.getInstance().isShadowEsServer()) {
        return;
    }
    RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(args[1]);
    Collection<String> indexs = new HashSet<String>(requestIndexRename.getIndex(args[1]));
    if (Pradar.isClusterTest()) {
        for (String index : indexs) {
            if (!Pradar.isClusterTestPrefix(index)) {
                /**
                 * 如果索引在白名单中,则不需要走
                 */
                if (GlobalConfig.getInstance().getSearchWhiteList().contains(index)) {
                    continue;
                }
                throw new PressureMeasureError("[error] forbidden pressurement into biz index. index = " + index);
            }
        }
    } else {
        for (String index : indexs) {
            if (Pradar.isClusterTestPrefix(index)) {
                logger.error("[error]  biz data into pressurement index.");
            }
        }
    }
}
Also used : PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) RequestIndexRename(com.pamirs.attach.plugin.es.common.RequestIndexRename) HashSet(java.util.HashSet)

Example 10 with RequestIndexRename

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

the class MultiTermVectorsRequestIndexRename method getIndex0.

@Override
public List<String> getIndex0(Object target) {
    MultiTermVectorsRequest mreq = (MultiTermVectorsRequest) target;
    List list = mreq.getRequests();
    List<String> indexes = new ArrayList<String>();
    for (Object req : list) {
        if (req == null) {
            continue;
        }
        RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(req);
        if (requestIndexRename != null) {
            indexes.addAll(requestIndexRename.getIndex(req));
        }
    }
    return indexes;
}
Also used : MultiTermVectorsRequest(org.elasticsearch.action.termvectors.MultiTermVectorsRequest) 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