Esempio n. 1
0
class RaindropHBaseClient:

  def __init__(self, host = 'localhost', port = 9090):
    self._port = port
    self._host = host
    self.connection = HBaseConnection(self._host, self._port)
    try:
      print "Connected to HBase %s" % self.connection.get_hbase_version()
    except:
      print "Error connecting to HBase"

    self.__init__tables()

  def __init__tables(self):
    if not self.connection.table_exists(MESSAGES_TABLE):
      self.__create_tables()

  def __create_tables(self):
    try:
      self.connection.create_table(MESSAGES_TABLE, IDS_COLUMN, SUMMARY_COLUMN, DATA_COLUMN)
    except AvroException, e:
      print e.message.get("message")
      raise e
Esempio n. 2
0
class RaindropHBaseClient:
    def __init__(self, host='localhost', port=9090):
        self._port = port
        self._host = host
        self.connection = HBaseConnection(self._host, self._port)
        try:
            print "Connected to HBase %s" % self.connection.get_hbase_version()
        except:
            print "Error connecting to HBase"

        self.__init__tables()

    def __init__tables(self):
        if not self.connection.table_exists(MESSAGES_TABLE):
            self.__create_tables()

    def __create_tables(self):
        try:
            self.connection.create_table(MESSAGES_TABLE, IDS_COLUMN,
                                         SUMMARY_COLUMN, DATA_COLUMN)
        except AvroException, e:
            print e.message.get("message")
            raise e
#! /usr/bin/env python

from pyhbase.connection import HBaseConnection

if __name__ == "__main__":
  hbase_conn = HBaseConnection('localhost', 9090)
  if not hbase_conn.table_exists('message_log'):
    hbase_conn.create_table('message_log', 'messages')
#! /usr/bin/env python

from pyhbase.connection import HBaseConnection

if __name__ == "__main__":
    hbase_conn = HBaseConnection('localhost', 9090)
    if not hbase_conn.table_exists('message_log'):
        hbase_conn.create_table('message_log', 'messages')