use of com.alipay.sofa.rpc.registry.mesh.model.SubscribeServiceRequest in project sofa-rpc by sofastack.
the class MeshApiClientTest method testSubscribe.
@Test
public void testSubscribe() {
// 11.166.22.163:12200?_TIMEOUT=3000&p=1&_SERIALIZETYPE=protobuf&_WARMUPTIME=0&_WARMUPWEIGHT=10&app_name=bar1&zone=GZ00A&_MAXREADIDLETIME=30&_IDLETIMEOUT=27&v=4.0&_WEIGHT=100&startTime=1524565802559
SubscribeServiceRequest request = new SubscribeServiceRequest();
request.setServiceName("com.alipay.rpc.common.service.facade.pb.SampleServicePb:1.0");
SubscribeServiceResult result = meshApiClient.subscribeService(request);
Assert.assertTrue(result.isSuccess());
}
use of com.alipay.sofa.rpc.registry.mesh.model.SubscribeServiceRequest in project sofa-rpc by sofastack.
the class MeshRegistry method buildSubscribeServiceRequest.
protected SubscribeServiceRequest buildSubscribeServiceRequest(ConsumerConfig consumerConfig) {
String key = MeshRegistryHelper.buildMeshKey(consumerConfig, consumerConfig.getProtocol());
SubscribeServiceRequest subscribeRequest = new SubscribeServiceRequest();
subscribeRequest.setServiceName(key);
return subscribeRequest;
}
use of com.alipay.sofa.rpc.registry.mesh.model.SubscribeServiceRequest in project sofa-rpc by sofastack.
the class MeshRegistry method subscribe.
@Override
public List<ProviderGroup> subscribe(final ConsumerConfig config) {
final ProviderInfoListener providerInfoListener = config.getProviderInfoListener();
asyncCreateConnectionExecutor.execute(new Runnable() {
@Override
public void run() {
final String appName = config.getAppName();
registerAppInfoOnce(appName);
SubscribeServiceRequest subscribeRequest = buildSubscribeServiceRequest(config);
SubscribeServiceResult subscribeServiceResult = client.subscribeService(subscribeRequest);
if (subscribeServiceResult == null || !subscribeServiceResult.isSuccess()) {
throw new RuntimeException("regist consumer occors error," + subscribeRequest);
}
List<ProviderGroup> providerGroups = new ArrayList<ProviderGroup>();
ProviderGroup providerGroup = new ProviderGroup();
List<ProviderInfo> providerInfos = new ArrayList<ProviderInfo>();
String url = fillProtocolAndVersion(subscribeServiceResult, client.getHost(), "", config.getProtocol());
ProviderInfo providerInfo = SofaRegistryHelper.parseProviderInfo(url);
providerInfos.add(providerInfo);
providerGroup.setProviderInfos(providerInfos);
providerGroups.add(providerGroup);
if (EventBus.isEnable(ConsumerSubEvent.class)) {
ConsumerSubEvent event = new ConsumerSubEvent(config);
EventBus.post(event);
}
if (providerInfoListener != null) {
providerInfoListener.updateAllProviders(providerGroups);
}
}
});
// async
return null;
}
Aggregations