internal TimeSeriesBatchOperation(TimeSeriesStore store, string timeSeriesName, TimeSeriesBatchOptions batchOptions = null)
            : base(store, timeSeriesName)
        {
            if (batchOptions != null && batchOptions.BatchSizeLimit < 1)
            {
                throw new ArgumentException("batchOptions.BatchSizeLimit cannot be negative", "batchOptions");
            }

            _defaultOptions   = batchOptions ?? new TimeSeriesBatchOptions(); //defaults do exist
            streamingStarted  = new AsyncManualResetEvent();
            batchOperationTcs = new TaskCompletionSource <bool>();
            cts           = new CancellationTokenSource();
            appendQueue   = new BlockingCollection <TimeSeriesAppend>(_defaultOptions.BatchSizeLimit);
            singleAuthUrl = string.Format("{0}ts/{1}/singleAuthToken", ServerUrl, timeSeriesName);

            OperationId        = Guid.NewGuid();
            disposed           = false;
            batchOperationTask = StartBatchOperation();
            if (streamingStarted.WaitAsync().Wait(DefaultOptions.StreamingInitializeTimeout) == false ||
                batchOperationTask.IsFaulted)
            {
                throw new InvalidOperationException("Failed to start streaming batch.", batchOperationTask.Exception);
            }
            closeAndReopenStreamingTimer = CreateNewTimer();
        }
예제 #2
0
            public TimeSeriesBatchOperation NewBatch(TimeSeriesBatchOptions options = null)
            {
                if (parent.Name == null)
                {
                    throw new ArgumentException("Time series isn't set!");
                }

                parent.AssertInitialized();

                return(new TimeSeriesBatchOperation(parent, parent.Name, options));
            }