Search in sources :

Example 1 with ServiceUnavailableException

use of jakarta.ws.rs.ServiceUnavailableException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorDateThrowableTest.

/*
   * @testName: constructorDateThrowableTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:363; JAXRS:JAVADOC:357; JAXRS:JAVADOC:358;
   * JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "service unavailable" exception with a date
   * specifying the "Retry-After" information for the failed request and an
   * underlying request failure cause.
   *
   * Get the retry time for the failed request.
   * 
   * Check if the underlying response contains the information on when is it
   * possible to HttpHeaders#RETRY_AFTER retry the request.
   * 
   * getResponse
   */
public void constructorDateThrowableTest() throws Fault {
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.SECOND, 40);
    for (Throwable t : throwables) {
        ServiceUnavailableException e = new ServiceUnavailableException(calendar.getTime(), t);
        assertResponse(e);
        assertCause(e, t);
        assertRetryTimeMin(e, 40);
        assertHasRetryAfter(e, true);
    }
}
Also used : Calendar(java.util.Calendar) IOException(java.io.IOException) ServiceUnavailableException(jakarta.ws.rs.ServiceUnavailableException)

Example 2 with ServiceUnavailableException

use of jakarta.ws.rs.ServiceUnavailableException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorResponseTest.

/*
   * @testName: constructorResponseTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:362; JAXRS:JAVADOC:357; JAXRS:JAVADOC:358;
   * JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "service unavailable" exception.
   * java.lang.IllegalArgumentException - in case the status code set in the
   * response is not HTTP 503.
   * 
   * Get the retry time for the failed request.
   * 
   * Check if the underlying response contains the information on when is it
   * possible to HttpHeaders#RETRY_AFTER retry the request.
   * 
   * getResponse
   */
public void constructorResponseTest() throws Fault {
    ServiceUnavailableException e = new ServiceUnavailableException(buildResponse(STATUS));
    assertResponse(e, HOST);
    assertRetryTimeIsNull(e, true);
    assertHasRetryAfter(e, false);
}
Also used : ServiceUnavailableException(jakarta.ws.rs.ServiceUnavailableException)

Example 3 with ServiceUnavailableException

use of jakarta.ws.rs.ServiceUnavailableException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringLongTest.

/*
   * @testName: constructorStringLongTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1105; JAXRS:JAVADOC:357; JAXRS:JAVADOC:358;
   * JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "service unavailable" exception with an
   * interval specifying the "Retry-After" information for the failed request.
   * 
   * Get the retry time for the failed request.
   * 
   * Check if the underlying response contains the information on when is it
   * possible to HttpHeaders#RETRY_AFTER retry the request.
   * 
   * getResponse
   */
public void constructorStringLongTest() throws Fault {
    ServiceUnavailableException e = new ServiceUnavailableException(MESSAGE, 5L);
    assertResponse(e);
    assertRetryTimeMin(e, 5);
    assertHasRetryAfter(e, true);
    assertMessage(e);
}
Also used : ServiceUnavailableException(jakarta.ws.rs.ServiceUnavailableException)

Example 4 with ServiceUnavailableException

use of jakarta.ws.rs.ServiceUnavailableException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringLongThrowableTest.

/*
   * @testName: constructorStringLongThrowableTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1109; JAXRS:JAVADOC:357; JAXRS:JAVADOC:358;
   * JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new "service unavailable" exception.
   * java.lang.IllegalArgumentException - in case the status code set in the
   * response is not HTTP 503.
   *
   * Get the retry time for the failed request.
   * 
   * Check if the underlying response contains the information on when is it
   * possible to HttpHeaders#RETRY_AFTER retry the request.
   * 
   * getResponse
   */
public void constructorStringLongThrowableTest() throws Fault {
    Throwable[] throwables = new Throwable[] { new RuntimeException(), new IOException(), new Error(), new Throwable() };
    for (Throwable t : throwables) {
        ServiceUnavailableException e = new ServiceUnavailableException(MESSAGE, 30L, t);
        assertResponse(e);
        assertCause(e, t);
        assertRetryTimeMin(e, 30);
        assertHasRetryAfter(e, true);
        assertMessage(e);
    }
}
Also used : IOException(java.io.IOException) ServiceUnavailableException(jakarta.ws.rs.ServiceUnavailableException)

Example 5 with ServiceUnavailableException

use of jakarta.ws.rs.ServiceUnavailableException in project fscrawler by dadoonet.

the class WorkplaceSearchClient method start.

@Override
public void start() throws IOException {
    logger.debug("Starting Workplace Search client");
    Path jobMappingDir = config.resolve(settings.getName()).resolve("_mappings");
    wpSearchClient = new WPSearchClient(config, jobMappingDir).withHost(settings.getWorkplaceSearch().getServer().decodedUrl()).withUsername(settings.getWorkplaceSearch().getUsername(), settings.getElasticsearch().getUsername()).withPassword(settings.getWorkplaceSearch().getPassword(), settings.getElasticsearch().getPassword()).withBulkSize(settings.getWorkplaceSearch().getBulkSize()).withFlushInterval(settings.getWorkplaceSearch().getFlushInterval());
    wpSearchClient.start();
    try {
        version = wpSearchClient.getVersion();
        logger.info("Workplace Client connected to a node running version {}", version);
        // If the source name is provided, let's use it
        String sourceName = settings.getWorkplaceSearch().getName();
        if (sourceName == null) {
            // If not, we will use a default one
            sourceName = generateDefaultCustomSourceName(settings.getName());
        }
        wpSearchClient.configureCustomSource(settings.getWorkplaceSearch().getId(), sourceName);
    } catch (ServiceUnavailableException e) {
        logger.fatal("Can not connect to Workplace Search service. " + "Check that you have workplace search running at {}: {}", settings.getWorkplaceSearch().getServer().decodedUrl(), e.getMessage());
        logger.debug("Full trace", e);
        throw new IOException("Can not connect to Workplace Search service.");
    }
}
Also used : Path(java.nio.file.Path) WPSearchClient(fr.pilato.elasticsearch.crawler.fs.thirdparty.wpsearch.WPSearchClient) ServiceUnavailableException(jakarta.ws.rs.ServiceUnavailableException) IOException(java.io.IOException)

Aggregations

ServiceUnavailableException (jakarta.ws.rs.ServiceUnavailableException)18 IOException (java.io.IOException)7 Calendar (java.util.Calendar)4 WPSearchClient (fr.pilato.elasticsearch.crawler.fs.thirdparty.wpsearch.WPSearchClient)1 JsonArray (jakarta.json.JsonArray)1 JsonObject (jakarta.json.JsonObject)1 BadRequestException (jakarta.ws.rs.BadRequestException)1 ClientErrorException (jakarta.ws.rs.ClientErrorException)1 ForbiddenException (jakarta.ws.rs.ForbiddenException)1 InternalServerErrorException (jakarta.ws.rs.InternalServerErrorException)1 NotAcceptableException (jakarta.ws.rs.NotAcceptableException)1 NotAllowedException (jakarta.ws.rs.NotAllowedException)1 NotAuthorizedException (jakarta.ws.rs.NotAuthorizedException)1 NotFoundException (jakarta.ws.rs.NotFoundException)1 NotSupportedException (jakarta.ws.rs.NotSupportedException)1 RedirectionException (jakarta.ws.rs.RedirectionException)1 ServerErrorException (jakarta.ws.rs.ServerErrorException)1 Client (jakarta.ws.rs.client.Client)1 WebTarget (jakarta.ws.rs.client.WebTarget)1 SseEventSource (jakarta.ws.rs.sse.SseEventSource)1