Java Code Examples for org.apache.kylin.metadata.project.ProjectManager#addModelToProject()
The following examples show how to use
org.apache.kylin.metadata.project.ProjectManager#addModelToProject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubeMetaIngester.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
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); } }
Example 2
Source File: DataModelManager.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
public DataModelDesc createDataModelDesc(DataModelDesc desc, String projectName, String owner) throws IOException { try (AutoLock lock = modelMapLock.lockForWrite()) { String name = desc.getName(); if (dataModelDescMap.containsKey(name)) throw new IllegalArgumentException("DataModelDesc '" + name + "' already exists"); ProjectManager prjMgr = ProjectManager.getInstance(config); ProjectInstance prj = prjMgr.getProject(projectName); if (prj.containsModel(name)) { throw new IllegalStateException("project " + projectName + " already contains model " + name); } desc.setOwner(owner); logger.info("Saving Model {} to Project {} with {} as owner", desc.getName(), projectName, owner); desc = saveDataModelDesc(desc, projectName); // now that model is saved, update project formally try { prjMgr.addModelToProject(name, projectName); } catch (WriteConflictException e) { logger.warn("Add model: {} to project: {} failed for write conflicts, rollback", name, projectName, e); crud.delete(desc); throw e; } return desc; } }
Example 3
Source File: CubeMetaIngester.java From kylin with Apache License 2.0 | 5 votes |
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); } }
Example 4
Source File: DataModelManager.java From kylin with Apache License 2.0 | 5 votes |
public DataModelDesc createDataModelDesc(DataModelDesc desc, String projectName, String owner) throws IOException { try (AutoLock lock = modelMapLock.lockForWrite()) { String name = desc.getName(); if (dataModelDescMap.containsKey(name)) throw new IllegalArgumentException("DataModelDesc '" + name + "' already exists"); ProjectManager prjMgr = ProjectManager.getInstance(config); ProjectInstance prj = prjMgr.getProject(projectName); if (prj.containsModel(name)) { throw new IllegalStateException("project " + projectName + " already contains model " + name); } desc.setOwner(owner); logger.info("Saving Model {} to Project {} with {} as owner", desc.getName(), projectName, owner); desc = saveDataModelDesc(desc, projectName); // now that model is saved, update project formally try { prjMgr.addModelToProject(name, projectName); } catch (WriteConflictException e) { logger.warn("Add model: {} to project: {} failed for write conflicts, rollback", name, projectName, e); crud.delete(desc); throw e; } return desc; } }