Package com.datastax.driver.core

Examples of com.datastax.driver.core.ResultSet


     *
     * @return true if the RHQ user exists, false otherwise
     */
    protected boolean userExists() {
        try {
            ResultSet resultSet = execute("SELECT * FROM system_auth.users WHERE name = '" + username + "'");
            return !resultSet.all().isEmpty();
        } catch (Exception e) {
            log.error(e);
            throw new RuntimeException(e);
        }
    }
View Full Code Here


     *
     * @return true if the RHQ schema exists, false otherwise
     */
    protected boolean schemaExists() {
        try {
            ResultSet resultSet = execute("SELECT * FROM system.schema_keyspaces WHERE keyspace_name = 'rhq'");
            if (!resultSet.all().isEmpty()) {
                resultSet = execute(
                    "SELECT * FROM system.schema_columnfamilies " +
                    "WHERE keyspace_name='rhq' AND columnfamily_name='schema_version'");
                return !resultSet.all().isEmpty();
            }
            return false;
        } catch (AuthenticationException exp) {
            throw exp;
        } catch (Exception e) {
View Full Code Here

     * @return current RHQ schema version
     */
    protected int getInstalledSchemaVersion() {
        int maxVersion = 0;
        try {
            ResultSet resultSet = execute("SELECT version FROM rhq.schema_version");
            for (Row row : resultSet.all()) {
                if (maxVersion < row.getInt(0)) {
                    maxVersion = row.getInt(0);
                }
            }
        } catch (Exception e) {
View Full Code Here

     * @return existing replication factor
     */
    protected int queryReplicationFactor() {
        int replicationFactor = 1;
        try {
            ResultSet resultSet = execute(
                "SELECT strategy_options FROM system.schema_keyspaces where keyspace_name='rhq'");
            Row row = resultSet.one();

            String replicationFactorString = "replication_factor\"";
            String resultString = row.getString(0);
            resultString = resultString.substring(resultString.indexOf(replicationFactorString)
                + replicationFactorString.length());
View Full Code Here

                    log.debug(bucket + " data for schedule id " + scheduleId + " has already been migrated. It will " +
                        "be skipped.");
                    latch.countDown();
                } else {
                    readPermits.acquire();
                    ResultSet resultSet = session.execute(query.bind(scheduleId));
                    ListenableFuture<Integer> migrationFuture = threadPool.submit(new MetricsWriter(scheduleId, bucket,
                        resultSet));
                    Futures.addCallback(migrationFuture, migrationFinished(scheduleId, bucket, latch, migrationLog));
                }
            }
View Full Code Here

            }
        }
    }

    private void dropTables() {
        ResultSet resultSet = session.execute("SELECT columnfamily_name FROM system.schema_columnfamilies " +
            "WHERE keyspace_name = 'rhq'");
        for (Row row : resultSet) {
            String table = row.getString(0);
            if (table.equals("one_hour_metrics") || table.equals("six_hour_metrics") ||
                table.equals("twenty_four_hour_metrics")) {
View Full Code Here

    private void updateIndex(String oldBucket, String newBucket, DateTime startDay, DateTime start, DateTime end,
        Duration timeSlice) {
        DateTime time = start;
        BoundStatement statement = find412IndexEntries.bind(oldBucket, startDay.toDate(), start.toDate());
        ResultSet resultSet = session.execute(statement);
        DateTime day = startDay;
        int startScheduleId = 0;
        int count = 0;
        int partition = 0;
View Full Code Here

    }

    private void updateIndex(String oldBucket, String newBucket, DateTime start, DateTime end, Duration timeSlice) {
        DateTime time = start;
        BoundStatement statement = find411IndexEntries.bind(oldBucket, start.toDate());
        ResultSet resultSet = session.execute(statement);
        int count = 0;
        int scheduleId = 0;
        int partition = 0;

        do {
View Full Code Here

        }
        return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis());
    }

    private boolean cacheIndexExists() {
        ResultSet resultSet = session.execute("SELECT columnfamily_name FROM system.schema_columnfamilies " +
            "WHERE keyspace_name = 'rhq' AND columnfamily_name = 'metrics_cache_index'");
        return !resultSet.isExhausted();
    }
View Full Code Here

        assertDataMigrated(numSchedules, "twenty_four_hour");
    }

    private void assertDataMigrated(int numSchedules, String bucket) {
        for (int i = -1; i > -numSchedules; --i) {
            ResultSet resultSet = session.execute("select * from " + Table.AGGREGATE_METRICS + " where schedule_id = " +
                i + " and bucket = '" + bucket + "' limit 1");
            assertFalse(resultSet.isExhausted(), "Failed to migrate " + bucket + " data for schedule id " + i);
        }
    }
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.ResultSet

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.