use of org.apache.servicecomb.core.definition.MicroserviceMeta in project incubator-servicecomb-java-chassis by apache.
the class HighwayServerInvoke method doInit.
private void doInit(TcpConnection connection, long msgId, RequestHeader header, Buffer bodyBuffer) throws Exception {
this.connection = connection;
this.msgId = msgId;
this.header = header;
MicroserviceMeta microserviceMeta = microserviceMetaManager.ensureFindValue(header.getDestMicroservice());
SchemaMeta schemaMeta = microserviceMeta.ensureFindSchemaMeta(header.getSchemaId());
this.operationMeta = schemaMeta.ensureFindOperation(header.getOperationName());
this.operationProtobuf = ProtobufManager.getOrCreateOperation(operationMeta);
this.bodyBuffer = bodyBuffer;
}
use of org.apache.servicecomb.core.definition.MicroserviceMeta 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.core.definition.MicroserviceMeta in project incubator-servicecomb-java-chassis by apache.
the class MockUtil method mockRegisterManager.
public void mockRegisterManager() throws InstantiationException, IllegalAccessException {
MicroserviceMeta microserviceMeta = microserviceMetaManager.getOrCreateMicroserviceMeta("app:test");
microserviceMeta.putExtData("RestServicePathManager", new ServicePathManager(microserviceMeta));
ConsumerSchemaFactory consumerSchemaFactory = new MockUp<ConsumerSchemaFactory>() {
@Mock
public MicroserviceMeta getOrCreateConsumer(String microserviceName) {
return microserviceMeta;
}
}.getMockInstance();
CseContext.getInstance().setConsumerSchemaFactory(consumerSchemaFactory);
}
use of org.apache.servicecomb.core.definition.MicroserviceMeta in project incubator-servicecomb-java-chassis by apache.
the class CseClientHttpRequest method createRequestMeta.
private RequestMeta createRequestMeta(String httpMetod, URI uri) {
String microserviceName = uri.getAuthority();
ReferenceConfig referenceConfig = ReferenceConfigUtils.getForInvoke(microserviceName);
MicroserviceMeta microserviceMeta = referenceConfig.getMicroserviceMeta();
ServicePathManager servicePathManager = ServicePathManager.getServicePathManager(microserviceMeta);
if (servicePathManager == null) {
throw new Error(String.format("no schema defined for %s:%s", microserviceMeta.getAppId(), microserviceMeta.getName()));
}
OperationLocator locator = servicePathManager.consumerLocateOperation(path, httpMetod);
RestOperationMeta swaggerRestOperation = locator.getOperation();
Map<String, String> pathParams = locator.getPathVarMap();
return new RequestMeta(referenceConfig, swaggerRestOperation, pathParams);
}
use of org.apache.servicecomb.core.definition.MicroserviceMeta in project incubator-servicecomb-java-chassis by apache.
the class Invoker method prepare.
protected void prepare() {
referenceConfig = ReferenceConfigUtils.getForInvoke(microserviceName);
MicroserviceMeta microserviceMeta = referenceConfig.getMicroserviceMeta();
if (StringUtils.isEmpty(schemaId)) {
// 未指定schemaId,看看consumer接口是否等于契约接口
schemaMeta = microserviceMeta.findSchemaMeta(consumerIntf);
if (schemaMeta == null) {
// 尝试用consumer接口名作为schemaId
schemaId = consumerIntf.getName();
schemaMeta = microserviceMeta.ensureFindSchemaMeta(schemaId);
}
} else {
schemaMeta = microserviceMeta.ensureFindSchemaMeta(schemaId);
}
this.swaggerConsumer = CseContext.getInstance().getSwaggerEnvironment().createConsumer(consumerIntf, schemaMeta.getSwaggerIntf());
}
Aggregations