Example usage for com.google.common.collect Range toString

List of usage examples for com.google.common.collect Range toString

Introduction

In this page you can find the example usage for com.google.common.collect Range toString.

Prototype

@Override
public String toString() 

Source Link

Document

Returns a string representation of this range, such as "[3..5)" (other examples are listed in the class documentation).

Usage

From source file:eu.wisebed.wiseui.server.rpc.ReservationServiceImpl.java

/**
 * {@inheritDoc}/*w  w w .  j av a 2 s .  co  m*/
 */
@Override
public List<ConfidentialReservationData> getConfidentialReservations(final String rsEndpointUrl,
        final List<SecretAuthenticationKey> secretAuthenticationKeys, final Date pivotDate,
        final Range dateRange) throws AuthenticationException, ReservationException {

    ifNullOrEmptyArgument(rsEndpointUrl, "rsEndpointUrl is null");
    ifNullArgument(secretAuthenticationKeys, "secretAuthenticationKeys is null");
    ifNullArgument(pivotDate, "pivotDate is null");

    LOGGER.info(format("getConfidentialReservations( %s, %s, %s )", rsEndpointUrl, pivotDate.toString(),
            dateRange.toString()));

    /* Convert from dateRange to date to avoid client-site date calculation */
    Map<String, Date> fromAndTo = convertRange2Date(pivotDate, dateRange);
    final Date from = fromAndTo.get(FROM_KEY);
    final Date to = fromAndTo.get(TO_KEY);

    // call getConfidentialReservations with distinct from, to date objects
    return getConfidentialReservations(rsEndpointUrl, secretAuthenticationKeys, from, to);
}

From source file:com.rackspacecloud.blueflood.io.astyanax.AstyanaxReader.java

/**
 * Get data points for multiple {@link Locator}, for the specified {@link Range} and
 * {@link Granularity}.//from   ww w . jav  a 2s.  co  m
 *
 * This method is eventually called from all the output handlers for query requests.
 *
 * @param locators
 * @param range
 * @param gran
 * @return
 */
public Map<Locator, MetricData> getDatapointsForRange(List<Locator> locators, Range range, Granularity gran) {
    ListMultimap<ColumnFamily, Locator> locatorsByCF = ArrayListMultimap.create();
    Map<Locator, MetricData> results = new HashMap<Locator, MetricData>();
    for (Locator locator : locators) {
        try {
            RollupType rollupType = RollupType
                    .fromString(metaCache.get(locator, MetricMetadata.ROLLUP_TYPE.name().toLowerCase()));

            ColumnFamily cf = CassandraModel.getColumnFamily(rollupType, gran);
            List<Locator> locs = locatorsByCF.get(cf);
            locs.add(locator);
        } catch (Exception e) {
            // pass for now. need metric to figure this stuff out.
            log.error(String.format("error getting datapoints for locator %s, range %s, granularity %s",
                    locator, range.toString(), gran.toString()), e);
        }
    }

    for (ColumnFamily CF : locatorsByCF.keySet()) {
        List<Locator> locs = locatorsByCF.get(CF);
        results.putAll(getNumericDataForRangeLocatorList(range, gran, CF, locs));
    }

    return results;
}

From source file:com.rackspacecloud.blueflood.io.datastax.DAbstractMetricIO.java

/**
 *  Give a {@link com.datastax.driver.core.ResultSetFuture}, get
 *  the corresponding data from it and return it as a
 *  Table of locator, long and rollup.//from  w  w w.  j av  a  2  s  . c om
 */
public <T extends Object> Table<Locator, Long, T> toLocatorTimestampValue(List<ResultSetFuture> futures,
        Locator locator, String columnFamily, Range range) {
    Table<Locator, Long, T> locatorTimestampRollup = HashBasedTable.create();
    for (ResultSetFuture future : futures) {
        try {
            List<Row> rows = future.getUninterruptibly().all();

            // we only want to count the number of points we
            // get when we're querying the metrics_full
            if (StringUtils.isNotEmpty(columnFamily)
                    && columnFamily.equals(CassandraModel.CF_METRICS_FULL_NAME)) {
                Instrumentation.getRawPointsIn5MinHistogram().update(rows.size());
            }

            for (Row row : rows) {
                String key = row.getString(DMetricsCFPreparedStatements.KEY);
                Locator loc = Locator.createLocatorFromDbKey(key);
                Long hash = row.getLong(DMetricsCFPreparedStatements.COLUMN1);
                locatorTimestampRollup.put(loc, hash,
                        (T) fromByteBuffer(row.getBytes(DMetricsCFPreparedStatements.VALUE)));
            }
        } catch (Exception ex) {
            Instrumentation.markReadError();
            LOG.error(String.format("error reading metric for locator %s, column family '%s', range %s",
                    locator, columnFamily, range.toString()), ex);
        }
    }
    return locatorTimestampRollup;
}