Java Code Examples for org.apache.kylin.metadata.project.ProjectInstance#DEFAULT_PROJECT_NAME

The following examples show how to use org.apache.kylin.metadata.project.ProjectInstance#DEFAULT_PROJECT_NAME . 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: KylinTestBase.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
protected static void setupAll() throws Exception {
    //setup env
    HBaseMetadataTestCase.staticCreateTestMetadata();
    config = KylinConfig.getInstanceFromEnv();

    //setup cube conn
    String project = ProjectInstance.DEFAULT_PROJECT_NAME;
    cubeConnection = QueryConnection.getConnection(project);

    //setup h2
    h2Connection = DriverManager.getConnection("jdbc:h2:mem:db" + (h2InstanceCount++) + ";CACHE_SIZE=32072", "sa",
            "");
    // Load H2 Tables (inner join)
    H2Database h2DB = new H2Database(h2Connection, config, project);
    h2DB.loadAllTables();
}
 
Example 2
Source File: KylinTestBase.java    From kylin with Apache License 2.0 6 votes vote down vote up
protected static void setupAll() throws Exception {
    //setup env
    HBaseMetadataTestCase.staticCreateTestMetadata();
    config = KylinConfig.getInstanceFromEnv();

    //setup cube conn
    String project = ProjectInstance.DEFAULT_PROJECT_NAME;
    cubeConnection = QueryConnection.getConnection(project);

    //setup h2
    h2Connection = DriverManager.getConnection("jdbc:h2:mem:db" + (h2InstanceCount++) + ";CACHE_SIZE=32072", "sa",
            "");
    // Load H2 Tables (inner join)
    H2Database h2DB = new H2Database(h2Connection, config, project);
    h2DB.loadAllTables();
}
 
Example 3
Source File: CubeController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * save cubeDesc
 *
 * @return Table metadata array
 * @throws IOException
 */
@RequestMapping(value = "", method = { RequestMethod.POST }, produces = { "application/json" })
@ResponseBody
public CubeRequest saveCubeDesc(@RequestBody CubeRequest cubeRequest) {

    CubeDesc desc = deserializeCubeDesc(cubeRequest);

    if (desc == null) {
        cubeRequest.setMessage("CubeDesc is null.");
        return cubeRequest;
    }
    String name = desc.getName();
    if (StringUtils.isEmpty(name)) {
        logger.info("Cube name should not be empty.");
        throw new BadRequestException("Cube name should not be empty.");
    }
    if (!ValidateUtil.isAlphanumericUnderscore(name)) {
        throw new BadRequestException("Invalid Cube name, only letters, numbers and underscore supported.");
    }

    validateColumnFamily(desc);

    try {
        desc.setUuid(RandomUtil.randomUUID().toString());
        String projectName = (null == cubeRequest.getProject()) ? ProjectInstance.DEFAULT_PROJECT_NAME
                : cubeRequest.getProject();
        ProjectInstance project = cubeService.getProjectManager().getProject(projectName);
        if (project == null) {
            throw new NotFoundException("Project " + projectName + " doesn't exist");
        }
        cubeService.createCubeAndDesc(project, desc);
    } catch (Exception e) {
        logger.error("Failed to deal with the request.", e);
        throw new InternalErrorException(e.getLocalizedMessage(), e);
    }

    cubeRequest.setUuid(desc.getUuid());
    cubeRequest.setSuccessful(true);
    return cubeRequest;
}
 
Example 4
Source File: ModelController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
/**
 *
 * create model
 * @throws java.io.IOException
 */
@RequestMapping(value = "", method = { RequestMethod.POST }, produces = { "application/json" })
@ResponseBody
public ModelRequest saveModelDesc(@RequestBody ModelRequest modelRequest) {
    //Update Model
    DataModelDesc modelDesc = deserializeDataModelDesc(modelRequest);
    if (modelDesc == null || StringUtils.isEmpty(modelDesc.getName())) {
        return modelRequest;
    }

    if (StringUtils.isEmpty(modelDesc.getName())) {
        logger.info("Model name should not be empty.");
        throw new BadRequestException("Model name should not be empty.");
    }
    if (!ValidateUtil.isAlphanumericUnderscore(modelDesc.getName())) {
        throw new BadRequestException(
                String.format(Locale.ROOT,
                        "Invalid model name %s, only letters, numbers and underscore supported.",
                modelDesc.getName()));
    }

    try {
        modelDesc.setUuid(RandomUtil.randomUUID().toString());
        String projectName = (null == modelRequest.getProject()) ? ProjectInstance.DEFAULT_PROJECT_NAME
                : modelRequest.getProject();

        modelService.createModelDesc(projectName, modelDesc);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        logger.error("Failed to deal with the request:" + e.getLocalizedMessage(), e);
        throw new InternalErrorException("Failed to deal with the request: " + e.getLocalizedMessage(), e);
    }

    modelRequest.setUuid(modelDesc.getUuid());
    modelRequest.setSuccessful(true);
    return modelRequest;
}
 
Example 5
Source File: CubeController.java    From kylin with Apache License 2.0 5 votes vote down vote up
/**
 * save cubeDesc
 *
 * @return Table metadata array
 * @throws IOException
 */
@RequestMapping(value = "", method = { RequestMethod.POST }, produces = { "application/json" })
@ResponseBody
public CubeRequest saveCubeDesc(@RequestBody CubeRequest cubeRequest) {

    CubeDesc desc = deserializeCubeDesc(cubeRequest);

    if (desc == null) {
        cubeRequest.setMessage("CubeDesc is null.");
        return cubeRequest;
    }
    String name = desc.getName();
    if (StringUtils.isEmpty(name)) {
        logger.info("Cube name should not be empty.");
        throw new BadRequestException("Cube name should not be empty.");
    }
    if (!ValidateUtil.isAlphanumericUnderscore(name)) {
        throw new BadRequestException("Invalid Cube name, only letters, numbers and underscore supported.");
    }

    validateColumnFamily(desc);

    try {
        desc.setUuid(RandomUtil.randomUUID().toString());
        String projectName = (null == cubeRequest.getProject()) ? ProjectInstance.DEFAULT_PROJECT_NAME
                : cubeRequest.getProject();
        ProjectInstance project = cubeService.getProjectManager().getProject(projectName);
        if (project == null) {
            throw new NotFoundException("Project " + projectName + " doesn't exist");
        }
        cubeService.createCubeAndDesc(project, desc);
    } catch (Exception e) {
        logger.error("Failed to deal with the request.", e);
        throw new InternalErrorException(e.getLocalizedMessage(), e);
    }

    cubeRequest.setUuid(desc.getUuid());
    cubeRequest.setSuccessful(true);
    return cubeRequest;
}
 
Example 6
Source File: ModelController.java    From kylin with Apache License 2.0 5 votes vote down vote up
/**
 *
 * create model
 * @throws java.io.IOException
 */
@RequestMapping(value = "", method = { RequestMethod.POST }, produces = { "application/json" })
@ResponseBody
public ModelRequest saveModelDesc(@RequestBody ModelRequest modelRequest) {
    //Update Model
    DataModelDesc modelDesc = deserializeDataModelDesc(modelRequest);
    if (modelDesc == null || StringUtils.isEmpty(modelDesc.getName())) {
        return modelRequest;
    }

    if (StringUtils.isEmpty(modelDesc.getName())) {
        logger.info("Model name should not be empty.");
        throw new BadRequestException("Model name should not be empty.");
    }
    if (!ValidateUtil.isAlphanumericUnderscore(modelDesc.getName())) {
        throw new BadRequestException(
                String.format(Locale.ROOT,
                        "Invalid model name %s, only letters, numbers and underscore supported.",
                modelDesc.getName()));
    }

    try {
        modelDesc.setUuid(RandomUtil.randomUUID().toString());
        String projectName = (null == modelRequest.getProject()) ? ProjectInstance.DEFAULT_PROJECT_NAME
                : modelRequest.getProject();

        modelService.createModelDesc(projectName, modelDesc);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        logger.error("Failed to deal with the request:" + e.getLocalizedMessage(), e);
        throw new InternalErrorException("Failed to deal with the request: " + e.getLocalizedMessage(), e);
    }

    modelRequest.setUuid(modelDesc.getUuid());
    modelRequest.setSuccessful(true);
    return modelRequest;
}
 
Example 7
Source File: ITJdbcTableReaderTest.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {

    super.createTestMetadata();

    System.setProperty("kylin.source.jdbc.connection-url", "jdbc:h2:mem:db" + "_jdbc_table_reader");
    System.setProperty("kylin.source.jdbc.driver", "org.h2.Driver");
    System.setProperty("kylin.source.jdbc.user", "sa");
    System.setProperty("kylin.source.jdbc.pass", "");

    config = KylinConfig.getInstanceFromEnv();

    h2Connection = DriverManager.getConnection("jdbc:h2:mem:db" + "_jdbc_table_reader", "sa", "");

    String project = ProjectInstance.DEFAULT_PROJECT_NAME;
    H2Database h2DB = new H2Database(h2Connection, config, project);

    DataModelManager mgr = DataModelManager.getInstance(KylinConfig.getInstanceFromEnv());
    ModelDataGenerator gen = new ModelDataGenerator(mgr.getDataModelDesc("ci_left_join_model"), 10000);
    gen.generate();

    h2DB.loadAllTables();

}
 
Example 8
Source File: ITJdbcSourceTableLoaderTest.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {

    super.createTestMetadata();

    System.setProperty("kylin.source.jdbc.connection-url", "jdbc:h2:mem:db" + "_jdbc_source_table_loader");
    System.setProperty("kylin.source.jdbc.driver", "org.h2.Driver");
    System.setProperty("kylin.source.jdbc.user", "sa");
    System.setProperty("kylin.source.jdbc.pass", "");

    config = KylinConfig.getInstanceFromEnv();

    h2Connection = DriverManager.getConnection("jdbc:h2:mem:db" + "_jdbc_source_table_loader", "sa", "");

    String project = ProjectInstance.DEFAULT_PROJECT_NAME;
    H2Database h2DB = new H2Database(h2Connection, config, project);

    DataModelManager mgr = DataModelManager.getInstance(KylinConfig.getInstanceFromEnv());
    ModelDataGenerator gen = new ModelDataGenerator(mgr.getDataModelDesc("ci_left_join_model"), 10000);
    gen.generate();

    h2DB.loadAllTables();

}
 
Example 9
Source File: ITJdbcTableReaderTest.java    From kylin with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {

    super.createTestMetadata();

    System.setProperty("kylin.source.jdbc.connection-url", "jdbc:h2:mem:db" + "_jdbc_table_reader");
    System.setProperty("kylin.source.jdbc.driver", "org.h2.Driver");
    System.setProperty("kylin.source.jdbc.user", "sa");
    System.setProperty("kylin.source.jdbc.pass", "");

    config = KylinConfig.getInstanceFromEnv();

    h2Connection = DriverManager.getConnection("jdbc:h2:mem:db" + "_jdbc_table_reader", "sa", "");

    String project = ProjectInstance.DEFAULT_PROJECT_NAME;
    H2Database h2DB = new H2Database(h2Connection, config, project);

    DataModelManager mgr = DataModelManager.getInstance(KylinConfig.getInstanceFromEnv());
    ModelDataGenerator gen = new ModelDataGenerator(mgr.getDataModelDesc("ci_left_join_model"), 10000);
    gen.generate();

    h2DB.loadAllTables();

}
 
Example 10
Source File: ITJdbcSourceTableLoaderTest.java    From kylin with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {

    super.createTestMetadata();

    System.setProperty("kylin.source.jdbc.connection-url", "jdbc:h2:mem:db" + "_jdbc_source_table_loader");
    System.setProperty("kylin.source.jdbc.driver", "org.h2.Driver");
    System.setProperty("kylin.source.jdbc.user", "sa");
    System.setProperty("kylin.source.jdbc.pass", "");

    config = KylinConfig.getInstanceFromEnv();

    h2Connection = DriverManager.getConnection("jdbc:h2:mem:db" + "_jdbc_source_table_loader", "sa", "");

    String project = ProjectInstance.DEFAULT_PROJECT_NAME;
    H2Database h2DB = new H2Database(h2Connection, config, project);

    DataModelManager mgr = DataModelManager.getInstance(KylinConfig.getInstanceFromEnv());
    ModelDataGenerator gen = new ModelDataGenerator(mgr.getDataModelDesc("ci_left_join_model"), 10000);
    gen.generate();

    h2DB.loadAllTables();

}