protected void doAcknowledge(String apiKey, String queue, Collection<String> messageIds) { checkNotNull(queue, "queue"); checkNotNull(messageIds, "messageIds"); try { URI uri = _queueService.clone() .segment(queue, "ack") .queryParam("partitioned", _partitionSafe) .build(); _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .post(messageIds); } catch (EmoClientException e) { throw convertException(e); } }
@Override public void deleteStashTime(String id, String dataCenter) { checkNotNull(id, "id"); checkNotNull(dataCenter, "dataCenter"); try { URI uri = _compactionControlSource.clone() .segment("_compcontrol", "stash-time", id) .queryParam("dataCenter", dataCenter) .build(); _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, _apiKey) .delete(); } catch (UniformInterfaceException e) { throw convertException(e); } }
@Override public void deleteStashTime(String id, String dataCenter) { checkNotNull(id, "id"); checkNotNull(dataCenter, "dataCenter"); try { URI uri = _compactionControlSource.clone() .segment("_compcontrol", "stash-time", id) .queryParam("dataCenter", dataCenter) .build(); _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, _apiKey) .delete(); } catch (UniformInterfaceException e) { throw convertException(e); } }
protected void doRenew(String apiKey, String queue, Collection<String> messageIds, Duration claimTtl) { checkNotNull(queue, "queue"); checkNotNull(messageIds, "messageIds"); checkNotNull(claimTtl, "claimTtl"); try { URI uri = _queueService.clone() .segment(queue, "renew") .queryParam("ttl", Ttls.toSeconds(claimTtl, 0, Integer.MAX_VALUE)) .queryParam("partitioned", _partitionSafe) .build(); _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .post(messageIds); } catch (EmoClientException e) { throw convertException(e); } }
public void sendAll(String apiKey, String queue, Collection<?> messages) { checkNotNull(queue, "queue"); checkNotNull(messages, "messages"); if (messages.isEmpty()) { return; } try { URI uri = _queueService.clone() .segment(queue, "sendbatch") .build(); _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .post(messages); } catch (EmoClientException e) { throw convertException(e); } }
@Override public void setTableAttributes(String apiKey, String table, Map<String, String> attributes, Audit audit) { checkNotNull(table, "table"); checkNotNull(attributes, "attributes"); checkNotNull(audit, "audit"); URI uri = _blobStore.clone() .segment("_table", table, "attributes") .queryParam("audit", RisonHelper.asORison(audit)) .build(); try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(attributes); } catch (EmoClientException e) { throw convertException(e); } }
@Override public void createTable(String apiKey, String table, TableOptions options, Map<String, String> attributes, Audit audit) throws TableExistsException { checkNotNull(table, "table"); checkNotNull(options, "options"); checkNotNull(attributes, "attributes"); checkNotNull(audit, "audit"); URI uri = _blobStore.clone() .segment("_table", table) .queryParam("options", RisonHelper.asORison(options)) .queryParam("audit", RisonHelper.asORison(audit)) .build(); try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(attributes); } catch (EmoClientException e) { throw convertException(e); } }
@Override public Map<StashTimeKey, StashRunTimeInfo> getStashTimesForPlacement(String placement) { checkNotNull(placement, "placement"); try { URI uri = _compactionControlSource.clone() .segment("_compcontrol", "stash-time") .queryParam("placement", placement) .build(); return _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, _apiKey) .get(Map.class); } catch (UniformInterfaceException e) { throw convertException(e); } }
@Override public void setTableAttributes(String apiKey, String table, Map<String, String> attributes, Audit audit) { checkNotNull(table, "table"); checkNotNull(attributes, "attributes"); checkNotNull(audit, "audit"); URI uri = _blobStore.clone() .segment("_table", table, "attributes") .queryParam("audit", RisonHelper.asORison(audit)) .build(); try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .put(attributes); } catch (EmoClientException e) { throw convertException(e); } }
@Override public Map<StashTimeKey, StashRunTimeInfo> getStashTimesForPlacement(String placement) { checkNotNull(placement, "placement"); try { URI uri = _compactionControlSource.clone() .segment("_compcontrol", "stash-time") .queryParam("placement", placement) .build(); return _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, _apiKey) .get(Map.class); } catch (UniformInterfaceException e) { throw convertException(e); } }
@Override public void dropTable(String apiKey, String table, Audit audit) throws UnknownTableException { checkNotNull(table, "table"); checkNotNull(audit, "audit"); URI uri = _blobStore.clone() .segment("_table", table) .queryParam("audit", RisonHelper.asORison(audit)) .build(); try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .delete(); } catch (EmoClientException e) { throw convertException(e); } }
@Override public void renew(String apiKey, @PartitionKey String subscription, Collection<String> eventKeys, Duration claimTtl) { checkNotNull(subscription, "subscription"); checkNotNull(eventKeys, "eventKeys"); checkNotNull(claimTtl, "claimTtl"); try { URI uri = _databus.clone() .segment(subscription, "renew") .queryParam("ttl", Ttls.toSeconds(claimTtl, 0, Integer.MAX_VALUE)) .queryParam("partitioned", _partitionSafe) .build(); _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .post(eventKeys); } catch (EmoClientException e) { throw convertException(e); } }
@Override public void purgeTableUnsafe(String apiKey, String table, Audit audit) { checkNotNull(table, "table"); checkNotNull(audit, "audit"); URI uri = _blobStore.clone() .segment("_table", table, "purge") .queryParam("audit", RisonHelper.asORison(audit)) .build(); try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .post(); } catch (EmoClientException e) { throw convertException(e); } }
@Override public void purgeTableUnsafe(String apiKey, String table, Audit audit) { checkNotNull(table, "table"); checkNotNull(audit, "audit"); URI uri = _blobStore.clone() .segment("_table", table, "purge") .queryParam("audit", RisonHelper.asORison(audit)) .build(); try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .post(); } catch (EmoClientException e) { throw convertException(e); } }
@Override public void dropTable(String apiKey, String table, Audit audit) throws UnknownTableException { checkNotNull(table, "table"); checkNotNull(audit, "audit"); URI uri = _blobStore.clone() .segment("_table", table) .queryParam("audit", RisonHelper.asORison(audit)) .build(); try { _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .delete(); } catch (EmoClientException e) { throw convertException(e); } }
@Override public void acknowledge(String apiKey, @PartitionKey String subscription, Collection<String> eventKeys) { checkNotNull(subscription, "subscription"); checkNotNull(eventKeys, "eventKeys"); try { URI uri = _databus.clone() .segment(subscription, "ack") .queryParam("partitioned", _partitionSafe) .build(); _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .post(eventKeys); } catch (EmoClientException e) { throw convertException(e); } }
@Override public Map<StashTimeKey, StashRunTimeInfo> getAllStashTimes() { try { URI uri = _compactionControlSource.clone() .segment("_compcontrol", "stash-time") .build(); return _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, _apiKey) .get(Map.class); } catch (UniformInterfaceException e) { throw convertException(e); } }
public void send(String apiKey, String queue, final Object message) { checkNotNull(queue, "queue"); try { URI uri = _queueService.clone() .segment(queue, "send") .build(); _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) // Wrap the message in a JSONWrappedObject that forces Jersey to use Jackson to serialize it // no matter what the type. Otherwise null and String objects don't get serialized correctly. .post(new JSONWrappedObject("", "", message)); } catch (EmoClientException e) { throw convertException(e); } }
@Override public Map<StashTimeKey, StashRunTimeInfo> getAllStashTimes() { try { URI uri = _compactionControlSource.clone() .segment("_compcontrol", "stash-time") .build(); return _client.resource(uri) .type(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, _apiKey) .get(Map.class); } catch (UniformInterfaceException e) { throw convertException(e); } }
@Override public void createRole(String apiKey, CreateEmoRoleRequest request) throws EmoRoleExistsException { checkNotNull(request, "request"); EmoRoleKey roleKey = checkNotNull(request.getRoleKey(), "roleKey"); try { URI uri = _uac.clone() .segment("role") .segment(roleKey.getGroup()) .segment(roleKey.getId()) .build(); _client.resource(uri) .type(APPLICATION_X_CREATE_ROLE_TYPE) .accept(MediaType.APPLICATION_JSON_TYPE) .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey) .post(JsonHelper.asJson(request)); } catch (EmoClientException e) { throw convertException(e); } }