@Override public SEARCH_RESULT_TYPE search(final SearchRequest request) { Client client = ClientBuilder.newClient(); WebTarget target = client.target(API_BASE_URL_V3); target = request.appendPathAndQueryParameters(target); target = withAuthToken(target); int retries = 0; QuandlRuntimeException lastException; do { try { return _metaDataPackager.ofSearchResult(_restDataProvider.getJSONResponse(target, request)); } catch (QuandlTooManyRequestsException qtmre) { lastException = qtmre; s_logger.debug("Quandl returned Too Many Requests, retrying if appropriate"); if (qtmre.isDataExhausted()) { throw new QuandlRequestFailedException("Data request limit exceeded", qtmre); } } catch (QuandlServiceUnavailableException qsue) { lastException = qsue; s_logger.debug("Quandl returned Service Not Available, retrying if appropriate"); } } while (_sessionOptions.getRetryPolicy().checkRetries(retries++)); throw new QuandlRequestFailedException("Giving up on request after " + retries + " retries.", lastException); } }
/** * Run tests using previously collected Quandl response data and compare with previously collected results. */ @Test(groups = { "integration" }) public void runFileBasedTests() { runTests(new FileRESTDataProvider(_apiKey), new ResultChecker(), RetryPolicy.createSequenceRetryPolicy(new long[] { 1, 1, 1, 1 })); }
/** * Run tests using previously collected Quandl response data and compare with previously collected results. */ @Test(groups = { "integration" }) public void runFileBasedTests() { runTests(new FileRESTDataProvider(_apiKey), new ResultChecker(), RetryPolicy.createSequenceRetryPolicy(new long[] { 1, 1, 1, 1 })); }
@Override public SearchResult search(final SearchRequest request) { Client client = ClientBuilder.newClient(); WebTarget target = client.target(API_BASE_URL_V3); target = withAuthToken(target); target = request.appendPathAndQueryParameters(target); int retries = 0; QuandlRuntimeException lastException; do { try { return SearchResult.of(_restDataProvider.getJSONResponse(target, request)); } catch (QuandlTooManyRequestsException qtmre) { lastException = qtmre; s_logger.debug("Quandl returned Too Many Requests, retrying if appropriate"); if (qtmre.isDataExhausted()) { throw new QuandlRequestFailedException("Data request limit exceeded", qtmre); } } catch (QuandlServiceUnavailableException qsue) { lastException = qsue; s_logger.debug("Quandl returned Service Not Available, retrying if appropriate"); } } while (_sessionOptions.getRetryPolicy().checkRetries(retries++)); throw new QuandlRequestFailedException("Giving up on request after " + retries + " retries.", lastException); } }
private void runDirectTests() { runTests(new JSONTabularResultRESTDataProvider(), new ResultChecker(), RetryPolicy.createSequenceRetryPolicy(new long[] { 1, 5, 20, 60 })); }
@Override public METADATA_TYPE getMetaData(final MetaDataRequest request) { ArgumentChecker.notNull(request, "request"); Client client = ClientBuilder.newClient(); WebTarget target = client.target(API_BASE_URL_V3); target = request.appendPathAndQueryParameters(target); target = withAuthToken(target); int retries = 0; QuandlRuntimeException lastException; do { try { return _metaDataPackager.ofMetaData(_restDataProvider.getJSONResponse(target, request)); } catch (QuandlTooManyRequestsException qtmre) { lastException = qtmre; s_logger.debug("Quandl returned Too Many Requests, retrying if appropriate"); if (qtmre.isDataExhausted()) { throw new QuandlRequestFailedException("Data request limit exceeded", qtmre); } } catch (QuandlServiceUnavailableException qsue) { lastException = qsue; s_logger.debug("Quandl returned Service Not Available, retrying if appropriate"); } } while (_sessionOptions.getRetryPolicy().checkRetries(retries++)); throw new QuandlRequestFailedException("Giving up on request after " + retries + " retries.", lastException); }
private void runRecording() { runTests(new RecordingRESTDataProvider(_apiKey), new ResultSaver(), RetryPolicy.createSequenceRetryPolicy(new long[] { 1, 5, 20, 60 })); }
@Override public MetaDataResult getMetaData(final MetaDataRequest request) { ArgumentChecker.notNull(request, "request"); Client client = ClientBuilder.newClient(); WebTarget target = client.target(API_BASE_URL_V3); target = withAuthToken(target); target = request.appendPathAndQueryParameters(target); JSONObject object = null; int retries = 0; QuandlRuntimeException lastException; do { try { return MetaDataResult.of(_restDataProvider.getJSONResponse(target, request)); } catch (QuandlTooManyRequestsException qtmre) { lastException = qtmre; s_logger.debug("Quandl returned Too Many Requests, retrying if appropriate"); if (qtmre.isDataExhausted()) { throw new QuandlRequestFailedException("Data request limit exceeded", qtmre); } } catch (QuandlServiceUnavailableException qsue) { lastException = qsue; s_logger.debug("Quandl returned Service Not Available, retrying if appropriate"); } } while (object == null && _sessionOptions.getRetryPolicy().checkRetries(retries++)); throw new QuandlRequestFailedException("Giving up on request after " + retries + " retries.", lastException); }
private void runRecording() { runTests(new RecordingRESTDataProvider(_apiKey), new ResultSaver(), RetryPolicy.createSequenceRetryPolicy(new long[] { 1, 5, 20, 60 })); }
@Override public TABLE_TYPE getDataSet(final DataSetRequest request) { ArgumentChecker.notNull(request, "request"); Client client = getClient(); WebTarget target = client.target(API_BASE_URL_V3); target = request.appendPathAndQueryParameters(target); target = withAuthToken(target); int retries = 0; QuandlRuntimeException lastException; do { try { return _restDataProvider.getTabularResponse(target, request); } catch (QuandlTooManyRequestsException qtmre) { lastException = qtmre; s_logger.debug("Quandl returned Too Many Requests, retrying if appropriate"); if (qtmre.isDataExhausted()) { throw new QuandlRequestFailedException("Data request limit exceeded", qtmre); } } catch (QuandlServiceUnavailableException qsue) { lastException = qsue; s_logger.debug("Quandl returned Service Not Available, retrying if appropriate"); } } while (_sessionOptions.getRetryPolicy().checkRetries(retries++)); throw new QuandlRequestFailedException("Giving up on request after " + retries + " retries.", lastException); }
private void runDirectTests() { runTests(new DefaultRESTDataProvider(), new ResultChecker(), RetryPolicy.createSequenceRetryPolicy(new long[] { 1, 5, 20, 60 })); }
@Override public TabularResult getDataSet(final DataSetRequest request) { ArgumentChecker.notNull(request, "request"); Client client = getClient(); WebTarget target = client.target(API_BASE_URL_V3); target = withAuthToken(target); target = request.appendPathAndQueryParameters(target); int retries = 0; QuandlRuntimeException lastException; do { try { return _restDataProvider.getTabularResponse(target, request); } catch (QuandlTooManyRequestsException qtmre) { lastException = qtmre; s_logger.debug("Quandl returned Too Many Requests, retrying if appropriate"); if (qtmre.isDataExhausted()) { throw new QuandlRequestFailedException("Data request limit exceeded", qtmre); } } catch (QuandlServiceUnavailableException qsue) { lastException = qsue; s_logger.debug("Quandl returned Service Not Available, retrying if appropriate"); } } while (_sessionOptions.getRetryPolicy().checkRetries(retries++)); throw new QuandlRequestFailedException("Giving up on request after " + retries + " retries.", lastException); }