Search in sources :

Example 11 with RequestIndexRename

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

the class MultiTermVectorsRequestIndexRename method reindex0.

@Override
public List<String> reindex0(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.reindex(req));
        } else {
            throw new PressureMeasureError("elasticsearch " + req.getClass().getName() + " is not supported!");
        }
    }
    return indexes;
}
Also used : PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) 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)

Example 12 with RequestIndexRename

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

the class MultiPercolateRequestIndexRename method getIndex0.

@Override
public List<String> getIndex0(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.getIndex(req));
        }
    }
    return indexes;
}
Also used : MultiPercolateRequest(org.elasticsearch.action.percolate.MultiPercolateRequest) ArrayList(java.util.ArrayList) RequestIndexRename(com.pamirs.attach.plugin.es.common.RequestIndexRename) List(java.util.List) ArrayList(java.util.ArrayList)

Example 13 with RequestIndexRename

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

the class AbstractRestClientShadowServerInterceptor method doShadowIndexInterceptor.

protected CutOffResult doShadowIndexInterceptor(Advice advice) {
    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);
    }
    return CutOffResult.PASSED;
}
Also used : PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) RequestIndexRename(com.pamirs.attach.plugin.es.common.RequestIndexRename)

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