public void Execute(PrimitiveInterface.Tuple tuple) { string value = tuple.Get(0) as string; if (string.IsNullOrWhiteSpace(value)) { return; } if (wordsCount.ContainsKey(value)) { wordsCount[value]++; } else { wordsCount[value] = 1; } // Not necessary to update database for each entry if (wordsCount[value] % 1000 == 0) { WordCountEntry entity = new WordCountEntry() { Word = value, Count = wordsCount[value], Bolt = this.context.ActorId, RowKey = value + "____" + this.context.ActorId, }; TableOperation insertOperation = TableOperation.InsertOrReplace(entity); table.Execute(insertOperation); } }
public void Execute(PrimitiveInterface.Tuple tuple) { string tagId = tuple.Get(0) as string; string dateTime = tuple.Get(1) as string; string page = tuple.Get(2) as string; string location = tuple.Get(3) as string; // Summary Page on if (string.IsNullOrWhiteSpace(page) || !string.Equals(tagId, "8819")) { return; } var parts = dateTime.Split(new char[] { '/' }); string key = page + "_" + parts[0] + "_" + parts[1] + "_" + parts[2] + "_" + parts[3]; if (localCache.ContainsKey(key)) { localCache[key]++; } else { localCache[key] = 1; } if ((DateTime.Now - this.lastUpdateTime).TotalSeconds > 15) { this.lastUpdateTime = DateTime.Now; foreach (string k in this.localCache.Keys) { PageTotalCountEntry entity = new PageTotalCountEntry() { Name = k, Count = localCache[k], Bolt = this.context.ActorId, RowKey = k, }; TableOperation insertOperation = TableOperation.InsertOrReplace(entity); table.Execute(insertOperation); } } }
public void Execute(PrimitiveInterface.Tuple tuple) { string tagId = tuple.Get(0) as string; string dateTime = tuple.Get(1) as string; string page = tuple.Get(2) as string; string location = tuple.Get(3) as string; var parts = dateTime.Split(new char[] { '/' }); string key = tagId + "_" + parts[0] + "_" + parts[1] + "_" + parts[2] + "_" + parts[3]; if (localCache.ContainsKey(key)) { localCache[key]++; } else { localCache[key] = 1; } if ((DateTime.Now - this.lastUpdateTime).TotalSeconds > 15) { this.lastUpdateTime = DateTime.Now; foreach (string k in this.localCache.Keys) { TagIdTotalCountEntry entity = new TagIdTotalCountEntry() { Name = k, Count = localCache[k], Bolt = this.context.ActorId, RowKey = k, }; TableOperation insertOperation = TableOperation.InsertOrReplace(entity); table.Execute(insertOperation); } } this.emitter.Emit(tuple); }
public void Execute(PrimitiveInterface.Tuple tuple) { string dateTime = tuple.Get(0) as string; string tenantName = tuple.Get(1) as string; string reportName = tuple.Get(2) as string; string completness = tuple.Get(3) as string; string key = reportName + "_" + dateTime; var parts = dateTime.Split(new char[] { '/' }); if (RequestCountCache.ContainsKey(key)) { RequestCountCache[key]++; TotalCompletnessCache[key] += double.Parse(completness); } else { RequestCountCache[key] = 1; TotalCompletnessCache[key] = double.Parse(completness); } // Not necessary to update database for each entry // Todo update flaged data each 15 seconds, and clear dirty data if (RequestCountCache[key] % 50 == 0) { ReportCompletnessEntry entity = new ReportCompletnessEntry() { Name = key, RequestCount = RequestCountCache[key], TotalCompletness = TotalCompletnessCache[key], Completness = TotalCompletnessCache[key] / RequestCountCache[key], Bolt = this.context.ActorId, RowKey = reportName + "_" + parts[0] + "_" + parts[1] + "_" + parts[2] + "_" + parts[3], }; TableOperation insertOperation = TableOperation.InsertOrReplace(entity); table.Execute(insertOperation); } }
public void Execute(PrimitiveInterface.Tuple tuple) { string value = tuple.Get(0) as string; if (string.IsNullOrWhiteSpace(value)) { return; } var parts = value.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string word in parts) { this.emitter.Emit(new PrimitiveInterface.Tuple(word)); } }
/// <summary> /// Emit /// </summary> /// <param name="tuple"></param> public void Emit(PrimitiveInterface.Tuple tuple) { if (this.queues.Count == 0) { throw new InvalidOperationException("This bolt doesn't have any output queue enabled."); } Random random = new Random(); int index = 0; switch (this.schemaGroupingMode) { case "ShuffleGrouping": index = random.Next(this.queues.Count); this.queues[index].AddMessage(new CloudQueueMessage(tuple.GetSeriliableContent())); break; case "FieldGrouping": StringBuilder distributedValue = new StringBuilder(); foreach (string filed in this.groupingFields) { distributedValue.Append(tuple.Get(this.declaredFields.IndexOf(filed))); } index = Math.Abs(distributedValue.ToString().GetHashCode()) % this.queues.Count; this.queues[index].AddMessage(new CloudQueueMessage(tuple.GetSeriliableContent())); break; case "AllGrouping": foreach (CloudQueue queue in this.queues) { queue.AddMessage(new CloudQueueMessage(tuple.GetSeriliableContent())); } break; default: break; } ; }
public void Execute(PrimitiveInterface.Tuple tuple) { string delimiter = "|$$|0="; string log = tuple.Get(0) as string; var parts = log.Split(new string[] { "|#|" }, StringSplitOptions.RemoveEmptyEntries); var date = DateTime.Parse(parts[1]); int indexDQLog = log.IndexOf(delimiter); if (indexDQLog >= 0) { var DQLog = log.Substring(indexDQLog + delimiter.Length); var message = DQLog.Split(new string[] { "|$$|" }, StringSplitOptions.RemoveEmptyEntries)[0]; DQLogProcessor DQProcessor = new DQLogProcessor(message); string reportName = DQProcessor.ReportName; string tenantName = DQProcessor.TenantName; //if ( // reportName.IndexOf("ConnectionbyClientType") >= 0 // || reportName.IndexOf("MailboxActivity") >= 0 // || reportName.IndexOf("StaleMailbox") >= 0 // || reportName.IndexOf("GroupActivity") >= 0 // || reportName.IndexOf("MailboxUsage") >= 0) //{ IList <string> strs = new List <string>() { string.Format("{0}/{1}", date.Date.ToShortDateString(), date.Hour), tenantName, reportName, DQProcessor.GetCompletness(date).ToString() }; this.emitter.Emit(new PrimitiveInterface.Tuple(strs)); //} } }