Package org.apache.hadoop.hbase.index

Examples of org.apache.hadoop.hbase.index.IndexedHTableDescriptor


  @Test(timeout = 180000)
  public void testIndexTableCreationAfterMasterRestart() throws Exception {
    HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());

    IndexedHTableDescriptor iHtd =
        createIndexedHTableDescriptor("testIndexTableCreationAfterMasterRestart", "cf",
          "index_name", "cf", "cq");
    admin.createTable(iHtd);
    admin.disableTable("testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX);
    admin.deleteTable("testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX);
View Full Code Here


  public void testPreCreateShouldNotBeSuccessfulIfIndicesAreNotSame() throws IOException,
      KeeperException, InterruptedException {
    HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);
    String userTableName = "testNotConsisIndex1";
    IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
    HColumnDescriptor hcd = new HColumnDescriptor("col");
    IndexSpecification iSpec1 = new IndexSpecification("Index1");
    iSpec1.addIndexColumn(hcd, "q1", ValueType.String, 10);
    ihtd.addFamily(hcd);
    ihtd.addIndex(iSpec1);
    IndexSpecification iSpec2 = new IndexSpecification("Index2");
    iSpec2.addIndexColumn(hcd, "q1", ValueType.Int, 10);
    ihtd.addIndex(iSpec2);

    boolean returnVal = false;
    try {
      admin.createTable(ihtd);
      fail("Exception should be thrown");
View Full Code Here

  public void testPreCreateShouldNotBeSuccessfulIfIndicesAreNotSameAtLength() throws IOException,
      KeeperException, InterruptedException {
    HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);
    String userTableName = "testNotConsisIndex2";
    IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
    HColumnDescriptor hcd = new HColumnDescriptor("col");
    IndexSpecification iSpec1 = new IndexSpecification("Index1");
    iSpec1.addIndexColumn(hcd, "q1", ValueType.String, 10);
    iSpec1.addIndexColumn(hcd, "q2", ValueType.String, 4);
    ihtd.addFamily(hcd);
    ihtd.addIndex(iSpec1);
    IndexSpecification iSpec2 = new IndexSpecification("Index2");
    iSpec2.addIndexColumn(hcd, "q3", ValueType.String, 10);
    iSpec2.addIndexColumn(hcd, "q2", ValueType.String, 10);
    ihtd.addIndex(iSpec2);

    boolean returnVal = false;
    try {
      admin.createTable(ihtd);
      fail("Exception should be thrown");
View Full Code Here

  public void testPreCreateShouldNotBeSuccessfulIfIndicesAreNotSameAtType() throws IOException,
      KeeperException, InterruptedException {
    HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);
    String userTableName = "testNotConsisIndex3";
    IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
    HColumnDescriptor hcd = new HColumnDescriptor("col");
    IndexSpecification iSpec1 = new IndexSpecification("Index1");
    iSpec1.addIndexColumn(hcd, "q1", ValueType.String, 10);
    iSpec1.addIndexColumn(hcd, "q2", ValueType.String, 10);
    ihtd.addFamily(hcd);
    ihtd.addIndex(iSpec1);
    IndexSpecification iSpec2 = new IndexSpecification("Index2");
    iSpec2.addIndexColumn(hcd, "q1", ValueType.Int, 10);
    iSpec2.addIndexColumn(hcd, "q3", ValueType.String, 10);
    ihtd.addIndex(iSpec2);
    boolean returnVal = false;
    try {
      admin.createTable(ihtd);
      fail("Exception should be thrown");
    } catch (IOException e) {
View Full Code Here

  public void testPreCreateShouldNotBeSuccessfulIfIndicesAreNotSameAtBothTypeAndLength()
      throws IOException, KeeperException, InterruptedException {
    HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);
    String userTableName = "testNotConsisIndex4";
    IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
    HColumnDescriptor hcd = new HColumnDescriptor("col");
    IndexSpecification iSpec1 = new IndexSpecification("Index1");
    iSpec1.addIndexColumn(hcd, "q1", ValueType.String, 10);
    iSpec1.addIndexColumn(hcd, "q2", ValueType.String, 10);
    ihtd.addFamily(hcd);
    ihtd.addIndex(iSpec1);
    IndexSpecification iSpec2 = new IndexSpecification("Index2");
    iSpec2.addIndexColumn(hcd, "q1", ValueType.Int, 10);
    iSpec2.addIndexColumn(hcd, "q2", ValueType.String, 7);
    ihtd.addIndex(iSpec2);

    boolean returnVal = false;
    try {
      admin.createTable(ihtd);
      fail("IOException should be thrown");
View Full Code Here

  public void testPreCreateShouldBeSuccessfulIfIndicesAreSame() throws IOException,
      KeeperException, InterruptedException {
    HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);
    String userTableName = "testConsisIndex";
    IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
    HColumnDescriptor hcd = new HColumnDescriptor("col");
    IndexSpecification iSpec1 = new IndexSpecification("Index1");
    iSpec1.addIndexColumn(hcd, "q1", ValueType.String, 10);
    ihtd.addFamily(hcd);
    ihtd.addIndex(iSpec1);
    IndexSpecification iSpec2 = new IndexSpecification("Index2");
    iSpec2.addIndexColumn(hcd, "q1", ValueType.String, 10);
    ihtd.addIndex(iSpec2);

    try {
      admin.createTable(ihtd);
    } catch (IOException e) {
      fail("Exception should not be thrown");
View Full Code Here

    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);
    HBaseAdmin admin = UTIL.getHBaseAdmin();
    Configuration config = UTIL.getConfiguration();

    String userTableName = "testCoLocationFixing";
    IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
    HColumnDescriptor hcd = new HColumnDescriptor("cf1");
    ihtd.addFamily(hcd);
    IndexSpecification iSpec = new IndexSpecification("idx");
    iSpec.addIndexColumn(hcd, "q", ValueType.String, 10);
    ihtd.addIndex(iSpec);

    char c = 'A';
    byte[][] splits = new byte[5][];
    for (int i = 0; i < 5; i++) {
      byte[] b = { (byte) c };
      c++;
      splits[i] = b;
    }
    admin.createTable(ihtd, splits);

    String userTableName1 = "testCoLocationFixing1";
    ihtd = new IndexedHTableDescriptor(userTableName1);
    ihtd.addFamily(hcd);
    iSpec = new IndexSpecification("idx1");
    iSpec.addIndexColumn(hcd, "q", ValueType.String, 10);
    ihtd.addIndex(iSpec);
    admin.createTable(ihtd, splits);

    String userTableName2 = "testCoLocationFixing2";
    ihtd = new IndexedHTableDescriptor(userTableName2);
    ihtd.addFamily(hcd);
    iSpec = new IndexSpecification("idx2");
    iSpec.addIndexColumn(hcd, "q", ValueType.String, 10);
    ihtd.addIndex(iSpec);
    admin.createTable(ihtd, splits);

    List<byte[]> regions = UTIL.getMetaTableRows(Bytes.toBytes(userTableName + "_idx"));
    List<byte[]> regionsEncod = getEncodedNames(regions);
View Full Code Here

    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);

    Configuration conf = UTIL.getConfiguration();
    String userTableName = "testPutContainingTheIndexedColumn";
    IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
    HColumnDescriptor hcd = new HColumnDescriptor("col");
    IndexSpecification iSpec = new IndexSpecification("Index1");
    iSpec.addIndexColumn(hcd, "ql", ValueType.String, 10);
    ihtd.addFamily(hcd);
    ihtd.addIndex(iSpec);
    admin.createTable(ihtd);
    ZKAssign.blockUntilNoRIT(zkw);

    HTable table = new HTable(conf, userTableName);
    // test put with the indexed column
View Full Code Here

  @Test(timeout = 180000)
  public void testIndexTableShouldBeDisabledIfUserTableDisabled() throws Exception {
    String tableName = "testIndexTableDisabledIfUserTableDisabled";
    String indexTableName = IndexUtils.getIndexTableName(tableName);
    HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
    IndexedHTableDescriptor iHtd =
        createIndexedHTableDescriptor(tableName, "cf", "index_name", "cf", "cq");
    admin.createTable(iHtd);
    admin.disableTable(tableName);
    assertTrue("User table should be disabled.", admin.isTableDisabled(tableName));
    assertTrue("Index table should be disabled.", admin.isTableDisabled(indexTableName));
View Full Code Here

  @Test(timeout = 180000)
  public void testIndexTableShouldBeEnabledIfUserTableEnabled() throws Exception {
    String tableName = "testIndexTableEnabledIfUserTableEnabled";
    String indexTableName = IndexUtils.getIndexTableName(tableName);
    HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
    IndexedHTableDescriptor iHtd =
        createIndexedHTableDescriptor(tableName, "cf", "index_name", "cf", "cq");
    admin.createTable(iHtd);
    admin.disableTable(tableName);
    admin.enableTable(tableName);
    assertTrue("User table should be enabled.", admin.isTableEnabled(tableName));
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.index.IndexedHTableDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.