Examples of TableLayoutDesc


Examples of org.kiji.schema.avro.TableLayoutDesc

public class TestAvroJson {
  private static final Logger LOG = LoggerFactory.getLogger(TestAvroJson.class);

  @Test
  public void testSerializeDeserialize() throws Exception {
    final TableLayoutDesc desc = KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST);
    final String json = ToJson.toJsonString(desc);
    LOG.info("Serialized JSON:\n{}", json);
    final TableLayoutDesc avro =
        (TableLayoutDesc) FromJson.fromJsonString(json, TableLayoutDesc.SCHEMA$);
    final String jsonAgain = ToJson.toJsonString(avro);
    assertEquals(json, jsonAgain);
  }
View Full Code Here

Examples of org.kiji.schema.avro.TableLayoutDesc

  @Test
  public void testFinalColumns() throws Exception {
    final Kiji kiji = getKiji();

    final TableLayoutDesc layoutDesc = KijiTableLayouts.getLayout(KijiTableLayouts.FINAL_COLUMN);
    kiji.createTable(layoutDesc);

    final KijiTable table = kiji.openTable("table");
    try {
      final KijiTableWriter writer = table.openTableWriter();
View Full Code Here

Examples of org.kiji.schema.avro.TableLayoutDesc

    try {
      final NavigableMap<Long, KijiTableLayout> layoutMap =
          metaTable.getTimedTableLayoutVersions(mTableURI.getTable(), Integer.MAX_VALUE);

      final KijiTableLayout currentLayout = layoutMap.lastEntry().getValue();
      final TableLayoutDesc update = mLayoutUpdate.apply(currentLayout);
      if (!Objects.equal(currentLayout.getDesc().getLayoutId(), update.getReferenceLayout())) {
        throw new InvalidLayoutException(String.format(
            "Reference layout ID %s does not match current layout ID %s.",
            update.getReferenceLayout(), currentLayout.getDesc().getLayoutId()));
      }

      final TableLayoutUpdateValidator validator = new TableLayoutUpdateValidator(mKiji);
      validator.validate(
          currentLayout,
          KijiTableLayout.createUpdatedLayout(update , currentLayout));

      final TableLayoutTracker layoutTracker =
          new TableLayoutTracker(mZKClient, mTableURI, mLayoutUpdateHandler);
      try {
        layoutTracker.start();
        final UsersTracker usersTracker =
            ZooKeeperUtils
                .newTableUsersTracker(mZKClient, mTableURI)
                .registerUpdateHandler(mUsersUpdateHandler);
        try {
          usersTracker.start();
          final String currentLayoutId = mLayoutUpdateHandler.getCurrentLayoutId();
          LOG.info("Table {} has current layout ID {}.", mTableURI, currentLayoutId);
          if (!Objects.equal(currentLayoutId, currentLayout.getDesc().getLayoutId())) {
            throw new InternalKijiError(String.format(
                "Inconsistency between meta-table and ZooKeeper: "
                + "meta-table layout has ID %s while ZooKeeper has layout ID %s.",
                currentLayout.getDesc().getLayoutId(), currentLayoutId));
          }

          final String consistentLayoutId = waitForConsistentView();
          if ((consistentLayoutId != null) && !Objects.equal(consistentLayoutId, currentLayoutId)) {
            throw new InternalKijiError(String.format(
                "Consistent layout ID %s does not match current layout %s for table %s.",
                consistentLayoutId, currentLayout, mTableURI));
          }

          writeMetaTable(update);
          final TableLayoutDesc newLayoutDesc = mNewLayout.getDesc();
          writeZooKeeper(newLayoutDesc);

          mLayoutUpdateHandler.waitForLayoutNotification(newLayoutDesc.getLayoutId());

          // The following is not necessary:
          while (true) {
            final String newLayoutId = waitForConsistentView();
            if (newLayoutId == null) {
              LOG.info("Layout update complete for table {}: table has no users.", mTableURI);
              break;
            } else if (Objects.equal(newLayoutId, newLayoutDesc.getLayoutId())) {
              LOG.info("Layout update complete for table {}: all users switched to layout ID {}.",
                  mTableURI, newLayoutId);
              break;
            } else {
              LOG.info("Layout update in progress for table {}: users still using layout ID {}.",
View Full Code Here

Examples of org.kiji.schema.avro.TableLayoutDesc

  /** Tests writer schema compatibility with a LONG reader schema. */
  @Test
  public void testReaderSchemaLong() throws Exception {
    final Kiji kiji = getKiji();
    final TableLayoutDesc desc = KijiTableLayouts.getLayout(LAYOUT_DEVELOPER);
    final CellSchema cellSchema = desc.getLocalityGroups().get(0)
        .getFamilies().get(0)
        .getColumns().get(0)
        .getColumnSchema();
    cellSchema.setReaders(Lists.newArrayList(
        AvroSchema.newBuilder()
View Full Code Here

Examples of org.kiji.schema.avro.TableLayoutDesc

  /** Tests writer schema compatibility with record schemas. */
  @Test
  public void testReaderSchemaTestRecord2() throws Exception {
    final Kiji kiji = getKiji();
    final TableLayoutDesc desc = KijiTableLayouts.getLayout(LAYOUT_DEVELOPER);
    final CellSchema cellSchema = desc.getLocalityGroups().get(0)
        .getFamilies().get(0)
        .getColumns().get(0)
        .getColumnSchema();
    cellSchema.setReaders(Lists.newArrayList(
        AvroSchema.newBuilder()
View Full Code Here

Examples of org.kiji.schema.avro.TableLayoutDesc

  // -----------------------------------------------------------------------------------------------

  @Test
  public void testSetLayout() throws Exception {
    final TableLayoutDesc layoutDesc = KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE);
    final KijiTableLayout expected = KijiTableLayout.newLayout(layoutDesc);
    final KijiTableLayout result =
        mTableLayoutDatabase.updateTableLayout(layoutDesc.getName(), layoutDesc);
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.kiji.schema.avro.TableLayoutDesc

    assertEquals(expected, result);
  }

  @Test
  public void testGetLayout() throws Exception {
    final TableLayoutDesc layoutDesc = KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE);
    final KijiTableLayout layout =
        mTableLayoutDatabase.updateTableLayout(layoutDesc.getName(), layoutDesc);

    final KijiTableLayout result = mTableLayoutDatabase.getTableLayout(layoutDesc.getName());
    assertEquals(layout, result);
  }
View Full Code Here

Examples of org.kiji.schema.avro.TableLayoutDesc

    assertEquals(layout, result);
  }

  @Test
  public void testTableExists() throws IOException {
    final TableLayoutDesc layoutDesc = KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE);
    final String tableName = layoutDesc.getName();
    final Kiji kiji = new InstanceBuilder(getKiji())
        .withTable(layoutDesc)
        .build();
    assertTrue(kiji.getMetaTable().tableExists(tableName));
    assertFalse(kiji.getMetaTable().tableExists("faketablename"));
View Full Code Here

Examples of org.kiji.schema.avro.TableLayoutDesc

    assertFalse(kiji.getMetaTable().tableExists("faketablename"));
  }

  @Test
  public void testGetMultipleLayouts() throws Exception {
    final TableLayoutDesc layoutDesc1 = KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE);
    layoutDesc1.setVersion("layout-1.0");
    final String tableName = layoutDesc1.getName();
    final KijiTableLayout layout1 = mTableLayoutDatabase.updateTableLayout(tableName, layoutDesc1);

    // This thread sleep prevents this value from overwriting the previous in case both writes occur
    // within the same millisecond.
    Thread.sleep(2);
    final TableLayoutDesc layoutDesc2 = KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE);
    layoutDesc2.setVersion("layout-1.0.1");
    layoutDesc2.setReferenceLayout(layout1.getDesc().getLayoutId());
    final KijiTableLayout layout2 = mTableLayoutDatabase.updateTableLayout(tableName, layoutDesc2);

    Thread.sleep(2);
    final TableLayoutDesc layoutDesc3 = KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE);
    layoutDesc3.setVersion("layout-1.1");
    layoutDesc3.setReferenceLayout(layout2.getDesc().getLayoutId());
    final KijiTableLayout layout3 = mTableLayoutDatabase.updateTableLayout(tableName, layoutDesc3);

    final NavigableMap<Long, KijiTableLayout> timeSeries =
        mTableLayoutDatabase.getTimedTableLayoutVersions(tableName, HConstants.ALL_VERSIONS);
    assertEquals(3, timeSeries.size());
View Full Code Here

Examples of org.kiji.schema.avro.TableLayoutDesc

   * table layout updates.
   */
  @Test
  public void testUniqueLayoutIDs() throws IOException {
    // Creates a table with a first layout:
    final TableLayoutDesc layoutDesc1 = KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE);
    layoutDesc1.setLayoutId("layout-ID");
    final String tableName = layoutDesc1.getName();
    mTableLayoutDatabase.updateTableLayout(tableName, layoutDesc1);

    // Try applying a new layout with the same layout ID the current layout has:
    final TableLayoutDesc layoutDesc2 = KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE);
    layoutDesc2.setReferenceLayout("layout-ID");
    layoutDesc2.setLayoutId("layout-ID");
    try {
      // This update must fail due to the duplicate layout ID "layout-ID":
      mTableLayoutDatabase.updateTableLayout(tableName, layoutDesc2);
      Assert.fail("layout2 should be invalid : its layout ID is not unique.");
    } catch (InvalidLayoutException ile) {
      // Expected:
      assertTrue(ile.getMessage().contains("Layout ID 'layout-ID' already exists"));
    }

    // Applies a new layout with a different ID:
    layoutDesc2.setLayoutId("layout2-ID");
    mTableLayoutDatabase.updateTableLayout(tableName, layoutDesc2);

    // Finally, try applying a new layout with a layout ID from a former layout:
    final TableLayoutDesc layoutDesc3 = KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE);
    layoutDesc3.setReferenceLayout("layout-ID");
    layoutDesc3.setLayoutId("layout-ID");
    try {
      // This update must fail due to the duplicate layout ID "layout-ID":
      mTableLayoutDatabase.updateTableLayout(tableName, layoutDesc3);
      Assert.fail("layout3 should be invalid : its layout ID is not unique.");
    } catch (InvalidLayoutException ile) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.