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);
}
}
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);
}
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);
}
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);
}
}
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.");
}
}
Aggregations