use of org.apache.servicecomb.serviceregistry.consumer.AppManager in project incubator-servicecomb-java-chassis by apache.
the class AbstractServiceRegistry method initAppManager.
protected void initAppManager() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
appManager = new AppManager(eventBus);
// we did not remove old InstanceCacheManager now
// microserviceVersionFactoryClass is null, means use old InstanceCacheManager
// must not throw exception
String microserviceVersionFactoryClass = serviceRegistryConfig.getMicroserviceVersionFactory();
if (microserviceVersionFactoryClass == null) {
return;
}
MicroserviceVersionFactory microserviceVersionFactory = (MicroserviceVersionFactory) Class.forName(microserviceVersionFactoryClass).newInstance();
appManager.setMicroserviceVersionFactory(microserviceVersionFactory);
LOGGER.info("microserviceVersionFactory is {}.", microserviceVersionFactoryClass);
}
use of org.apache.servicecomb.serviceregistry.consumer.AppManager in project incubator-servicecomb-java-chassis by apache.
the class OperationInstancesDiscoveryFilter method groupByVersion.
protected Map<MicroserviceVersionMeta, Map<String, MicroserviceInstance>> groupByVersion(Invocation invocation, Map<String, MicroserviceInstance> instances) {
OperationMeta latestOperationMeta = invocation.getOperationMeta();
MicroserviceMeta latestMicroserviceMeta = latestOperationMeta.getSchemaMeta().getMicroserviceMeta();
AppManager appManager = RegistryUtils.getServiceRegistry().getAppManager();
MicroserviceVersions MicroserviceVersions = appManager.getOrCreateMicroserviceVersions(latestMicroserviceMeta.getAppId(), latestMicroserviceMeta.getName());
Map<MicroserviceVersionMeta, Map<String, MicroserviceInstance>> versionMap = new IdentityHashMap<>();
for (MicroserviceInstance instance : instances.values()) {
MicroserviceVersionMeta versionMeta = MicroserviceVersions.getVersion(instance.getServiceId());
Map<String, MicroserviceInstance> versionInstances = versionMap.computeIfAbsent(versionMeta, vm -> {
return new HashMap<>();
});
versionInstances.put(instance.getInstanceId(), instance);
}
return versionMap;
}
Aggregations