Package org.hivedb.meta

Examples of org.hivedb.meta.Node


  @Test
  public void testLoadingWithoutPartitionDimension() throws Exception {
    Hive hive = Hive.load(getConnectString(H2TestCase.TEST_DB), CachingDataSourceProvider.getInstance());
    assertNotNull(hive);
    Node node = getNode();
    hive.addNode(node);

    Hive fetched = Hive.load(getConnectString(H2TestCase.TEST_DB), CachingDataSourceProvider.getInstance());
    assertEquals(1, fetched.getNodes().size());
    assertEquals(node, fetched.getNode(node.getName()));
  }
View Full Code Here


    assertEquals(1, fetched.getNodes().size());
    assertEquals(node, fetched.getNode(node.getName()));
  }

  private Node getNode() {
    return new Node(Hive.NEW_OBJECT_ID, "nodal", H2TestCase.TEST_DB, "", HiveDbDialect.H2);
  }
View Full Code Here

  @Test
  public void testLoadWithPartitionDimension() throws Exception {
    Hive hive = Hive.create(getConnectString(H2TestCase.TEST_DB), "DIM", Types.INTEGER, CachingDataSourceProvider.getInstance(), null);
    assertNotNull(hive);
    Node node = getNode();
    hive.addNode(node);

    Hive fetched = Hive.load(getConnectString(H2TestCase.TEST_DB), CachingDataSourceProvider.getInstance());
    assertEquals(1, fetched.getNodes().size());
    assertEquals(node, fetched.getNode(node.getName()));
  }
View Full Code Here

public class TestHiveWithNodeOutOfService extends HiveTest {

  @Test
  public void shouldThrowAnExceptionWhenAccessingRecordsOnAnOutOfServiceNode() throws Exception {
    Hive hive = getHive();
    Node outOfService = Atom.getFirst(hive.getNodes());
    outOfService.setStatus(Lockable.Status.unavailable);
    hive.updateNode(outOfService);
    try {
        hive.connection().daoSupport().getUnsafe(outOfService.getName());
        fail("No exception thrown");
    } catch (Exception e) {
        //pass
    }
View Full Code Here

  }

  @Test
  public void shouldLoadWithAnOutOfServiceNode() throws Exception {
    Hive hive = getHive();
    Node outOfService = Atom.getFirst(hive.getNodes());
    outOfService.setStatus(Lockable.Status.unavailable);
    hive.updateNode(outOfService);
    Hive newHive = Hive.load(hive.getUri(), CachingDataSourceProvider.getInstance());
    assertNotNull(newHive);
  }
View Full Code Here

  }

  @Test
  public void shouldContinueToFunctionWhenANodeIsMarkedOutOfService() throws Exception {
    Hive hive = getHive();
    Node outOfService = Atom.getFirst(hive.getNodes());
    outOfService.setStatus(Lockable.Status.unavailable);
    hive.updateNode(outOfService);
    Node inService = Filter.grepSingle(new Predicate<Node>(){
      public boolean f(Node item) {
        return item.getStatus() != Lockable.Status.unavailable;
      }
    }, hive.getNodes());
    hive.connection().daoSupport().getUnsafe(inService.getName());
  }
View Full Code Here

  }

  @Test
  public void shouldContinueToFunctionWhenANodeGoesDownButIsNotMarkedOutOfService() throws Exception {
    Hive hive = getHive();
    Node down = new Node("down","down","", HiveDbDialect.H2);
    hive.addNode(down);
    Node notDown = Filter.grepSingle(new Predicate<Node>(){
      public boolean f(Node item) {
        return item.getName() != "down";
      }
    }, hive.getNodes());
    hive.connection().daoSupport().getUnsafe(down.getName());
    hive.connection().daoSupport().getUnsafe(notDown.getName());
  }
View Full Code Here

@Config("hive_default")
public class HiveSessionFactoryBuilderTest extends HiveTest {
 
  @Test
  public void testCreateConfigurationFromNode() throws Exception {
    Node node = new Node(Hive.NEW_OBJECT_ID, "node", getHiveDatabaseName(), "", HiveDbDialect.H2);
    Configuration config = HiveSessionFactoryBuilderImpl.createConfigurationFromNode(node, new Properties());
    assertEquals(node.getUri(), config.getProperty("hibernate.connection.url"));
    assertEquals(H2Dialect.class.getName(), config.getProperty("hibernate.dialect"));
    assertEquals(node.getId().toString(), config.getProperty("hibernate.connection.shard_id"));
  }
View Full Code Here

    //Create a Hive
    Hive hive = Hive.create(getConnectString(H2TestCase.TEST_DB), dimensionName, Types.VARCHAR, CachingDataSourceProvider.getInstance(), null);

    //Create a Data Node
    Node dataNode = new Node(Hive.NEW_OBJECT_ID, "aNode", H2TestCase.TEST_DB, "", HiveDbDialect.H2);

    //Add it to the partition dimension
    hive.addNode(dataNode);

    //Make sure everything we just added actually got put into the hive meta data.
View Full Code Here

  public void testCreate() throws Exception {
    int count = getHive().getNodes().size();
    NodeDao dao = new NodeDao(getDataSource(getConnectString(getHiveDatabaseName())));
    assertEquals(count, dao.loadAll().size());

    Node full = createFullyPopulatedNode();
    Node minimal = createMinimalNode();

    dao.create(full);
    dao.create(minimal);

    List<Node> nodes = dao.loadAll();
    assertEquals(2 + count, nodes.size());

    Node fetchedFull = null;
    Node fetchedMinimal = null;

    for (Node n : nodes)
      if (n.getName().equals(full.getName()))
        fetchedFull = n;
      else if (n.getName().equals(minimal.getName()))
        fetchedMinimal = n;

    assertNotNull(fetchedFull);
    assertNotNull(fetchedMinimal);

    assertEquals(full, fetchedFull);
    assertEquals(minimal, fetchedMinimal);

    assertFalse(fetchedFull.getStatus().equals(Status.readOnly));
    assertFalse(fetchedMinimal.getStatus().equals(Status.readOnly));
  }
View Full Code Here

TOP

Related Classes of org.hivedb.meta.Node

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.