Search in sources :

Example 1 with BuildAgentHttpClient

use of org.jboss.pnc.buildagent.client.BuildAgentHttpClient 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)

Example 2 with BuildAgentHttpClient

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

the class EAPModulesAccessTest method shouldBeAbleToCreteBuildAgentClient.

/**
 * Requires access to undertow-core because of HttpClient usage
 */
@Test
public void shouldBeAbleToCreteBuildAgentClient() throws BuildAgentClientException {
    HttpClientConfiguration configuration = HttpClientConfiguration.newBuilder().termBaseUrl("http://localhost/").livenessResponseTimeout(30000L).build();
    BuildAgentClient client = new BuildAgentHttpClient(configuration);
    Assert.assertNotNull(client);
}
Also used : BuildAgentHttpClient(org.jboss.pnc.buildagent.client.BuildAgentHttpClient) BuildAgentClient(org.jboss.pnc.buildagent.client.BuildAgentClient) HttpClientConfiguration(org.jboss.pnc.buildagent.client.HttpClientConfiguration) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest)

Aggregations

BuildAgentClient (org.jboss.pnc.buildagent.client.BuildAgentClient)2 BuildAgentHttpClient (org.jboss.pnc.buildagent.client.BuildAgentHttpClient)2 HttpClientConfiguration (org.jboss.pnc.buildagent.client.HttpClientConfiguration)2 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