Examples of HBaseConnectionPool


Examples of co.nubetech.crux.pool.HBaseConnectionPool

          .getNewSession();
      List<Connection> connectionList = connectionDAO.findAll();
      logger.debug("connectionList size is: " + connectionList.size());
      KeyedPoolableObjectFactory factory = PoolUtils
          .synchronizedPoolableFactory(new HBaseConnectionPoolFactory());
      HBaseConnectionPool pool = new HBaseConnectionPool(factory);
      for (Connection connection : connectionList) {
        logger.debug("Connection is: " + connection);
        pool.addObject(connection);
      }
      filter.getServletContext().setAttribute(CruxConstants.HBASE_POOL,
          pool);

    } catch (Exception e) {
View Full Code Here

Examples of co.nubetech.crux.pool.HBaseConnectionPool

  }

  public HBaseFacade getHBaseFacade() {
    ServletContext servletContext = ServletActionContext
        .getServletContext();
    HBaseConnectionPool pool = (HBaseConnectionPool) servletContext
        .getAttribute(CruxConstants.HBASE_POOL);
    HBaseFacade hbaseFacade = new HBaseFacade(pool);
    return hbaseFacade;
  }
View Full Code Here

Examples of co.nubetech.crux.pool.HBaseConnectionPool

    datastore = datastoreDAO.findById(CruxConstants.DEFAULT_DATASTORE_ID);
    connection.setDatastore(datastore);

    ServletContext servletContext = ServletActionContext
        .getServletContext();
    HBaseConnectionPool pool = (HBaseConnectionPool) servletContext
        .getAttribute(CruxConstants.HBASE_POOL);

    try {
      pool.save(connection);
      // servletContext.setAttribute(CruxConstants.HBASE_POOL, pool);
      HBaseFacade hbaseFacade = getHBaseFacade();
      boolean isValidConnection = hbaseFacade
          .isValidConnection(connection);
      logger.debug("isValidConnection : " + isValidConnection);
      if (isValidConnection) {
        logger.debug("connection is saving.");
        connectionDAO.save(connection);
      } else {
        error.setMessage("This connection is not valid.");
        try {
          pool.delete(connection);
          // servletContext.setAttribute(CruxConstants.HBASE_POOL,
          // pool);
        } catch (Exception e1) {
          e1.printStackTrace();
          error.setMessage(e1.getMessage());
View Full Code Here

Examples of co.nubetech.crux.pool.HBaseConnectionPool

  public String deleteConnection() {
    long connectionId = connection.getId();
    ServletContext servletContext = ServletActionContext
        .getServletContext();
    HBaseConnectionPool pool = (HBaseConnectionPool) servletContext
        .getAttribute(CruxConstants.HBASE_POOL);

    try {
      connection = connectionDAO.findById(connectionId);
      logger.debug("Deleting Connection for connectionId: "
          + connectionId);
      connectionDAO.delete(connection);
      pool.delete(connection);
      // servletContext.setAttribute(CruxConstants.HBASE_POOL, pool);

    } catch (CruxException e) {
      e.printStackTrace();
      error.setMessage(e.getMessage());
View Full Code Here

Examples of co.nubetech.crux.pool.HBaseConnectionPool

    String hbaseRestServerPropertyValue = hbaseRestServerProperty
        .getValue();
    logger.debug("Updating connectionId: " + connection.getId());
    ServletContext servletContext = ServletActionContext
        .getServletContext();
    HBaseConnectionPool pool = (HBaseConnectionPool) servletContext
        .getAttribute(CruxConstants.HBASE_POOL);

    Connection connectionToTest = new Connection();
    ConnectionProperty property = new ConnectionProperty();
    property.setProperty(CruxConstants.HBASE_ZOOKEEPER_PROPERTY);
    property.setValue(hbaseRestServerPropertyValue);
    connectionToTest.addProperty(property);

    try {
      HBaseFacade hbaseFacade = getHBaseFacade();
      boolean isValidConnection = hbaseFacade
          .isValidConnection(connectionToTest);
      logger.debug("isValidConnection : " + isValidConnection);
      if (isValidConnection) {
        connection = connectionDAO.findById(connection.getId());
        Connection connectionToUpdate = connection;
        connection.setName(connectionName);
        hbaseRestServerProperty = connection.getProperties().get(
            CruxConstants.HBASE_ZOOKEEPER_PROPERTY);
        hbaseRestServerProperty.setValue(hbaseRestServerPropertyValue);

        pool.update(connectionToUpdate, connection);

        // Now checking whether this connection holds all the associated
        // childrens.
        String[] tables = hbaseFacade.getTableList(connection);
        ArrayList<String> tableList = new ArrayList<String>();
        for (int i = 0; i < tables.length; i++) {
          tableList.add(tables[i]);
        }
        long count = 0l;
        for (Mapping mapping : mappingDAO.findAll()) {
          long id = connection.getId();
          if (id == mapping.getConnection().getId()) {
            String tableName = mapping.getTableName();
            if (!tableList.contains(tableName)) {
              count++;
            } else {
              ArrayList<String> columnFamilyList = new ArrayList<String>();
              ArrayList<HColumnDescriptor> columnList = new ArrayList<HColumnDescriptor>(
                  hbaseFacade.getColumnFamilies(connection,
                      tableName));
              for (HColumnDescriptor hcolumnDescriptor : columnList) {
                columnFamilyList.add(hcolumnDescriptor
                    .getNameAsString());
              }
              Iterator<ColumnAlias> iterator = mapping
                  .getColumnAlias().values().iterator();
              while (iterator.hasNext()) {
                ColumnAlias columnAlias = iterator.next();
                String columnFamily = columnAlias
                    .getColumnFamily();
                if (!columnFamilyList.contains(columnFamily)) {
                  count++;
                }
              }
            }

          }
        }

        if (count == 0l) {
          logger.debug("connection is saving.");
          connectionDAO.save(connection);
        } else {
          error.setMessage("Connection can't be updated because it does not contain all "
              + "the tables and column family of the assosiated mapping.");
          try {
            connectionDAO.transaction.rollback();
            pool.update(connection, connectionToUpdate);
          } catch (Exception e1) {
            e1.printStackTrace();
            error.setMessage(e1.getMessage());
          }
        }
View Full Code Here

Examples of co.nubetech.crux.pool.HBaseConnectionPool

    connectionProperty.setProperty(CruxConstants.HBASE_ZOOKEEPER_PROPERTY);
    logger.debug("Port is: " + TEST_UTIL.getConfiguration().get("hbase.zookeeper.property.clientPort"));
    connectionProperty.setValue("localhost:"
        + TEST_UTIL.getConfiguration().get("hbase.zookeeper.property.clientPort"));
    connection.addProperty(connectionProperty);
    pool = new HBaseConnectionPool(factory);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.