예제 #1
0
 /**
  * Loads an schedule item from a datasource
  *
  * @param dataSource the datasource object where to look up the schedule item
  * @param rowKey the rowkey of the schedule item to retrieve
  * @return
  */
 public static ScheduleItem load(DataSource dataSource, Schedule schedule, String rowKey) {
   Table table = dataSource.getTable(ScheduleItem.tableName);
   Get get = ScheduleItem.fillGetObject(table.createGetObject(rowKey));
   Result result = table.get(get);
   ScheduleItem r = ScheduleItem.fromResultObject(schedule, result);
   return r;
 }
예제 #2
0
 /**
  * time stamps this schedule item in the underlying storage by udpating the content of the column
  * 'bigs:alive' with the current date only if the existing uuid is the same of this process.
  *
  * @param dataSource the datasource object where this schedule item is stored
  * @return true if the update was successful, false otherwise (if the existing uuid is different,
  *     meaning that somebody else is working on this schedule item)
  */
 public Boolean markAlive(DataSource dataSource) {
   Table table = dataSource.getTable(ScheduleItem.tableName);
   Put put = table.createPutObject(this.getRowkey());
   this.lastUpdate = new Date(Core.getTime());
   put = this.fillPutObject(put);
   put = Data.fillInHostMetadata(put);
   Boolean r = table.checkAndPut(this.getRowkey(), "bigs", "uuid", Core.myUUID.getBytes(), put);
   return r;
 }
예제 #3
0
  @Override
  public void run(String[] args) throws Exception {

    String tableName = args[0];
    File destinationDir = new File(".");
    if (args.length == 2) destinationDir = new File(args[1]);

    DataSource dataSource = BIGS.globalProperties.getPreparedDataSource();

    Table table = dataSource.getTable(tableName);
    ResultScanner scanner = table.getScan(table.createScanObject());
    Result r = null;
    while ((r = scanner.next()) != null) {
      File destFile = new File(destinationDir, r.getRowKey());
      Log.info("downloading to file " + destFile.getName());
      DataItem dataItem = DataItem.fromResult(r);
      FileOutputStream fstream = new FileOutputStream(destFile);
      fstream.write(dataItem.asFileContent());
      fstream.close();
    }
  }
예제 #4
0
 /**
  * saves this schedule item in the underlying datasource
  *
  * @param dataSource the datasource
  */
 public void save() {
   DataSource dataSource = BIGS.globalProperties.getPreparedDataSource();
   Table table = dataSource.getTable(ScheduleItem.tableName);
   table.put(Data.fillInHostMetadata(this.fillPutObject(table.createPutObject(this.getRowkey()))));
 }