Package com.yahoo.ycsb

Examples of com.yahoo.ycsb.DBException


            if (!connection.namespace_exists(NAMESPACE)) {
                connection.namespace_create(NAMESPACE);
            }   
            ns = connection.open_namespace(NAMESPACE);
        } catch (ClientException e) {
            throw new DBException("Could not open namespace", e);
        } catch (TException e) {
            throw new DBException("Could not open namespace", e);
        }
           
       
        _columnFamily = getProperties().getProperty("columnfamily");
        if (_columnFamily == null)
        {
            System.err.println("Error, must specify a " +
                "columnfamily for Hypertable table");
            throw new DBException("No columnfamily specified");
        }
    }
View Full Code Here


    public void cleanup() throws DBException
    {
        try {
            connection.namespace_close(ns);
        } catch (ClientException e) {
            throw new DBException("Could not close namespace", e);
        } catch (TException e) {
            throw new DBException("Could not close namespace", e);
        }
    }
View Full Code Here

            m_client = ConnectionHelper.createConnection(Thread.currentThread().getId(), servers, user, password, ratelimit);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            throw new DBException(e.getMessage());
        }
        m_workingData = new byte[1024 * 1024];
        m_writeBuf = ByteBuffer.wrap(m_workingData);
    }
View Full Code Here

        if (cluster == null)
        {
            String hosts = getProperties().getProperty("hosts");
            if (hosts == null)
            {
                throw new DBException("Required property \"hosts\" missing for CassandraClient");
            }

            column_family = getProperties().getProperty(COLUMN_FAMILY_PROPERTY);
           
            System.out.println(column_family);
View Full Code Here

            {
                i = Integer.parseInt(p);
            }
            catch (NumberFormatException e)
            {
                throw new DBException("Illegal number format in " + key + " property");
            }
        }
        return i;
    }
View Full Code Here

        try
        {
            String hosts = getProperties().getProperty("hosts");
            if (hosts == null)
            {
                throw new DBException("Required property \"hosts\" missing for CassandraClient");
            }

            column_family = getProperties().getProperty(COLUMN_FAMILY_PROPERTY);
            parent = new ColumnParent(column_family);

            _table = getProperties().getProperty("schema");
            ConnectionRetries = Integer.parseInt(getProperties().getProperty(CONNECTION_RETRY_PROPERTY,
                    CONNECTION_RETRY_PROPERTY_DEFAULT));

            String username = getProperties().getProperty(USERNAME_PROPERTY);
            String password = getProperties().getProperty(PASSWORD_PROPERTY);

            readConsistencyLevel = ConsistencyLevel.valueOf(getProperties().getProperty(
                    READ_CONSISTENCY_LEVEL_PROPERTY, READ_CONSISTENCY_LEVEL_PROPERTY_DEFAULT));
            writeConsistencyLevel = ConsistencyLevel.valueOf(getProperties().getProperty(
                    WRITE_CONSISTENCY_LEVEL_PROPERTY, WRITE_CONSISTENCY_LEVEL_PROPERTY_DEFAULT));
            scanConsistencyLevel = ConsistencyLevel.valueOf(getProperties().getProperty(
                    SCAN_CONSISTENCY_LEVEL_PROPERTY, SCAN_CONSISTENCY_LEVEL_PROPERTY_DEFAULT));
            deleteConsistencyLevel = ConsistencyLevel.valueOf(getProperties().getProperty(
                    DELETE_CONSISTENCY_LEVEL_PROPERTY, DELETE_CONSISTENCY_LEVEL_PROPERTY_DEFAULT));

            _debug = Boolean.parseBoolean(getProperties().getProperty("debug", "false"));

            String[] allhosts = hosts.split(",");
            String myhost = allhosts[random.nextInt(allhosts.length)];

            Exception connectexception = null;

//            System.out.println("Initiating connection");
            if (tr == null || client == null)
            {

                for (int retry = 0; retry < ConnectionRetries; retry++)
                {
                    tr = new TFramedTransport(new TSocket(myhost, 9160));
                    TProtocol proto = new TBinaryProtocol(tr);
//                    System.out.println("creating connection::");
                    client = new Cassandra.Client(proto);
                    try
                    {
                        tr.open();
                        connectexception = null;
                        break;
                    }
                    catch (Exception e)
                    {
                        connectexception = e;
                        logger.error(e);
                    }
                    try
                    {
                        Thread.sleep(1000);
                    }
                    catch (InterruptedException e)
                    {
                        logger.error(e);
                    }

                }
            }

            if (connectexception != null)
            {
                logger.info("Unable to connect to " + myhost + " after " + ConnectionRetries + " tries");
                throw new DBException(connectexception);
            }

            if (username != null && password != null)
            {
                Map<String, String> cred = new HashMap<String, String>();
                cred.put("username", username);
                cred.put("password", password);
                AuthenticationRequest req = new AuthenticationRequest(cred);
                try
                {
                    client.login(req);
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                    logger.info(e);
                    throw new DBException(e);
                }
            }
            client.set_keyspace(_table);
        }
        catch (Exception e)
View Full Code Here

    public void init() throws DBException
    {
        String hosts = getProperties().getProperty("hosts");
        if (hosts == null)
        {
            throw new DBException("Required property \"hosts\" missing for CassandraClient");
        }

        column_family = "pelopsuser";
        // column_family = getProperties().getProperty(COLUMN_FAMILY_PROPERTY,
        // COLUMN_FAMILY_PROPERTY_DEFAULT);
View Full Code Here

    storeName = getProperties().getProperty("store_name", "usertable");
   
    // Use store name to retrieve client
    storeClient = socketFactory.getStoreClient(storeName);
    if ( storeClient == null )
      throw new DBException("Unable to instantiate store client");
   
  }
View Full Code Here

      _columnFamily = getProperties().getProperty("columnfamily");
      if (_columnFamily == null)
      {
        System.err.println("Error, must specify a columnfamily for HBase table");
        throw new DBException("No columnfamily specified");
      }
      _columnFamilyBytes = Bytes.toBytes(_columnFamily);

    }
View Full Code Here

        try {
            if (_hTable != null) {
                _hTable.flushCommits();
            }
        } catch (IOException e) {
            throw new DBException(e);
        }
    }
View Full Code Here

TOP

Related Classes of com.yahoo.ycsb.DBException

Copyright © 2018 www.massapicom. 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.