Package org.hivedb

Examples of org.hivedb.Hive


  }

  @Test
  public void testGetKeySemaphoresOfPrimaryIndexKeyMultiNode() throws Exception {
    DbDirectory d = getDirectory();
    Hive hive = getHive();
    for (String pkey : getPrimaryIndexOrResourceKeys()) {
      for (Node node : hive.getNodes())
        d.insertPrimaryIndexKey(node, pkey);
      assertEquals(hive.getNodes().size(), d.getKeySemamphoresOfPrimaryIndexKey(pkey).size());
    }
  }
View Full Code Here


public class TestTerraFormingHiveFactory extends H2TestCase {
  private static final String HIVE = "hive";

  @Test
  public void barrenHiveDb() throws Exception {
    Hive hive = TerraformingHiveFactory.colonize(getConnectString(HIVE), getPersistedClasses());
    assertNotNull(hive);
    assertNotNull(hive.getPartitionDimension());
    assertNotNull(hive.getPartitionDimension().getResource("WeatherReport"));
  }
View Full Code Here

    }
  }

  @Test
  public void testMigration() throws Exception {
    Hive hive = Hive.load(getConnectString(getHiveDatabaseName()), CachingDataSourceProvider.getInstance());
    String primaryKey = new String("Asia");
    Integer secondaryKey = new Integer(7);

    Pair<Node, Node> nodes = initializeTestData(hive, primaryKey, secondaryKey);
    Node origin = nodes.getKey();
    Node destination = nodes.getValue();
    NodeResolver dir = new DbDirectory(hive.getPartitionDimension(), CachingDataSourceProvider.getInstance().getDataSource(getConnectString(getHiveDatabaseName())));
    PartitionKeyMover<String> pMover = new PrimaryMover(origin.getUri());
    Mover<Integer> secMover = new SecondaryMover();

    //Do the actual migration
    Migrator m = new HiveMigrator(hive);
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Test
  public void testFailDuringCopy() throws Exception {
    Hive hive = Hive.load(getConnectString(getHiveDatabaseName()), CachingDataSourceProvider.getInstance());
    String primaryKey = new String("Oceana");
    Integer secondaryKey = new Integer(7);

    Pair<Node, Node> nodes = initializeTestData(hive, primaryKey, secondaryKey);
    Node origin = nodes.getKey();
    Node destination = nodes.getValue();
    NodeResolver dir = new DbDirectory(hive.getPartitionDimension(), getDataSource(getConnectString(getHiveDatabaseName())));
    PartitionKeyMover<String> pMover = new PrimaryMover(origin.getUri());
    //This mover just craps out on copy
    Mover<Integer> failingMover = new Mover<Integer>() {
      public void copy(Integer item, Node node) {
        throw new RuntimeException("");
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Test
  public void testFailDuringDelete() throws Exception {
    Hive hive = Hive.load(getConnectString(getHiveDatabaseName()), CachingDataSourceProvider.getInstance());
    String primaryKey = new String("Asia");
    Integer secondaryKey = new Integer(7);

    Pair<Node, Node> nodes = initializeTestData(hive, primaryKey, secondaryKey);
    Node origin = nodes.getKey();
    Node destination = nodes.getValue();

    NodeResolver dir = new DbDirectory(hive.getPartitionDimension(), getDataSource(getConnectString(getHiveDatabaseName())));
    PartitionKeyMover<String> pMover = new PrimaryMover(origin.getUri());
//    This mover just craps out on delete
    Mover<Integer> failingMover = new Mover<Integer>() {
      public void copy(Integer item, Node node) {
        SimpleJdbcDaoSupport dao = new SimpleJdbcDaoSupport();
View Full Code Here

    }
  }

  @Test
  public void shouldOpenASessionByPrimaryKey() throws Exception {
    Hive hive = getHive();
    String asia = "Asia";
    hive.directory().insertPrimaryIndexKey(asia);
    final WeatherReportImpl report = new WeatherReportImpl();
    report.setContinent(asia);
    Session session = factory.openSession(asia);
    try {
      Node node = getNodeForFirstId(hive, hive.directory().getNodeIdsOfPrimaryIndexKey(asia));
      assertCorrectNode(session, node);
    } catch (Exception e) {
      fail(e.getMessage());
    } finally {
      session.close();
View Full Code Here

    }
  }

  @Test
  public void shouldOpenASessionByResourceId() throws Exception {
    Hive hive = getHive();
    String asia = "Asia";
    hive.directory().insertPrimaryIndexKey(asia);
    int id = 999;
    hive.directory().insertResourceId("WeatherReport", id, asia);
    final WeatherReportImpl report = new WeatherReportImpl();
    report.setContinent(asia);
    Session session = factory.openSession("WeatherReport", id);
    try {
      Node node = getNodeForFirstId(hive, hive.directory().getNodeIdsOfResourceId("WeatherReport", id));
      assertCorrectNode(session, node);
    } catch (Exception e) {
      fail(e.getMessage());
    } finally {
      session.close();
View Full Code Here

    }
  }

  @Test
  public void shouldOpenASessionBySecondaryIndex() throws Exception {
    Hive hive = getHive();
    String asia = "Asia";
    int id = 999;
    hive.directory().insertPrimaryIndexKey(asia);
    hive.directory().insertResourceId("WeatherReport", id, asia);
    int code = 765;
    hive.directory().insertSecondaryIndexKey("WeatherReport", "RegionCode", code, id);

    final WeatherReportImpl report = new WeatherReportImpl();
    report.setContinent(asia);
    Session session = factory.openSession("WeatherReport", "RegionCode", code);
    try {
      Node node = getNodeForFirstId(hive, hive.directory().getNodeIdsOfSecondaryIndexKey("WeatherReport", "RegionCode", code));
      assertCorrectNode(session, node);
    } catch (Exception e) {
      fail(e.getMessage());
    } finally {
      session.close();
View Full Code Here

    }
  }

  @Test
  public void shouldAddOpenSessionEvents() throws Exception {
    Hive hive = getHive();
    String asia = "Asia";
    hive.directory().insertPrimaryIndexKey(asia);
    final WeatherReportImpl report = new WeatherReportImpl();
    report.setContinent(asia);
    Session session = factory.openSession(asia);
    try {
      Node node = getNodeForFirstId(hive, hive.directory().getNodeIdsOfPrimaryIndexKey(asia));
      assertTrue("Opened a session to the wrong node", node.getUri().startsWith(RecordNodeOpenSessionEvent.getNode()));
    } catch (Exception e) {
      e.printStackTrace();
      fail("Exception thrown: " + e.getMessage());
    } finally {
View Full Code Here

    }
  }

  @Test
  public void shouldAddOpenSessionEventsToAllShardsSession() throws Exception {
    Hive hive = getHive();
    String asia = "Asia";
    hive.directory().insertPrimaryIndexKey(asia);
    final WeatherReportImpl report = WeatherReportImpl.generate();
    report.setContinent(asia);
    Session session = factory.openSession();
    report.setReportId(88);
    try {
      session.save(report);
      Node node = getNodeForFirstId(hive, hive.directory().getNodeIdsOfPrimaryIndexKey(asia));
      assertTrue("Opened a session to the wrong node", node.getUri().startsWith(RecordNodeOpenSessionEvent.getNode()));
    } catch (Exception e) {
      e.printStackTrace();
      fail("Exception thrown: " + e.getMessage());
    } finally {
View Full Code Here

TOP

Related Classes of org.hivedb.Hive

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.