use of com.alipay.sofa.rpc.metrics.lookout.RpcLookoutId in project sofa-rpc by sofastack.
the class ConsumerSubTest method testSubLookout.
@Test
public void testSubLookout() {
Registry registry = new DefaultRegistry();
if (Lookout.registry() == NoopRegistry.INSTANCE) {
Lookout.setRegistry(registry);
}
LookoutModule lookoutModule = new LookoutModule();
Assert.assertEquals(true, lookoutModule.needLoad());
lookoutModule.install();
ConsumerConfig consumerConfig = new ConsumerConfig();
consumerConfig.setInterfaceId("a");
EventBus.post(new ConsumerSubEvent(consumerConfig));
try {
TimeUnit.SECONDS.sleep(5);
} catch (InterruptedException e) {
e.printStackTrace();
}
RpcLookoutId rpcLookoutId = new RpcLookoutId();
InfoWrapper result = Lookout.registry().get(rpcLookoutId.fetchConsumerSubId());
final Object value = result.value();
Assert.assertTrue(value instanceof ConsumerConfig);
consumerConfig = (ConsumerConfig) value;
Assert.assertEquals("a", consumerConfig.getInterfaceId());
}
use of com.alipay.sofa.rpc.metrics.lookout.RpcLookoutId in project sofa-rpc by sofastack.
the class ProviderPubTest method testPubLookout.
@Test
public void testPubLookout() {
Registry registry = new DefaultRegistry();
if (Lookout.registry() == NoopRegistry.INSTANCE) {
Lookout.setRegistry(registry);
}
LookoutModule lookoutModule = new LookoutModule();
Assert.assertEquals(true, lookoutModule.needLoad());
lookoutModule.install();
ProviderConfig providerConfig = new ProviderConfig();
providerConfig.setInterfaceId("a");
EventBus.post(new ProviderPubEvent(providerConfig));
try {
TimeUnit.SECONDS.sleep(5);
} catch (InterruptedException e) {
e.printStackTrace();
}
RpcLookoutId rpcLookoutId = new RpcLookoutId();
InfoWrapper result = Lookout.registry().get(rpcLookoutId.fetchProviderPubId());
final Object value = result.value();
Assert.assertTrue(value instanceof ProviderConfig);
providerConfig = (ProviderConfig) value;
Assert.assertEquals("a", providerConfig.getInterfaceId());
}
Aggregations