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