Package org.kiji.schema

Examples of org.kiji.schema.Kiji$Factory


    final KijiURI uri = getKijiURI();

    // Update the data version of the Kiji instance:
    {
      final Kiji kiji = Kiji.Factory.open(uri);
      try {
        kiji.getSystemTable().setDataVersion(ProtocolVersion.parse("system-2.0"));
      } finally {
        kiji.release();
      }
    }

    final Kiji kiji = Kiji.Factory.open(uri);
    try {
      kiji.createTable(layout1);

      final KijiTable table = kiji.openTable("table_name");
      try {
        final BlockingQueue<String> layoutQueue = Queues.newArrayBlockingQueue(1);

        final TableLayoutTracker tracker =
            new TableLayoutTracker(((HBaseKiji) kiji).getZKClient(), table.getURI(),
                new QueuingTableLayoutUpdateHandler(layoutQueue))
              .start();

        Assert.assertEquals("1", layoutQueue.poll(5, TimeUnit.SECONDS));

        final HBaseTableLayoutUpdater updater =
            new HBaseTableLayoutUpdater((HBaseKiji) kiji, table.getURI(), layout2);
        try {
          final Thread thread =
              new Thread() {
                /** {@inheritDoc} */
                @Override
                public void run() {
                  try {
                    updater.update();
                  } catch (Exception exn) {
                    throw new RuntimeException(exn);
                  }
                }
              };
          thread.start();
          thread.join(5000);

          Assert.assertEquals("2", layoutQueue.poll(5, TimeUnit.SECONDS));

          tracker.close();
        } finally {
          updater.close();
        }
      } finally {
        table.release();
      }
      kiji.deleteTable("table_name");
    } finally {
      kiji.release();
    }
  }
View Full Code Here


  private HBaseKiji mKiji;

  @Before
  public void setUp() throws Exception {
    Kiji kiji = Kiji.Factory.get().open(getKijiURI());
    if (kiji instanceof HBaseKiji) {
      mKiji = (HBaseKiji) kiji;
    } else {
      throw new UnsupportedOperationException("Cannot test a non-HBase Kiji.");
    }
View Full Code Here

   *  - initial layout has a reader for an empty record
   *  - layout update adds a writer schema with a compatible record with one optional integer.
   */
  @Test
  public void testValidLayoutUpdate() throws IOException {
    final Kiji kiji = getKiji();

    final TableLayoutDesc desc = KijiTableLayouts.getLayout(KijiTableLayouts.SCHEMA_REG_TEST);
    desc.setVersion("layout-1.3.0");

    final Schema emptyRecordSchema = Schema.createRecord("Record", null, "org.ns", false);
    emptyRecordSchema.setFields(Lists.<Field>newArrayList());

    final Schema optIntRecordSchema = Schema.createRecord("Record", null, "org.ns", false);
    optIntRecordSchema.setFields(Lists.newArrayList(
        new Field("a", INT_SCHEMA, null, IntNode.valueOf(0))));

    final TableLayoutDesc originalDesc = new TableLayoutBuilder(desc, kiji)
        .withAvroValidationPolicy(
            KijiColumnName.create("info:fullname"), AvroValidationPolicy.STRICT)
        .withReader(KijiColumnName.create("info:fullname"), emptyRecordSchema)
        .build();

    kiji.createTable(originalDesc);

    final TableLayoutDesc newDesc = new TableLayoutBuilder(originalDesc, kiji)
        .withWriter(KijiColumnName.create("info:fullname"), optIntRecordSchema)
        .build();

    kiji.modifyTableLayout(newDesc);
  }
View Full Code Here

    kiji.modifyTableLayout(newDesc);
  }

  @Test
  public void testStrictValidation() throws IOException {
    final Kiji kiji = getKiji();

    // Strict validation should fail.
    final TableLayoutDesc strictDesc = prepareNewDesc(kiji, AvroValidationPolicy.STRICT);
    try {
      kiji.modifyTableLayout(strictDesc);
      fail("Should have thrown an InvalidLayoutSchemaException because int and string are "
          + "incompatible.");
    } catch (InvalidLayoutSchemaException ilse) {
      assertTrue(ilse.getReasons().contains(
          "In column: 'info:fullname' Reader schema: \"string\" is incompatible with "
View Full Code Here

    }
  }

  @Test
  public void testDeveloperValidation() throws IOException {
    final Kiji kiji = getKiji();

    // Developer validation should fail.
    final TableLayoutDesc developerDesc = prepareNewDesc(kiji, AvroValidationPolicy.DEVELOPER);
    try {
      kiji.modifyTableLayout(developerDesc);
      fail("Should have thrown an InvalidLayoutSchemaException because int and string are "
          + "incompatible.");
    } catch (InvalidLayoutSchemaException ilse) {
      assertTrue(ilse.getReasons().contains(
          "In column: 'info:fullname' Reader schema: \"string\" is incompatible with "
View Full Code Here

    }
  }

  @Test
  public void testNoneValidation() throws IOException {
    final Kiji kiji = getKiji();

    // None validation should pass despite the incompatible change.
    final TableLayoutDesc noneDesc = prepareNewDesc(kiji, AvroValidationPolicy.NONE);
    kiji.modifyTableLayout(noneDesc);
  }
View Full Code Here

    kiji.modifyTableLayout(noneDesc);
  }

  @Test
  public void testSchema10Validation() throws IOException {
    final Kiji kiji = getKiji();

    // Schema-1.0 validation should pass despite incompatible changes.
    final TableLayoutDesc schema10Desc = prepareNewDesc(kiji, AvroValidationPolicy.SCHEMA_1_0);
    kiji.modifyTableLayout(schema10Desc);
  }
View Full Code Here

  // with max versions = infiinity and verify that we get only one result back.

  @Test
  public void testCreateKijiTable() throws Exception {
    LOG.info("Opening an in-memory kiji instance");
    final Kiji kiji = getKiji();

    LOG.info(String.format("Opened fake Kiji '%s'.", kiji.getURI()));

    final KijiSystemTable systemTable = kiji.getSystemTable();
    assertTrue("Client data version should support installed Kiji instance data version",
        VersionInfo.getClientDataVersion().compareTo(systemTable.getDataVersion()) >= 0);

    assertNotNull(kiji.getSchemaTable());
    assertNotNull(kiji.getMetaTable());

    kiji.createTable(KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE_FORMATTED_EID));

    final KijiTable table = kiji.openTable("table");
    try {

      final KijiTableWriter writer = table.openTableWriter();
      try {
        writer.put(table.getEntityId("row1"), "family", "column", 0L, "Value at timestamp 0.");
View Full Code Here

  private static final String AMINO_MAN = "Amino Man";

  @BeforeClass
  public static void initShared() throws Exception {
    CLIENT_TEST_DELEGATE.setupKijiTest();
    Kiji kiji = CLIENT_TEST_DELEGATE.getKiji();
    // Use the counter test layout so that we can verify that trying to modify counters in an
    // atomic putter causes an exception.
    kiji.createTable(KijiTableLayouts.getLayout(KijiTableLayouts.USER_TABLE_FORMATTED_EID));
    mTable = kiji.openTable("user");
  }
View Full Code Here

  private static final byte[] VALUE1 = Bytes.toBytes("value1");
  private static final byte[] VALUE2 = Bytes.toBytes("value2");

  @Test
  public void testStoreVersion() throws IOException {
    final Kiji kiji = getKiji();
    final KijiSystemTable systemTable = kiji.getSystemTable();
    final ProtocolVersion originalDataVersion = systemTable.getDataVersion();
    systemTable.setDataVersion(ProtocolVersion.parse("kiji-99"));

    assertEquals(ProtocolVersion.parse("kiji-99"), systemTable.getDataVersion());
    systemTable.setDataVersion(originalDataVersion);
View Full Code Here

TOP

Related Classes of org.kiji.schema.Kiji$Factory

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.