public SpaceConfig newMessage() { return new SpaceConfig(); }
public static void addSpace(NamespaceService ns, String name) throws Exception { final SpaceConfig space = new SpaceConfig(); space.setName(name); ns.addOrUpdateSpace(new NamespaceKey(name), space); }
public static SpaceConfig getSpaceConfig(Space space) { SpaceConfig config = new SpaceConfig(); config.setName(space.getName()); config.setId(new EntityId(space.getId())); if (space.getTag() != null) { config.setTag(space.getTag()); } config.setCtime(space.getCreatedAt()); return config; }
@Test public void testGetSpaceCatalogEntityById() throws Exception { SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setId(new EntityId("space-id")); spaceConfig.setName("mySpace"); NameSpaceContainer namespaceContainer = new NameSpaceContainer(); namespaceContainer.setType(NameSpaceContainer.Type.SPACE); namespaceContainer.setSpace(spaceConfig); when(namespaceService.getEntityById(spaceConfig.getId().getId())).thenReturn(namespaceContainer); when(namespaceService.getEntities(Collections.singletonList(new NamespaceKey(spaceConfig.getName())))).thenReturn(Collections.singletonList(namespaceContainer)); // for children listing, we just send the space back to keep it simple when(namespaceService.list(new NamespaceKey(spaceConfig.getName()))).thenReturn(Collections.singletonList(namespaceContainer)); Optional<CatalogEntity> catalogEntityById = catalogServiceHelper.getCatalogEntityById(spaceConfig.getId().getId()); assertTrue(catalogEntityById.isPresent()); CatalogEntity catalogEntity = catalogEntityById.get(); assertTrue(catalogEntity instanceof Space); Space space = (Space) catalogEntity; assertEquals(space.getId(), spaceConfig.getId().getId()); assertEquals(space.getChildren().size(), 1); }
@BeforeClass public static void before() throws Exception { NamespaceService namespaceService = newNamespaceService(); SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setName("searchSpace"); namespaceService.addOrUpdateSpace(new NamespaceKey(spaceConfig.getName()), spaceConfig); }
@BeforeClass public static void init() throws Exception { BaseTestServer.init(); // setup space NamespaceKey key = new NamespaceKey("mySpace"); SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setName("mySpace"); newNamespaceService().addOrUpdateSpace(key, spaceConfig); }
@BeforeClass public static void init() throws Exception { BaseTestServer.init(); // setup space NamespaceKey key = new NamespaceKey("dsvTest"); SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setName("dsvTest"); newNamespaceService().addOrUpdateSpace(key, spaceConfig); }
public static SpaceConfig addOrUpdateSpace(NamespaceService service, SpacePath spacePath, Space space) throws NamespaceException, UserNotFoundException { SpaceConfig spaceConfig = new SpaceConfig() .setId(space.getId() != null ? new EntityId(space.getId()) : null) .setName(space.getName()) .setDescription(space.getDescription()) .setTag(space.getVersion()); service.addOrUpdateSpace(spacePath.toNamespaceKey(), spaceConfig); return service.getSpace(spacePath.toNamespaceKey()); }
private void createSpaceAndVDS(NamespaceKey spacePath, List<String> vdsPath) throws NamespaceException { // create space SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setName(spacePath.getRoot()); newNamespaceService().addOrUpdateSpace(spacePath, spaceConfig); // create vds VirtualDataset virtualDataset = new VirtualDataset(); virtualDataset.setSql("select * from sys.version"); DatasetConfig datasetConfig = new DatasetConfig(); datasetConfig.setName(vdsPath.get(vdsPath.size() - 1)); datasetConfig.setFullPathList(vdsPath); datasetConfig.setType(DatasetType.VIRTUAL_DATASET); datasetConfig.setVirtualDataset(virtualDataset); getSabotContext().getViewCreator(SystemUser.SYSTEM_USERNAME).createView(vdsPath, "select * from sys.version", null); } }
clearAllDataExceptUser(); getPopulator().populateSources(); SpaceConfig config = new SpaceConfig(); config.setName("testA"); namespaceService.addOrUpdateSpace(new SpacePath(config.getName()).toNamespaceKey(), config); config = new SpaceConfig(); config.setName("testB"); namespaceService.addOrUpdateSpace(new SpacePath(config.getName()).toNamespaceKey(), config);
DatasetVersionMutator service = newDatasetVersionMutator(); SpaceConfig config = new SpaceConfig(); config.setName("a"); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config.getName())).toNamespaceKey(), config); config = new SpaceConfig(); config.setName("b"); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config.getName())).toNamespaceKey(), config); config = new SpaceConfig(); config.setName("c"); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config.getName())).toNamespaceKey(), config);
public void addCPSource(boolean createFolder) throws Exception { getSourceService().registerSourceWithRuntime(InternalFileConf.create(TEST_SOURCE, new URI("classpath:///acceleration/"), SchemaMutability.ALL, CatalogService.DEFAULT_METADATA_POLICY)); final NamespaceService nsService = getNamespaceService(); final SpaceConfig config = new SpaceConfig().setName(TEST_SPACE); if(!nsService.exists(new SpacePath(config.getName()).toNamespaceKey())) { nsService.addOrUpdateSpace(new SpacePath(config.getName()).toNamespaceKey(), config); } if (createFolder) { final FolderConfig folderConfig = new FolderConfig().setName(TEST_FOLDER); nsService.addOrUpdateFolder(TEST_FOLDER_PATH.toNamespaceKey(), folderConfig); } }
protected void setSpace() throws NamespaceException, IOException { clearAllDataExceptUser(); final SpaceConfig foo = new SpaceConfig().setName("spacefoo"); SpacePath spacePath = new SpacePath(new SpaceName(foo.getName())); newNamespaceService().addOrUpdateSpace(spacePath.toNamespaceKey(), foo); newNamespaceService().addOrUpdateFolder(new FolderPath("spacefoo.folderbar").toNamespaceKey(), new FolderConfig().setName("folderbar").setFullPathList(asList("spacefoo", "folderbar"))); newNamespaceService().addOrUpdateFolder(new FolderPath("spacefoo.folderbar.folderbaz").toNamespaceKey(), new FolderConfig().setName("folderbaz").setFullPathList(asList("spacefoo", "folderbar", "folderbaz"))); }
@BeforeClass public static void init() throws Exception { BaseTestServer.init(); final NamespaceService nsService = getNamespaceService(); final SpaceConfig config = new SpaceConfig().setName(TEST_SPACE); nsService.addOrUpdateSpace(new SpacePath(config.getName()).toNamespaceKey(), config); materializationStore = new MaterializationStore(p(KVStoreProvider.class)); entriesStore = new ReflectionEntriesStore(p(KVStoreProvider.class)); }
when(namespaceService.getHome(new HomePath(HomeName.getUserHomePath("user")).toNamespaceKey())).thenReturn(homeConfig); SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setName("mySpace"); spaceConfig.setId(new EntityId("space-id"));
@Test public void testDownloadWithRelativeDatasetPath() throws Exception { SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setName("mySpace"); newNamespaceService().addOrUpdateSpace(new NamespaceKey("mySpace"), spaceConfig); FolderConfig folderConfig = new FolderConfig(); List<String> path = Arrays.asList("mySpace", "folder"); folderConfig.setFullPathList(path); folderConfig.setName("folder"); newNamespaceService().addOrUpdateFolder(new NamespaceKey(path), folderConfig); final DatasetPath dsPath = new DatasetPath("mySpace.folder.testVDS"); DatasetUI ds = createDatasetFromSQLAndSave(dsPath,"select * from DG.dsg1 LIMIT 10", asList("cp")); final DatasetPath dsPath2 = new DatasetPath("mySpace.folder.testVDS2"); DatasetUI ds2 = createDatasetFromSQLAndSave(dsPath2,"select * from testVDS", path); Job job = datasetService.prepareDownload(dsPath2, ds2.getDatasetVersion(), DownloadFormat.CSV, 50, SampleDataPopulator.DEFAULT_USER_NAME); job.getData().loadIfNecessary(); DownloadDataResponse downloadDataResponse = datasetService.downloadData(job.getJobAttempt().getInfo().getDownloadInfo(), SampleDataPopulator.DEFAULT_USER_NAME); final List<TestData> downloadedData = readDataCsv(downloadDataResponse.getInput()); assertEquals(10, downloadedData.size()); for (int i = 0; i < 10; ++i) { assertEquals("user" + i, downloadedData.get(i).getUser()); assertEquals(i%25, downloadedData.get(i).getAge()); assertEquals("address" + i, downloadedData.get(i).getAddress()); } }
NamespaceService namespaceService = newNamespaceService(); DatasetVersionMutator service = newDatasetVersionMutator(); SpaceConfig config = new SpaceConfig(); config.setName("a"); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config.getName())).toNamespaceKey(), config); config = new SpaceConfig(); config.setName("b"); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config.getName())).toNamespaceKey(), config); config = new SpaceConfig(); config.setName("c"); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config.getName())).toNamespaceKey(), config);
@Test public void testSpaces() throws Exception { final NamespaceService namespaceService = newNamespaceService(); final SpaceConfig config1 = new SpaceConfig(); final SpaceConfig config2 = new SpaceConfig();
@Test public void testCTASReplace() throws Exception { NamespaceKey namespaceKey = new NamespaceKey("ctasSpace"); SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setName("ctasSpace"); newNamespaceService().addOrUpdateSpace(namespaceKey, spaceConfig); SqlQuery ctas = getQueryFromSQL("CREATE OR REPLACE VIEW ctasSpace.ctastest AS select * from (VALUES (1))"); Job ctasJob = jobsService.submitJob(JobRequest.newBuilder() .setSqlQuery(ctas) .setQueryType(QueryType.UI_RUN) .build(), NoOpJobStatusListener.INSTANCE); waitForCompletion(ctasJob); ctas = getQueryFromSQL("CREATE OR REPLACE VIEW ctasSpace.ctastest AS select * from (VALUES (2))"); ctasJob = jobsService.submitJob(JobRequest.newBuilder() .setSqlQuery(ctas) .setQueryType(QueryType.UI_RUN) .build(), NoOpJobStatusListener.INSTANCE); waitForCompletion(ctasJob); newNamespaceService().deleteSpace(namespaceKey, newNamespaceService().getSpace(namespaceKey).getTag()); }
kvstore.start(); final NamespaceService namespaceService = new NamespaceServiceImpl(kvstore); final SpaceConfig space1 = new SpaceConfig(); final SpaceConfig space2 = new SpaceConfig();