use of org.apache.servicecomb.serviceregistry.version.VersionRule in project incubator-servicecomb-java-chassis by apache.
the class TestCompatiblePathVersionMapper method createVersionRule_32767.
@Test
public void createVersionRule_32767() {
VersionRule versionRule = mapper.getOrCreate("v32767");
Assert.assertEquals("32767.0.0+", versionRule.getVersionRule());
}
use of org.apache.servicecomb.serviceregistry.version.VersionRule in project incubator-servicecomb-java-chassis by apache.
the class LocalServiceRegistryClientImpl method findServiceInstances.
@Override
public MicroserviceInstances findServiceInstances(String selfMicroserviceId, String appId, String serviceName, String strVersionRule, String revision) {
int currentRevision = this.revision.get();
List<MicroserviceInstance> allInstances = new ArrayList<>();
MicroserviceInstances microserviceInstances = new MicroserviceInstances();
FindInstancesResponse response = new FindInstancesResponse();
if (revision != null && currentRevision == Integer.parseInt(revision)) {
microserviceInstances.setNeedRefresh(false);
return microserviceInstances;
}
microserviceInstances.setRevision(String.valueOf(currentRevision));
VersionRule versionRule = VersionRuleUtils.getOrCreate(strVersionRule);
Microservice latestMicroservice = findLatest(appId, serviceName, versionRule);
if (latestMicroservice == null) {
response.setInstances(allInstances);
microserviceInstances.setInstancesResponse(response);
return microserviceInstances;
}
Version latestVersion = VersionUtils.getOrCreate(latestMicroservice.getVersion());
for (Entry<String, Microservice> entry : microserviceIdMap.entrySet()) {
Microservice microservice = entry.getValue();
if (!isSameMicroservice(microservice, appId, serviceName)) {
continue;
}
Version version = VersionUtils.getOrCreate(entry.getValue().getVersion());
if (!versionRule.isMatch(version, latestVersion)) {
continue;
}
Map<String, MicroserviceInstance> instances = microserviceInstanceMap.get(entry.getValue().getServiceId());
allInstances.addAll(instances.values());
}
response.setInstances(allInstances);
microserviceInstances.setInstancesResponse(response);
return microserviceInstances;
}
use of org.apache.servicecomb.serviceregistry.version.VersionRule in project incubator-servicecomb-java-chassis by apache.
the class LocalServiceRegistryClientImpl method getMicroserviceId.
@Override
public String getMicroserviceId(String appId, String microserviceName, String strVersionRule) {
VersionRule versionRule = VersionRuleUtils.getOrCreate(strVersionRule);
Microservice latest = findLatest(appId, microserviceName, versionRule);
return latest != null ? latest.getServiceId() : null;
}
use of org.apache.servicecomb.serviceregistry.version.VersionRule in project incubator-servicecomb-java-chassis by apache.
the class OperationInstancesDiscoveryFilter method initOperationNodes.
protected Map<String, DiscoveryTreeNode> initOperationNodes(DiscoveryTreeNode parent, Map<MicroserviceVersionMeta, Map<String, MicroserviceInstance>> versionMap) {
Map<String, DiscoveryTreeNode> tmpChildren = new ConcurrentHashMapEx<>();
versionMap.keySet().stream().sorted(Comparator.comparing(MicroserviceVersion::getVersion)).forEach(meta -> {
for (OperationMeta operationMeta : meta.getMicroserviceMeta().getOperations()) {
tmpChildren.computeIfAbsent(operationMeta.getMicroserviceQualifiedName(), qualifiedName -> {
VersionRule versionRule = VersionRuleUtils.getOrCreate(meta.getVersion().getVersion() + "+");
return new DiscoveryTreeNode().attribute(VERSION_RULE, versionRule).subName(parent, versionRule.getVersionRule()).data(new HashMap<>());
});
}
});
return tmpChildren;
}
use of org.apache.servicecomb.serviceregistry.version.VersionRule in project incubator-servicecomb-java-chassis by apache.
the class TestCompatiblePathVersionMapper method getOrCreate.
@Test
public void getOrCreate() {
VersionRule versionRule = mapper.getOrCreate("v1");
Assert.assertEquals("1.0.0-2.0.0", versionRule.getVersionRule());
}
Aggregations