Java Code Examples for org.apache.kylin.common.KylinConfig#createInstanceFromUri()

The following examples show how to use org.apache.kylin.common.KylinConfig#createInstanceFromUri() . 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: MigrationRuleSet.java    From kylin with Apache License 2.0 6 votes vote down vote up
public Context(QueryService queryService, CubeInstance cubeInstance, String targetHost, String tgtProjectName) {
    this.queryService = queryService;
    this.cubeInstance = cubeInstance;
    this.targetAddress = targetHost;
    KylinConfig targetConfig = KylinConfig.createInstanceFromUri(targetHost);
    this.targetResourceStore = ResourceStore.getStore(targetConfig);
    this.tgtProjectName = tgtProjectName;

    List<ProjectInstance> projList = ProjectManager.getInstance(KylinConfig.getInstanceFromEnv())
            .findProjects(cubeInstance.getType(), cubeInstance.getName());
    if (projList.size() != 1) {
        throw new InternalErrorException("Cube " + cubeInstance.getName()
                + " should belong to only one project. However, it's belong to " + projList);
    }
    this.srcProjectName = projList.get(0).getName();
}
 
Example 2
Source File: JobRelatedMetaUtil.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public static void dumpResources(KylinConfig kylinConfig, File metaDir, Set<String> dumpList) throws IOException {
    long startTime = System.currentTimeMillis();

    ResourceStore from = ResourceStore.getStore(kylinConfig);
    KylinConfig localConfig = KylinConfig.createInstanceFromUri(metaDir.getAbsolutePath());
    ResourceStore to = ResourceStore.getStore(localConfig);
    for (String path : dumpList) {
        RawResource res = from.getResource(path);
        if (res == null)
            throw new IllegalStateException("No resource found at -- " + path);
        to.putResource(path, res.content(), res.lastModified());
        res.content().close();
    }

    logger.debug("Dump resources to {} took {} ms", metaDir, System.currentTimeMillis() - startTime);
}
 
Example 3
Source File: MetaDumpUtil.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public static void dumpResources(KylinConfig kylinConfig, String metaOutDir, Set<String> dumpList)
        throws IOException {
    long startTime = System.currentTimeMillis();

    ResourceStore from = ResourceStore.getStore(kylinConfig);
    KylinConfig localConfig = KylinConfig.createInstanceFromUri(metaOutDir);
    ResourceStore to = ResourceStore.getStore(localConfig);
    final String[] tolerantResources = { "/table_exd" };

    for (String path : dumpList) {
        RawResource res = from.getResource(path);
        if (res == null) {
            if (StringUtils.startsWithAny(path, tolerantResources)) {
                continue;
            } else {
                throw new IllegalStateException("No resource found at -- " + path);
            }
        }
        to.putResource(path, res.content(), res.lastModified());
        res.content().close();
    }

    logger.debug("Dump resources to {} took {} ms", metaOutDir, System.currentTimeMillis() - startTime);
}
 
Example 4
Source File: JobDiagnosisInfoCLI.java    From kylin with Apache License 2.0 5 votes vote down vote up
private void extractResources(File destDir) {
    logger.info("The resource paths going to be extracted:");
    for (String s : requiredResources) {
        logger.info(s + "(required)");
    }

    try {
        KylinConfig srcConfig = KylinConfig.getInstanceFromEnv();
        KylinConfig dstConfig = KylinConfig.createInstanceFromUri(destDir.getAbsolutePath());
        new ResourceTool().copy(srcConfig, dstConfig, requiredResources);
    } catch (Exception e) {
        throw new RuntimeException("Failed to extract job resources. ", e);
    }
}
 
Example 5
Source File: QueryCli.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        Options options = new Options();
        options.addOption(OPTION_METADATA);
        options.addOption(OPTION_SQL);

        CommandLineParser parser = new GnuParser();
        CommandLine commandLine = parser.parse(options, args);
        KylinConfig config = KylinConfig.createInstanceFromUri(commandLine.getOptionValue(OPTION_METADATA.getOpt()));
        String sql = commandLine.getOptionValue(OPTION_SQL.getOpt());

        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            conn = QueryConnection.getConnection(null);

            stmt = conn.createStatement();
            rs = stmt.executeQuery(sql);
            int n = 0;
            ResultSetMetaData meta = rs.getMetaData();
            while (rs.next()) {
                n++;
                for (int i = 1; i <= meta.getColumnCount(); i++) {
                    System.out.println(n + " - " + meta.getColumnLabel(i) + ":\t" + rs.getObject(i));
                }
            }
        } finally {
            DBUtils.closeQuietly(rs);
            DBUtils.closeQuietly(stmt);
            DBUtils.closeQuietly(conn);
        }

    }
 
Example 6
Source File: CubeMetaIngester.java    From kylin with Apache License 2.0 5 votes vote down vote up
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 7
Source File: CubeMetaIngester.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
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 8
Source File: JobDiagnosisInfoCLI.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private void extractResources(File destDir) {
    logger.info("The resource paths going to be extracted:");
    for (String s : requiredResources) {
        logger.info(s + "(required)");
    }

    try {
        KylinConfig srcConfig = KylinConfig.getInstanceFromEnv();
        KylinConfig dstConfig = KylinConfig.createInstanceFromUri(destDir.getAbsolutePath());
        new ResourceTool().copy(srcConfig, dstConfig, requiredResources);
    } catch (Exception e) {
        throw new RuntimeException("Failed to extract job resources. ", e);
    }
}
 
Example 9
Source File: ClusterUtil.java    From kylin with Apache License 2.0 5 votes vote down vote up
public ClusterUtil(String configURI, boolean ifJobFSHAEnabled, boolean ifHBaseFSHAEnabled) throws IOException {
    this.kylinConfig = KylinConfig.createInstanceFromUri(configURI);
    this.restClient = new RestClient(configURI);
    Path hdfsWorkingPath = Path.getPathWithoutSchemeAndAuthority(new Path(kylinConfig.getHdfsWorkingDirectory()));
    String tmpHdfsWorkingDirectory = hdfsWorkingPath.toString();
    this.hdfsWorkingDirectory = tmpHdfsWorkingDirectory.endsWith("/") ? tmpHdfsWorkingDirectory
            : tmpHdfsWorkingDirectory + "/";

    this.jobConf = KylinConfig.getConfigFromString(restClient.getHDFSConfiguration());
    this.jobFS = FileSystem.get(jobConf);
    this.jobHdfsWorkingDirectoryQualified = getQualifiedPath(jobConf, hdfsWorkingDirectory, ifJobFSHAEnabled);

    this.hbaseConf = KylinConfig.getConfigFromString(restClient.getHBaseConfiguration());
    this.hbaseFS = FileSystem.get(hbaseConf);
    this.hbaseHdfsWorkingDirectoryQualified = getQualifiedPath(hbaseConf, hdfsWorkingDirectory, ifHBaseFSHAEnabled);

    this.hbaseConn = ConnectionFactory.createConnection(hbaseConf);
    this.resourceStore = new HBaseResourceStore(kylinConfig) {
        @Override
        protected Connection getConnection() {
            return hbaseConn;
        }

        @Override
        protected Configuration getCurrentHBaseConfiguration() {
            return hbaseConf;
        }
    };
    this.hbaseAdmin = hbaseConn.getAdmin();
}
 
Example 10
Source File: ResourceStore.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static String dumpResources(KylinConfig kylinConfig, Collection<String> dumpList) throws IOException {
    File tmp = File.createTempFile("kylin_job_meta", "");
    FileUtils.forceDelete(tmp); // we need a directory, so delete the file first

    File metaDir = new File(tmp, "meta");
    metaDir.mkdirs();

    // write kylin.properties
    File kylinPropsFile = new File(metaDir, "kylin.properties");
    kylinConfig.exportToFile(kylinPropsFile);

    ResourceStore from = ResourceStore.getStore(kylinConfig);
    KylinConfig localConfig = KylinConfig.createInstanceFromUri(metaDir.getAbsolutePath());
    ResourceStore to = ResourceStore.getStore(localConfig);
    for (String path : dumpList) {
        RawResource res = from.getResource(path);
        if (res == null)
            throw new IllegalStateException("No resource found at -- " + path);
        to.putResource(path, res.content(), res.lastModified());
        res.close();
    }

    String metaDirURI = OptionsHelper.convertToFileURL(metaDir.getAbsolutePath());
    if (metaDirURI.startsWith("/")) // note Path on windows is like "d:/../..."
        metaDirURI = "file://" + metaDirURI;
    else
        metaDirURI = "file:///" + metaDirURI;
    logger.info("meta dir is: {}", metaDirURI);

    return metaDirURI;
}
 
Example 11
Source File: QueryCli.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        Options options = new Options();
        options.addOption(OPTION_METADATA);
        options.addOption(OPTION_SQL);

        CommandLineParser parser = new GnuParser();
        CommandLine commandLine = parser.parse(options, args);
        KylinConfig config = KylinConfig.createInstanceFromUri(commandLine.getOptionValue(OPTION_METADATA.getOpt()));
        String sql = commandLine.getOptionValue(OPTION_SQL.getOpt());

        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            conn = QueryConnection.getConnection(null);

            stmt = conn.createStatement();
            rs = stmt.executeQuery(sql);
            int n = 0;
            ResultSetMetaData meta = rs.getMetaData();
            while (rs.next()) {
                n++;
                for (int i = 1; i <= meta.getColumnCount(); i++) {
                    System.out.println(n + " - " + meta.getColumnLabel(i) + ":\t" + rs.getObject(i));
                }
            }
        } finally {
            DBUtils.closeQuietly(rs);
            DBUtils.closeQuietly(stmt);
            DBUtils.closeQuietly(conn);
        }

    }
 
Example 12
Source File: ResourceStore.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static String dumpResources(KylinConfig kylinConfig, Collection<String> dumpList) throws IOException {
    File tmp = File.createTempFile("kylin_job_meta", "");
    FileUtils.forceDelete(tmp); // we need a directory, so delete the file first

    File metaDir = new File(tmp, "meta");
    metaDir.mkdirs();

    // write kylin.properties
    File kylinPropsFile = new File(metaDir, "kylin.properties");
    kylinConfig.exportToFile(kylinPropsFile);

    ResourceStore from = ResourceStore.getStore(kylinConfig);
    KylinConfig localConfig = KylinConfig.createInstanceFromUri(metaDir.getAbsolutePath());
    ResourceStore to = ResourceStore.getStore(localConfig);
    for (String path : dumpList) {
        RawResource res = from.getResource(path);
        if (res == null)
            throw new IllegalStateException("No resource found at -- " + path);
        to.putResource(path, res.content(), res.lastModified());
        res.close();
    }

    String metaDirURI = OptionsHelper.convertToFileURL(metaDir.getAbsolutePath());
    if (metaDirURI.startsWith("/")) // note Path on windows is like "d:/../..."
        metaDirURI = "file://" + metaDirURI;
    else
        metaDirURI = "file:///" + metaDirURI;
    logger.info("meta dir is: {}", metaDirURI);

    return metaDirURI;
}
 
Example 13
Source File: AbstractHadoopJob.java    From Kylin with Apache License 2.0 5 votes vote down vote up
private void dumpResources(KylinConfig kylinConfig, File metaDir, ArrayList<String> dumpList) throws IOException {
    ResourceStore from = ResourceStore.getStore(kylinConfig);
    KylinConfig localConfig = KylinConfig.createInstanceFromUri(metaDir.getAbsolutePath());
    ResourceStore to = ResourceStore.getStore(localConfig);
    for (String path : dumpList) {
        InputStream in = from.getResource(path);
        if (in == null)
            throw new IllegalStateException("No resource found at -- " + path);
        long ts = from.getResourceTimestamp(path);
        to.putResource(path, in, ts);
        //The following log is duplicate with in ResourceStore
        //log.info("Dumped resource " + path + " to " + metaDir.getAbsolutePath());
    }
}
 
Example 14
Source File: CubeMetadataUpgrade.java    From kylin with Apache License 2.0 4 votes vote down vote up
public CubeMetadataUpgrade(String newMetadataUrl) {
    KylinConfig.destroyInstance();
    config = KylinConfig.createInstanceFromUri(newMetadataUrl);
    store = ResourceStore.getStore(config);
}
 
Example 15
Source File: CubeMigrationCheckCLI.java    From kylin with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws ParseException, IOException {

        OptionsHelper optionsHelper = new OptionsHelper();

        Options options = new Options();
        options.addOption(OPTION_FIX);
        options.addOption(OPTION_DST_CFG_URI);
        options.addOption(OPTION_CUBE);

        boolean ifFix = false;
        String dstCfgUri;
        String cubeName;
        logger.info("jobs args: " + Arrays.toString(args));
        try {

            optionsHelper.parseOptions(options, args);

            logger.info("options: '" + options.toString() + "'");
            logger.info("option value 'fix': '" + optionsHelper.getOptionValue(OPTION_FIX) + "'");
            ifFix = Boolean.parseBoolean(optionsHelper.getOptionValue(OPTION_FIX));

            logger.info("option value 'dstCfgUri': '" + optionsHelper.getOptionValue(OPTION_DST_CFG_URI) + "'");
            dstCfgUri = optionsHelper.getOptionValue(OPTION_DST_CFG_URI);

            logger.info("option value 'cube': '" + optionsHelper.getOptionValue(OPTION_CUBE) + "'");
            cubeName = optionsHelper.getOptionValue(OPTION_CUBE);

        } catch (ParseException e) {
            optionsHelper.printUsage(CubeMigrationCheckCLI.class.getName(), options);
            throw e;
        }

        KylinConfig kylinConfig;
        if (dstCfgUri == null) {
            kylinConfig = KylinConfig.getInstanceFromEnv();
        } else {
            kylinConfig = KylinConfig.createInstanceFromUri(dstCfgUri);
        }

        CubeMigrationCheckCLI checkCLI = new CubeMigrationCheckCLI(kylinConfig, ifFix);
        checkCLI.execute(cubeName);
    }
 
Example 16
Source File: CubeMetadataUpgrade.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public CubeMetadataUpgrade(String newMetadataUrl) {
    KylinConfig.destroyInstance();
    config = KylinConfig.createInstanceFromUri(newMetadataUrl);
    store = ResourceStore.getStore(config);
}
 
Example 17
Source File: AdminServiceTest.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetPublicConfig() throws IOException {
    //set ../examples/test_metadata/kylin.properties empty
    File file = FileUtils.getFile(LOCALMETA_TEMP_DATA + "kylin.properties");
    FileUtils.deleteQuietly(file);
    FileUtils.touch(file);
    String path = Thread.currentThread().getContextClassLoader().getResource("kylin.properties").getPath();

    KylinConfig config = KylinConfig.createInstanceFromUri(path);
    String timeZone = config.getTimeZone();
    try (SetAndUnsetThreadLocalConfig autoUnset = KylinConfig.setAndUnsetThreadLocalConfig(config)) {
    
        String expected = "kylin.web.link-streaming-guide=http://kylin.apache.org/\n" +
                "kylin.web.dashboard-enabled=\n" +
                "kylin.web.contact-mail=\n" +
                "kylin.job.scheduler.default=0\n" +
                "kylin.query.cache-enabled=true\n" +
                "kylin.web.link-diagnostic=\n" +
                "kylin.web.help.length=4\n" +
                "kylin.web.timezone=\n" +
                "kylin.server.external-acl-provider=\n" +
                "kylin.tool.auto-migrate-cube.enabled=\n" +
                "kylin.storage.default=2\n" +
                "kylin.cube.cubeplanner.enabled=true\n" +
                "kylin.web.help=\n" +
                "kylin.web.export-allow-other=true\n" +
                "kylin.web.link-hadoop=\n" +
                "kylin.web.hide-measures=RAW\n" +
                "kylin.htrace.show-gui-trace-toggle=false\n" +
                "kylin.security.additional-profiles=\n" +
                "kylin.web.export-allow-admin=true\n" +
                "kylin.env=QA\n" +
                "kylin.web.hive-limit=20\n" +
                "kylin.engine.default=2\n" +
                "kylin.web.help.3=onboard|Cube Design Tutorial|http://kylin.apache.org/docs/howto/howto_optimize_cubes.html\n" +
                "kylin.web.default-time-filter=1\n" +
                "kylin.web.help.2=tableau|Tableau Guide|http://kylin.apache.org/docs/tutorial/tableau_91.html\n" +
                "kylin.web.help.1=odbc|ODBC Driver|http://kylin.apache.org/docs/tutorial/odbc.html\n" +
                "kylin.web.help.0=start|Getting Started|http://kylin.apache.org/docs/tutorial/kylin_sample.html\n" +
                "kylin.security.profile=testing\n";
        Assert.assertEquals(expected, adminService.getPublicConfig());
    }
}
 
Example 18
Source File: CubeMetaExtractorTest.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Test
public void testExtractorByPrj() throws IOException {
    folder.create();
    File tempDir = folder.getRoot();
    String tempDirAbsPath = tempDir.getAbsolutePath();
    List<String> args = new ArrayList<>();
    args.add("-destDir");
    args.add(tempDirAbsPath);
    args.add("-project");
    args.add("default");
    args.add("-compress");
    args.add("false");
    args.add("-packagetype");
    args.add("cubemeta");
    String[] cubeMetaArgs = new String[args.size()];
    args.toArray(cubeMetaArgs);

    CubeMetaExtractor cubeMetaExtractor = new CubeMetaExtractor();
    cubeMetaExtractor.execute(cubeMetaArgs);

    File[] files = tempDir.listFiles();
    Preconditions.checkState(files.length == 1);
    String dumpDir = files[0].getAbsolutePath();
    KylinConfig instanceFromUri = KylinConfig.createInstanceFromUri(dumpDir);
    NavigableSet<String> tables = new ResourceTool().list(instanceFromUri, "table");
    NavigableSet<String> tableExds = new ResourceTool().list(instanceFromUri, "table_exd");
    Set<String> expectTbl = Sets.newHashSet(
            "/table/DEFAULT.FIFTY_DIM.json", //
            "/table/DEFAULT.STREAMING_TABLE.json", //
            "/table/DEFAULT.STREAMING_CATEGORY.json", //
            "/table/DEFAULT.TEST_ACCOUNT.json", //
            "/table/DEFAULT.TEST_CATEGORY_GROUPINGS.json", //
            "/table/DEFAULT.TEST_COUNTRY.json", //
            "/table/DEFAULT.TEST_KYLIN_FACT.json", //
            "/table/DEFAULT.TEST_ORDER.json", //
            "/table/EDW.TEST_CAL_DT.json", //
            "/table/EDW.TEST_SELLER_TYPE_DIM.json", //
            "/table/EDW.TEST_SITES.json", //
            "/table/SSB.CUSTOMER.json", //
            "/table/SSB.DATES.json", //
            "/table/SSB.PART.json", //
            "/table/SSB.SUPPLIER.json", //
            "/table/SSB.V_LINEORDER.json", //
            "/table/DEFAULT.STREAMING_V2_TABLE.json", //
            "/table/DEFAULT.STREAMING_V2_USER_INFO_TABLE.json"
    );
    Set<String> expectTblExd = Sets.newHashSet(
            "/table_exd/DEFAULT.TEST_COUNTRY.json", //
            "/table_exd/DEFAULT.TEST_KYLIN_FACT--default.json"); //
    Assert.assertEquals(expectTbl, tables);
    Assert.assertEquals(expectTblExd, tableExds);
}
 
Example 19
Source File: CubeMigrationCheckCLI.java    From kylin with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws ParseException, IOException {
    logger.warn("org.apache.kylin.storage.hbase.util.CubeMigrationCheckCLI is deprecated, use org.apache.kylin.tool.CubeMigrationCheckCLI instead");

    OptionsHelper optionsHelper = new OptionsHelper();

    Options options = new Options();
    options.addOption(OPTION_FIX);
    options.addOption(OPTION_DST_CFG_URI);
    options.addOption(OPTION_CUBE);

    boolean ifFix = false;
    String dstCfgUri;
    String cubeName;
    logger.info("jobs args: " + Arrays.toString(args));
    try {

        optionsHelper.parseOptions(options, args);

        logger.info("options: '" + options.toString() + "'");
        logger.info("option value 'fix': '" + optionsHelper.getOptionValue(OPTION_FIX) + "'");
        ifFix = Boolean.parseBoolean(optionsHelper.getOptionValue(OPTION_FIX));

        logger.info("option value 'dstCfgUri': '" + optionsHelper.getOptionValue(OPTION_DST_CFG_URI) + "'");
        dstCfgUri = optionsHelper.getOptionValue(OPTION_DST_CFG_URI);

        logger.info("option value 'cube': '" + optionsHelper.getOptionValue(OPTION_CUBE) + "'");
        cubeName = optionsHelper.getOptionValue(OPTION_CUBE);

    } catch (ParseException e) {
        optionsHelper.printUsage(CubeMigrationCheckCLI.class.getName(), options);
        throw e;
    }

    KylinConfig kylinConfig;
    if (dstCfgUri == null) {
        kylinConfig = KylinConfig.getInstanceFromEnv();
    } else {
        kylinConfig = KylinConfig.createInstanceFromUri(dstCfgUri);
    }

    CubeMigrationCheckCLI checkCLI = new CubeMigrationCheckCLI(kylinConfig, ifFix);
    checkCLI.execute(cubeName);
}
 
Example 20
Source File: BaseTestDistributedScheduler.java    From kylin with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
    staticCreateTestMetadata();

    new File(confDstPath1).getParentFile().mkdirs();
    new File(confDstPath2).getParentFile().mkdirs();
    KylinConfig srcConfig = KylinConfig.getInstanceFromEnv();

    localMetaDir = Files.createTempDir();
    backup = srcConfig.getMetadataUrl().toString();
    srcConfig.setProperty("kylin.metadata.url", localMetaDir.getAbsolutePath());
    srcConfig.exportToFile(new File(confDstPath1));
    srcConfig.exportToFile(new File(confDstPath2));

    kylinConfig1 = KylinConfig.createInstanceFromUri(new File(confDstPath1).getAbsolutePath());
    kylinConfig2 = KylinConfig.createInstanceFromUri(new File(confDstPath2).getAbsolutePath());

    initZk();
    
    ZookeeperDistributedLock.Factory factory = new ZookeeperDistributedLock.Factory(kylinConfig1);
    jobLock1 = (ZookeeperDistributedLock) factory.lockForClient(serverName1);
    jobLock2 = (ZookeeperDistributedLock) factory.lockForClient(serverName2);

    execMgr = ExecutableManager.getInstance(kylinConfig1);
    for (String jobId : execMgr.getAllJobIds()) {
        execMgr.deleteJob(jobId);
    }

    scheduler1 = DistributedScheduler.getInstance(kylinConfig1);
    scheduler1.init(new JobEngineConfig(kylinConfig1), jobLock1);
    if (!scheduler1.hasStarted()) {
        throw new RuntimeException("scheduler1 not started");
    }

    scheduler2 = DistributedScheduler.getInstance(kylinConfig2);
    scheduler2.init(new JobEngineConfig(kylinConfig2), jobLock2);
    if (!scheduler2.hasStarted()) {
        throw new RuntimeException("scheduler2 not started");
    }

    Thread.sleep(10000);
}