示例#1
0
 public BatchRegistry(Task batch, IChangeFeedObserverContext context)
 {
     _batch   = batch ?? throw new ArgumentNullException(nameof(batch));
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
示例#2
0
 public Task CloseAsync(IChangeFeedObserverContext context, ChangeFeedObserverCloseReason reason)
 {
     return(Task.CompletedTask);
 }
 public Task CloseAsync(IChangeFeedObserverContext context, ChangeFeedObserverCloseReason reason)
 {
     _onClose.TrackValue(1, context.PartitionKeyRangeId);
     _logger.LogInformation("Document change observer stopped: {0}", context.PartitionKeyRangeId);
     return(Task.CompletedTask);
 }
示例#4
0
 public Task CloseAsync(IChangeFeedObserverContext context, ChangeFeedObserverCloseReason reason)
 {
     Trace.TraceInformation("Observer closed, {0}", context.PartitionKeyRangeId);
     Trace.TraceInformation("Reason for shutdown, {0}", reason);
     return(Task.CompletedTask);
 }
示例#5
0
 public Task CloseAsync(IChangeFeedObserverContext context, ChangeFeedObserverCloseReason reason)
 {
     Console.WriteLine("Closing partition processing:" + context.PartitionKeyRangeId);
     return(Task.CompletedTask);
 }
示例#6
0
 public Task CloseAsync(IChangeFeedObserverContext context, ChangeFeedObserverCloseReason reason)
 {
     return(this.observer.CloseAsync(context, reason));
 }
 public async Task CloseAsync(IChangeFeedObserverContext context, ChangeFeedObserverCloseReason reason)
 {
     this._logger.LogInformation($"Stopping to monitor CosmosDB document collection '{this._options.FeedCollectionInfo.CollectionName}'. Silo: '{this._siloName}' | Partition key range: '{context.PartitionKeyRangeId}' | Reason: '{reason}'");
     this._ctsClose.Cancel();
     await this._checkpointerTask;
 }
示例#8
0
 public Task OpenAsync(IChangeFeedObserverContext context)
 {
     Console.WriteLine($"OpenAsync: {context.PartitionKeyRangeId}, {context.FeedResponse}");
     return(Task.CompletedTask);
 }
 /// <summary>
 /// Add a processing batch task to be checkpointed later on.
 /// </summary>
 /// <param name="task">The batck task</param>
 /// <param name="context">The Change Feed context</param>
 public void AddBatch(Task task, IChangeFeedObserverContext context)
 {
     this._batches.Enqueue(new BatchRegistry(task, context));
 }
 public Task OpenAsync(IChangeFeedObserverContext context)
 {
     this._logger.LogInformation($"Starting to monitor CosmosDB document collection '{this._options.FeedCollectionInfo.CollectionName}'. Silo: '{this._siloName}' | Partition key range: '{context.PartitionKeyRangeId}'");
     this._checkpointerTask = this._checkpointer.RunAsync(this._ctsClose.Token);
     return(Task.CompletedTask);
 }
示例#11
0
        public async void IngestDocs(
            SqlClientExtension client,
            IChangeFeedObserverContext context,
            IReadOnlyList <Document> docs,
            CancellationToken cancellationToken,
            Uri destinationCollectionUri)
        {
            // Model is received
            foreach (var doc in docs)
            {
                SensorReading sensorReading =
                    JsonConvert.DeserializeObject <SensorReading>(doc.ToString());
                // Load the aggregated model from the destination

                List <object> aggDocs =
                    await GetSiteIdAggDocs(client, sensorReading);

                if (aggDocs != null && aggDocs.Any())
                {
                    await UpdateSiteIdAgg(client, aggDocs[0], sensorReading);
                }
                else
                {
                    SiteIdAggModel siteIdAggModel    = SiteIdAggModel.GetNewDoc(sensorReading);
                    bool           isExits           = false;
                    bool           isCreateCompleted = false;

                    try
                    {
                        for (int i = 0; i < retries; i++)
                        {
                            if (!isExits)
                            {
                                await client.CreateDocument(siteIdAggModel, false);

                                isCreateCompleted = true;
                            }

                            if (isCreateCompleted)
                            {
                                break;
                            }
                        }
                    }
                    catch (DocumentClientException docEx)
                    {
                        if (docEx.StatusCode == HttpStatusCode.Conflict)
                        {
                            // Eat this may be other process created the document already.
                            isExits           = true;
                            isCreateCompleted = true;
                            //wait for second to retry
                            System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 1));
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError(ex.Message, false);
                        //wait for second to retry
                        System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 1));
                    }

                    if (isExits)
                    {
                        aggDocs =
                            await GetSiteIdAggDocs(client, sensorReading);
                        await UpdateSiteIdAgg(client, aggDocs[0], sensorReading);
                    }
                }
            }
        }
示例#12
0
 public void IngestDocsInBulk(SqlClientExtension client, IChangeFeedObserverContext context, IReadOnlyList <Document> docs, CancellationToken cancellationToken, Uri destinationCollectionUri)
 {
     throw new NotImplementedException();
 }
示例#13
0
 public Task CloseAsync(IChangeFeedObserverContext context, Microsoft.Azure.Documents.ChangeFeedProcessor.FeedProcessing.ChangeFeedObserverCloseReason reason)
 {
     return(Task.CompletedTask);
 }
示例#14
0
 public Task OpenAsync(IChangeFeedObserverContext context)
 {
     return(Task.CompletedTask);
 }
示例#15
0
 public Task CloseAsync(IChangeFeedObserverContext context, ChangeFeedObserverCloseReason reason)
 {
     return(Task.CompletedTask);  // Note: requires targeting .Net 4.6+.
 }
示例#16
0
 public Task CloseAsync(IChangeFeedObserverContext context, ChangeFeedObserverCloseReason reason)
 {
     Console.WriteLine($"CloseAsync: {context.PartitionKeyRangeId}, {context.FeedResponse}, {reason}");
     return(Task.CompletedTask);  // Note: requires targeting .Net 4.6+.
 }
 public Task OpenAsync(IChangeFeedObserverContext context)
 {
     return(TaskHelper.Done);
 }
示例#18
0
 public Task OpenAsync(IChangeFeedObserverContext context)
 {
     Console.WriteLine("Opening partition processing:" + context.PartitionKeyRangeId);
     return(Task.CompletedTask);
 }
示例#19
0
 public Task CloseAsync(IChangeFeedObserverContext context, ChangeFeedObserverCloseReason reason)
 {
     Console.WriteLine("Closed:" + context.PartitionKeyRangeId + " due to " + reason);
     return(Task.CompletedTask);
 }
示例#20
0
 public Task OpenAsync(IChangeFeedObserverContext context)
 {
     return(this.observer.OpenAsync(context));
 }
示例#21
0
 public Task ProcessChangesAsync(IChangeFeedObserverContext context, IReadOnlyList <Document> docs, CancellationToken cancellationToken)
 {
     Console.WriteLine("ProcessChangesAsync: partition {0}, {1} docs", context.PartitionKeyRangeId, docs.Count);
     return(Task.CompletedTask);
 }
 /// <summary>
 /// Called when change feed observer is opened;
 /// this function prints out observer partition key id.
 /// </summary>
 /// <param name="context">The context specifying partition for this observer, etc.</param>
 /// <returns>A Task to allow asynchronous execution</returns>
 public Task OpenAsync(IChangeFeedObserverContext context)
 {
     Console.ForegroundColor = ConsoleColor.Magenta;
     Console.WriteLine("Observer opened for partition Key Range: {0}", context.PartitionKeyRangeId);
     return(Task.CompletedTask);
 }
示例#23
0
 public Task OpenAsync(IChangeFeedObserverContext context) => Task.CompletedTask;
 public Task OpenAsync(IChangeFeedObserverContext context)
 {
     _onOpen.TrackValue(1, context.PartitionKeyRangeId);
     _logger.LogInformation("Document change observer started...{0}", context.PartitionKeyRangeId);
     return(Task.CompletedTask);
 }
示例#25
0
 public Task OpenAsync(IChangeFeedObserverContext context)
 {
     Trace.TraceInformation("Observer opened, {0}", context.PartitionKeyRangeId);
     return(Task.CompletedTask);
 }