use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class ShadowEsClientHolder method createShadowRestClient.
private static RestClient createShadowRestClient(RestClient target) {
List<String> nodesAddressAsString = getNodesAddressAsString(target);
ShadowEsServerConfig shadowEsServerConfig = findMatchShadowEsServerConfig(nodesAddressAsString);
if (shadowEsServerConfig == null) {
throw new PressureMeasureError(String.format("影子集群未配置,业务节点:%s", StringUtils.join(nodesAddressAsString, ",")));
}
RestClientDefinition restClientDefinition = RestClientDefinitionStrategy.match(target);
return restClientDefinition.solve(target, shadowEsServerConfig);
}
use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class WrapperRequest method readRequest.
private byte[] readRequest(HttpServletRequest request) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ServletInputStream in = request.getInputStream();
byte[] data = new byte[1024];
int len = 0;
while ((len = in.read(data)) != -1) {
bos.write(data, 0, len);
}
return bos.toByteArray();
} catch (IOException e) {
if (Pradar.isClusterTest()) {
throw new PressureMeasureError(e);
}
return null;
}
}
use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class CacheAsMapInterceptor method getResult0.
@Override
protected Object getResult0(Advice advice) {
/**
* 压测状态为关闭,如果当前为压测流量则直接报错
*/
if (!PradarSwitcher.isClusterTestEnabled()) {
if (Pradar.isClusterTest()) {
throw new PressureMeasureError(PradarSwitcher.PRADAR_SWITCHER_OFF + ":" + AppNameUtils.appName());
}
return advice.getReturnObj();
}
boolean clusterTest = Pradar.isClusterTest();
ConcurrentMap returnObj = (ConcurrentMap) advice.getReturnObj();
Set<Map.Entry> set = returnObj.entrySet();
ConcurrentMap concurrentMap = Maps.newConcurrentMap();
for (Map.Entry o : set) {
if (clusterTest && o.getKey() instanceof ClusterTestCacheWrapperKey) {
concurrentMap.put(((ClusterTestCacheWrapperKey) o.getKey()).getKey(), o.getValue());
} else if (!clusterTest && !(o.getKey() instanceof ClusterTestCacheWrapperKey)) {
concurrentMap.put(o.getKey(), o.getValue());
}
}
return concurrentMap;
}
use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class CacheOperationInterceptor method getParameter0.
@Override
protected Object[] getParameter0(Advice advice) throws Throwable {
Object[] parameterArray = advice.getParameterArray();
if (!Pradar.isClusterTest()) {
// 非压测流量
return parameterArray;
}
/**
* 压测状态为关闭,如果当前为压测流量则直接报错
*/
if (!PradarSwitcher.isClusterTestEnabled()) {
if (Pradar.isClusterTest()) {
throw new PressureMeasureError(PradarSwitcher.PRADAR_SWITCHER_OFF + ":" + AppNameUtils.appName());
}
return parameterArray;
}
if (parameterArray.length == 0) {
return parameterArray;
}
if (parameterArray[0] instanceof Map) {
Set<Map.Entry> set = ((Map) parameterArray[0]).entrySet();
HashMap<Object, Object> objectObjectHashMap = new HashMap<Object, Object>();
for (Map.Entry o : set) {
if (o.getKey() instanceof ClusterTestCacheWrapperKey) {
return parameterArray;
}
objectObjectHashMap.put(new ClusterTestCacheWrapperKey(o.getKey()), o.getValue());
}
parameterArray[0] = objectObjectHashMap;
} else if (parameterArray[0] instanceof Iterable) {
Iterable<?> objects = (Iterable<?>) parameterArray[0];
Iterator<?> iterator = objects.iterator();
ArrayList<Object> objects1 = new ArrayList<Object>();
while (iterator.hasNext()) {
Object next = iterator.next();
if (next instanceof ClusterTestCacheWrapperKey) {
return parameterArray;
}
objects1.add(new ClusterTestCacheWrapperKey(next));
}
parameterArray[0] = objects1;
} else {
if (parameterArray[0] instanceof ClusterTestCacheWrapperKey) {
return parameterArray;
}
parameterArray[0] = new ClusterTestCacheWrapperKey(parameterArray[0]);
}
return parameterArray;
}
use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class AbstractTransportClientDefinition method addPtTransportAddress.
protected void addPtTransportAddress(TransportClient transportClient, ShadowEsServerConfig shadowEsServerConfig) {
for (String performanceTestNode : shadowEsServerConfig.getPerformanceTestNodes()) {
try {
HostAndPort hostAndPort = new HostAndPort(performanceTestNode);
transportClient.addTransportAddress(hostAndPort.toTransportAddress());
} catch (UnknownHostException e) {
throw new PressureMeasureError("影子sever nodes配置错误!", e);
}
}
}
Aggregations