Exemplo n.º 1
0
 // @Override
 public void cleanup() {
   try {
     HBaseTest.getAllRecord(this.tableName);
   } catch (Exception e) {
     LOG.error("Error closing connections", e);
   }
 }
Exemplo n.º 2
0
  // @Override
  public void execute(Tuple tuple) {
    // String[] oneLine = tuple.getString(0).split("\t");
    try {
      String originalTweet = tuple.getStringByField("original-tweet");
      String county_id = tuple.getStringByField("county_id");
      String url = tuple.getStringByField("url");
      int sentiment = tuple.getIntegerByField("sentiment");
      HBaseTest.addRecord(this.tableName, county_id, "tweet", "", originalTweet);
      HBaseTest.addRecord(this.tableName, county_id, "url", "", url);
      HBaseTest.addRecord(this.tableName, county_id, "sentiment", "", String.valueOf(sentiment));
    } catch (Exception e) {
      LOG.error("Error inserting data into HBase table", e);
    }

    collector.emit(new Values(tuple.getString(0)));
    // acknowledge even if there is an error
    collector.ack(tuple);
  }
Exemplo n.º 3
0
 public HBaseUpdateBolt(String habse_cf, String tablename) {
   try {
     tableName = tablename;
     HBASE_CF = habse_cf.split(",");
     HBaseTest.creatTable(tableName, HBASE_CF);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }