def saveResultToTwoHbase(res_rdd1: RDD[String], logsTableStr: String) = { val trueHbaseTableStr = "Hbase01" createTable(trueHbaseTableStr) val rdd2: RDD[(ImmutableBytesWritable, Put)] = res_rdd1.map(resultmodel => { /*-1未计算,0计算中,1计算完成,2计算失败*/ if (resultmodel.toInt > 2) { val put = new Put(Bytes.toBytes("000000" + new Date().getTime)) put.addColumn(Bytes.toBytes(Allocation.HBASE_FAMILY), Bytes.toBytes("name"), Bytes.toBytes(resultmodel)) (new ImmutableBytesWritable(Bytes.toBytes(trueHbaseTableStr)), put) } else { val put = new Put(Bytes.toBytes("111111" + new Date().getTime)) put.addColumn(Bytes.toBytes(Allocation.HBASE_FAMILY), Bytes.toBytes("name"), Bytes.toBytes(resultmodel)) (new ImmutableBytesWritable(Bytes.toBytes(logsTableStr)), put) } }) // saveResultToHbase(rdd2) } private def saveResultToHbase(res_rdd: RDD[(ImmutableBytesWritable, Put)]): Unit = { val hConf = HBaseConfiguration.create() hConf.set("hbase.zookeeper.quorum", CU.getProps(Allocation.ZKQUORUM_IP)) hConf.set("hbase.zookeeper.property.clientPort", CU.getProps(Allocation.ZKQUORUM_PORT)) val jobConf = new JobConf(hConf, this.getClass) res_rdd.saveAsNewAPIHadoopFile("", classOf[ImmutableBytesWritable], classOf[Put], classOf[MultiTableOutputFormat], jobConf) }