Refine search
private ProjectInstance getProjectInstance(String projectName) { return ProjectManager.getInstance(KylinConfig.getInstanceFromEnv()).getProject(projectName); }
public CubeInstance createCube(CubeInstance cube, String projectName, String owner) throws IOException { try (AutoLock lock = cubeMapLock.lockForWrite()) { logger.info("Creating cube '{}-->{}' from instance object. '", projectName, cube.getName()); // save cube resource cube.setOwner(owner); updateCubeWithRetry(new CubeUpdate(cube), 0); ProjectManager.getInstance(config).moveRealizationToProject(RealizationType.CUBE, cube.getName(), projectName, owner); return cube; } }
private void delete(HybridInstance hybridInstance) throws IOException { ProjectManager.getInstance(kylinConfig).removeRealizationsFromProjects(RealizationType.HYBRID, hybridInstance.getName()); store.deleteResource(hybridInstance.getResourcePath()); hybridManager.reloadAllHybridInstance(); logger.info("HybridInstance was deleted at: " + hybridInstance.getResourcePath()); }
@Override public KylinConfig getConfig() { if (project == null) { return config; } else { ProjectInstance projInstance = ProjectManager.getInstance(config).getProject(project); return projInstance == null ? config : projInstance.getConfig(); } }
public ProjectInstance moveRealizationToProject(RealizationType type, String realizationName, String newProjectName, String owner) throws IOException { try (AutoLock lock = prjMapLock.lockForWrite()) { removeRealizationsFromProjects(type, realizationName); return addRealizationToProject(type, realizationName, newProjectName, owner); } }
private List<String> getProjects(String projectSeed) { List<String> result = Lists.newLinkedList(); if (projectSeed.equalsIgnoreCase("-all")) { ProjectManager projectManager = ProjectManager.getInstance(KylinConfig.getInstanceFromEnv()); for (ProjectInstance projectInstance : projectManager.listAllProjects()) { result.add(projectInstance.getName()); } } else { result.add(projectSeed); } if (result.isEmpty()) { throw new RuntimeException("No project to extract."); } return result; }
@Test public void testHappyIngest() { String srcPath = Thread.currentThread().getContextClassLoader().getResource("cloned_cube_and_model.zip").getPath(); CubeMetaIngester.main(new String[] { "-project", "default", "-srcPath", srcPath }); ProjectInstance project = ProjectManager.getInstance(KylinConfig.getInstanceFromEnv()).getProject("default"); Assert.assertEquals(1, Collections.frequency(project.getTables(), "DEFAULT.TEST_KYLIN_FACT")); Assert.assertTrue(project.getModels().contains("cloned_model")); Assert.assertTrue(project.getRealizationEntries().contains(RealizationEntry.create(RealizationType.CUBE, "cloned_cube"))); getTestConfig().clearManagers(); CubeInstance instance = CubeManager.getInstance(KylinConfig.getInstanceFromEnv()).getCube("cloned_cube"); Assert.assertTrue(instance != null); }
exportPath = exportDir.getAbsolutePath(); kylinConfig = KylinConfig.getInstanceFromEnv(); metadataManager = DataModelManager.getInstance(kylinConfig); projectManager = ProjectManager.getInstance(kylinConfig); hybridManager = HybridManager.getInstance(kylinConfig); cubeManager = CubeManager.getInstance(kylinConfig); for (ProjectInstance projectInstance : projectManager.listAllProjects()) { requireProject(projectInstance); String projectNames = optionsHelper.getOptionValue(OPTION_PROJECT); for (String projectName : StringUtil.splitByComma(projectNames)) { ProjectInstance projectInstance = projectManager.getProject(projectName); Preconditions.checkNotNull(projectInstance, "Project " + projectName + " does not exist."); requireProject(projectInstance);
public static boolean exposeMore(String project) { return ProjectManager.getInstance(KylinConfig.getInstanceFromEnv()).getProject(project).getConfig() .isPushDownEnabled(); }
public QueryRequestLimits(String project) { this.project = project; ProjectManager mgr = ProjectManager.getInstance(KylinConfig.getInstanceFromEnv()); ProjectInstance prj = mgr.getProject(project); this.maxConcurrentQuery = prj.getConfig().getQueryConcurrentRunningThresholdForProject(); boolean ok = openQueryRequest(project, maxConcurrentQuery); if (!ok) { Message msg = MsgPicker.getMsg(); logger.warn("Directly return exception as too many concurrent query requests for project: {}", project); throw new BadRequestException(msg.getQUERY_TOO_MANY_RUNNING()); } }
public JobInstanceExtractor() { config = KylinConfig.getInstanceFromEnv(); executableManager = ExecutableManager.getInstance(config); projectManager = ProjectManager.getInstance(config); packageType = "jobInstances"; options.addOption(OPTION_PROJECT); options.addOption(OPTION_CUBE); options.addOption(OPTION_PERIOD); }
@Test public void test3Delete() throws IOException { HybridManager hybridManager = HybridManager.getInstance(KylinConfig.getInstanceFromEnv()); Assert.assertNull(hybridManager.getHybridInstance("ssb_hybrid")); HybridCubeCLI.main(new String[] { "-name", "ssb_hybrid", "-project", "default", "-model", "ssb", "-cubes", "ssb_cube1,ssb_cube2", "-action", "create" }); Assert.assertNotNull(hybridManager.getHybridInstance("ssb_hybrid")); HybridCubeCLI.main(new String[] { "-name", "ssb_hybrid", "-project", "default", "-model", "ssb", "-action", "delete" }); HybridInstance hybridInstance = hybridManager.getHybridInstance("ssb_hybrid"); Assert.assertNull(hybridInstance); Assert.assertEquals(0, ProjectManager.getInstance(KylinConfig.getInstanceFromEnv()).findProjects(RealizationType.HYBRID, "ssb_hybrid").size()); }
public void updateII(IIInstance ii) throws IOException { logger.info("Updating II instance : " + ii.getName()); getStore().putResource(ii.getResourcePath(), ii, II_SERIALIZER); iiMap.put(ii.getName(), ii); //this is a duplicate call to take care of scenarios where REST cache service unavailable ProjectManager.getInstance(KylinConfig.getInstanceFromEnv()).clearL2Cache(); }
@Test public void testNewProject() throws Exception { ProjectManager prjMgr = ProjectManager.getInstance(getTestConfig()); CubeManager cubeMgr = CubeManager.getInstance(getTestConfig()); CubeDescManager cubeDescMgr = CubeDescManager.getInstance(getTestConfig()); int originalProjectCount = prjMgr.listAllProjects().size(); int originalCubeCount = cubeMgr.listAllCubes().size(); int originalCubeCountInDefault = prjMgr.listAllRealizations("default").size(); ResourceStore store = getStore(); CubeInstance createdCube = cubeMgr.createCube("cube_in_alien_project", "alien", desc, null); assertTrue(createdCube.equals(cubeMgr.getCube("cube_in_alien_project"))); ProjectManager proMgr = ProjectManager.getInstance(getTestConfig()); Set<IRealization> realizations = proMgr.listAllRealizations("alien"); assertTrue(realizations.contains(createdCube)); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount + 1); assertTrue(prjMgr.listAllRealizations("ALIEN").iterator().next().getName().equalsIgnoreCase("CUBE_IN_ALIEN_PROJECT")); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount + 1); prjMgr.moveRealizationToProject(RealizationType.CUBE, "cube_in_alien_project", "default", null); assertTrue(prjMgr.listAllRealizations("ALIEN").size() == 0); assertTrue(prjMgr.listAllRealizations("default").size() == originalCubeCountInDefault + 1); assertTrue(ProjectManager.getInstance(getTestConfig()).listAllRealizations("default").contains(createdCube)); prjMgr.moveRealizationToProject(RealizationType.CUBE, "cube_in_alien_project", "alien", null); assertTrue(prjMgr.listAllRealizations("ALIEN").size() == 1); assertTrue(prjMgr.listAllRealizations("default").size() == originalCubeCountInDefault); assertTrue(ProjectManager.getInstance(getTestConfig()).listAllRealizations("alien").contains(createdCube));
@Test public void testProjectsLoadAfterProjectChange() throws IOException { ProjectManager prjMgr = ProjectManager.getInstance(getTestConfig()); CubeManager cubeMgr = CubeManager.getInstance(getTestConfig()); CubeInstance cube = cubeMgr.getCube("ci_left_join_cube"); assertTrue(prjMgr.getRealizationsByTable("default", "default.test_kylin_fact").contains(cube)); prjMgr.removeRealizationsFromProjects(RealizationType.CUBE, cube.getName()); assertTrue(!prjMgr.getRealizationsByTable("default", "default.test_kylin_fact").contains(cube)); prjMgr.moveRealizationToProject(RealizationType.CUBE, cube.getName(), "default", "tester"); assertTrue(prjMgr.getRealizationsByTable("default", "default.test_kylin_fact").contains(cube)); }
public String getProject() { DataModelDesc modelDesc = getModel(); if (modelDesc == null) { // In case the model for cube not exists in metadata List<ProjectInstance> ownerPrj = ProjectManager.getInstance(config).findProjects(RealizationType.CUBE, name); if (ownerPrj.size() == 1) { return ownerPrj.get(0).getName(); } else { throw new IllegalStateException("No project found for cube " + name); } } else { return getModel().getProject(); } }
private void injest(File metaRoot) throws IOException { KylinConfig srcConfig = KylinConfig.createInstanceFromUri(metaRoot.getAbsolutePath()); TableMetadataManager srcMetadataManager = TableMetadataManager.getInstance(srcConfig); DataModelManager srcModelManager = DataModelManager.getInstance(srcConfig); HybridManager srcHybridManager = HybridManager.getInstance(srcConfig); CubeManager srcCubeManager = CubeManager.getInstance(srcConfig); CubeDescManager srcCubeDescManager = CubeDescManager.getInstance(srcConfig); checkAndMark(srcMetadataManager, srcModelManager, srcHybridManager, srcCubeManager, srcCubeDescManager); new ResourceTool().copy(srcConfig, kylinConfig, Lists.newArrayList(requiredResources)); // clear the cache Broadcaster.getInstance(kylinConfig).notifyClearAll(); ProjectManager projectManager = ProjectManager.getInstance(kylinConfig); for (TableDesc tableDesc : srcMetadataManager.listAllTables(null)) { logger.info("add " + tableDesc + " to " + targetProjectName); projectManager.addTableDescToProject(Lists.newArrayList(tableDesc.getIdentity()).toArray(new String[0]), targetProjectName); } for (CubeInstance cube : srcCubeManager.listAllCubes()) { logger.info("add " + cube + " to " + targetProjectName); projectManager.addModelToProject(cube.getModel().getName(), targetProjectName); projectManager.moveRealizationToProject(RealizationType.CUBE, cube.getName(), targetProjectName, null); } }
public void verify() { logger.info("================================================================="); logger.info("The changes are applied, now it's time to verify the new metadata store by reloading all metadata:"); logger.info("================================================================="); config.clearManagers(); DataModelManager.getInstance(config); CubeDescManager.getInstance(config); CubeManager.getInstance(config); ProjectManager.getInstance(config); //cleanup(); }
@Test public void testExistingProject() throws Exception { ProjectManager prjMgr = ProjectManager.getInstance(getTestConfig()); CubeManager cubeMgr = CubeManager.getInstance(getTestConfig()); CubeDescManager cubeDescMgr = CubeDescManager.getInstance(getTestConfig()); int originalProjectCount = prjMgr.listAllProjects().size(); int originalCubeCount = cubeMgr.listAllCubes().size(); ResourceStore store = getStore(); // clean legacy in case last run failed store.deleteResource("/cube/new_cube_in_default.json"); CubeDesc desc = cubeDescMgr.getCubeDesc("test_kylin_cube_with_slr_desc"); CubeInstance createdCube = cubeMgr.createCube("new_cube_in_default", ProjectInstance.DEFAULT_PROJECT_NAME, desc, null); assertTrue(createdCube.equals(cubeMgr.getCube("new_cube_in_default"))); //System.out.println(JsonUtil.writeValueAsIndentString(createdCube)); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount + 1); CubeInstance droppedCube = cubeMgr.dropCube("new_cube_in_default", true); assertTrue(createdCube.equals(droppedCube)); assertNull(cubeMgr.getCube("new_cube_in_default")); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount); }
private static LookupSnapshotBuildJob initJob(CubeInstance cube, String tableName, String submitter, KylinConfig kylinConfig) { List<ProjectInstance> projList = ProjectManager.getInstance(kylinConfig).findProjects(cube.getType(), cube.getName()); if (projList == null || projList.size() == 0) { throw new RuntimeException("Cannot find the project containing the cube " + cube.getName() + "!!!"); } else if (projList.size() >= 2) { String msg = "Find more than one project containing the cube " + cube.getName() + ". It does't meet the uniqueness requirement!!! "; throw new RuntimeException(msg); } LookupSnapshotBuildJob result = new LookupSnapshotBuildJob(); SimpleDateFormat format = new SimpleDateFormat("z yyyy-MM-dd HH:mm:ss", Locale.ROOT); format.setTimeZone(TimeZone.getTimeZone(kylinConfig.getTimeZone())); result.setDeployEnvName(kylinConfig.getDeployEnv()); result.setProjectName(projList.get(0).getName()); CubingExecutableUtil.setCubeName(cube.getName(), result.getParams()); result.setName(JOB_TYPE + " CUBE - " + cube.getName() + " - " + " TABLE - " + tableName + " - " + format.format(new Date(System.currentTimeMillis()))); result.setSubmitter(submitter); result.setNotifyList(cube.getDescriptor().getNotifyList()); return result; }