Search in sources :

Example 51 with PressureMeasureError

use of com.pamirs.pradar.exception.PressureMeasureError 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 52 with PressureMeasureError

use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.

the class CloseIndexRequestIndexRename method reindex0.

@Override
public List<String> reindex0(Object target) {
    CloseIndexRequest req = (CloseIndexRequest) target;
    String[] indexes = req.indices();
    for (int i = 0, len = indexes.length; i < len; i++) {
        String index = indexes[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);
            indexes[i] = index;
        }
    }
    req.indices(indexes);
    return Arrays.asList(indexes);
}
Also used : CloseIndexRequest(org.elasticsearch.action.admin.indices.close.CloseIndexRequest) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError)

Example 53 with PressureMeasureError

use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.

the class CloseIndexRequestIndexRename0 method reindex0.

@Override
public List<String> reindex0(Object target) {
    CloseIndexRequest req = (CloseIndexRequest) target;
    String[] indexes = req.indices();
    for (int i = 0, len = indexes.length; i < len; i++) {
        String index = indexes[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);
            indexes[i] = index;
        }
    }
    try {
        Reflect.on(req).set("indices", indexes);
    } catch (ReflectException e) {
        throw new PressureMeasureError("can't found field indices from " + CloseIndexRequest.class.getName());
    }
    return Arrays.asList(indexes);
}
Also used : CloseIndexRequest(org.elasticsearch.client.indices.CloseIndexRequest) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException)

Example 54 with PressureMeasureError

use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.

the class DeleteAliasRequestRename method reindex0.

@Override
public List<String> reindex0(Object target) {
    DeleteAliasRequest req = (DeleteAliasRequest) target;
    String index = req.getIndex();
    /**
     * 如果在白名单中则不允许写
     */
    if (GlobalConfig.getInstance().getSearchWhiteList().contains(index)) {
        throw new PressureMeasureError("Cluster Test request can't write business index ! " + index);
    }
    if (!Pradar.isClusterTestPrefix(index)) {
        index = Pradar.addClusterTestPrefixLower(index);
    }
    Reflect.on(req).set("index", index);
    return Arrays.asList(index);
}
Also used : PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) DeleteAliasRequest(org.elasticsearch.client.indices.DeleteAliasRequest)

Example 55 with PressureMeasureError

use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.

the class AnalyzeRequestIndexRename0 method reindex0.

@Override
public List<String> reindex0(Object target) {
    AnalyzeRequest req = (AnalyzeRequest) target;
    String index = req.index();
    /**
     * 如果在白名单中则不允许写
     */
    if (GlobalConfig.getInstance().getSearchWhiteList().contains(index)) {
        return Arrays.asList(index);
    }
    if (!Pradar.isClusterTestPrefix(index)) {
        index = Pradar.addClusterTestPrefixLower(index);
    }
    try {
        Reflect.on(req).set("index", index);
    } catch (ReflectException e) {
        throw new PressureMeasureError("can't found field index from " + AnalyzeRequest.class.getName());
    }
    return Arrays.asList(index);
}
Also used : PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) AnalyzeRequest(org.elasticsearch.client.indices.AnalyzeRequest) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException)

Aggregations

PressureMeasureError (com.pamirs.pradar.exception.PressureMeasureError)150 PradarException (com.pamirs.pradar.exception.PradarException)34 DataSourceMeta (com.pamirs.pradar.pressurement.agent.shared.service.DataSourceMeta)14 Connection (java.sql.Connection)14 SQLException (java.sql.SQLException)13 ArrayList (java.util.ArrayList)13 Map (java.util.Map)11 MatchConfig (com.pamirs.pradar.internal.config.MatchConfig)8 ShadowDatabaseConfig (com.pamirs.pradar.internal.config.ShadowDatabaseConfig)8 HashMap (java.util.HashMap)8 MongoNamespace (com.mongodb.MongoNamespace)7 RequestIndexRename (com.pamirs.attach.plugin.es.common.RequestIndexRename)7 ProcessControlException (com.shulie.instrument.simulator.api.ProcessControlException)7 MQTraceContext (com.pamirs.attach.plugin.alibaba.rocketmq.common.MQTraceContext)6 SpanRecord (com.pamirs.pradar.interceptor.SpanRecord)6 ReflectException (com.shulie.instrument.simulator.api.reflect.ReflectException)6 List (java.util.List)6 ConsumeMessageContext (org.apache.rocketmq.client.hook.ConsumeMessageContext)6 ConsumeMessageContext (com.alibaba.rocketmq.client.hook.ConsumeMessageContext)5 WrapperRequest (com.pamirs.attach.plugin.hessian.common.WrapperRequest)5