コード例 #1
0
  /** Starts the Cassandra DB, using any Persisted data files */
  public void start() throws Exception {
    if (dbsvc != null) {
      return;
    }

    DataObjectScanner dataObjectScanner = new DataObjectScanner();
    dataObjectScanner.setPackages(modelPackages.toArray(new String[0]));
    dataObjectScanner.init();

    ServiceImpl dummyDBService = new ServiceImpl();
    dummyDBService.setName("dbsvc");
    dummyDBService.setVersion("1");
    dummyDBService.setEndpoint(URI.create("thrift://localhost:9170"));
    dummyDBService.setId("foobar");

    SchemaUtil schemaUtil = new SchemaUtil();
    schemaUtil.setKeyspaceName("Testing");
    schemaUtil.setService(dummyDBService);
    schemaUtil.setCoordinator(coordinatorClient);
    schemaUtil.setDataObjectScanner(dataObjectScanner);

    String config = createConfig(dataDir.getAbsolutePath());
    dbsvc = new DbServiceImpl();
    dbsvc.setConfig(config);
    dbsvc.setSchemaUtil(schemaUtil);
    dbsvc.setCoordinator(coordinatorClient);
    dbsvc.setService(dummyDBService);
    dbsvc.start();
  }
コード例 #2
0
  /** Stops the Cassandra DB, keeping all persistent data intact */
  public void stop() throws Exception {
    dbsvc.stop();

    dbsvc = null;
  }