Java Code Examples for com.datastax.driver.core.BoundStatement#setTimestamp()

The following examples show how to use com.datastax.driver.core.BoundStatement#setTimestamp() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AggregateDaoImpl.java    From glowroot with Apache License 2.0 6 votes vote down vote up
private ListenableFuture<?> insertTransactionSummaries(RollupParams rollup,
        AggregateQuery query, Map<String, MutableSummary> summaries) throws Exception {
    BoundStatement boundStatement;
    List<ListenableFuture<?>> futures = new ArrayList<>();
    PreparedStatement preparedStatement =
            getInsertTransactionPS(summaryTable, rollup.rollupLevel());
    for (Map.Entry<String, MutableSummary> entry : summaries.entrySet()) {
        MutableSummary summary = entry.getValue();
        boundStatement = preparedStatement.bind();
        int i = 0;
        boundStatement.setString(i++, rollup.agentRollupId());
        boundStatement.setString(i++, query.transactionType());
        boundStatement.setTimestamp(i++, new Date(query.to()));
        boundStatement.setString(i++, entry.getKey());
        boundStatement.setDouble(i++, summary.totalDurationNanos);
        boundStatement.setLong(i++, summary.transactionCount);
        boundStatement.setInt(i++, rollup.adjustedTTL().generalTTL());
        futures.add(session.writeAsync(boundStatement));
    }
    return Futures.allAsList(futures);
}
 
Example 2
Source File: AggregateDaoImpl.java    From glowroot with Apache License 2.0 6 votes vote down vote up
private ListenableFuture<?> rollupErrorSummaryFromRows(RollupParams rollup,
        AggregateQuery query, Iterable<Row> rows) throws Exception {
    long errorCount = 0;
    long transactionCount = 0;
    for (Row row : rows) {
        errorCount += row.getLong(0);
        transactionCount += row.getLong(1);
    }
    BoundStatement boundStatement =
            getInsertOverallPS(errorSummaryTable, rollup.rollupLevel()).bind();
    int i = 0;
    boundStatement.setString(i++, rollup.agentRollupId());
    boundStatement.setString(i++, query.transactionType());
    boundStatement.setTimestamp(i++, new Date(query.to()));
    boundStatement.setLong(i++, errorCount);
    boundStatement.setLong(i++, transactionCount);
    boundStatement.setInt(i++, rollup.adjustedTTL().generalTTL());
    return session.writeAsync(boundStatement);
}
 
Example 3
Source File: GaugeValueDaoImpl.java    From glowroot with Apache License 2.0 6 votes vote down vote up
@Override
public List<GaugeValue> readGaugeValues(String agentRollupId, String gaugeName, long from,
        long to, int rollupLevel) throws Exception {
    BoundStatement boundStatement = readValuePS.get(rollupLevel).bind();
    int i = 0;
    boundStatement.setString(i++, agentRollupId);
    boundStatement.setString(i++, gaugeName);
    boundStatement.setTimestamp(i++, new Date(from));
    boundStatement.setTimestamp(i++, new Date(to));
    ResultSet results = session.read(boundStatement);
    List<GaugeValue> gaugeValues = new ArrayList<>();
    for (Row row : results) {
        i = 0;
        gaugeValues.add(GaugeValue.newBuilder()
                .setCaptureTime(checkNotNull(row.getTimestamp(i++)).getTime())
                .setValue(row.getDouble(i++))
                .setWeight(row.getLong(i++))
                .build());
    }
    return gaugeValues;
}
 
Example 4
Source File: SchemaUpgrade.java    From glowroot with Apache License 2.0 6 votes vote down vote up
private void rewriteHeartbeatTablePart1() throws Exception {
    if (!tableExists("heartbeat")) {
        // must be upgrading all the way from a glowroot version prior to heartbeat
        return;
    }
    logger.info("rewriting heartbeat table (part 1)...");
    dropTableIfExists("heartbeat_temp");
    session.updateSchemaWithRetry("create table if not exists heartbeat_temp (agent_id varchar,"
            + " central_capture_time timestamp, primary key (agent_id, central_capture_time))");
    PreparedStatement insertTempPS = session.prepare("insert into heartbeat_temp (agent_id,"
            + " central_capture_time) values (?, ?)");
    ResultSet results = session.read("select agent_id, central_capture_time from heartbeat");
    Queue<ListenableFuture<?>> futures = new ArrayDeque<>();
    for (Row row : results) {
        BoundStatement boundStatement = insertTempPS.bind();
        boundStatement.setString(0, row.getString(0));
        boundStatement.setTimestamp(1, row.getTimestamp(1));
        futures.add(session.writeAsync(boundStatement));
        waitForSome(futures);
    }
    MoreFutures.waitForAll(futures);
    logger.info("rewriting heartbeat table (part 1) - complete");
}
 
Example 5
Source File: SceneDaoImpl.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
protected Statement prepareUpsert(SceneDefinition sd, Date ts) {
   BoundStatement bs = upsert.bind();
   bs.setUUID(Column.PLACE_ID.columnName(), sd.getPlaceId());
   bs.setInt(Column.ID.columnName(), sd.getSequenceId());
   bs.setTimestamp(Column.CREATED.columnName(), sd.getCreated());
   bs.setTimestamp(Column.MODIFIED.columnName(), sd.getModified());
   bs.setString(Column.NAME.columnName(), sd.getName());
   bs.setString(Column.DESCRIPTION.columnName(), sd.getDescription());
   bs.setSet(Column.TAGS.columnName(), sd.getTags());
   bs.setString(SceneColumn.TEMPLATE.columnName(), sd.getTemplate());
   bs.setBool(SceneColumn.SATISFIABLE.columnName(), sd.isSatisfiable());
   bs.setBool(SceneColumn.NOTIFICATION.columnName(), sd.isNotification());
   bs.setTimestamp(SceneColumn.LAST_FIRE_TIME.columnName(), sd.getLastFireTime());
   bs.setString(SceneColumn.LAST_FIRE_STATE.columnName(), sd.getLastFireState());
   bs.setBool(SceneColumn.ENABLED.columnName(),sd.isEnabled());

   if(sd.getAction() != null) {
      bs.setBytes(ActionColumn.ACTION.columnName(), ByteBuffer.wrap(sd.getAction()));
   }
   else {
      bs.setBytes(ActionColumn.ACTION.columnName(), ByteBuffer.wrap(new byte [] {}));
   }
   return bs;
}
 
Example 6
Source File: GaugeNameDao.java    From glowroot with Apache License 2.0 6 votes vote down vote up
List<Future<?>> insert(String agentRollupId, long captureTime, String gaugeName)
        throws Exception {
    long rollupCaptureTime = CaptureTimes.getRollup(captureTime, DAYS.toMillis(1));
    GaugeKey rateLimiterKey = ImmutableGaugeKey.of(agentRollupId, rollupCaptureTime, gaugeName);
    if (!rateLimiter.tryAcquire(rateLimiterKey)) {
        return ImmutableList.of();
    }
    BoundStatement boundStatement = insertPS.bind();
    int i = 0;
    boundStatement.setString(i++, agentRollupId);
    boundStatement.setTimestamp(i++, new Date(rollupCaptureTime));
    boundStatement.setString(i++, gaugeName);
    int maxRollupTTL = configRepository.getCentralStorageConfig().getMaxRollupTTL();
    boundStatement.setInt(i++, Common.getAdjustedTTL(maxRollupTTL, rollupCaptureTime, clock));
    return ImmutableList.of(session.writeAsync(boundStatement));
}
 
Example 7
Source File: Tools.java    From glowroot with Apache License 2.0 6 votes vote down vote up
private void executeGaugeValueDeletes(int rollupLevel, String thresholdComparator,
        Date threshold, Set<GaugeValuePartitionKey> partitionKeys) throws Exception {
    String tableName = "gauge_value_rollup_" + rollupLevel;
    PreparedStatement deletePS = session.prepare("delete from " + tableName
            + " where agent_rollup = ? and gauge_name = ? and capture_time "
            + thresholdComparator + " ?");
    int count = 0;
    List<Future<?>> futures = new ArrayList<>();
    for (GaugeValuePartitionKey partitionKey : partitionKeys) {
        BoundStatement boundStatement = deletePS.bind();
        int i = 0;
        boundStatement.setString(i++, partitionKey.agentRollupId());
        boundStatement.setString(i++, partitionKey.gaugeName());
        boundStatement.setTimestamp(i++, threshold);
        futures.add(session.writeAsync(boundStatement));
        count++;
    }
    MoreFutures.waitForAll(futures);
    startupLogger.info("{} range deletes executed against {}", count, tableName);

}
 
Example 8
Source File: InvitationDAOImpl.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
public void reject(String code, String reason) {
   Preconditions.checkNotNull(code, "code is required");

   try(Context timer = rejectTimer.time()) {
      BoundStatement stmt = new BoundStatement(reject);
      stmt.setString(Column.code.name(), StringUtils.lowerCase(code));
      stmt.setTimestamp(Column.rejected.name(), new Date());
      stmt.setString(Column.rejectReason.name(), reason);
      session.execute(stmt);
   }
}
 
Example 9
Source File: SchemaUpgrade.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private void rewriteOpenIncidentTablePart2() throws Exception {
    if (!tableExists("open_incident_temp")) {
        // previously failed mid-upgrade prior to updating schema version
        return;
    }
    dropTableIfExists("open_incident");
    session.createTableWithLCS("create table if not exists open_incident (one int,"
            + " agent_rollup_id varchar, condition blob, severity varchar, notification blob,"
            + " open_time timestamp, primary key (one, agent_rollup_id, condition, severity))");
    PreparedStatement insertPS = session.prepare("insert into open_incident (one,"
            + " agent_rollup_id, condition, severity, notification, open_time) values"
            + " (1, ?, ?, ?, ?, ?)");
    Map<String, V09AgentRollup> v09AgentRollups = getV09AgentRollupsFromAgentRollupTable();
    ResultSet results = session.read("select agent_rollup_id, condition, severity,"
            + " notification, open_time from open_incident_temp where one = 1");
    for (Row row : results) {
        String v09AgentRollupId = row.getString(0);
        V09AgentRollup v09AgentRollup = v09AgentRollups.get(v09AgentRollupId);
        if (v09AgentRollup == null) {
            // v09AgentRollupId was manually deleted (via the UI) from the agent_rollup
            // table in which case its parent is no longer known and best to ignore
            continue;
        }
        BoundStatement boundStatement = insertPS.bind();
        boundStatement.setString(0, v09AgentRollup.agentRollupId());
        boundStatement.setBytes(1, row.getBytes(1));
        boundStatement.setString(2, row.getString(2));
        boundStatement.setBytes(3, row.getBytes(3));
        boundStatement.setTimestamp(4, row.getTimestamp(4));
        session.write(boundStatement);
    }
    dropTableIfExists("open_incident_temp");
}
 
Example 10
Source File: SyntheticMonitorIdDao.java    From glowroot with Apache License 2.0 5 votes vote down vote up
Map<String, String> getSyntheticMonitorIds(String agentRollupId, long from, long to)
        throws Exception {
    long rolledUpFrom = CaptureTimes.getRollup(from, DAYS.toMillis(1));
    long rolledUpTo = CaptureTimes.getRollup(to, DAYS.toMillis(1));
    BoundStatement boundStatement = readPS.bind();
    boundStatement.setString(0, agentRollupId);
    boundStatement.setTimestamp(1, new Date(rolledUpFrom));
    boundStatement.setTimestamp(2, new Date(rolledUpTo));
    ResultSet results = session.read(boundStatement);
    Map<String, String> syntheticMonitorIds = new HashMap<>();
    for (Row row : results) {
        syntheticMonitorIds.put(checkNotNull(row.getString(0)), checkNotNull(row.getString(1)));
    }
    return syntheticMonitorIds;
}
 
Example 11
Source File: AggregateDaoImpl.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private static void bindQuery(BoundStatement boundStatement, String agentRollupId,
        SummaryQuery query) {
    int i = 0;
    boundStatement.setString(i++, agentRollupId);
    boundStatement.setString(i++, query.transactionType());
    boundStatement.setTimestamp(i++, new Date(query.from()));
    boundStatement.setTimestamp(i++, new Date(query.to()));
}
 
Example 12
Source File: AggregateDaoImpl.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private ListenableFuture<?> insertQueries(List<MutableQuery> queries, int rollupLevel,
        String agentRollupId, String transactionType, @Nullable String transactionName,
        long captureTime, TTL adjustedTTL) throws Exception {
    List<ListenableFuture<?>> futures = new ArrayList<>();
    for (MutableQuery query : queries) {
        BoundStatement boundStatement;
        if (transactionName == null) {
            boundStatement = getInsertOverallPS(queryTable, rollupLevel).bind();
        } else {
            boundStatement = getInsertTransactionPS(queryTable, rollupLevel).bind();
        }
        String fullTextSha1 = query.getFullTextSha1();
        int i = 0;
        boundStatement.setString(i++, agentRollupId);
        boundStatement.setString(i++, transactionType);
        if (transactionName != null) {
            boundStatement.setString(i++, transactionName);
        }
        boundStatement.setTimestamp(i++, new Date(captureTime));
        boundStatement.setString(i++, query.getType());
        boundStatement.setString(i++, query.getTruncatedText());
        // full_query_text_sha1 cannot be null since it is used in clustering key
        boundStatement.setString(i++, Strings.nullToEmpty(fullTextSha1));
        boundStatement.setDouble(i++, query.getTotalDurationNanos());
        boundStatement.setLong(i++, query.getExecutionCount());
        if (query.hasTotalRows()) {
            boundStatement.setLong(i++, query.getTotalRows());
        } else {
            boundStatement.setToNull(i++);
        }
        boundStatement.setInt(i++, adjustedTTL.queryTTL());
        futures.add(session.writeAsync(boundStatement));
    }
    return Futures.allAsList(futures);
}
 
Example 13
Source File: AggregateDaoImpl.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private ListenableFuture<?> insertServiceCalls(List<MutableServiceCall> serviceCalls,
        int rollupLevel, String agentRollupId, String transactionType,
        @Nullable String transactionName, long captureTime, TTL adjustedTTL) throws Exception {
    List<ListenableFuture<?>> futures = new ArrayList<>();
    for (MutableServiceCall serviceCall : serviceCalls) {
        BoundStatement boundStatement;
        if (transactionName == null) {
            boundStatement = getInsertOverallPS(serviceCallTable, rollupLevel).bind();
        } else {
            boundStatement = getInsertTransactionPS(serviceCallTable, rollupLevel).bind();
        }
        int i = 0;
        boundStatement.setString(i++, agentRollupId);
        boundStatement.setString(i++, transactionType);
        if (transactionName != null) {
            boundStatement.setString(i++, transactionName);
        }
        boundStatement.setTimestamp(i++, new Date(captureTime));
        boundStatement.setString(i++, serviceCall.getType());
        boundStatement.setString(i++, serviceCall.getText());
        boundStatement.setDouble(i++, serviceCall.getTotalDurationNanos());
        boundStatement.setLong(i++, serviceCall.getExecutionCount());
        boundStatement.setInt(i++, adjustedTTL.serviceCallTTL());
        futures.add(session.writeAsync(boundStatement));
    }
    return Futures.allAsList(futures);
}
 
Example 14
Source File: InvitationDAOImpl.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
public void accept(String code) {
   Preconditions.checkNotNull(code, "code is required");

   try(Context timer = acceptTimer.time()) {
      BoundStatement stmt = new BoundStatement(acceptExistingPerson);
      stmt.setString(Column.code.name(), StringUtils.lowerCase(code));
      stmt.setTimestamp(Column.accepted.name(), new Date());
      session.execute(stmt);
   }
}
 
Example 15
Source File: HeartbeatDao.java    From glowroot with Apache License 2.0 5 votes vote down vote up
public boolean exists(String agentRollupId, long centralCaptureFrom, long centralCaptureTo)
        throws Exception {
    BoundStatement boundStatement = existsPS.bind();
    int i = 0;
    boundStatement.setString(i++, agentRollupId);
    boundStatement.setTimestamp(i++, new Date(centralCaptureFrom));
    boundStatement.setTimestamp(i++, new Date(centralCaptureTo));
    return !session.read(boundStatement).isExhausted();
}
 
Example 16
Source File: SchemaUpgrade.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private void rewriteHeartbeatTablePart2() throws Exception {
    if (!tableExists("heartbeat_temp")) {
        // previously failed mid-upgrade prior to updating schema version
        return;
    }
    logger.info("rewriting heartbeat table (part 2)...");
    Map<String, V09AgentRollup> v09AgentRollups = getV09AgentRollupsFromAgentRollupTable();
    dropTableIfExists("heartbeat");
    session.createTableWithTWCS("create table if not exists heartbeat (agent_id varchar,"
            + " central_capture_time timestamp, primary key (agent_id, central_capture_time))",
            HeartbeatDao.EXPIRATION_HOURS);
    PreparedStatement insertPS = session.prepare("insert into heartbeat (agent_id,"
            + " central_capture_time) values (?, ?) using ttl ?");
    int ttl = Ints.saturatedCast(HOURS.toSeconds(HeartbeatDao.EXPIRATION_HOURS));
    ResultSet results =
            session.read("select agent_id, central_capture_time from heartbeat_temp");
    Queue<ListenableFuture<?>> futures = new ArrayDeque<>();
    for (Row row : results) {
        String v09AgentRollupId = row.getString(0);
        V09AgentRollup v09AgentRollup = v09AgentRollups.get(v09AgentRollupId);
        if (v09AgentRollup == null) {
            // v09AgentRollupId was manually deleted (via the UI) from the agent_rollup
            // table in which case its parent is no longer known and best to ignore
            continue;
        }
        Date centralCaptureDate = checkNotNull(row.getTimestamp(1));
        int adjustedTTL = Common.getAdjustedTTL(ttl, centralCaptureDate.getTime(), clock);
        BoundStatement boundStatement = insertPS.bind();
        int i = 0;
        boundStatement.setString(i++, v09AgentRollup.agentRollupId());
        boundStatement.setTimestamp(i++, centralCaptureDate);
        boundStatement.setInt(i++, adjustedTTL);
        futures.add(session.writeAsync(boundStatement));
        waitForSome(futures);
    }
    MoreFutures.waitForAll(futures);
    dropTableIfExists("heartbeat_temp");
    logger.info("rewriting heartbeat table (part 2) - complete");
}
 
Example 17
Source File: AggregateDaoImpl.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private static void bindQueryForRollupFromChild(BoundStatement boundStatement,
        String agentRollupId, AggregateQuery query) {
    int i = 0;
    boundStatement.setString(i++, agentRollupId);
    boundStatement.setString(i++, query.transactionType());
    String transactionName = query.transactionName();
    if (transactionName != null) {
        boundStatement.setString(i++, transactionName);
    }
    boundStatement.setTimestamp(i++, new Date(query.to()));
}
 
Example 18
Source File: TraceDaoImpl.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private static void bindCount(BoundStatement boundStatement, String agentRollupId,
        String agentId, String traceId, Trace.Header header, int adjustedTTL, boolean overall,
        boolean partial, boolean cassandra2x) {
    int i = bind(boundStatement, agentRollupId, agentId, traceId, header, overall,
            partial && !cassandra2x);
    if (partial) {
        if (cassandra2x) {
            // don't set real_capture_time, so this still looks like data prior to 0.13.1
            boundStatement.setToNull(i++);
        } else {
            boundStatement.setTimestamp(i++, new Date(header.getCaptureTime()));
        }
    }
    boundStatement.setInt(i++, adjustedTTL);
}
 
Example 19
Source File: SchemaUpgrade.java    From glowroot with Apache License 2.0 4 votes vote down vote up
private void rewriteResolvedIncidentTablePart2() throws Exception {
    if (!tableExists("resolved_incident_temp")) {
        // previously failed mid-upgrade prior to updating schema version
        return;
    }
    dropTableIfExists("resolved_incident");
    session.createTableWithTWCS("create table if not exists resolved_incident (one int,"
            + " resolve_time timestamp, agent_rollup_id varchar, condition blob, severity"
            + " varchar, notification blob, open_time timestamp, primary key (one,"
            + " resolve_time, agent_rollup_id, condition)) with clustering order by"
            + " (resolve_time desc)", Constants.RESOLVED_INCIDENT_EXPIRATION_HOURS, true);
    PreparedStatement insertPS = session.prepare("insert into resolved_incident (one,"
            + " resolve_time, agent_rollup_id, condition, severity, notification,"
            + " open_time) values (1, ?, ?, ?, ?, ?, ?) using ttl ?");
    Map<String, V09AgentRollup> v09AgentRollups = getV09AgentRollupsFromAgentRollupTable();
    int ttl = Ints.saturatedCast(
            HOURS.toSeconds(Constants.RESOLVED_INCIDENT_EXPIRATION_HOURS));
    ResultSet results = session.read("select resolve_time, agent_rollup_id, condition,"
            + " severity, notification, open_time from resolved_incident_temp where one = 1");
    for (Row row : results) {
        String v09AgentRollupId = row.getString(1);
        V09AgentRollup v09AgentRollup = v09AgentRollups.get(v09AgentRollupId);
        if (v09AgentRollup == null) {
            // v09AgentRollupId was manually deleted (via the UI) from the agent_rollup
            // table in which case its parent is no longer known and best to ignore
            continue;
        }
        Date resolveTime = checkNotNull(row.getTimestamp(0));
        int adjustedTTL = Common.getAdjustedTTL(ttl, resolveTime.getTime(), clock);
        BoundStatement boundStatement = insertPS.bind();
        boundStatement.setTimestamp(0, resolveTime);
        boundStatement.setString(1, v09AgentRollup.agentRollupId());
        boundStatement.setBytes(2, row.getBytes(2));
        boundStatement.setString(3, row.getString(3));
        boundStatement.setBytes(4, row.getBytes(4));
        boundStatement.setTimestamp(5, row.getTimestamp(5));
        boundStatement.setInt(6, adjustedTTL);
        session.write(boundStatement);
    }
    dropTableIfExists("resolved_incident_temp");
}
 
Example 20
Source File: SchemaUpgrade.java    From glowroot with Apache License 2.0 4 votes vote down vote up
private void populateActiveAgentTable(int rollupLevel) throws Exception {
    logger.info("populating active_agent_rollup_{} table - this could take"
            + " several minutes on large data sets...", rollupLevel);
    dropTableIfExists("active_agent_rollup_" + rollupLevel);
    int expirationHours =
            getCentralStorageConfig(session).rollupExpirationHours().get(rollupLevel);
    session.createTableWithTWCS("create table if not exists active_agent_rollup_" + rollupLevel
            + " (one int, capture_time timestamp, agent_id varchar, primary key (one,"
            + " capture_time, agent_id))", expirationHours);
    PreparedStatement insertPS = session.prepare("insert into active_agent_rollup_"
            + rollupLevel + " (one, capture_time, agent_id) values (1, ?, ?) using ttl ?");
    int ttl = Ints.saturatedCast(HOURS.toSeconds(expirationHours));
    long rollupIntervalMillis;
    if (rollupLevel < 3) {
        rollupIntervalMillis =
                RollupConfig.buildRollupConfigs().get(rollupLevel + 1).intervalMillis();
    } else {
        rollupIntervalMillis = DAYS.toMillis(1);
    }
    int[] negativeOffsets = new int[(int) (DAYS.toMillis(1) / rollupIntervalMillis)];
    for (int i = 0; i < negativeOffsets.length; i++) {
        negativeOffsets[i] = (int) (rollupIntervalMillis * (i + 1 - negativeOffsets.length));
    }
    PreparedStatement readPS = session.prepare(
            "select capture_time, agent_id from agent where one = 1 and capture_time > ?");
    BoundStatement boundStatement = readPS.bind();
    long now = clock.currentTimeMillis();
    boundStatement.setTimestamp(0, new Date(now - HOURS.toMillis(expirationHours)));
    ResultSet results = session.read(boundStatement);
    Queue<ListenableFuture<?>> futures = new ArrayDeque<>();
    for (Row row : results) {
        Date captureDate = checkNotNull(row.getTimestamp(0));
        String agentId = row.getString(1);
        for (int negativeOffset : negativeOffsets) {
            long offsetCaptureTime = captureDate.getTime() + negativeOffset;
            int adjustedTTL = Common.getAdjustedTTL(ttl, offsetCaptureTime, clock);
            boundStatement = insertPS.bind();
            boundStatement.setTimestamp(0, new Date(offsetCaptureTime));
            boundStatement.setString(1, agentId);
            boundStatement.setInt(2, adjustedTTL);
            futures.add(session.writeAsync(boundStatement));
            waitForSome(futures);
            if (offsetCaptureTime > now) {
                break;
            }
        }
    }
    MoreFutures.waitForAll(futures);
    logger.info("populating active_agent_rollup_{} table - complete", rollupLevel);
}