/// <summary>
        /// Serializes measurements to InfluxDB.
        /// </summary>
        protected override void ProcessMeasurements(IMeasurement[] measurements)
        {
            if (measurements.Length == 0)
                return;

            if (m_useParallelPosting)
            {
                List<IMeasurement[]> measurementGroups = new List<IMeasurement[]>();
                IMeasurement[] measurementGroup = measurements.Take(m_valuesPerPost).ToArray();
                int skipCount = measurementGroup.Length;

                while (measurementGroup.Length > 0)
                {
                    measurementGroups.Add(measurementGroup);
                    measurementGroup = measurements.Skip(skipCount).Take(m_valuesPerPost).ToArray();
                    skipCount += measurementGroup.Length;
                }

                Parallel.ForEach(measurementGroups, PostMeasurementsToArchive);
                m_totalParallelGroups += measurementGroups.Count;
            }
            else
            {
                PostMeasurementsToArchive(measurements);
            }
        }
예제 #2
0
 /// <summary>
 /// Archives <paramref name="measurements"/> locally.
 /// </summary>
 /// <param name="measurements">Measurements to be archived.</param>
 protected override void ProcessMeasurements(IMeasurement[] measurements)
 {
     if ((object)measurements != null)
     {
         for (int i = 0; i < measurements.Length; i += m_bulkInsertLimit)
         {
             BulkInsert(measurements.Skip(i).Take(m_bulkInsertLimit));
         }
     }
 }