use of org.apache.servicecomb.serviceregistry.api.response.FindInstancesResponse in project incubator-servicecomb-java-chassis by apache.
the class TestMicroserviceVersions method setUp.
@Before
public void setUp() throws Exception {
microserviceInstances = new MicroserviceInstances();
findInstancesResponse = new FindInstancesResponse();
}
use of org.apache.servicecomb.serviceregistry.api.response.FindInstancesResponse in project incubator-servicecomb-java-chassis by apache.
the class TestMicroserviceInstances method setUp.
@Before
public void setUp() throws Exception {
microserviceInstances = new MicroserviceInstances();
findInstancesResponse = new FindInstancesResponse();
instances = new ArrayList<>();
instances.add(Mockito.mock(MicroserviceInstance.class));
}
use of org.apache.servicecomb.serviceregistry.api.response.FindInstancesResponse in project incubator-servicecomb-java-chassis by apache.
the class TestAppManager method setUp.
@Before
public void setUp() throws Exception {
microserviceInstances = new MicroserviceInstances();
findInstancesResponse = new FindInstancesResponse();
findInstancesResponse.setInstances(Collections.emptyList());
microserviceInstances.setInstancesResponse(findInstancesResponse);
}
use of org.apache.servicecomb.serviceregistry.api.response.FindInstancesResponse in project incubator-servicecomb-java-chassis by apache.
the class TestMicroserviceManager method setUp.
@Before
public void setUp() throws Exception {
microserviceInstances = new MicroserviceInstances();
findInstancesResponse = new FindInstancesResponse();
findInstancesResponse.setInstances(Collections.emptyList());
microserviceInstances.setInstancesResponse(findInstancesResponse);
}
use of org.apache.servicecomb.serviceregistry.api.response.FindInstancesResponse 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;
}
Aggregations