use of org.apache.servicecomb.foundation.common.cache.VersionedCache in project java-chassis by ServiceComb.
the class TestDateTimeSchema method testDateTimeSchemaMulticast.
private void testDateTimeSchemaMulticast() throws Exception {
DiscoveryContext context = new DiscoveryContext();
VersionedCache serversVersionedCache = discoveryTree.discovery(context, "springmvctest", "springmvc", "0+");
List<String> enpoints = serversVersionedCache.data();
for (String endpoint : enpoints) {
InvocationContext invocationContext = new InvocationContext();
invocationContext.addLocalContext(LoadbalanceHandler.SERVICECOMB_SERVER_ENDPOINT, endpoint);
Date date = new Date();
TestMgr.check(date.getTime(), dateTimeSchemaWithContextInf.getDate(invocationContext, date).getTime());
invocationContext = new InvocationContext();
invocationContext.addLocalContext(LoadbalanceHandler.SERVICECOMB_SERVER_ENDPOINT, parseEndpoint(endpoint));
date = new Date();
TestMgr.check(date.getTime(), dateTimeSchemaWithContextInf.getDate(invocationContext, date).getTime());
}
}
use of org.apache.servicecomb.foundation.common.cache.VersionedCache 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.foundation.common.cache.VersionedCache in project java-chassis by ServiceComb.
the class TestDiscoveryTree method getOrCreateRoot_expired.
@Test
public void getOrCreateRoot_expired() {
Deencapsulation.setField(discoveryTree, "root", parent);
VersionedCache inputCache = new VersionedCache().cacheVersion(parent.cacheVersion() + 1);
DiscoveryTreeNode root = discoveryTree.getOrCreateRoot(inputCache);
Assert.assertEquals(inputCache.cacheVersion(), root.cacheVersion());
Assert.assertSame(Deencapsulation.getField(discoveryTree, "root"), root);
}
use of org.apache.servicecomb.foundation.common.cache.VersionedCache in project java-chassis by ServiceComb.
the class TestDiscoveryTreeNode method fromCache.
@Test
public void fromCache() {
Object data = new Object();
VersionedCache other = new VersionedCache().cacheVersion(1).name("cache").data(data);
node.fromCache(other);
Assert.assertEquals(1, node.cacheVersion());
Assert.assertEquals("cache", node.name());
Assert.assertSame(data, node.data());
}
use of org.apache.servicecomb.foundation.common.cache.VersionedCache in project java-chassis by ServiceComb.
the class LoadbalanceHandler method getOrCreateLoadBalancer.
protected LoadBalancer getOrCreateLoadBalancer(Invocation invocation) {
DiscoveryContext context = new DiscoveryContext();
context.setInputParameters(invocation);
VersionedCache serversVersionedCache = discoveryTree.discovery(context, invocation.getAppId(), invocation.getMicroserviceName(), invocation.getMicroserviceVersionRule());
invocation.addLocalContext(CONTEXT_KEY_SERVER_LIST, serversVersionedCache.data());
return loadBalancerMap.computeIfAbsent(serversVersionedCache.name(), name -> createLoadBalancer(invocation.getMicroserviceName()));
}
Aggregations