Package org.kiji.schema.avro

Examples of org.kiji.schema.avro.TableLayoutDesc


      return backup;
    }

    for (Row row: rows) {
      final long timestamp = row.getDate(QUALIFIER_TIME).getTime();
      final TableLayoutDesc layout =
          decodeTableLayoutDesc(ByteUtils.toBytes(row.getBytes(QUALIFIER_LAYOUT)));

      // TODO: May need some check here that the update is not null
      final TableLayoutDesc update =
          decodeTableLayoutDesc(ByteUtils.toBytes(row.getBytes(QUALIFIER_UPDATE)));

      history.add(TableLayoutBackupEntry.newBuilder()
          .setLayout(layout)
          .setUpdate(update)
View Full Code Here


    getPrintStream().println("Parsing table layout: " + mLayout);
    final Path path = new Path(mLayout);
    final FileSystem fs =
        fileSystemSpecified(path) ? path.getFileSystem(getConf()) : FileSystem.getLocal(getConf());
    final FSDataInputStream inputStream = fs.open(path);
    final TableLayoutDesc tableLayout = KijiTableLayout.readTableLayoutDescFromJSON(inputStream);
    final String tableName = tableLayout.getName();
    Preconditions.checkArgument(
        (mTableURI.getTable() == null) || tableName.equals(mTableURI.getTable()),
        "Table name '%s' does not match URI %s", tableName, mTableURI);

    // For large numbers of initial regions, table creation may take a long time as we wait for
    // the new regions to come online. Increase the hbase RPC timeout to compensate.
    int hbaseTimeout = getConf().getInt("hbase.rpc.timeout", 60000);
    hbaseTimeout = hbaseTimeout * 10;
    getConf().setInt("hbase.rpc.timeout", hbaseTimeout);

    getPrintStream().println("Creating Kiji table " + mTableURI);
    if (mNumRegions >= 1) {
      // Create a table with an initial number of evenly split regions.
      mKiji.createTable(tableLayout, mNumRegions);

    } else if (!mSplitKeyFilePath.isEmpty()) {
      switch (KijiTableLayout.getEncoding(tableLayout.getKeysFormat())) {
      case HASH:
      case HASH_PREFIX:
        throw new IllegalArgumentException(
            "Row key hashing is enabled for the table. Use --num-regions=N instead.");
      case RAW:
        break;
      case FORMATTED:
        // TODO Support pre-splitting tables for FORMATTED RKF
        // (https://jira.kiji.org/browse/SCHEMA-172)
        throw new RuntimeException("CLI support for FORMATTED row keys is not yet available");
      default:
        throw new RuntimeException(
            "Unexpected row key encoding: "
                + KijiTableLayout.getEncoding(tableLayout.getKeysFormat()));
      }
      // Open the split key file.
      final Path splitKeyFilePath = new Path(mSplitKeyFilePath);
      final FileSystem splitKeyPathFs = fileSystemSpecified(splitKeyFilePath)
          ? splitKeyFilePath.getFileSystem(getConf())
View Full Code Here

      Assert.assertNotNull(kiji.getZKClient());

      kiji.createTable(KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST));
      final KijiTable table = kiji.openTable("foo");
      try {
        final TableLayoutDesc layoutUpdate =
            TableLayoutDesc.newBuilder(table.getLayout().getDesc()).build();
        layoutUpdate.setReferenceLayout(layoutUpdate.getLayoutId());
        layoutUpdate.setLayoutId("2");

        final KijiTableLayout newLayout = kiji.modifyTableLayout(layoutUpdate);

      } finally {
        table.release();
View Full Code Here

  }

  @Test
  public void testDeletingKijiTableWithUsersDoesNotFail() throws Exception {
    final Kiji kiji = getKiji();
    final TableLayoutDesc layoutDesc = KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST);
    final String tableName = layoutDesc.getName();
    kiji.createTable(layoutDesc);
    final KijiTable table = kiji.openTable(tableName);
    try {
      kiji.deleteTable(tableName);
    } finally {
View Full Code Here

    final String tableName = "IntegrationTestTableLayoutUpdate";
    final KijiURI tableURI = KijiURI.newBuilder(uri).withTableName(tableName).build();
    final String layoutId1 = "1";

    final HBaseKiji kiji = (HBaseKiji) getKiji();
    final TableLayoutDesc layoutDesc = KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST);
    layoutDesc.setLayoutId(layoutId1);
    layoutDesc.setName(tableName);
    kiji.createTable(layoutDesc);

    final BlockingQueue<Multimap<String, String>> queue = Queues.newSynchronousQueue();

    final UsersTracker tracker =
View Full Code Here

    final String layoutId1 = "1";
    final String layoutId2 = "2";
    final HBaseKiji kiji = (HBaseKiji) Kiji.Factory.open(uri);

    try {
      final TableLayoutDesc layoutDesc = KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST);
      layoutDesc.setLayoutId(layoutId1);
      layoutDesc.setName(tableName);
      kiji.createTable(layoutDesc);

      final BlockingQueue<Multimap<String, String>> queue = Queues.newArrayBlockingQueue(10);

      final UsersTracker tracker =
          ZooKeeperUtils
              .newTableUsersTracker(kiji.getZKClient(), tableURI)
              .registerUpdateHandler(new QueueingUsersUpdateHandler(queue));
      try {
        tracker.start();
        // Initial user map should be empty:
        assertEquals(ImmutableSetMultimap.<String, String>of(), queue.poll(2, TimeUnit.SECONDS));

        KijiTable kijiTable = kiji.openTable(tableName);
        try {
          // We opened a table, user map must contain exactly one entry:
          assertEquals(ImmutableSet.of(layoutId1),
              ImmutableSet.copyOf(queue.poll(2, TimeUnit.SECONDS).values()));

          // Push a layout update (a no-op, but with a new layout ID):
          final TableLayoutDesc newLayoutDesc =
              KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST);
          newLayoutDesc.setReferenceLayout(layoutId1);
          newLayoutDesc.setLayoutId(layoutId2);
          newLayoutDesc.setName(tableName);

          kiji.modifyTableLayout(newLayoutDesc);

          // The new user map should eventually reflect the new layout ID. There may be an
          // intermediate state of no registered users, and then the table user is re-registered
View Full Code Here

  private volatile InstanceMonitor mInstanceMonitor;

  @Before
  public void setUpTestInstanceMonitor() throws Exception {
    Kiji kiji = getKiji();
    TableLayoutDesc layout = KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE);
    kiji.createTable(layout);
    mTableURI = KijiURI.newBuilder(kiji.getURI()).withTableName(layout.getName()).build();
    mZKClient = ZooKeeperUtils.getZooKeeperClient(mTableURI);

    mInstanceMonitor = new InstanceMonitor(
        kiji.getSystemTable().getDataVersion(),
        kiji.getURI(),
View Full Code Here

   * Tests the creation of a table that uses all of the layout-1.2.0 hbase attributes.
   */
  @Test
  public void testHBaseAttributesWithFullFeaturedTable() throws IOException {
    // Create the table
    TableLayoutDesc fullFeaturedLayout = KijiTableLayouts.getLayout(KijiTableLayouts.FULL_FEATURED);
    mKiji.createTable(fullFeaturedLayout);

    // Get the table descriptor
    HTableDescriptor hTableDescriptor = getHbaseTableDescriptor(FULL_FEATURED_TABLE_NAME);

View Full Code Here

   * of full-featured-layout.json).
   */
  @Test
  public void testUpdateTableLayoutHBaseAttributes() throws IOException {
    // Create the table
    TableLayoutDesc fullFeaturedLayout = TableLayoutDesc.newBuilder(
      KijiTableLayouts.getLayout(KijiTableLayouts.FULL_FEATURED))
      .setLayoutId("full-featured-base")
      .build();
    mKiji.createTable(fullFeaturedLayout);

    // Build a new layout based on the first one, change values and call update table on it
    TableLayoutDesc updatedLayout = TableLayoutDesc.newBuilder(fullFeaturedLayout)
      .setLayoutId("full-featured-update")
      .setReferenceLayout(fullFeaturedLayout.getLayoutId())
      .setMaxFilesize(fullFeaturedLayout.getMaxFilesize() + 1000L)
      .setMemstoreFlushsize(fullFeaturedLayout.getMemstoreFlushsize() + 1000L)
      .setLocalityGroups(Lists.newArrayList(
View Full Code Here

   * programatically modified version of simple.json).
   */
  @Test
  public void testUpdateTableLayoutOnTableWithNoHBaseSettingsSet() throws IOException {
    // Create the table
    TableLayoutDesc simpleLayout = TableLayoutDesc.newBuilder(
      KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE))
      .setLayoutId("base")
      .setVersion("layout-1.2.0")
      .build();
    mKiji.createTable(simpleLayout);

    // Build a new layout based on the first one, change values and call update table on it
    long updatedMaxFilesize = 8 * 1024L * 1024L * 1024L;
    long updatedMemstoreFlushsize = 2 * 1024L * 1024L * 1024L;
    int updatedBlocksize = 2048;
    TableLayoutDesc updatedLayout = TableLayoutDesc.newBuilder(simpleLayout)
      .setLayoutId("updated")
      .setReferenceLayout(simpleLayout.getLayoutId())
      .setMaxFilesize(updatedMaxFilesize)
      .setMemstoreFlushsize(updatedMemstoreFlushsize)
      .setLocalityGroups(Lists.newArrayList(
View Full Code Here

TOP

Related Classes of org.kiji.schema.avro.TableLayoutDesc

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.