use of com.alipay.lookout.api.Metric in project sofa-rpc by sofastack.
the class RpcLookoutTest method testFutureServiceStats.
/**
* test provider service stats
*/
@Test
public void testFutureServiceStats() {
// future
for (int i = 0; i < 4; i++) {
try {
lookoutService.sayFuture("lookout_future");
SofaResponseFuture.getResponse(3000, true);
} catch (Exception e) {
LOGGER.error("future error", e);
}
}
try {
TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
String methodName = "sayFuture";
Metric metric = fetchWithNameAndMethod("rpc.provider.service.stats", methodName);
if (metric == null) {
Assert.fail("no provider metric was found null");
}
assertMethod(metric, true, 4, methodName, 0, 0);
Metric consumerMetric = fetchWithNameAndMethod("rpc.consumer.service.stats", methodName);
if (consumerMetric == null) {
Assert.fail("no consumer metric was found null");
}
assertMethod(consumerMetric, false, 4, methodName, 1620, 534);
}
use of com.alipay.lookout.api.Metric in project sofa-rpc by sofastack.
the class RpcLookoutTest method after.
@After
public void after() {
final Registry currentRegistry = Lookout.registry();
// clear all metrics now
Iterator<Metric> itar = currentRegistry.iterator();
while (itar.hasNext()) {
Metric metric = itar.next();
Id id = metric.id();
currentRegistry.removeMetric(id);
}
if (serverConfig != null) {
serverConfig.destroy();
}
if (providerConfig != null) {
providerConfig.unExport();
}
if (consumerConfig != null) {
consumerConfig.unRefer();
}
}
use of com.alipay.lookout.api.Metric in project sofa-rpc by sofastack.
the class RpcLookoutTest method testThreadPoolConfig.
/**
* test thread pool config
*
* @throws Exception Exception
*/
@Test
public void testThreadPoolConfig() throws Exception {
Metric metric = fetchWithNameAndMethod("rpc.bolt.threadpool.config", "");
Collection<Measurement> measurements = metric.measure().measurements();
assertTrue(measurements.size() == 1);
for (Measurement measurement : measurements) {
// 判断ThreadPool启动配置
Object obj = measurement.value();
assertEquals(30, corePoolSize.get(obj));
assertEquals(500, maxPoolSize.get(obj));
assertEquals(600, queueSize.get(obj));
}
}
use of com.alipay.lookout.api.Metric in project sofa-rpc by sofastack.
the class RpcLookoutTest method beforeClass.
@BeforeClass
public static void beforeClass() {
RpcRunningState.setUnitTestMode(false);
try {
Class clazz = RpcLookout.class;
Class[] innerClazzs = clazz.getDeclaredClasses();
for (Class cls : innerClazzs) {
if (cls.getName().contains("ThreadPoolConfig")) {
corePoolSize = cls.getDeclaredField("corePoolSize");
corePoolSize.setAccessible(true);
maxPoolSize = cls.getDeclaredField("maxPoolSize");
maxPoolSize.setAccessible(true);
queueSize = cls.getDeclaredField("queueSize");
queueSize.setAccessible(true);
}
}
} catch (Exception e) {
LOGGER.error("", e);
}
Registry registry = new DefaultRegistry();
final Registry currentRegistry = Lookout.registry();
if (currentRegistry == NoopRegistry.INSTANCE) {
Lookout.setRegistry(registry);
} else {
// clear all metrics now
Iterator<Metric> itar = currentRegistry.iterator();
while (itar.hasNext()) {
Metric metric = itar.next();
Id id = metric.id();
currentRegistry.removeMetric(id);
}
}
}
Aggregations