Java Code Examples for org.apache.kylin.metadata.project.ProjectInstance#containsModel()

The following examples show how to use org.apache.kylin.metadata.project.ProjectInstance#containsModel() . 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: DataModelManager.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
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 2
Source File: ProjectService.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public String getProjectOfModel(String modelName) {
    for (ProjectInstance p : getProjectManager().listAllProjects()) {
        if (p.containsModel(modelName))
            return p.getName();
    }
    return null;
}
 
Example 3
Source File: DataModelManager.java    From kylin with Apache License 2.0 5 votes vote down vote up
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 4
Source File: ProjectService.java    From kylin with Apache License 2.0 5 votes vote down vote up
public String getProjectOfModel(String modelName) {
    for (ProjectInstance p : getProjectManager().listAllProjects()) {
        if (p.containsModel(modelName))
            return p.getName();
    }
    return null;
}