use of com.pamirs.pradar.exception.PressureMeasureError 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.pradar.exception.PressureMeasureError 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.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class IndexRequestIndexRename method reindex0.
@Override
public List<String> reindex0(Object target) {
IndexRequest req = (IndexRequest) target;
String index = req.index();
/**
* 如果在白名单中则不允许写
*/
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(req.index());
}
req.index(index);
return Arrays.asList(index);
}
use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class IndicesAliasesRequestIndexRename method reindex0.
@Override
public List<String> reindex0(Object target) {
IndicesAliasesRequest req = (IndicesAliasesRequest) target;
final List<IndicesAliasesRequest.AliasActions> aliasActions = req.getAliasActions();
List<String> indexes = new ArrayList<String>();
for (int i = 0, len = aliasActions.size(); i < len; i++) {
IndicesAliasesRequest.AliasActions aliasAction = aliasActions.get(i);
String[] indices = aliasAction.indices();
for (String index : indices) {
/**
* 如果在白名单中则不允许写
*/
if (GlobalConfig.getInstance().getSearchWhiteList().contains(index)) {
throw new PressureMeasureError("Cluster Test request can't refresh business index !");
}
if (!Pradar.isClusterTestPrefix(index)) {
index = Pradar.addClusterTestPrefixLower(index);
indices[i] = index;
}
}
aliasAction.indices(indices);
indexes.addAll(Arrays.asList(indices));
}
return indexes;
}
use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class CacheOperationGetAllResInterceptor method getParameter0.
@Override
protected Object[] getParameter0(Advice advice) throws Throwable {
/**
* 压测状态为关闭,如果当前为压测流量则直接报错
*/
if (!PradarSwitcher.isClusterTestEnabled()) {
if (Pradar.isClusterTest()) {
throw new PressureMeasureError(PradarSwitcher.PRADAR_SWITCHER_OFF + ":" + AppNameUtils.appName());
}
return advice.getParameterArray();
}
if (!Pradar.isClusterTest()) {
// 非压测流量
return advice.getParameterArray();
}
Object[] parameterArray = advice.getParameterArray();
if (null == parameterArray || parameterArray.length == 0) {
return advice.getParameterArray();
}
if (parameterArray[0] instanceof Map) {
Map o = (Map) parameterArray[0];
Set<Map.Entry> set = o.entrySet();
LinkedHashMap<Object, Object> objectObjectLinkedHashMap = Maps.newLinkedHashMap();
for (Map.Entry o1 : set) {
if (o1.getKey() instanceof ClusterTestCacheWrapperKey) {
objectObjectLinkedHashMap.put(((ClusterTestCacheWrapperKey) o1.getKey()).getKey(), o1.getValue());
} else {
objectObjectLinkedHashMap.put(o1.getKey(), o1.getValue());
}
}
parameterArray[0] = objectObjectLinkedHashMap;
} else if (parameterArray[0] instanceof Iterable) {
Iterable<? extends Map.Entry> o = (Iterable) parameterArray[0];
if (null != o) {
ArrayList<? extends Map.Entry> objects = Lists.newArrayList();
Iterator iterator = o.iterator();
HashMap objectObjectHashMap = Maps.newHashMap();
while (iterator.hasNext()) {
Map.Entry next = (Map.Entry) iterator.next();
Object key = next.getKey();
if (key instanceof ClusterTestCacheWrapperKey) {
objectObjectHashMap.put(((ClusterTestCacheWrapperKey) key).getKey(), next.getValue());
} else {
objectObjectHashMap.put(key, next.getValue());
}
}
objects.addAll(objectObjectHashMap.entrySet());
parameterArray[0] = objects;
}
}
return parameterArray;
}
Aggregations