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;
}
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;
}
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;
}
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.");
}
}
}
}
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;
}
Aggregations