@GET @Path("/apps/{app-id}/workflows/{workflow-id}/runs/{run-id}/localdatasets") public void getWorkflowLocalDatasets(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String applicationId, @PathParam("workflow-id") String workflowId, @PathParam("run-id") String runId) throws NotFoundException, DatasetManagementException { WorkflowSpecification workflowSpec = getWorkflowSpecForValidRun(namespaceId, applicationId, workflowId, runId); Map<String, DatasetSpecificationSummary> localDatasetSummaries = new HashMap<>(); for (Map.Entry<String, DatasetCreationSpec> localDatasetEntry : workflowSpec.getLocalDatasetSpecs().entrySet()) { String mappedDatasetName = localDatasetEntry.getKey() + "." + runId; String datasetType = localDatasetEntry.getValue().getTypeName(); Map<String, String> datasetProperties = localDatasetEntry.getValue().getProperties().getProperties(); if (datasetFramework.hasInstance(new DatasetId(namespaceId, mappedDatasetName))) { localDatasetSummaries.put(localDatasetEntry.getKey(), new DatasetSpecificationSummary(mappedDatasetName, datasetType, datasetProperties)); } } responder.sendJson(HttpResponseStatus.OK, GSON.toJson(localDatasetSummaries)); }
@GET @Path("/apps/{app-id}/workflows/{workflow-id}/runs/{run-id}/localdatasets") public void getWorkflowLocalDatasets(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String applicationId, @PathParam("workflow-id") String workflowId, @PathParam("run-id") String runId) throws NotFoundException, DatasetManagementException { WorkflowSpecification workflowSpec = getWorkflowSpecForValidRun(namespaceId, applicationId, workflowId, runId); Map<String, DatasetSpecificationSummary> localDatasetSummaries = new HashMap<>(); for (Map.Entry<String, DatasetCreationSpec> localDatasetEntry : workflowSpec.getLocalDatasetSpecs().entrySet()) { String mappedDatasetName = localDatasetEntry.getKey() + "." + runId; String datasetType = localDatasetEntry.getValue().getTypeName(); Map<String, String> datasetProperties = localDatasetEntry.getValue().getProperties().getProperties(); if (datasetFramework.hasInstance(new DatasetId(namespaceId, mappedDatasetName))) { localDatasetSummaries.put(localDatasetEntry.getKey(), new DatasetSpecificationSummary(mappedDatasetName, datasetType, datasetProperties)); } } responder.sendJson(HttpResponseStatus.OK, GSON.toJson(localDatasetSummaries)); }
@Override public Collection<DatasetSpecificationSummary> getInstances(NamespaceId namespaceId, Map<String, String> properties) { readLock.lock(); try { // don't expect this to be called a lot. // might be better to maintain this collection separately and just return it, but seems like its not worth it. Collection<DatasetSpecification> specs = instances.row(namespaceId).values(); ImmutableList.Builder<DatasetSpecificationSummary> specSummaries = ImmutableList.builder(); for (DatasetSpecification spec : specs) { if (properties.isEmpty() || Maps.difference(properties, spec.getProperties()).entriesOnlyOnLeft().isEmpty()) { specSummaries.add(new DatasetSpecificationSummary(spec.getName(), spec.getType(), spec.getProperties())); } } return specSummaries.build(); } finally { readLock.unlock(); } }
@Override public Collection<DatasetSpecificationSummary> getInstances(NamespaceId namespaceId, Map<String, String> properties) { readLock.lock(); try { // don't expect this to be called a lot. // might be better to maintain this collection separately and just return it, but seems like its not worth it. Collection<DatasetSpecification> specs = instances.row(namespaceId).values(); ImmutableList.Builder<DatasetSpecificationSummary> specSummaries = ImmutableList.builder(); for (DatasetSpecification spec : specs) { if (properties.isEmpty() || Maps.difference(properties, spec.getProperties()).entriesOnlyOnLeft().isEmpty()) { specSummaries.add(new DatasetSpecificationSummary(spec.getName(), spec.getType(), spec.getProperties())); } } return specSummaries.build(); } finally { readLock.unlock(); } }
static Collection<DatasetSpecificationSummary> spec2Summary(Collection<DatasetSpecification> specs) { List<DatasetSpecificationSummary> datasetSummaries = Lists.newArrayList(); for (DatasetSpecification spec : specs) { // TODO: (CDAP-3097) handle system datasets specially within a namespace instead of filtering them out // by the handler. This filter is only in the list endpoint because the other endpoints are used by // HBaseQueueAdmin through DatasetFramework. spec = DatasetsUtil.fixOriginalProperties(spec); datasetSummaries.add(new DatasetSpecificationSummary(spec.getName(), spec.getType(), spec.getDescription(), spec.getOriginalProperties())); } return datasetSummaries; }
static Collection<DatasetSpecificationSummary> spec2Summary(Collection<DatasetSpecification> specs) { List<DatasetSpecificationSummary> datasetSummaries = Lists.newArrayList(); for (DatasetSpecification spec : specs) { // TODO: (CDAP-3097) handle system datasets specially within a namespace instead of filtering them out // by the handler. This filter is only in the list endpoint because the other endpoints are used by // HBaseQueueAdmin through DatasetFramework. if (QueueConstants.STATE_STORE_NAME.equals(spec.getName())) { continue; } spec = DatasetsUtil.fixOriginalProperties(spec); datasetSummaries.add(new DatasetSpecificationSummary(spec.getName(), spec.getType(), spec.getDescription(), spec.getOriginalProperties())); } return datasetSummaries; }
private DatasetSpecificationSummary spec2Summary(DatasetSpecification spec) { return new DatasetSpecificationSummary(spec.getName(), spec.getType(), spec.getDescription(), spec.getOriginalProperties()); }