Package org.kiji.schema.layout.impl

Examples of org.kiji.schema.layout.impl.TableLayoutMonitor$DefaultTableLayoutMonitor


  @Test
  public void testOpenReaders() throws IOException {
    final KijiTable table = mKiji.openTable("user");
    try {
      final HBaseKijiTable htable = HBaseKijiTable.downcast(table);
      final TableLayoutMonitor monitor = htable.getTableLayoutMonitor();
      assertTrue(monitor.getLayoutConsumers().isEmpty());
      // Readers should register with the table as they open.
      final KijiTableReader reader = table.openTableReader();
      // Check that all readers are accounted for.
      assertTrue(monitor.getLayoutConsumers().size() == 1);
      // Readers should unregister as they close.
      reader.close();
      // Check that no readers remain.
      assertTrue(monitor.getLayoutConsumers().isEmpty());
    } finally {
      table.release();
    }
  }
View Full Code Here


  @Test
  public void testOpenWriters() throws IOException {
    final KijiTable table = mKiji.openTable("user");
    try {
      final HBaseKijiTable htable = HBaseKijiTable.downcast(table);
      final TableLayoutMonitor monitor = htable.getTableLayoutMonitor();
      assertTrue(monitor.getLayoutConsumers().isEmpty());
      // Writers should register with the table as they open.
      final KijiTableWriter writer = table.openTableWriter();
      final KijiBufferedWriter bufferedWriter = table.getWriterFactory().openBufferedWriter();
      final AtomicKijiPutter atomicPutter = table.getWriterFactory().openAtomicPutter();

      // Check that all writers are accounted for.
      final Set<LayoutConsumer> consumers = monitor.getLayoutConsumers();
      assertTrue(consumers.size() == 3);

      // Writers should unregister as they close.
      writer.close();
      bufferedWriter.close();
      atomicPutter.close();

      // Check that no writers remain.
      assertTrue(monitor.getLayoutConsumers().isEmpty());
    } finally {
      table.release();
    }
  }
View Full Code Here

  @Test
  public void testUpdateLayout() throws IOException {
    final KijiTable table = mKiji.openTable("user");
    try {
      final HBaseKijiTable htable = HBaseKijiTable.downcast(table);
      final TableLayoutMonitor monitor = htable.getTableLayoutMonitor();
      assertTrue(monitor.getLayoutConsumers().isEmpty());
      final KijiTableWriter writer = table.openTableWriter();
      try {
        assertTrue(monitor.getLayoutConsumers().size() == 1);

        // We can write to info:name, but not family:column.
        writer.put(table.getEntityId("foo"), "info", "name", "new-val");
        try {
          writer.put(table.getEntityId("foo"), "family", "column", "foo-val");
          fail("writer.put() should have thrown an IOException.");
        } catch (NoSuchColumnException nsce) {
          assertEquals("family:column", nsce.getMessage());
        }

        // Update the table layout.
        final KijiTableLayout newLayout =
            KijiTableLayout.newLayout(KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE));
        monitor.updateLayoutConsumers(newLayout);

        // Now we can write to family:column, but not info:name.
        writer.put(table.getEntityId("foo"), "family", "column", "foo-val");
        try {
          writer.put(table.getEntityId("foo"), "info", "name", "two-val");
View Full Code Here

TOP

Related Classes of org.kiji.schema.layout.impl.TableLayoutMonitor$DefaultTableLayoutMonitor

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.