/** * Helper method which creates a new entity or update the existing entity with given entity * * @param entity * @throws NamespaceException */ private void createOrUpdateEntity(final NamespaceEntity entity, NamespaceAttribute... attributes) throws NamespaceException { final NamespaceKey entityPath = entity.getPathKey().getPath(); final List<NameSpaceContainer> entitiesOnPath = getEntitiesOnPath(entityPath); doCreateOrUpdateEntity(entity, entitiesOnPath, attributes); }
@SuppressWarnings("unchecked") public T setConnectionConf(AbstractConnectionConf conf) { setType(conf.getType()); setConfig(conf.toBytesString()); return (T) this; }
@Override public DatasetConfig renameDataset(NamespaceKey oldDatasetPath, NamespaceKey newDatasetPath) throws NamespaceException { return doRenameDataset(oldDatasetPath, newDatasetPath, getEntitiesOnPath(oldDatasetPath.getParent()), getEntitiesOnPath(newDatasetPath.getParent())); }
@Override public SourceConfig getSource(String username, String sourcename) throws NamespaceException { return factoryProvider.get() .get(username) .getSource(new NamespaceKey(sourcename)); } }
public Builder withDefaultSchema(List<String> defaultSchemaPath){ if(defaultSchemaPath == null) { userSession.defaultSchemaPath = null; return this; } userSession.defaultSchemaPath = new NamespaceKey(defaultSchemaPath); return this; }
@Override public List<NameSpaceContainer> list(NamespaceKey root) throws NamespaceException { final List<NameSpaceContainer> entitiesOnPath = getEntitiesOnPath(root); final NameSpaceContainer rootContainer = lastElement(entitiesOnPath); if (rootContainer == null) { throw new NamespaceNotFoundException(root, "not found"); } if (!isListable(rootContainer.getType())) { throw new NamespaceNotFoundException(root, "no listable entity found"); } return doList(root, entitiesOnPath); }
@Override public String toString() { return "metadata-refresh-" + sourceKey.getRoot(); } }
protected void doCreateOrUpdateEntity(final NamespaceEntity entity, List<NameSpaceContainer> entitiesOnPath, NamespaceAttribute... attributes) throws NamespaceException { final NameSpaceContainer prevContainer = lastElement(entitiesOnPath); ensureIdExistsTypeMatches(entity, prevContainer); namespace.put(entity.getPathKey().getKey(), entity.getContainer()); }
protected NameSpaceContainer doDeleteEntity(final NamespaceKey path, final Type type, String version, List<NameSpaceContainer> entitiesOnPath, boolean deleteRoot) throws NamespaceException { final NamespaceInternalKey key = new NamespaceInternalKey(path, keyNormalization); final NameSpaceContainer container = lastElement(entitiesOnPath); traverseAndDeleteChildren(key, container); if(deleteRoot) { namespace.delete(key.getKey(), version); } return container; }
private boolean storeSchema(NamespaceKey key, DatasetConfig config) throws NamespaceException { try { namespace.addOrUpdateDataset(key, config); return true; } catch (final ConcurrentModificationException ex) { return false; } } }
public NamespaceService getNamespaceService(String userName) { // TODO (DX-10053): Add the below check when the ticket is resolved // checkIfCoordinator(); return namespaceServiceFactory.get(userName); }
@Override public void addOrUpdateSource(NamespaceKey sourcePath, SourceConfig sourceConfig, NamespaceAttribute... attributes) throws NamespaceException { createOrUpdateEntity(NamespaceEntity.toEntity(SOURCE, sourcePath, sourceConfig, keyNormalization), attributes); }
@Override public BoundedDatasetCount getDatasetCount(NamespaceKey root, long searchTimeLimitMillis, int countLimitToStopSearch) throws NamespaceException { return getDatasetCountHelper(root, searchTimeLimitMillis, countLimitToStopSearch); }
public byte[] getRangeStartKey() { if (cachedRangeStartKey == null) { buildRangeKeys(); } return cachedRangeStartKey; }
@Override public String toString() { return "fix-fail-to-start-" + sourceKey.getRoot(); } }
@Override public void addOrUpdateSpace(NamespaceKey spacePath, SpaceConfig spaceConfig, NamespaceAttribute... attributes) throws NamespaceException { createOrUpdateEntity(NamespaceEntity.toEntity(SPACE, spacePath, spaceConfig, keyNormalization), attributes); }
@Override public void addOrUpdateFolder(NamespaceKey folderPath, FolderConfig folderConfig, NamespaceAttribute... attributes) throws NamespaceException { createOrUpdateEntity(NamespaceEntity.toEntity(FOLDER, folderPath, folderConfig, keyNormalization), attributes); }
@Override public void addOrUpdateHome(NamespaceKey homePath, HomeConfig homeConfig) throws NamespaceException { createOrUpdateEntity(NamespaceEntity.toEntity(HOME, homePath, homeConfig, keyNormalization)); }