@Override public boolean isRetriableException(Exception e) { return (e instanceof EmoClientException && ((EmoClientException) e).getResponse().getStatus() >= 500) || e instanceof JsonStreamingEOFException; }
@Override public boolean isRetriableException(Exception e) { return (e instanceof EmoClientException && ((EmoClientException) e).getResponse().getStatus() >= 500) || e instanceof JsonStreamingEOFException; }
@Override public boolean isRetriableException(Exception e) { return (e instanceof EmoClientException && ((EmoClientException) e).getResponse().getStatus() >= 500) || e instanceof JsonStreamingEOFException; }
@Override public boolean isRetriableException(Exception e) { return (e instanceof EmoClientException && ((EmoClientException) e).getResponse().getStatus() >= 500); }
@Override public boolean isRetriableException(Exception e) { return (e instanceof EmoClientException && ((EmoClientException) e).getResponse().getStatus() >= 500) || e instanceof JsonStreamingEOFException; }
@Override public boolean isRetriableException(Exception e) { return (e instanceof EmoClientException && ((EmoClientException) e).getResponse().getStatus() >= 500) || e instanceof JsonStreamingEOFException; }
@Override public boolean isRetriableException(Exception e) { return (e instanceof EmoClientException && ((EmoClientException) e).getResponse().getStatus() >= 500); }
@Override public void createTable(String apiKey, String table, TableOptions options, Map<String, ?> template, Audit audit) throws TableExistsException { checkNotNull(table, "table"); checkNotNull(options, "options"); checkNotNull(template, "template"); checkNotNull(audit, "audit"); URI uri = _dataStore.clone() .segment("_table", table) .queryParam("options", RisonHelper.asORison(options)) .queryParam("audit", RisonHelper.asORison(audit)) .build(); for (int attempt = 0; ; attempt++) { try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(template); return; } catch (EmoClientException e) { // The SoR returns a 301 response when we need to make this request against a different data center. // Follow the redirect a few times but don't loop forever. if (e.getResponse().getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode() && attempt < 5) { uri = e.getResponse().getLocation(); continue; } throw convertException(e); } } }
@Override public void createTable(String apiKey, String table, TableOptions options, Map<String, ?> template, Audit audit) throws TableExistsException { checkNotNull(table, "table"); checkNotNull(options, "options"); checkNotNull(template, "template"); checkNotNull(audit, "audit"); URI uri = _dataStore.clone() .segment("_table", table) .queryParam("options", RisonHelper.asORison(options)) .queryParam("audit", RisonHelper.asORison(audit)) .build(); for (int attempt = 0; ; attempt++) { try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(template); return; } catch (EmoClientException e) { // The SoR returns a 301 response when we need to make this request against a different data center. // Follow the redirect a few times but don't loop forever. if (e.getResponse().getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode() && attempt < 5) { uri = e.getResponse().getLocation(); continue; } throw convertException(e); } } }
@Override public void setTableTemplate(String apiKey, String table, Map<String, ?> template, Audit audit) { checkNotNull(table, "table"); checkNotNull(template, "template"); checkNotNull(audit, "audit"); URI uri = _dataStore.clone() .segment("_table", table, "template") .queryParam("audit", RisonHelper.asORison(audit)) .build(); for (int attempt = 0; ; attempt++) { try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(template); return; } catch (EmoClientException e) { // The SoR returns a 301 response when we need to make this request against a different data center. // Follow the redirect a few times but don't loop forever. if (e.getResponse().getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode() && attempt < 5) { uri = e.getResponse().getLocation(); continue; } throw convertException(e); } } }
@Override public void setTableTemplate(String apiKey, String table, Map<String, ?> template, Audit audit) { checkNotNull(table, "table"); checkNotNull(template, "template"); checkNotNull(audit, "audit"); URI uri = _dataStore.clone() .segment("_table", table, "template") .queryParam("audit", RisonHelper.asORison(audit)) .build(); for (int attempt = 0; ; attempt++) { try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(template); return; } catch (EmoClientException e) { // The SoR returns a 301 response when we need to make this request against a different data center. // Follow the redirect a few times but don't loop forever. if (e.getResponse().getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode() && attempt < 5) { uri = e.getResponse().getLocation(); continue; } throw convertException(e); } } }
@Override public void createFacade(String apiKey, String table, FacadeOptions options, Audit audit) throws TableExistsException { checkNotNull(table, "table"); checkNotNull(options, "options"); checkNotNull(audit, "audit"); URI uri = _dataStore.clone() .segment("_facade", table) .queryParam("options", RisonHelper.asORison(options)) .queryParam("audit", RisonHelper.asORison(audit)) .build(); for (int attempt = 0; ; attempt++) { try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(); return; } catch (EmoClientException e) { // The SoR returns a 301 response when we need to make this request against a different data center. // Follow the redirect a few times but don't loop forever. if (e.getResponse().getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode() && attempt < 5) { uri = e.getResponse().getLocation(); continue; } throw convertException(e); } } }
@Override public void createFacade(String apiKey, String table, FacadeOptions options, Audit audit) throws TableExistsException { checkNotNull(table, "table"); checkNotNull(options, "options"); checkNotNull(audit, "audit"); URI uri = _dataStore.clone() .segment("_facade", table) .queryParam("options", RisonHelper.asORison(options)) .queryParam("audit", RisonHelper.asORison(audit)) .build(); for (int attempt = 0; ; attempt++) { try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(); return; } catch (EmoClientException e) { // The SoR returns a 301 response when we need to make this request against a different data center. // Follow the redirect a few times but don't loop forever. if (e.getResponse().getStatus() == Response.Status.MOVED_PERMANENTLY.getStatusCode() && attempt < 5) { uri = e.getResponse().getLocation(); continue; } throw convertException(e); } } }
protected RuntimeException convertException(EmoClientException e) { EmoResponse response = e.getResponse(); String exceptionType = response.getFirstHeader("X-BV-Exception"); if (response.getStatus() == Response.Status.BAD_REQUEST.getStatusCode() && IllegalArgumentException.class.getName().equals(exceptionType)) { return new IllegalArgumentException(response.getEntity(String.class), e); } else if (response.getStatus() == Response.Status.NOT_FOUND.getStatusCode() && UnknownMoveException.class.getName().equals(exceptionType)) { return response.getEntity(UnknownMoveException.class); } else if (response.getStatus() == Response.Status.FORBIDDEN.getStatusCode() && UnauthorizedException.class.getName().equals(exceptionType)) { if (response.hasEntity()) { return (RuntimeException) response.getEntity(UnauthorizedException.class).initCause(e); } else { return (RuntimeException) new UnauthorizedException().initCause(e); } } else if (response.getStatus() == Response.Status.SERVICE_UNAVAILABLE.getStatusCode() && ServiceUnavailableException.class.getName().equals(exceptionType)) { if (response.hasEntity()) { return (RuntimeException) response.getEntity(ServiceUnavailableException.class).initCause(e); } else { return (RuntimeException) new ServiceUnavailableException().initCause(e); } } return e; }
@SuppressWarnings ("ThrowableResultOfMethodCallIgnored") private RuntimeException convertException(EmoClientException e) { EmoResponse response = e.getResponse(); String exceptionType = response.getFirstHeader("X-BV-Exception");
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") private RuntimeException convertException(EmoClientException e) { EmoResponse response = e.getResponse(); String exceptionType = response.getFirstHeader("X-BV-Exception");
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") private RuntimeException convertException(EmoClientException e) { EmoResponse response = e.getResponse(); String exceptionType = response.getFirstHeader("X-BV-Exception");
@SuppressWarnings ("ThrowableResultOfMethodCallIgnored") private RuntimeException convertException(EmoClientException e) { EmoResponse response = e.getResponse(); String exceptionType = response.getFirstHeader("X-BV-Exception");
@SuppressWarnings ("ThrowableResultOfMethodCallIgnored") private RuntimeException convertException(EmoClientException e) { EmoResponse response = e.getResponse(); String exceptionType = response.getFirstHeader("X-BV-Exception");
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") private RuntimeException convertException(EmoClientException e) { EmoResponse response = e.getResponse(); String exceptionType = response.getFirstHeader("X-BV-Exception");