(Listener2 listener)
| 204 | } |
| 205 | |
| 206 | @Override |
| 207 | public void start(Listener2 listener) { |
| 208 | this.listener = checkNotNull(listener, "listener"); |
| 209 | try { |
| 210 | xdsClient = xdsClientPool.getObject(); |
| 211 | } catch (Exception e) { |
| 212 | listener.onError( |
| 213 | Status.UNAVAILABLE.withDescription("Failed to initialize xDS").withCause(e)); |
| 214 | return; |
| 215 | } |
| 216 | BootstrapInfo bootstrapInfo = xdsClient.getBootstrapInfo(); |
| 217 | String listenerNameTemplate; |
| 218 | if (targetAuthority == null || targetAuthority.isEmpty()) { |
| 219 | // Both https://github.com/grpc/proposal/blob/master/A27-xds-global-load-balancing.md and |
| 220 | // A47-xds-federation.md seem to treat an empty authority the same as an undefined one. |
| 221 | listenerNameTemplate = bootstrapInfo.clientDefaultListenerResourceNameTemplate(); |
| 222 | } else { |
| 223 | AuthorityInfo authorityInfo = bootstrapInfo.authorities().get(targetAuthority); |
| 224 | if (authorityInfo == null) { |
| 225 | listener.onError(Status.INVALID_ARGUMENT.withDescription( |
| 226 | "invalid target URI: target authority not found in the bootstrap")); |
| 227 | return; |
| 228 | } |
| 229 | listenerNameTemplate = authorityInfo.clientListenerResourceNameTemplate(); |
| 230 | } |
| 231 | String replacement = serviceAuthority; |
| 232 | if (listenerNameTemplate.startsWith(XDSTP_SCHEME)) { |
| 233 | replacement = XdsClient.percentEncodePath(replacement); |
| 234 | } |
| 235 | String ldsResourceName = expandPercentS(listenerNameTemplate, replacement); |
| 236 | if (!XdsClient.isResourceNameValid(ldsResourceName, XdsListenerResource.getInstance().typeUrl()) |
| 237 | ) { |
| 238 | listener.onError(Status.INVALID_ARGUMENT.withDescription( |
| 239 | "invalid listener resource URI for service authority: " + serviceAuthority)); |
| 240 | return; |
| 241 | } |
| 242 | ldsResourceName = XdsClient.canonifyResourceName(ldsResourceName); |
| 243 | callCounterProvider = SharedCallCounterMap.getInstance(); |
| 244 | |
| 245 | resolveState = new ResolveState(ldsResourceName); |
| 246 | resolveState.start(); |
| 247 | } |
| 248 | |
| 249 | @Override |
| 250 | public void refresh() { |
nothing calls this directly
no test coverage detected