use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestRSAProviderTokenManager method testTokenExpried.
@Test
public void testTokenExpried() {
String tokenStr = "e8a04b54cf2711e7b701286ed488fc20@c8636e5acf1f11e7b701286ed488fc20@1511315597475@9t0tp8ce80SUM5ts6iRGjFJMvCdQ7uvhpyh0RM7smKm3p4wYOrojr4oT1Pnwx7xwgcgEFbQdwPJxIMfivpQ1rHGqiLp67cjACvJ3Ke39pmeAVhybsLADfid6oSjscFaJ@WBYouF6hXYrXzBA31HC3VX8Bw9PNgJUtVqOPAaeW9ye3q/D7WWb0M+XMouBIWxWY6v9Un1dGu5Rkjlx6gZbnlHkb2VO8qFR3Y6lppooWCirzpvEBRjlJQu8LPBur0BCfYGq8XYrEZA2NU6sg2zXieqCSiX6BnMnBHNn4cR9iZpk=";
RSAProviderTokenManager tokenManager = new RSAProviderTokenManager();
MicroserviceInstance microserviceInstance = new MicroserviceInstance();
Map<String, String> properties = new HashMap<>();
microserviceInstance.setProperties(properties);
properties.put(Const.INSTANCE_PUBKEY_PRO, "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCxKl5TNUTec7fL2degQcCk6vKf3c0wsfNK5V6elKzjWxm0MwbRj/UeR20VSnicBmVIOWrBS9LiERPPvjmmWUOSS2vxwr5XfhBhZ07gCAUNxBOTzgMo5nE45DhhZu5Jzt5qSV6o10Kq7+fCCBlDZ1UoWxZceHkUt5AxcrhEDulFjQIDAQAB");
Assert.assertFalse(tokenManager.valid(tokenStr));
}
use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class OperationInstancesDiscoveryFilter method groupByVersion.
protected Map<MicroserviceVersionMeta, Map<String, MicroserviceInstance>> groupByVersion(Invocation invocation, Map<String, MicroserviceInstance> instances) {
OperationMeta latestOperationMeta = invocation.getOperationMeta();
MicroserviceMeta latestMicroserviceMeta = latestOperationMeta.getSchemaMeta().getMicroserviceMeta();
AppManager appManager = RegistryUtils.getServiceRegistry().getAppManager();
MicroserviceVersions MicroserviceVersions = appManager.getOrCreateMicroserviceVersions(latestMicroserviceMeta.getAppId(), latestMicroserviceMeta.getName());
Map<MicroserviceVersionMeta, Map<String, MicroserviceInstance>> versionMap = new IdentityHashMap<>();
for (MicroserviceInstance instance : instances.values()) {
MicroserviceVersionMeta versionMeta = MicroserviceVersions.getVersion(instance.getServiceId());
Map<String, MicroserviceInstance> versionInstances = versionMap.computeIfAbsent(versionMeta, vm -> {
return new HashMap<>();
});
versionInstances.put(instance.getInstanceId(), instance);
}
return versionMap;
}
use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestOperationInstancesDiscoveryFilter method regMicroservice.
private Microservice regMicroservice(String serviceId, String version, Class<?> schemaCls, int instanceCount) {
String schemaId = "sid";
Microservice microservice = new Microservice();
microservice.setServiceId(serviceId);
microservice.setAppId(appId);
microservice.setServiceName(microserviceName);
microservice.setVersion(version);
microservice.setSchemas(Arrays.asList(schemaId));
serviceRegistry.getServiceRegistryClient().registerMicroservice(microservice);
SwaggerGenerator generator = new SwaggerGenerator(swaggerGeneratorContext, schemaCls);
String schemaContent = SwaggerUtils.swaggerToString(generator.generate());
serviceRegistry.getServiceRegistryClient().registerSchema(serviceId, schemaId, schemaContent);
for (int idx = 0; idx < instanceCount; idx++) {
MicroserviceInstance instance = createInstance(serviceId);
serviceRegistry.getServiceRegistryClient().registerMicroserviceInstance(instance);
}
return microservice;
}
use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestIpPortManager method testCreateServiceRegistryCacheWithInstanceCache.
@Test
public void testCreateServiceRegistryCacheWithInstanceCache() {
List<MicroserviceInstance> list = new ArrayList<>();
MicroserviceInstance e1 = new MicroserviceInstance();
list.add(e1);
new MockUp<RegistryUtils>() {
@Mock
public List<MicroserviceInstance> findServiceInstance(String appId, String serviceName, String versionRule) {
return list;
}
};
}
use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class AbstractServiceRegistry method unregisterInstance.
public boolean unregisterInstance() {
MicroserviceInstance microserviceInstance = microservice.getInstance();
boolean result = srClient.unregisterMicroserviceInstance(microserviceInstance.getServiceId(), microserviceInstance.getInstanceId());
if (!result) {
LOGGER.error("Unregister microservice instance failed. microserviceId={} instanceId={}", microserviceInstance.getServiceId(), microserviceInstance.getInstanceId());
return false;
}
LOGGER.info("Unregister microservice instance success. microserviceId={} instanceId={}", microserviceInstance.getServiceId(), microserviceInstance.getInstanceId());
return true;
}
Aggregations