private void updateExplore(DatasetId datasetInstance, DatasetProperties creationProperties, DatasetSpecification oldSpec, DatasetSpecification newSpec) { // Enable ad-hoc exploration of dataset // Note: today explore enable is not transactional with dataset create - CDAP-1393 try { exploreFacade.updateExploreDataset(datasetInstance, oldSpec, newSpec); } catch (Exception e) { LOG.error("Cannot update Explore for dataset instance {} with old properties {} and new properties {}", datasetInstance, oldSpec.getOriginalProperties(), creationProperties.getProperties(), e); // TODO: at this time we want to still allow using dataset even if it cannot be used for exploration } }
private void updateExplore(DatasetId datasetInstance, DatasetProperties creationProperties, DatasetSpecification oldSpec, DatasetSpecification newSpec) { // Enable ad-hoc exploration of dataset // Note: today explore enable is not transactional with dataset create - CDAP-1393 try { exploreFacade.updateExploreDataset(datasetInstance, oldSpec, newSpec); } catch (Exception e) { LOG.error("Cannot update Explore for dataset instance {} with old properties {} and new properties {}", datasetInstance, oldSpec.getOriginalProperties(), creationProperties.getProperties(), e); // TODO: at this time we want to still allow using dataset even if it cannot be used for exploration } }
if (spec == null || spec.getOriginalProperties() != null) { return spec;
if (spec == null || spec.getOriginalProperties() != null) { return spec;
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; }
/** * Return the original properties of a dataset instance, that is, the properties with which the dataset was * created or last reconfigured. * @param instance the id of the dataset * @return The original properties as stored in the dataset's spec, or if they are not available, a best effort * to derive the original properties from the top-level properties of the spec * @throws UnauthorizedException if perimeter security and authorization are enabled, and the current user does not * have any privileges on the #instance */ Map<String, String> getOriginalProperties(DatasetId instance) throws Exception { // Only return the properties if authorization succeeds if (!DatasetsUtil.isSystemDatasetInUserNamespace(instance)) { AuthorizationUtil.ensureAccess(instance, authorizationEnforcer, authenticationContext.getPrincipal()); } DatasetSpecification spec = instanceManager.get(instance); if (spec == null) { throw new NotFoundException(instance); } return DatasetsUtil.fixOriginalProperties(spec).getOriginalProperties(); }
/** * Return the original properties of a dataset instance, that is, the properties with which the dataset was * created or last reconfigured. * @param instance the id of the dataset * @return The original properties as stored in the dataset's spec, or if they are not available, a best effort * to derive the original properties from the top-level properties of the spec * @throws UnauthorizedException if perimeter security and authorization are enabled, and the current user does not * have any privileges on the #instance */ Map<String, String> getOriginalProperties(DatasetId instance) throws Exception { // Only return the properties if authorization succeeds if (!DatasetsUtil.isSystemDatasetInUserNamespace(instance)) { AuthorizationUtil.ensureAccess(instance, authorizationEnforcer, authenticationContext.getPrincipal()); } DatasetSpecification spec = instanceManager.get(instance); if (spec == null) { throw new NotFoundException(instance); } return DatasetsUtil.fixOriginalProperties(spec).getOriginalProperties(); }
private DatasetSpecificationSummary spec2Summary(DatasetSpecification spec) { return new DatasetSpecificationSummary(spec.getName(), spec.getType(), spec.getDescription(), spec.getOriginalProperties()); }
private void testFix(String type, DatasetProperties props) { DatasetDefinition def = DatasetFrameworkTestUtil.getDatasetDefinition( inMemoryDatasetFramework, NamespaceId.DEFAULT, type); Assert.assertNotNull(def); DatasetSpecification spec = def.configure("nn", props); Map<String, String> originalProperties = DatasetsUtil.fixOriginalProperties(spec).getOriginalProperties(); Assert.assertEquals(props.getProperties(), originalProperties); } }
/** * Drops the specified dataset instance. * * @param instance the {@link DatasetId} to drop * @throws NamespaceNotFoundException if the namespace was not found * @throws DatasetNotFoundException if the dataset instance was not found * @throws IOException if there was a problem in checking if the namespace exists over HTTP * @throws UnauthorizedException if perimeter security and authorization are enabled, and the current user does not * have {@link Action#ADMIN} privileges on the #instance */ void drop(DatasetId instance) throws Exception { Principal requestingUser = authenticationContext.getPrincipal(); if (!DatasetsUtil.isSystemDatasetInUserNamespace(instance)) { authorizationEnforcer.enforce(instance, requestingUser, Action.ADMIN); } ensureNamespaceExists(instance.getParent()); DatasetSpecification spec = instanceManager.get(instance); if (spec == null) { throw new DatasetNotFoundException(instance); } dropDataset(instance, spec); // Publish in here instead of the dropDataset(instance, spec) method as that private method // is used in the dropAll case. For metadata publishing, the dropAll is a different operation. if (publishCUD && !isLocalDataset(spec.getOriginalProperties()) && !isLocalDataset(spec.getProperties())) { metadataPublisher.publish(instance, DatasetInstanceOperation.delete(requestingUser)); } }
/** * Drops the specified dataset instance. * * @param instance the {@link DatasetId} to drop * @throws NamespaceNotFoundException if the namespace was not found * @throws DatasetNotFoundException if the dataset instance was not found * @throws IOException if there was a problem in checking if the namespace exists over HTTP * @throws UnauthorizedException if perimeter security and authorization are enabled, and the current user does not * have {@link Action#ADMIN} privileges on the #instance */ void drop(DatasetId instance) throws Exception { Principal requestingUser = authenticationContext.getPrincipal(); if (!DatasetsUtil.isSystemDatasetInUserNamespace(instance)) { authorizationEnforcer.enforce(instance, requestingUser, Action.ADMIN); } ensureNamespaceExists(instance.getParent()); DatasetSpecification spec = instanceManager.get(instance); if (spec == null) { throw new DatasetNotFoundException(instance); } dropDataset(instance, spec); // Publish in here instead of the dropDataset(instance, spec) method as that private method // is used in the dropAll case. For metadata publishing, the dropAll is a different operation. if (publishCUD && !isLocalDataset(spec.getOriginalProperties()) && !isLocalDataset(spec.getProperties())) { metadataPublisher.publish(instance, DatasetInstanceOperation.delete(requestingUser)); } }
Map<String, String> storedOriginalProps = meta.getSpec().getOriginalProperties(); Assert.assertEquals(props.getProperties(), storedOriginalProps); Assert.assertEquals(newProps.getProperties(), meta.getSpec().getOriginalProperties()); Assert.assertEquals("val2", meta.getSpec().getProperty("prop2")); Assert.assertNull(meta.getSpec().getProperty("prop1"));