blueflood-core/src/main/java/com/rackspacecloud/blueflood/io/datastax/DBasicMetricsRW.java
private void insertMetricsInBatch(Collection<IMetric> metrics) throws IOException {

        BatchStatement batch = new BatchStatement(BatchStatement.Type.UNLOGGED);

        for (IMetric metric : metrics) {
            BoundStatement bound = simpleNumberIO.getBoundStatementForMetric(metric);
            batch.add(bound);
            Instrumentation.markFullResMetricWritten();

            Locator locator = metric.getLocator();
            if( !LocatorCache.getInstance().isLocatorCurrentInBatchLayer(locator) ) {
                LocatorCache.getInstance().setLocatorCurrentInBatchLayer(locator);
                batch.add(locatorIO.getBoundStatementForLocator( locator ));
            }

            // if we are recording delayed metrics, we may need to do an
            // extra insert
            if ( isRecordingDelayedMetrics ) {
                BoundStatement bs = getBoundStatementForMetricIfDelayed(metric);
                if ( bs != null ) {
                    batch.add(bs);
                }
            }
        }
        LOG.trace(String.format("insert batch statement size=%d", batch.size()));

        try {
            DatastaxIO.getSession().execute(batch);
        } catch ( Exception ex ) {
            Instrumentation.markWriteError();
            LOG.error(String.format("error writing batch of %d metrics", batch.size()), ex );
        }
    }
private void insertMetricsInBatch(Collection<IMetric> metrics) throws IOException {

        BatchStatement batch = new BatchStatement(BatchStatement.Type.UNLOGGED);

        for (IMetric metric : metrics) {
            BoundStatement bound = simpleNumberIO.getBoundStatementForMetric(metric);
            batch.add(bound);
            Instrumentation.markFullResMetricWritten();

            Locator locator = metric.getLocator();
            if( !LocatorCache.getInstance().isLocatorCurrentInBatchLayer(locator) ) {
                LocatorCache.getInstance().setLocatorCurrentInBatchLayer(locator);
                batch.add(locatorIO.getBoundStatementForLocator( locator ));
            }

            // if we are recording delayed metrics, we may need to do an
            // extra insert
            if ( isRecordingDelayedMetrics ) {
                BoundStatement bs = getBoundStatementForMetricIfDelayed(metric);
                if ( bs != null ) {
                    batch.add(bs);
                }
            }
        }
        LOG.trace(String.format("insert batch statement size=%d", batch.size()));

        try {
            DatastaxIO.getSession().execute(batch);
        } catch ( Exception ex ) {
            Instrumentation.markWriteError();
            LOG.error(String.format("error writing batch of %d metrics", batch.size()), ex );
        }
    }
private void insertMetricsInBatch ( Collection < IMetric > metrics ) throws IOException { BatchStatement batch = new BatchStatement ( BatchStatement . Type . UNLOGGED ) ; for ( IMetric metric : metrics ) { BoundStatement bound = simpleNumberIO . getBoundStatementForMetric ( metric ) ; batch . add ( bound ) ; Instrumentation . markFullResMetricWritten ( ) ; Locator locator = metric . getLocator ( ) ; if ( ! LocatorCache . getInstance ( ) . isLocatorCurrentInBatchLayer ( locator ) ) { LocatorCache . getInstance ( ) . setLocatorCurrentInBatchLayer ( locator ) ; batch . add ( locatorIO . getBoundStatementForLocator ( locator ) ) ; } // if we are recording delayed metrics, we may need to do an // extra insert if ( isRecordingDelayedMetrics ) { BoundStatement bs = getBoundStatementForMetricIfDelayed ( metric ) ; if ( bs != null ) { batch . add ( bs ) ; } } } LOG . trace ( String . format ( "insert batch statement size=%d" , batch . size ( ) ) ) ; try { DatastaxIO . getSession ( ) . execute ( batch ) ; } catch ( Exception ex ) { Instrumentation . markWriteError ( ) ; LOG . error ( String . format ( "error writing batch of %d metrics" , batch . size ( ) ) , ex ) ; } }
Inserts a collection of metrics in a batch using an unlogged
{@link BatchStatement}

@param metrics
@return
Inserts a collection of metrics in a batch using an unlogged { @link BatchStatement }