Package com.hmsonline.virgil

Examples of com.hmsonline.virgil.CassandraStorage


      System.setProperty("cassandra-foreground", "true");
      System.setProperty(VirgilConfiguration.CASSANDRA_PORT_PROPERTY, "9160");
      System.setProperty(VirgilConfiguration.CASSANDRA_HOST_PROPERTY, "localhost");
            System.setProperty(VirgilConfiguration.CASSANDRA_EMBEDDED, "1");
      CassandraDaemon.main(null);
      return new CassandraStorage(config, indexer);
    } else {
      String cassandraHost = params.getOptionValue("host");
      if (cassandraHost == null)
        throw new RuntimeException("Need to specify a host if not running in embedded mode. (-e)");
      String cassandraPort = params.getOptionValue("port");
      if (cassandraPort == null)
        cassandraPort = "9160";
            System.setProperty(VirgilConfiguration.CASSANDRA_HOST_PROPERTY, cassandraHost);
      System.setProperty(VirgilConfiguration.CASSANDRA_PORT_PROPERTY, cassandraPort);
            System.setProperty(VirgilConfiguration.CASSANDRA_EMBEDDED, "0");
      System.out.println("Starting virgil against remote cassandra server [" + cassandraHost + ":"
          + cassandraPort + "]");
      return new CassandraStorage(config, indexer);
    }
  }
View Full Code Here


  @Override
  protected void run(AbstractService<VirgilConfiguration> service, VirgilConfiguration config, CommandLine params)
      throws Exception {
    assert (service instanceof VirgilService);
    VirgilService virgil = (VirgilService) service;
    CassandraStorage storage = this.createCassandraStorage(params, config);
    virgil.setStorage(storage);
    virgil.setConfig(config);
    super.run(service, config, params);
  }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void testDatabaseServices() throws Exception {
       
        CassandraStorage dataService = VirgilService.storage;
        JSONObject slice = new JSONObject();
        slice.put("FIRST_NAME", "John");
        slice.put("LAST_NAME", "Smith");

        try { // CLEANUP FROM BEFORE
            dataService.dropKeyspace(KEYSPACE);
        } catch (Exception e) {
        }

        // CREATE KEYSPACE
        dataService.addKeyspace(KEYSPACE);

        // CREATE COLUMN FAMILY
        dataService.createColumnFamily(KEYSPACE, COLUMN_FAMILY, null);

        // INSERT THE ROW
        dataService.setColumn(KEYSPACE, COLUMN_FAMILY, KEY, slice, ConsistencyLevel.ONE, false);

        // FETCH THE ROW (VERIFY INSERT ROW)
        JSONObject json = dataService.getSlice(KEYSPACE, COLUMN_FAMILY, KEY, ConsistencyLevel.ONE);
        assertEquals(JSON.parse("{\"FIRST_NAME\":\"John\",\"LAST_NAME\":\"Smith\"}"), json);

        // ADD A COLUMN
        dataService.addColumn(KEYSPACE, COLUMN_FAMILY, KEY, "STATE", "CA", ConsistencyLevel.ONE, false);

        // FETCH THE ROW (VERIFY ADD COLUMN)
        json = dataService.getSlice(KEYSPACE, COLUMN_FAMILY, KEY, ConsistencyLevel.ONE);
        assertEquals(JSON.parse("{\"STATE\":\"CA\",\"FIRST_NAME\":\"John\",\"LAST_NAME\":\"Smith\"}"), json);

        // DELETE THE ROW
        dataService.deleteRow(KEYSPACE, COLUMN_FAMILY, "TEST_SLICE", ConsistencyLevel.ONE, false);
        json = dataService.getSlice(KEYSPACE, COLUMN_FAMILY, "TEST_SLICE", ConsistencyLevel.ONE);
        assertEquals(null, json);

        // DROP COLUMN FAMILY
        dataService.dropColumnFamily(KEYSPACE, COLUMN_FAMILY);
        boolean threw = false;
        try {
            json = dataService.getSlice(KEYSPACE, COLUMN_FAMILY, "TEST_SLICE", ConsistencyLevel.ONE);
        } catch (InvalidRequestException ire) {
            threw = true;
        }
        assertTrue("Expected exception when accessing dropped column family.", threw);

        // DROP KEY SPACE
        dataService.dropKeyspace(KEYSPACE);
        boolean threw1 = false;
        try {
            json = dataService.getSlice(KEYSPACE, COLUMN_FAMILY, "TEST_SLICE", ConsistencyLevel.ONE);
        } catch (InvalidRequestException ire) {
            threw1 = true;
        }
        assertTrue("Expected exception when accessing dropped key space.", threw1);
    }
View Full Code Here

TOP

Related Classes of com.hmsonline.virgil.CassandraStorage

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.