Package com.pardot.rhombus.helpers

Examples of com.pardot.rhombus.helpers.ConnectionManagerTester


  }

  @Test
  public void testPreferRhombusStorageDefinition() throws Exception {
    // Set up a connection manager
    ConnectionManagerTester cm = getConnectionManager();

    // Manually drop our Rhombus keyspace
    cm.dropKeyspace(cm.getRhombusKeyspaceName());

    // Manually drop the functional keyspace if it exists
    CKeyspaceDefinition definition = JsonUtil.objectFromJsonResource(CKeyspaceDefinition.class
        , this.getClass().getClassLoader(), "CKeyspaceTestData.js");
    cm.dropKeyspace(definition.getName());

    // Build the keyspace from the base definition
    cm.buildKeyspace(definition, false);

    // Simulate a new process interacting with this Rhombus data by tearing down the cluster
    // and getting a new connection manager
    cm.teardown();
    cm = getConnectionManager();

    // Make a slightly altered new definition
    CKeyspaceDefinition definition2 = JsonUtil.objectFromJsonResource(CKeyspaceDefinition.class
        , this.getClass().getClassLoader(), "CKeyspaceTestData.js");
    CDefinition keyspaceDef = definition2.getDefinitions().values().iterator().next();
    Map<String, CField> fields = keyspaceDef.getFields();
    fields.put("new_field", new CField("new_field", CField.CDataType.ASCII));
    assertNotEquals(definition, definition2);

    ObjectMapper om = cm.getObjectMapper(definition2);
    CKeyspaceDefinition omDef = om.getKeyspaceDefinition_ONLY_FOR_TESTING();
    assertEquals(definition, omDef);

    cm.teardown();
  }
View Full Code Here


  }

  @Test
  public void testGetKeyspaceFromRhombusStorage() throws Exception {
    // Set up a connection manager
    ConnectionManagerTester cm = getConnectionManager();

    // Manually drop our Rhombus keyspace
    cm.dropKeyspace(cm.getRhombusKeyspaceName());

    // Manually drop the functional keyspace if it exists
    CKeyspaceDefinition definition = JsonUtil.objectFromJsonResource(CKeyspaceDefinition.class
        , this.getClass().getClassLoader(), "CKeyspaceTestData.js");
    cm.dropKeyspace(definition.getName());

    // Build the keyspace from the base definition
    cm.buildKeyspace(definition, false);

    // Simulate a new process interacting with this Rhombus data by tearing down the cluster
    // and getting a new connection manager
    cm.teardown();
    cm = getConnectionManager();

    ObjectMapper om = cm.getObjectMapper(definition.getName());
    CKeyspaceDefinition rhombusStorageKeyspaceDefinition = om.getKeyspaceDefinition_ONLY_FOR_TESTING();
    assertEquals(definition, rhombusStorageKeyspaceDefinition);

    cm.teardown();
  }
View Full Code Here

  }

  @Test
  public void testRhombusKeyspaceCreatedIfNotExists() throws Exception {
    // Set up a connection manager
    ConnectionManagerTester cm = getConnectionManager();

    // Manually drop our Rhombus keyspace
    cm.dropKeyspace(cm.getRhombusKeyspaceName());

    // Get the Rhombus object mapper
    CKeyspaceDefinition definition = JsonUtil.objectFromJsonResource(CKeyspaceDefinition.class
        , this.getClass().getClassLoader(), "CKeyspaceTestData.js");
    ObjectMapper om = cm.getRhombusObjectMapper(definition);
    assertNotNull(om);

    cm.teardown();
  }
View Full Code Here

  }

  @Test
  public void testKeyspaceCreatedFromDefinitionIfNotExists() throws Exception {
    // Set up a connection manager
    ConnectionManagerTester cm = getConnectionManager();

    // Manually drop our Rhombus keyspace
    cm.dropKeyspace(cm.getRhombusKeyspaceName());

    // Manually drop the functional keyspace if it exists
    CKeyspaceDefinition definition = JsonUtil.objectFromJsonResource(CKeyspaceDefinition.class
        , this.getClass().getClassLoader(), "CKeyspaceTestData.js");
    cm.dropKeyspace(definition.getName());

    // Try to get an object mapper for the functional keyspace
    cm.getObjectMapper(definition);
    assertNotNull(definition);

    // Make sure we have stored the keyspace definition in our Rhombus keyspace
    ObjectMapper rhombusObjectMapper = cm.getRhombusObjectMapper(definition);
    CKeyspaceDefinition createdDefinition = rhombusObjectMapper.hydrateRhombusKeyspaceDefinition(definition.getName());
    assertEquals(definition, createdDefinition);

    // Close down our ConnectionManager, make a new one, and verify that we get the proper keyspace
    cm.teardown();
    cm = getConnectionManager();
    ObjectMapper defObjectMapper = cm.getObjectMapper(definition);
    assertEquals(definition, defObjectMapper.getKeyspaceDefinition_ONLY_FOR_TESTING());

    cm.teardown();
  }
View Full Code Here

    return RhombusFunctionalTest.getConnectionManagerStatic();
    }

  protected static ConnectionManagerTester getConnectionManagerStatic() throws IOException {
    //Get a connection manager based on the test properties
    ConnectionManagerTester connectionManager = TestHelpers.getTestConnectionManager();
    connectionManager.setLogCql(true);
    connectionManager.buildCluster(true);
    assertNotNull(connectionManager);
    return connectionManager;
  }
View Full Code Here

    }

    public void testOneObject() throws Exception {

      //Get a connection manager based on the test properties
      ConnectionManagerTester cm = TestHelpers.getTestConnectionManager();
      cm.setLogCql(true);
      cm.buildCluster(true);

      CObjectShardList shardIdLists = new ShardListMock(Arrays.asList(1L,2L,3L,4L,5L));

      //Build our keyspace definition object
      CKeyspaceDefinition definition = JsonUtil.objectFromJsonResource(CKeyspaceDefinition.class, this.getClass().getClassLoader(), "MultiInsertKeyspace.js");

      //Rebuild the keyspace and get the object mapper
      cm.buildKeyspace(definition, true);

      ObjectMapper om = cm.getObjectMapper(definition);
      om.setLogCql(true);

      int nDataItems = 1;

      List<Map<String, Object>> values2 = generateNObjects(nDataItems);

      List<Map<String, Object>> updatedValues2 = Lists.newArrayList();
      for (Map<String, Object> baseValue : values2) {
        updatedValues2.add(JsonUtil.rhombusMapFromJsonMap(baseValue, definition.getDefinitions().get("object2")));
      }

      Map<String, List<Map<String, Object>>> multiInsertMap = Maps.newHashMap();
      multiInsertMap.put("object2", updatedValues2);

      //Insert data
      om.insertBatchMixed(multiInsertMap);

      // generate a executorIterator
      SortedMap<String, Object> indexValues = Maps.newTreeMap();
      indexValues.put("account_id", UUID.fromString("00000003-0000-0030-0040-000000030000"));
      indexValues.put("user_id", UUID.fromString("00000003-0000-0030-0040-000000030000"));

      UUID stop = UUID.fromString(uuidList.get(nDataItems-1));
      CDefinition cDefinition = definition.getDefinitions().get("object2");
      BaseCQLStatementIterator unBoundedIterator = (BaseCQLStatementIterator) CObjectCQLGenerator.makeCQLforList(KEYSPACE_NAME, shardIdLists, cDefinition, indexValues, CObjectOrdering.DESCENDING, null, stop, 10l, true, false, false);
      Session session = cm.getRhombusSession(definition);
      CQLExecutor cqlExecutor = new CQLExecutor(session, true, definition.getConsistencyLevel());
      CQLExecutorIterator cqlExecutorIterator = new CQLExecutorIterator(cqlExecutor, unBoundedIterator);
      cqlExecutorIterator.setPageSize(nDataItems);

View Full Code Here

    }

    public void testIterator() throws Exception {

      //Get a connection manager based on the test properties
      ConnectionManagerTester cm = TestHelpers.getTestConnectionManager();
      cm.setLogCql(true);
      cm.buildCluster(true);

      CObjectShardList shardIdLists = new ShardListMock(Arrays.asList(1L,2L,3L,4L,5L));

      //Build our keyspace definition object
      CKeyspaceDefinition definition = JsonUtil.objectFromJsonResource(CKeyspaceDefinition.class, this.getClass().getClassLoader(), "MultiInsertKeyspace.js");

      //Rebuild the keyspace and get the object mapper
      cm.buildKeyspace(definition, true);

      ObjectMapper om = cm.getObjectMapper(definition);
      om.setLogCql(true);

      // Set up test data
      // we will insert 200 objects
      int nDataItems = 200;

      List<Map<String, Object>> values2 = generateNObjects(nDataItems);

      List<Map<String, Object>> updatedValues2 = Lists.newArrayList();
      for (Map<String, Object> baseValue : values2) {
        updatedValues2.add(JsonUtil.rhombusMapFromJsonMap(baseValue, definition.getDefinitions().get("object2")));
      }

      Map<String, List<Map<String, Object>>> multiInsertMap = Maps.newHashMap();
      multiInsertMap.put("object2", updatedValues2);

      //Insert data
      om.insertBatchMixed(multiInsertMap);

      // generate a executorIterator
      SortedMap<String, Object> indexValues = Maps.newTreeMap();
      indexValues.put("account_id", UUID.fromString("00000003-0000-0030-0040-000000030000"));
      indexValues.put("user_id", UUID.fromString("00000003-0000-0030-0040-000000030000"));

      UUID stop = UUID.fromString(uuidList.get(nDataItems-1));
      CDefinition cDefinition = definition.getDefinitions().get("object2");
      BaseCQLStatementIterator unBoundedIterator = (BaseCQLStatementIterator) CObjectCQLGenerator.makeCQLforList(KEYSPACE_NAME, shardIdLists, cDefinition, indexValues, CObjectOrdering.DESCENDING, null, stop, 10l, true, false, false);
      Session session = cm.getRhombusSession(definition);
      CQLExecutor cqlExecutor = new CQLExecutor(session, true, definition.getConsistencyLevel());
      CQLExecutorIterator cqlExecutorIterator = new CQLExecutorIterator(cqlExecutor, unBoundedIterator);
      cqlExecutorIterator.setPageSize(nDataItems);

View Full Code Here

    public void testPageSizePlus1() throws Exception {

      String objectType = "object2";

      //Get a connection manager based on the test properties
      ConnectionManagerTester cm = TestHelpers.getTestConnectionManager();
      cm.setLogCql(true);
      cm.buildCluster(true);

      CObjectShardList shardIdLists = new ShardListMock(Arrays.asList(1L,2L,3L,4L,5L));

      //Build our keyspace definition object
      CKeyspaceDefinition definition = JsonUtil.objectFromJsonResource(CKeyspaceDefinition.class, this.getClass().getClassLoader(), "MultiInsertKeyspace.js");

      //Rebuild the keyspace and get the object mapper
      cm.buildKeyspace(definition, true);

      ObjectMapper om = cm.getObjectMapper(definition);
      om.setLogCql(true);

      // Set up test data
      // we will insert 20 objects
      int nDataItems = 20;

      List<Map<String, Object>> values2 = generateNObjects(nDataItems);

      List<Map<String, Object>> updatedValues2 = Lists.newArrayList();
      for (Map<String, Object> baseValue : values2) {
        updatedValues2.add(JsonUtil.rhombusMapFromJsonMap(baseValue, definition.getDefinitions().get("object2")));
      }

      Map<String, List<Map<String, Object>>> multiInsertMap = Maps.newHashMap();
      multiInsertMap.put(objectType, updatedValues2);

      //Insert data
      om.insertBatchMixed(multiInsertMap);

      // generate a executorIterator
      SortedMap<String, Object> indexValues = Maps.newTreeMap();
      indexValues.put("account_id", UUID.fromString("00000003-0000-0030-0040-000000030000"));
      indexValues.put("user_id", UUID.fromString("00000003-0000-0030-0040-000000030000"));
      Criteria criteria = new Criteria();
      criteria.setIndexKeys(indexValues);

      CObjectCQLGenerator cqlGenerator = om.getCqlGenerator_ONLY_FOR_TESTING();
      CQLStatementIterator unBoundedIterator = cqlGenerator.makeCQLforList(objectType, criteria, false);

      Session session = cm.getRhombusSession(definition);
      CQLExecutor cqlExecutor = new CQLExecutor(session, true, definition.getConsistencyLevel());
      CQLExecutorIterator cqlExecutorIterator = new CQLExecutorIterator(cqlExecutor, unBoundedIterator);
      cqlExecutorIterator.setPageSize(nDataItems-1);

View Full Code Here

    }

    public void test5Pages() throws Exception {

      //Get a connection manager based on the test properties
      ConnectionManagerTester cm = TestHelpers.getTestConnectionManager();
      cm.setLogCql(true);
      cm.buildCluster(true);

      CObjectShardList shardIdLists = new ShardListMock(Arrays.asList(1L,2L,3L,4L,5L));

      //Build our keyspace definition object
      CKeyspaceDefinition definition = JsonUtil.objectFromJsonResource(CKeyspaceDefinition.class, this.getClass().getClassLoader(), "MultiInsertKeyspace.js");

      //Rebuild the keyspace and get the object mapper
      cm.buildKeyspace(definition, true);

      ObjectMapper om = cm.getObjectMapper(definition);
      om.setLogCql(true);

      // Set up test data
      // we will insert 200 objects
      int nDataItems = 200;

      List<Map<String, Object>> values2 = generateNObjects(nDataItems);

      List<Map<String, Object>> updatedValues2 = Lists.newArrayList();
      for (Map<String, Object> baseValue : values2) {
        updatedValues2.add(JsonUtil.rhombusMapFromJsonMap(baseValue, definition.getDefinitions().get("object2")));
      }

      Map<String, List<Map<String, Object>>> multiInsertMap = Maps.newHashMap();
      multiInsertMap.put("object2", updatedValues2);

      //Insert data
      om.insertBatchMixed(multiInsertMap);

      // generate a executorIterator
      SortedMap<String, Object> indexValues = Maps.newTreeMap();
      indexValues.put("account_id", UUID.fromString("00000003-0000-0030-0040-000000030000"));
      indexValues.put("user_id", UUID.fromString("00000003-0000-0030-0040-000000030000"));

      UUID stop = UUID.fromString(uuidList.get(nDataItems-1));
      CDefinition cDefinition = definition.getDefinitions().get("object2");
      BaseCQLStatementIterator unBoundedIterator = (BaseCQLStatementIterator) CObjectCQLGenerator.makeCQLforList(KEYSPACE_NAME, shardIdLists, cDefinition, indexValues, CObjectOrdering.DESCENDING, null, stop, 10l, true, false, false);
      Session session = cm.getRhombusSession(definition);
      CQLExecutor cqlExecutor = new CQLExecutor(session, true, definition.getConsistencyLevel());
      CQLExecutorIterator cqlExecutorIterator = new CQLExecutorIterator(cqlExecutor, unBoundedIterator);
      cqlExecutorIterator.setPageSize((nDataItems/5));

View Full Code Here

TOP

Related Classes of com.pardot.rhombus.helpers.ConnectionManagerTester

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.