/** * Get the latest flow status * @param flowId identifier of flow status to get * @return a {@link FlowStatus} with the flow status * @throws RemoteInvocationException */ public FlowStatus getLatestFlowStatus(FlowId flowId) throws RemoteInvocationException { LOG.debug("getFlowConfig with groupName " + flowId.getFlowGroup() + " flowName " + flowId.getFlowName()); FindRequest<FlowStatus> findRequest = _flowstatusesRequestBuilders.findByLatestFlowStatus().flowIdParam(flowId).build(); Response<CollectionResponse<FlowStatus>> response = _restClient.get().sendRequest(findRequest).getResponse(); List<FlowStatus> flowStatusList = response.getEntity().getElements(); if (flowStatusList.isEmpty()) { return null; } else { Preconditions.checkArgument(flowStatusList.size() == 1); return flowStatusList.get(0); } }
/** * Get a collection of {@link JobExecutionQueryResult}s for a collection of {@link JobExecutionQuery}s. * * <p> * The order of {@link JobExecutionQueryResult}s may not match the order of {@link JobExecutionQuery}s. * </p> * * @param queries a collection of {@link JobExecutionQuery}s * @return a collection of {@link JobExecutionQueryResult}s * @throws RemoteInvocationException */ public Collection<JobExecutionQueryResult> batchGet(Collection<JobExecutionQuery> queries) throws RemoteInvocationException { Set<ComplexResourceKey<JobExecutionQuery, EmptyRecord>> ids = Sets.newHashSet(); for (JobExecutionQuery query : queries) { ids.add(new ComplexResourceKey<JobExecutionQuery, EmptyRecord>(query, new EmptyRecord())); } BatchGetKVRequest<ComplexResourceKey<JobExecutionQuery, EmptyRecord>, JobExecutionQueryResult> batchGetRequest = new JobExecutionsBuilders().batchGet().ids(ids).buildKV(); BatchKVResponse<ComplexResourceKey<JobExecutionQuery, EmptyRecord>, JobExecutionQueryResult> response = this.restClient.sendRequest(batchGetRequest, ErrorHandlingBehavior.TREAT_SERVER_ERROR_AS_SUCCESS) .getResponseEntity(); return response.getResults().values(); }
/** * Delete a flow configuration * @param flowId identifier of flow configuration to delete * @throws RemoteInvocationException */ public void deleteFlowConfigWithStateStore(FlowId flowId) throws RemoteInvocationException { LOG.debug("deleteFlowConfig and state store with groupName " + flowId.getFlowGroup() + " flowName " + flowId.getFlowName()); DeleteRequest<FlowConfig> deleteRequest = _flowconfigsV2RequestBuilders.delete() .id(new ComplexResourceKey<>(flowId, new FlowStatusId())).setHeader(DELETE_STATE_STORE_KEY, Boolean.TRUE.toString()).build(); ResponseFuture<EmptyRecord> response = _restClient.get().sendRequest(deleteRequest); response.getResponse(); }
/** * Get a collection of {@link JobExecutionQueryResult}s for a collection of {@link JobExecutionQuery}s. * * <p> * The order of {@link JobExecutionQueryResult}s may not match the order of {@link JobExecutionQuery}s. * </p> * * @param queries a collection of {@link JobExecutionQuery}s * @return a collection of {@link JobExecutionQueryResult}s * @throws RemoteInvocationException */ public Collection<JobExecutionQueryResult> batchGet(Collection<JobExecutionQuery> queries) throws RemoteInvocationException { Set<ComplexResourceKey<JobExecutionQuery, EmptyRecord>> ids = Sets.newHashSet(); for (JobExecutionQuery query : queries) { ids.add(new ComplexResourceKey<JobExecutionQuery, EmptyRecord>(query, new EmptyRecord())); } BatchGetKVRequest<ComplexResourceKey<JobExecutionQuery, EmptyRecord>, JobExecutionQueryResult> batchGetRequest = new JobExecutionsBuilders().batchGet().ids(ids).buildKV(); BatchKVResponse<ComplexResourceKey<JobExecutionQuery, EmptyRecord>, JobExecutionQueryResult> response = this.restClient.sendRequest(batchGetRequest, ErrorHandlingBehavior.TREAT_SERVER_ERROR_AS_SUCCESS) .getResponseEntity(); return response.getResults().values(); }
/** * Create a flow configuration * @param flowConfig flow configuration attributes * @throws RemoteInvocationException */ public void createFlowConfig(FlowConfig flowConfig) throws RemoteInvocationException { LOG.debug("createFlowConfig with groupName " + flowConfig.getId().getFlowGroup() + " flowName " + flowConfig.getId().getFlowName()); CreateIdRequest<ComplexResourceKey<FlowId, EmptyRecord>, FlowConfig> request = _flowconfigsRequestBuilders.create().input(flowConfig).build(); ResponseFuture<IdResponse<ComplexResourceKey<FlowId, EmptyRecord>>> flowConfigResponseFuture = _restClient.get().sendRequest(request); flowConfigResponseFuture.getResponse(); }
/** * Delete a flow configuration * @param flowId identifier of flow configuration to delete * @throws RemoteInvocationException */ public void deleteFlowConfigWithStateStore(FlowId flowId) throws RemoteInvocationException { LOG.debug("deleteFlowConfig and state store with groupName " + flowId.getFlowGroup() + " flowName " + flowId.getFlowName()); DeleteRequest<FlowConfig> deleteRequest = _flowconfigsRequestBuilders.delete() .id(new ComplexResourceKey<>(flowId, new EmptyRecord())).setHeader(DELETE_STATE_STORE_KEY, Boolean.TRUE.toString()).build(); ResponseFuture<EmptyRecord> response = _restClient.get().sendRequest(deleteRequest); response.getResponse(); }
/** * Delete a flow configuration * @param flowId identifier of flow configuration to delete * @throws RemoteInvocationException */ public void deleteFlowConfig(FlowId flowId) throws RemoteInvocationException { LOG.debug("deleteFlowConfig with groupName {}, flowName {}", flowId.getFlowGroup(), flowId.getFlowName()); DeleteRequest<FlowConfig> deleteRequest = _flowconfigsV2RequestBuilders.delete() .id(new ComplexResourceKey<>(flowId, new FlowStatusId())).build(); ResponseFuture<EmptyRecord> response = _restClient.get().sendRequest(deleteRequest); response.getResponse(); }
/** * Delete a flow configuration * @param flowId identifier of flow configuration to delete * @throws RemoteInvocationException */ public void deleteFlowConfig(FlowId flowId) throws RemoteInvocationException { LOG.debug("deleteFlowConfig with groupName " + flowId.getFlowGroup() + " flowName " + flowId.getFlowName()); DeleteRequest<FlowConfig> deleteRequest = _flowconfigsRequestBuilders.delete() .id(new ComplexResourceKey<>(flowId, new EmptyRecord())).build(); ResponseFuture<EmptyRecord> response = _restClient.get().sendRequest(deleteRequest); response.getResponse(); }
/** * Create a flow configuration * It differs from {@link FlowConfigClient} in a way that it returns FlowStatusId, * which can be used to find the FlowExecutionId * @param flowConfig FlowConfig to be used to create the flow * @return FlowStatusId * @throws RemoteInvocationException */ public FlowStatusId createFlowConfig(FlowConfig flowConfig) throws RemoteInvocationException { LOG.debug("createFlowConfig with groupName " + flowConfig.getId().getFlowGroup() + " flowName " + flowConfig.getId().getFlowName()); CreateIdRequest<ComplexResourceKey<FlowId, FlowStatusId>, FlowConfig> request = _flowconfigsV2RequestBuilders.create().input(flowConfig).build(); ResponseFuture<IdResponse<ComplexResourceKey<FlowId, FlowStatusId>>> flowConfigResponseFuture = _restClient.get().sendRequest(request); return createFlowStatusId(flowConfigResponseFuture.getResponse().getLocation().toString()); }
/** * Get a flow configuration * @param flowId identifier of flow configuration to get * @return a {@link FlowConfig} with the flow configuration * @throws RemoteInvocationException */ public FlowConfig getFlowConfig(FlowId flowId) throws RemoteInvocationException { LOG.debug("getFlowConfig with groupName " + flowId.getFlowGroup() + " flowName " + flowId.getFlowName()); GetRequest<FlowConfig> getRequest = _flowconfigsRequestBuilders.get() .id(new ComplexResourceKey<>(flowId, new EmptyRecord())).build(); Response<FlowConfig> response = _restClient.get().sendRequest(getRequest).getResponse(); return response.getEntity(); }
/** * Get a flow configuration * @param flowId identifier of flow configuration to get * @return a {@link FlowConfig} with the flow configuration * @throws RemoteInvocationException */ public FlowConfig getFlowConfig(FlowId flowId) throws RemoteInvocationException { LOG.debug("getFlowConfig with groupName " + flowId.getFlowGroup() + " flowName " + flowId.getFlowName()); GetRequest<FlowConfig> getRequest = _flowconfigsV2RequestBuilders.get() .id(new ComplexResourceKey<>(flowId, new FlowStatusId())).build(); Response<FlowConfig> response = _restClient.get().sendRequest(getRequest).getResponse(); return response.getEntity(); }
/** * Get a flow status * @param flowStatusId identifier of flow status to get * @return a {@link FlowStatus} with the flow status * @throws RemoteInvocationException */ public FlowStatus getFlowStatus(FlowStatusId flowStatusId) throws RemoteInvocationException { LOG.debug("getFlowConfig with groupName " + flowStatusId.getFlowGroup() + " flowName " + flowStatusId.getFlowName()); GetRequest<FlowStatus> getRequest = _flowstatusesRequestBuilders.get() .id(new ComplexResourceKey<>(flowStatusId, new EmptyRecord())).build(); Response<FlowStatus> response = _restClient.get().sendRequest(getRequest).getResponse(); return response.getEntity(); }
/** * Get a {@link org.apache.gobblin.rest.JobExecutionQueryResult} for a {@link org.apache.gobblin.rest.JobExecutionQuery}. * * @param query a {@link org.apache.gobblin.rest.JobExecutionQuery} * @return a {@link org.apache.gobblin.rest.JobExecutionQueryResult} * @throws RemoteInvocationException */ public JobExecutionQueryResult get(JobExecutionQuery query) throws RemoteInvocationException { GetRequest<JobExecutionQueryResult> getRequest = new JobExecutionsBuilders().get() .id(new ComplexResourceKey<JobExecutionQuery, EmptyRecord>(query, new EmptyRecord())).build(); Response<JobExecutionQueryResult> response = this.restClient.sendRequest(getRequest, ErrorHandlingBehavior.TREAT_SERVER_ERROR_AS_SUCCESS).getResponse(); return response.getEntity(); }
/** * Update a flow configuration * @param flowConfig flow configuration attributes * @throws RemoteInvocationException */ public void updateFlowConfig(FlowConfig flowConfig) throws RemoteInvocationException { LOG.debug("updateFlowConfig with groupName " + flowConfig.getId().getFlowGroup() + " flowName " + flowConfig.getId().getFlowName()); FlowId flowId = new FlowId().setFlowGroup(flowConfig.getId().getFlowGroup()) .setFlowName(flowConfig.getId().getFlowName()); UpdateRequest<FlowConfig> updateRequest = _flowconfigsRequestBuilders.update().id(new ComplexResourceKey<>(flowId, new EmptyRecord())) .input(flowConfig).build(); ResponseFuture<EmptyRecord> response = _restClient.get().sendRequest(updateRequest); response.getResponse(); }
/** * Update a flow configuration * @param flowConfig flow configuration attributes * @throws RemoteInvocationException */ public void updateFlowConfig(FlowConfig flowConfig) throws RemoteInvocationException { LOG.debug("updateFlowConfig with groupName " + flowConfig.getId().getFlowGroup() + " flowName " + flowConfig.getId().getFlowName()); FlowId flowId = new FlowId().setFlowGroup(flowConfig.getId().getFlowGroup()) .setFlowName(flowConfig.getId().getFlowName()); UpdateRequest<FlowConfig> updateRequest = _flowconfigsV2RequestBuilders.update().id(new ComplexResourceKey<>(flowId, new FlowStatusId())) .input(flowConfig).build(); ResponseFuture<EmptyRecord> response = _restClient.get().sendRequest(updateRequest); response.getResponse(); }
private PermitAllocation getPermitAllocation(PermitRequest permitRequest, RestClient restClient, PermitsGetRequestBuilder getBuilder) throws Exception { Request<PermitAllocation> request = getBuilder.id(new ComplexResourceKey<>(permitRequest, new EmptyRecord())).build(); ResponseFuture<PermitAllocation> responseFuture = restClient.sendRequest(request); Response<PermitAllocation> response = responseFuture.getResponse(); return response.getEntity(); }
private static <K, V extends RecordTemplate> List<CreateIdStatus<K>> batchCreateOldBuilders(RestClient restClient, BatchCreateRequestBuilder<K, V> builder, List<V> entities) throws RemoteInvocationException { BatchCreateRequest<V> request = builder.inputs(entities).build(); Response<CollectionResponse<CreateStatus>> response = restClient.sendRequest(request).getResponse(); List<CreateStatus> elements = response.getEntity().getElements(); List<CreateIdStatus<K>> result = new ArrayList<CreateIdStatus<K>>(elements.size()); for (CreateStatus status : elements) { @SuppressWarnings("unchecked") CreateIdStatus<K> createIdStatus = (CreateIdStatus<K>) status; result.add(createIdStatus); } return result; }
/** * Get the latest flow status * @param flowId identifier of flow status to get * @return a {@link FlowStatus} with the flow status * @throws RemoteInvocationException */ public FlowStatus getLatestFlowStatus(FlowId flowId) throws RemoteInvocationException { LOG.debug("getFlowConfig with groupName " + flowId.getFlowGroup() + " flowName " + flowId.getFlowName()); FindRequest<FlowStatus> findRequest = _flowstatusesRequestBuilders.findByLatestFlowStatus().flowIdParam(flowId).build(); Response<CollectionResponse<FlowStatus>> response = _restClient.get().sendRequest(findRequest).getResponse(); List<FlowStatus> flowStatusList = response.getEntity().getElements(); if (flowStatusList.isEmpty()) { return null; } else { Preconditions.checkArgument(flowStatusList.size() == 1); return flowStatusList.get(0); } }
/** * Get the latest flow status * @param flowId identifier of flow status to get * @return a {@link FlowStatus} with the flow status * @throws RemoteInvocationException */ public FlowStatus getLatestFlowStatus(FlowId flowId) throws RemoteInvocationException { LOG.debug("getFlowConfig with groupName " + flowId.getFlowGroup() + " flowName " + flowId.getFlowName()); FindRequest<FlowStatus> findRequest = _flowstatusesRequestBuilders.findByLatestFlowStatus().flowIdParam(flowId).build(); Response<CollectionResponse<FlowStatus>> response = _restClient.get().sendRequest(findRequest).getResponse(); List<FlowStatus> flowStatusList = response.getEntity().getElements(); if (flowStatusList.isEmpty()) { return null; } else { Preconditions.checkArgument(flowStatusList.size() == 1); return flowStatusList.get(0); } }
/** * Delete a flow configuration * @param flowId identifier of flow configuration to delete * @throws RemoteInvocationException */ public void deleteFlowConfigWithStateStore(FlowId flowId) throws RemoteInvocationException { LOG.debug("deleteFlowConfig and state store with groupName " + flowId.getFlowGroup() + " flowName " + flowId.getFlowName()); DeleteRequest<FlowConfig> deleteRequest = _flowconfigsRequestBuilders.delete() .id(new ComplexResourceKey<>(flowId, new EmptyRecord())).setHeader(DELETE_STATE_STORE_KEY, Boolean.TRUE.toString()).build(); ResponseFuture<EmptyRecord> response = _restClient.get().sendRequest(deleteRequest); response.getResponse(); }