use of org.apache.servicecomb.registry.cache.InstanceCache in project java-chassis by ServiceComb.
the class ClassificationAddress method generateZoneAndRegionAddress.
private Map<String, List<String>> generateZoneAndRegionAddress(String key) {
InstanceCache KieCaches = instanceCacheManager.getOrCreate(REGISTRY_APP_ID, key, DefinitionConst.VERSION_RULE_LATEST);
List<CacheEndpoint> CacheEndpoints = new ArrayList<>();
if (REGISTRY_SERVICE_NAME.equals(key)) {
CacheEndpoints = KieCaches.getOrCreateTransportMap().get(defaultTransport);
maxRetryTimes = CacheEndpoints.size();
} else {
if (KieCaches.getInstanceMap().size() <= 0) {
return null;
}
CacheEndpoints = KieCaches.getOrCreateTransportMap().get(defaultTransport);
}
Map<String, List<String>> zoneAndRegion = new HashMap<>();
dataCenterInfo = findRegion(CacheEndpoints);
Set<String> sameZone = new HashSet<>();
Set<String> sameRegion = new HashSet<>();
for (CacheEndpoint cacheEndpoint : CacheEndpoints) {
if (regionAndAZMatch(dataCenterInfo, cacheEndpoint.getInstance())) {
sameZone.add(cacheEndpoint.getEndpoint());
} else {
sameRegion.add(cacheEndpoint.getEndpoint());
}
}
zoneAndRegion.put("sameZone", new ArrayList<>(sameZone));
zoneAndRegion.put("sameRegion", new ArrayList<>(sameRegion));
return zoneAndRegion;
}
use of org.apache.servicecomb.registry.cache.InstanceCache in project java-chassis by ServiceComb.
the class TestClientTimeout method getServiceCombServerStats.
private static ServiceCombServerStats getServiceCombServerStats() {
InstanceCache instanceCache = DiscoveryManager.INSTANCE.getInstanceCacheManager().getOrCreate(RegistrationManager.INSTANCE.getAppId(), "jaxrs", "0+");
org.apache.servicecomb.registry.api.registry.MicroserviceInstance microserviceInstance = instanceCache.getInstanceMap().values().iterator().next();
ServiceCombServer serviceCombServer = ServiceCombLoadBalancerStats.INSTANCE.getServiceCombServer(microserviceInstance);
return ServiceCombLoadBalancerStats.INSTANCE.getServiceCombServerStats(serviceCombServer);
}
use of org.apache.servicecomb.registry.cache.InstanceCache in project java-chassis by ServiceComb.
the class MicroserviceVersionRule method initData.
private void initData(MicroserviceVersionRuleData data) {
if (data.latestVersion == null) {
data.latestVersion = findLatest(data.versions, data.instances.values());
}
data.instanceCache = new InstanceCache(appId, microserviceName, versionRule.getVersionRule(), data.instances);
data.versionedCache = new VersionedCache().name(versionRule.getVersionRule()).autoCacheVersion().data(data.instances);
}
use of org.apache.servicecomb.registry.cache.InstanceCache in project java-chassis by ServiceComb.
the class TestInstanceCache method testCacheChanged.
@Test
public void testCacheChanged() {
InstanceCache newCache = new InstanceCache("testAppID", "testMicroServiceName", "1.0", instanceCache.getInstanceMap());
Assert.assertTrue(instanceCache.cacheChanged(newCache));
}
use of org.apache.servicecomb.registry.cache.InstanceCache in project java-chassis by ServiceComb.
the class TestInstanceCache method beforeClass.
@BeforeClass
public static void beforeClass() {
MicroserviceInstance instance = new MicroserviceInstance();
instance.setStatus(MicroserviceInstanceStatus.UP);
List<String> endpoints = new ArrayList<>();
endpoints.add("rest://127.0.0.1:8080");
instance.setEndpoints(endpoints);
instance.setInstanceId("1");
instMap.put(instance.getInstanceId(), instance);
instanceCache = new InstanceCache("testAppID", "testMicroServiceName", "1.0", instMap);
}
Aggregations