use of org.apache.servicecomb.core.Transport in project incubator-servicecomb-java-chassis by apache.
the class AbstractEndpointsCache method createEndpoints.
protected List<ENDPOINT> createEndpoints(Map<String, List<CacheEndpoint>> transportMap) {
List<ENDPOINT> tmpEndpoints = new ArrayList<>();
for (Entry<String, List<CacheEndpoint>> entry : transportMap.entrySet()) {
Transport transport = transportManager.findTransport(entry.getKey());
if (transport == null) {
continue;
}
List<CacheEndpoint> endpointList = entry.getValue();
if (endpointList == null) {
continue;
}
for (CacheEndpoint cacheEndpoint : endpointList) {
ENDPOINT endpoint = createEndpoint(transport, cacheEndpoint);
tmpEndpoints.add(endpoint);
}
}
return tmpEndpoints;
}
use of org.apache.servicecomb.core.Transport in project incubator-servicecomb-java-chassis by apache.
the class TransportManager method groupByName.
protected Map<String, List<Transport>> groupByName() {
Map<String, List<Transport>> groups = new HashMap<>();
for (Transport transport : transports) {
List<Transport> list = groups.computeIfAbsent(transport.getName(), name -> {
return new ArrayList<>();
});
list.add(transport);
}
return groups;
}
use of org.apache.servicecomb.core.Transport in project incubator-servicecomb-java-chassis by apache.
the class TransportManager method buildTransportMap.
protected void buildTransportMap() {
Map<String, List<Transport>> groups = groupByName();
for (Entry<String, List<Transport>> entry : groups.entrySet()) {
List<Transport> group = entry.getValue();
checkTransportGroup(group);
Transport transport = chooseOneTransport(group);
transportMap.put(transport.getName(), transport);
}
}
use of org.apache.servicecomb.core.Transport in project incubator-servicecomb-java-chassis by apache.
the class TransportManager method init.
public void init() throws Exception {
buildTransportMap();
for (Transport transport : transportMap.values()) {
if (transport.init()) {
Endpoint endpoint = transport.getPublishEndpoint();
if (endpoint != null && endpoint.getEndpoint() != null) {
LOGGER.info("endpoint to publish: {}", endpoint.getEndpoint());
Microservice microservice = RegistryUtils.getMicroservice();
microservice.getInstance().getEndpoints().add(endpoint.getEndpoint());
}
continue;
}
}
}
use of org.apache.servicecomb.core.Transport in project incubator-servicecomb-java-chassis by apache.
the class TransportClientHandler method handle.
@Override
public void handle(Invocation invocation, AsyncResponse asyncResp) throws Exception {
Transport transport = invocation.getTransport();
log.debug("Sending request {} to {}", invocation.getMicroserviceQualifiedName(), invocation.getEndpoint().getEndpoint());
transport.send(invocation, asyncResp);
}
Aggregations