MCPcopy Create free account
hub / github.com/grpc/grpc-java / handleRequest

Method handleRequest

xds/src/main/java/io/grpc/xds/CsdsService.java:120–162  ·  view source on GitHub ↗
(
      ClientStatusRequest request, StreamObserver<ClientStatusResponse> responseObserver)

Source from the content-addressed store, hash-verified

118 }
119
120 private boolean handleRequest(
121 ClientStatusRequest request, StreamObserver<ClientStatusResponse> responseObserver) {
122 StatusException error = null;
123
124 if (request.getNodeMatchersCount() > 0) {
125 error = new StatusException(
126 Status.INVALID_ARGUMENT.withDescription("node_matchers not supported"));
127 } else {
128 List<String> targets = xdsClientPoolFactory.getTargets();
129 List<ClientConfig> clientConfigs = new ArrayList<>(targets.size());
130
131 for (int i = 0; i < targets.size() && error == null; i++) {
132 try {
133 ClientConfig clientConfig = getConfigForRequest(targets.get(i));
134 if (clientConfig != null) {
135 clientConfigs.add(clientConfig);
136 }
137 } catch (InterruptedException e) {
138 Thread.currentThread().interrupt();
139 logger.log(Level.FINE, "Server interrupted while building CSDS config dump", e);
140 error = Status.ABORTED.withDescription("Thread interrupted").withCause(e).asException();
141 } catch (RuntimeException e) {
142 logger.log(Level.WARNING, "Unexpected error while building CSDS config dump", e);
143 error = Status.INTERNAL.withDescription("Unexpected internal error").withCause(e)
144 .asException();
145 }
146 }
147
148 try {
149 responseObserver.onNext(getStatusResponse(clientConfigs));
150 } catch (RuntimeException e) {
151 logger.log(Level.WARNING, "Unexpected error while processing CSDS config dump", e);
152 error = Status.INTERNAL.withDescription("Unexpected internal error").withCause(e)
153 .asException();
154 }
155 }
156
157 if (error == null) {
158 return true; // All clients reported without error
159 }
160 responseObserver.onError(error);
161 return false;
162 }
163
164 private ClientConfig getConfigForRequest(String target) throws InterruptedException {
165 ObjectPool<XdsClient> xdsClientPool = xdsClientPoolFactory.get(target);

Callers 2

fetchClientStatusMethod · 0.80
onNextMethod · 0.80

Calls 12

getConfigForRequestMethod · 0.95
getStatusResponseMethod · 0.95
withDescriptionMethod · 0.80
asExceptionMethod · 0.80
withCauseMethod · 0.80
getTargetsMethod · 0.65
sizeMethod · 0.65
getMethod · 0.65
addMethod · 0.65
onNextMethod · 0.65
onErrorMethod · 0.65
logMethod · 0.45

Tested by

no test coverage detected