Examples of KijiSystemTable


Examples of org.kiji.schema.KijiSystemTable

   * @param kiji the connected Kiji instance.
   * @throws java.io.IOException if there is an error communicating with HBase.
   */
  public void restoreSystemVars(MetadataBackup backup, Kiji kiji) throws IOException {
    // Restore all System table entries from the file.
    final KijiSystemTable systemTable = kiji.getSystemTable();
    LOG.info("Restoring system table entries...");
    systemTable.fromBackup(backup.getSystemTable());
    LOG.info(String.format("Restored %d entries.", backup.getSystemTable().getEntries().size()));
  }
View Full Code Here

Examples of org.kiji.schema.KijiSystemTable

  private static ProtocolVersion getSystemVersion(
      final KijiURI instanceURI,
      final Configuration conf,
      final HTableInterfaceFactory htableFactory
  ) throws IOException {
    final KijiSystemTable systemTable = new HBaseSystemTable(instanceURI, conf, htableFactory);
    try {
      return systemTable.getDataVersion();
    } finally {
      systemTable.close();
    }
  }
View Full Code Here

Examples of org.kiji.schema.KijiSystemTable

    assertEquals(Versions.MAX_SYSTEM_VERSION, VersionInfo.getClientDataVersion());
  }

  @Test
  public void testGetClusterDataVersion() throws Exception {
    final KijiSystemTable systemTable = createMock(KijiSystemTable.class);
    // This version number for this test was picked out of a hat.
    expect(systemTable.getDataVersion()).andReturn(ProtocolVersion.parse("system-1.1")).anyTimes();

    final Kiji kiji = createMock(Kiji.class);
    expect(kiji.getSystemTable()).andReturn(systemTable).anyTimes();

    replay(systemTable);
View Full Code Here

Examples of org.kiji.schema.KijiSystemTable

    verify(kiji);
  }

  @Test
  public void testValidateVersion() throws Exception {
    final KijiSystemTable systemTable = createMock(KijiSystemTable.class);
    expect(systemTable.getDataVersion()).andReturn(VersionInfo.getClientDataVersion()).anyTimes();

    final Kiji kiji = createMock(Kiji.class);
    expect(kiji.getSystemTable()).andReturn(systemTable).anyTimes();

    replay(systemTable);
View Full Code Here

Examples of org.kiji.schema.KijiSystemTable

    verify(kiji);
  }

  @Test
  public void testValidateVersionFail() throws Exception {
    final KijiSystemTable systemTable = createMock(KijiSystemTable.class);
    expect(systemTable.getDataVersion()).andReturn(ProtocolVersion.parse("kiji-0.9")).anyTimes();

    final Kiji kiji = createMock(Kiji.class);
    expect(kiji.getSystemTable()).andReturn(systemTable).anyTimes();

    replay(systemTable);
View Full Code Here

Examples of org.kiji.schema.KijiSystemTable

  @Test
  public void testBackupAndRestore() throws InterruptedException, IOException {
    final Kiji kiji = getKiji();
    final KijiMetaTable metaTable = kiji.getMetaTable();
    final KijiSchemaTable schemaTable = kiji.getSchemaTable();
    final KijiSystemTable systemTable = kiji.getSystemTable();

    // Update the layout for table foo.
    final TableLayoutDesc layout =
        KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST_FORMATTED_EID);
    final KijiTableLayout updatedLayout = metaTable.updateTableLayout("foo", layout);

    // Insert a user-level key-value pair for table foo.
    metaTable.putValue("foo", "key", BYTES_VALUE);

    // Insert a key-value pair in the system table
    systemTable.putValue("testKey", Bytes.toBytes("testValue"));

    // The meta table should have a single table, foo, in it.
    assertEquals(1, metaTable.listTables().size());
    assertEquals(1, metaTable.tableSet().size());

    // The meta table should have a single key-value pair, "key"/"value", for table foo.
    assertEquals(1, metaTable.keySet("foo").size());
    assertArrayEquals(BYTES_VALUE, metaTable.getValue("foo", "key"));

    // write to backupBuilder
    final MetadataBackup.Builder backupBuilder = MetadataBackup.newBuilder()
        .setLayoutVersion(kiji.getSystemTable().getDataVersion().toString())
        .setMetaTable(
            MetaTableBackup.newBuilder()
                .setTables(new HashMap<String, TableBackup>())
                .build())
        .setSchemaTable(
            SchemaTableBackup.newBuilder()
                .setEntries(new ArrayList<SchemaTableEntry>())
                .build())
        .setSystemTable(
            SystemTableBackup.newBuilder()
                .setEntries(new ArrayList<SystemTableEntry>())
                .build());
    backupBuilder.setMetaTable(metaTable.toBackup());
    backupBuilder.setSchemaTable(schemaTable.toBackup());
    backupBuilder.setSystemTable(systemTable.toBackup());
    final MetadataBackup backup = backupBuilder.build();

    // make sure metadata key-value pairs are what we expect.
    List<KeyValueBackupEntry> keyValues =
        backup.getMetaTable().getTables().get("foo").getKeyValueBackup().getKeyValues();
    assertEquals(1, keyValues.size());
    assertEquals("key", keyValues.get(0).getKey());
    assertArrayEquals(BYTES_VALUE, keyValues.get(0).getValue().array());

    // make sure layouts are what we expect.
    List<TableLayoutBackupEntry> layoutBackups =
        backup.getMetaTable().getTables().get("foo").getTableLayoutsBackup().getLayouts();
    assertEquals(1, layoutBackups.size());
    assertEquals(updatedLayout.getDesc(), layoutBackups.get(0).getLayout());

    // Delete the entries for "foo" from the meta table.
    metaTable.deleteTable("foo");
    assertTrue(!metaTable.tableSet().contains("foo"));
    LOG.info("metaTable tables = " + metaTable.listTables());
    assertEquals(0, metaTable.listTables().size());
    assertEquals(0, metaTable.tableSet().size());

    final CassandraMetadataRestorer restorer = new CassandraMetadataRestorer();
    restorer.restoreTables(backup, kiji);

    final KijiMetaTable newMetaTable = kiji.getMetaTable();
    assertEquals("The number of tables with layouts is incorrect.", 1,
        newMetaTable.listTables().size());
    assertEquals("The number of tables with kv pairs is incorrect.", 1,
        newMetaTable.tableSet().size());
    assertEquals("The number of keys for the foo table is incorrect.", 1,
        newMetaTable.keySet("foo").size());
    assertArrayEquals(BYTES_VALUE, newMetaTable.getValue("foo", "key"));

    systemTable.putValue("testKey", Bytes.toBytes("changedValue"));
    restorer.restoreSystemVars(backup, kiji);
    assertEquals("testValue", Bytes.toString(systemTable.getValue("testKey")));
  }
View Full Code Here

Examples of org.kiji.schema.KijiSystemTable

    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));
View Full Code Here

Examples of org.kiji.schema.KijiSystemTable

   * @param kiji the connected Kiji instance.
   * @throws IOException if there is an error communicating with HBase.
   */
  public void restoreSystemVars(MetadataBackup backup, Kiji kiji) throws IOException {
    // Restore all System table entries from the file.
    final KijiSystemTable systemTable = kiji.getSystemTable();
    LOG.info("Restoring system table entries...");
    systemTable.fromBackup(backup.getSystemTable());
    LOG.info(String.format("Restored %d entries.", backup.getSystemTable().getEntries().size()));
  }
View Full Code Here

Examples of org.kiji.schema.KijiSystemTable

  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

Examples of org.kiji.schema.KijiSystemTable

  }

  @Test
  public void testPutGet() throws IOException {
    final Kiji kiji = getKiji();
    final KijiSystemTable systemTable = kiji.getSystemTable();

    assertNull(systemTable.getValue(KEY));

    systemTable.putValue(KEY, VALUE1);
    assertArrayEquals(VALUE1, systemTable.getValue(KEY));

    systemTable.putValue(KEY, VALUE2);
    assertArrayEquals(VALUE2, systemTable.getValue(KEY));
  }
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.