Beispiel #1
0
  @Override
  public int run(String[] args) throws Exception {

    // Get a log4j logger
    Logger logger = Logger.getLogger(App.class);

    // Find the schema from the repository
    FileSystemDatasetRepository repo =
        new FileSystemDatasetRepository.Builder()
            .rootDirectory(new URI("/tmp/data"))
            .configuration(getConf())
            .get();
    Schema schema = repo.getMetadataProvider().load("events").getSchema();

    // Build some events using the generic Avro API and log them using log4j
    GenericRecordBuilder builder = new GenericRecordBuilder(schema);
    for (long i = 0; i < 10; i++) {
      GenericRecord event = builder.set("id", i).set("message", "Hello " + i).build();
      System.out.println("Sending to log4j: " + event);
      logger.info(event);
    }

    return 0;
  }
 @Override
 public Dataset load(String name) {
   return fsRepository.load(name);
 }
 @Override
 public Dataset create(String name, DatasetDescriptor descriptor) {
   // avoids calling fsRepository.create, which creates the data path
   metadataProvider.create(name, descriptor);
   return fsRepository.load(name);
 }