Beispiel #1
0
  private void setUp(RecipeExecLocation recipeExecLocation) throws Exception {
    clusterHC = cluster.getClusterHelper().getHCatClient();
    clusterHC2 = cluster2.getClusterHelper().getHCatClient();
    bundles[0] = new Bundle(BundleUtil.readHCatBundle(), cluster);
    bundles[1] = new Bundle(BundleUtil.readHCatBundle(), cluster2);
    bundles[0].generateUniqueBundle(this);
    bundles[1].generateUniqueBundle(this);
    final ClusterMerlin srcCluster = bundles[0].getClusterElement();
    final ClusterMerlin tgtCluster = bundles[1].getClusterElement();
    String recipeDir = "HiveDrRecipe";
    if (MerlinConstants.IS_SECURE) {
      recipeDir = "HiveDrSecureRecipe";
    }
    Bundle.submitCluster(recipeExecLocation.getRecipeBundle(bundles[0], bundles[1]));
    recipeMerlin =
        RecipeMerlin.readFromDir(recipeDir, FalconCLI.RecipeOperation.HIVE_DISASTER_RECOVERY)
            .withRecipeCluster(recipeExecLocation.getRecipeCluster(srcCluster, tgtCluster));
    recipeMerlin
        .withSourceCluster(srcCluster)
        .withTargetCluster(tgtCluster)
        .withFrequency(new Frequency("5", Frequency.TimeUnit.minutes))
        .withValidity(TimeUtil.getTimeWrtSystemTime(-5), TimeUtil.getTimeWrtSystemTime(15));
    recipeMerlin.setUniqueName(this.getClass().getSimpleName());

    connection = cluster.getClusterHelper().getHiveJdbcConnection();
    runSql(connection, "drop database if exists hdr_sdb1 cascade");
    runSql(connection, "create database hdr_sdb1");
    runSql(connection, "use hdr_sdb1");

    connection2 = cluster2.getClusterHelper().getHiveJdbcConnection();
    runSql(connection2, "drop database if exists hdr_sdb1 cascade");
    runSql(connection2, "create database hdr_sdb1");
    runSql(connection2, "use hdr_sdb1");
  }
Beispiel #2
0
  @Test
  public void drTwoDstTablesTwoRequests() throws Exception {
    final RecipeExecLocation recipeExecLocation = RecipeExecLocation.TargetCluster;
    setUp(recipeExecLocation);
    final HCatClient clusterHC3 = cluster3.getClusterHelper().getHCatClient();
    final Connection connection3 = cluster3.getClusterHelper().getHiveJdbcConnection();
    runSql(connection3, "drop database if exists hdr_sdb1 cascade");
    runSql(connection3, "create database hdr_sdb1");
    runSql(connection3, "use hdr_sdb1");

    final String tblName = "vanillaTable";
    recipeMerlin.withSourceDb(DB_NAME).withSourceTable(tblName);
    final String recipe1Name = recipeMerlin.getName();
    final List<String> command1 = recipeMerlin.getSubmissionCommand();

    final Bundle bundle3 = new Bundle(BundleUtil.readHCatBundle(), cluster3);
    bundle3.generateUniqueBundle(this);
    bundle3.submitClusters(prism);
    recipeMerlin
        .withTargetCluster(bundle3.getClusterElement())
        .withRecipeCluster(
            recipeExecLocation.getRecipeCluster(
                bundles[0].getClusterElement(), bundle3.getClusterElement()));
    recipeMerlin.setUniqueName(this.getClass().getSimpleName());

    final List<String> command2 = recipeMerlin.getSubmissionCommand();
    final String recipe2Name = recipeMerlin.getName();

    runSql(connection, "create table " + tblName + "(comment string)");

    bootstrapCopy(connection, clusterFS, tblName, connection2, clusterFS2, tblName);
    bootstrapCopy(connection, clusterFS, tblName, connection3, clusterFS3, tblName);

    runSql(
        connection,
        "insert into table "
            + tblName
            + " values"
            + "('this string has been added post bootstrap - should appear after dr')");

    Assert.assertEquals(Bundle.runFalconCLI(command1), 0, "Recipe submission failed.");
    Assert.assertEquals(Bundle.runFalconCLI(command2), 0, "Recipe submission failed.");

    InstanceUtil.waitTillInstanceReachState(
        recipeExecLocation.getRecipeOC(clusterOC, clusterOC2),
        recipe1Name,
        1,
        CoordinatorAction.Status.SUCCEEDED,
        EntityType.PROCESS);
    InstanceUtil.waitTillInstanceReachState(
        recipeExecLocation.getRecipeOC(clusterOC, clusterOC3),
        recipe2Name,
        1,
        CoordinatorAction.Status.SUCCEEDED,
        EntityType.PROCESS);

    final NotifyingAssert anAssert = new NotifyingAssert(true);
    HiveAssert.assertTableEqual(
        cluster,
        clusterHC.getTable(DB_NAME, tblName),
        cluster2,
        clusterHC2.getTable(DB_NAME, tblName),
        anAssert);
    HiveAssert.assertTableEqual(
        cluster,
        clusterHC.getTable(DB_NAME, tblName),
        cluster3,
        clusterHC3.getTable(DB_NAME, tblName),
        anAssert);
    anAssert.assertAll();
  }