use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class ServiceRegistryListener method onCreateMicroserviceVersion.
@EnableExceptionPropagation
@SubscriberOrder(-1000)
@Subscribe
public void onCreateMicroserviceVersion(CreateMicroserviceVersionEvent event) {
// TODO:如果失败,应该标记出错,以便删除MicroserviceVersions
MicroserviceVersion microserviceVersion = event.getMicroserviceVersion();
Microservice microservice = microserviceVersion.getMicroservice();
// not shortName, to support cross app invoke
String microserviceName = microserviceVersion.getMicroserviceName();
MicroserviceMeta microserviceMeta = new MicroserviceMeta(scbEngine, microserviceName, true);
microserviceMeta.setHandlerChain(scbEngine.getConsumerHandlerManager().getOrCreate(microserviceName));
microserviceMeta.setFilterChain(scbEngine.getFilterChainsManager().findConsumerChain(microserviceName));
MicroserviceVersions microserviceVersions = microserviceVersion.getMicroserviceVersions();
microserviceMeta.setMicroserviceVersionsMeta(getMicroserviceVersionsMeta(microserviceVersions));
boolean isServiceCenter = DefinitionConst.REGISTRY_APP_ID.equals(microservice.getAppId()) && DefinitionConst.REGISTRY_SERVICE_NAME.equals(microservice.getServiceName());
// service center better to resolve the problem.
if (!isServiceCenter) {
for (String schemaId : microservice.getSchemas()) {
Swagger swagger = scbEngine.getSwaggerLoader().loadSwagger(microservice, microserviceVersion.getInstances(), schemaId);
// non java-chassis framework.
if (swagger != null) {
microserviceMeta.registerSchemaMeta(schemaId, swagger);
}
}
}
microserviceMeta.putExtData(CORE_MICROSERVICE_VERSION, microserviceVersion);
microserviceVersion.getVendorExtensions().put(CORE_MICROSERVICE_META, microserviceMeta);
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class LocalRegistryServerTest method testGetAllMicroservice.
private void testGetAllMicroservice() {
List<Microservice> microserviceList = DiscoveryManager.INSTANCE.getAllMicroservices();
int expectedCount = 0;
for (Microservice m : microserviceList) {
if (m.getServiceName().equals("demo-local-registry-client") || m.getServiceName().equals("demo-local-registry-server") || m.getServiceName().equals("demo-local-registry-server-bean")) {
expectedCount++;
}
}
TestMgr.check(3, expectedCount);
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class MultiRegistriesServerTestCase method testGetAllMicroservice.
private void testGetAllMicroservice() {
List<Microservice> microserviceList = DiscoveryManager.INSTANCE.getAllMicroservices();
Set<String> names = new HashSet<>();
for (Microservice m : microserviceList) {
if (m.getServiceName().equals("demo-multi-registries-client") || m.getServiceName().equals("demo-multi-registries-server") || m.getServiceName().equals("thirdParty-service-center") || m.getServiceName().equals("thirdParty-no-schema-server")) {
names.add(m.getServiceName());
}
}
TestMgr.check(4, names.size());
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class HealthMonitorDataProvider method getMonitorData.
private MonitorData getMonitorData() {
Collection<HystrixCommandMetrics> instances = HystrixCommandMetrics.getInstances();
MonitorData monitorData = new MonitorData();
Microservice microservice = RegistryUtils.getMicroservice();
MicroserviceInstance microserviceInstance = RegistryUtils.getMicroserviceInstance();
monitorData.setAppId(microservice.getAppId());
monitorData.setName(microservice.getServiceName());
monitorData.setVersion(microservice.getVersion());
monitorData.setServiceId(microservice.getServiceId());
monitorData.setInstance(microserviceInstance.getHostName());
monitorData.setInstanceId(microserviceInstance.getInstanceId());
if (MonitorConstant.insCacheEnabled()) {
InstanceCacheChecker checker = new InstanceCacheChecker(DiscoveryManager.INSTANCE.getAppManager());
monitorData.setProvidersCache(checker.check().getProducers());
}
exactProcessInfo(monitorData);
synchronized (lock) {
if (this.instanceCacheSummary != null) {
Diagnosis diagnosis = new Diagnosis();
diagnosis.setInstanceCache(instanceCacheSummary);
monitorData.setDiagnosis(diagnosis);
this.instanceCacheSummary = null;
}
}
if (instances.isEmpty()) {
return monitorData;
}
for (HystrixCommandMetrics instance : instances) {
monitorData.appendInterfaceInfo(instance);
}
return monitorData;
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class DarklaunchServerListFilter method divideServerGroup.
private void divideServerGroup(List<ServiceCombServer> serverList, DarklaunchRule rule, List<ServiceCombServer> defaultGroup) {
for (ServiceCombServer server : serverList) {
boolean hasGroup = false;
for (DarklaunchRuleItem item : rule.getRuleItems()) {
Microservice microservice = MicroserviceCache.getInstance().getService(server.getInstance().getServiceId());
item.getGroupCondition().setActual(DarklaunchRule.PROP_VERSION, microservice.getVersion());
if (item.getGroupCondition().match()) {
item.addServer(server);
hasGroup = true;
}
}
if (!hasGroup) {
defaultGroup.add(server);
}
}
}
Aggregations