Search in sources :

Example 1 with BuildAgentClientException

use of org.jboss.pnc.buildagent.client.BuildAgentClientException in project pnc by project-ncl.

the class DefaultClientFactory method createHttpBuildAgentClient.

@Override
public BuildAgentClient createHttpBuildAgentClient(String terminalUrl, String executionId, Map<String, String> callbackHeaders, List<Request.Header> requestHeaders) throws BuildAgentClientException {
    List<Request.Header> headers = callbackHeaders.entrySet().stream().map(e -> new Request.Header(e.getKey(), e.getValue())).collect(Collectors.toList());
    HttpClientConfiguration configuration = null;
    try {
        URL callbackUrl = new URL(StringUtils.stripEndingSlash(pncBaseUrl) + "/build-execution/" + executionId + "/completed");
        Request callback = new Request(Request.Method.POST, callbackUrl.toURI(), headers);
        configuration = HttpClientConfiguration.newBuilder().termBaseUrl(terminalUrl).callback(callback).livenessResponseTimeout(30000L).retryConfig(retryConfig).requestHeaders(requestHeaders).build();
    } catch (MalformedURLException | URISyntaxException e) {
        new BuildAgentClientException("Invalid callback URL.", e);
    }
    return new BuildAgentHttpClient(httpClient, configuration);
}
Also used : BuildAgentClient(org.jboss.pnc.buildagent.client.BuildAgentClient) GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) StringUtils(org.jboss.pnc.common.util.StringUtils) Inject(javax.inject.Inject) BuildAgentSocketClient(org.jboss.pnc.buildagent.client.BuildAgentSocketClient) PreDestroy(javax.annotation.PreDestroy) RetryConfig(org.jboss.pnc.buildagent.api.httpinvoke.RetryConfig) Map(java.util.Map) BuildAgentHttpClient(org.jboss.pnc.buildagent.client.BuildAgentHttpClient) SocketClientConfiguration(org.jboss.pnc.buildagent.client.SocketClientConfiguration) HttpClientConfiguration(org.jboss.pnc.buildagent.client.HttpClientConfiguration) Logger(org.slf4j.Logger) TaskStatusUpdateEvent(org.jboss.pnc.buildagent.api.TaskStatusUpdateEvent) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) List(java.util.List) BuildAgentClientException(org.jboss.pnc.buildagent.client.BuildAgentClientException) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) Request(org.jboss.pnc.api.dto.Request) TermdBuildDriverModuleConfig(org.jboss.pnc.common.json.moduleconfig.TermdBuildDriverModuleConfig) ApplicationScoped(javax.enterprise.context.ApplicationScoped) HttpClient(org.jboss.pnc.buildagent.common.http.HttpClient) ResponseMode(org.jboss.pnc.buildagent.api.ResponseMode) MalformedURLException(java.net.MalformedURLException) BuildAgentHttpClient(org.jboss.pnc.buildagent.client.BuildAgentHttpClient) Request(org.jboss.pnc.api.dto.Request) BuildAgentClientException(org.jboss.pnc.buildagent.client.BuildAgentClientException) URISyntaxException(java.net.URISyntaxException) HttpClientConfiguration(org.jboss.pnc.buildagent.client.HttpClientConfiguration) URL(java.net.URL)

Aggregations

IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 TimeoutException (java.util.concurrent.TimeoutException)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 PostConstruct (javax.annotation.PostConstruct)1 PreDestroy (javax.annotation.PreDestroy)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Inject (javax.inject.Inject)1 Request (org.jboss.pnc.api.dto.Request)1 ResponseMode (org.jboss.pnc.buildagent.api.ResponseMode)1 TaskStatusUpdateEvent (org.jboss.pnc.buildagent.api.TaskStatusUpdateEvent)1 RetryConfig (org.jboss.pnc.buildagent.api.httpinvoke.RetryConfig)1 BuildAgentClient (org.jboss.pnc.buildagent.client.BuildAgentClient)1 BuildAgentClientException (org.jboss.pnc.buildagent.client.BuildAgentClientException)1