(
ClientStatusRequest request, StreamObserver<ClientStatusResponse> responseObserver)
| 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); |
no test coverage detected