private void ToolStripComboBoxITEM_SelectedIndexChanged(object sender, EventArgs e) { // update with selected snapsots items' SSCat = toolStripComboBoxCATEGORY.SelectedItem as SnapshotCategory; var xaxis = SSCat != null ? SSCat.XAxis : null; var yaxis = SSCat != null ? SSCat.YAxis : null; if (SSCat != null) { SSCat.Selected = toolStripComboBoxITEM.SelectedItem as SnapshotItem; } SnapshotItem sItem = SSCat != null?SSCat.GetSelectedItem() : null; if (sItem != null) { toolStripComboBoxX.ComboBox.DataSource = sItem.GetHeaderTitles(); toolStripComboBoxX.SelectedItem = xaxis; toolStripComboBoxY.ComboBox.DataSource = sItem.GetHeaderTitles(); toolStripComboBoxY.SelectedItem = yaxis; } else { toolStripComboBoxX.ComboBox.DataSource = null; toolStripComboBoxX.SelectedItem = null; toolStripComboBoxY.ComboBox.DataSource = null; toolStripComboBoxY.SelectedItem = null; } _getPlotData(); chartViewer1.Redraw(); }
static SnapshotItem Generate(string key, string value, long sequence) { var item = new SnapshotItem(); item.AsPublicSnapshot(key, value, typeof(string), sequence); item.Serialize(serializer); return(item); }
static SnapshotItem Generate(int value, long sequence, int remaining) { var item = new SnapshotItem(); item.AsPartOfSystemSnapshot(sequence, remaining, "key", value, value.GetType()); item.Serialize(serializer); return(item); }
public async Task Add<T>(T aggregate) where T : class, IAggregate { using (var repo = new RawSnapshotsRepository(option)) { var snapshot = _snapshotsConstructor.GetSnapshot(aggregate); var item = new SnapshotItem { Manifest = snapshot.GetType().AssemblyQualifiedShortName(), PersistenceId = EntityActorName.New<T>(aggregate.Id).Name, Snapshot = new DomainSerializer().ToBinary(snapshot), Timestamp = BusinessDateTime.UtcNow }; await repo.Save(item.PersistenceId, item); } }
public void Add <T>(T aggregate) where T : IAggregate { var serializer = new WireJsonSerializer(); using (var repo = new RawSnapshotsRepository(_writeString)) { var snapshot = aggregate.GetSnapshot(); var item = new SnapshotItem() { Manifest = snapshot.GetType().AssemblyQualifiedShortName(), PersistenceId = AggregateActorName.New <T>(aggregate.Id).Name, Snapshot = serializer.ToBinary(snapshot), Timestamp = BusinessDateTime.UtcNow }; repo.Save(item.PersistenceId, item); } }
private long CalcuateCostAndUpdate(SnapshotItem item) { // if it is already calcuated before, and if our thread already got the value propagated to, // use the cached value if (item.Entry.Cost != UnitializedCost) { return(item.Entry.Cost); } // calculate the cost and try to cache it, again, there could be a race where two threads calculating same // cost and trying to set the field. but no big deal. Interlocked.CompareExchange(ref item.Entry.Cost, costCalculator(item.Item), UnitializedCost); // either we updated or other thread updated. so use the information cached. // Interlocked should have behaved as a full memory barrior making sure all threads see same value // for the field. return(item.Entry.Cost); }
private bool Send(SnapshotItem message, IModel currentChannel) { // FUTURE: ContentType and ContentEncoding will be dynamic based upon serialization, e.g. +json, +msgpack, +pb, etc. var meta = currentChannel.CreateBasicProperties(); meta.AppId = this.normalizedNodeId; meta.DeliveryMode = Persistent; meta.Type = message.MementoType; meta.Timestamp = new AmqpTimestamp(SystemTime.EpochUtcNow); meta.MessageId = message.CurrentSequence.ToMessageId(this.nodeId, message.ComputedHash); meta.ContentType = ContentType; meta.ContentEncoding = ContentEncoding; meta.Headers = new Hashtable { { "x-meta-key", message.Key }, { "x-meta-sequence", message.CurrentSequence.ToString(CultureInfo.InvariantCulture) }, { "x-meta-hash", message.ComputedHash.ToString(CultureInfo.InvariantCulture) } }; try { currentChannel.BasicPublish(message.MementoType.NormalizeType(), string.Empty, meta, message.Serialized); } catch (AlreadyClosedException e) { var reason = e.ShutdownReason; if (reason != null && reason.Initiator == ShutdownInitiator.Peer && reason.ReplyCode == ExchangeNotFound) { Log.Fatal("Exchange '{0}' does not exist.".FormatWith(message.MementoType.NormalizeType()), e); // CONFIG: use throttling to log4net xml config } Wait.Sleep(); this.Close(); return(false); } catch { this.Close(); return(false); } return(true); }
public bool Send(SnapshotItem message) { // FUTURE: get this under test (when we start dispatching projections) if (message == null) { throw new ArgumentNullException(); } if (this.disposed) { return(false); } var currentChannel = this.OpenChannel(false); if (currentChannel == null) { return(false); } return(this.Send(message, currentChannel)); }
public bool Send(SnapshotItem message) { return(false); }
private void _getPlotData() { SSCat = toolStripComboBoxCATEGORY.SelectedItem as SnapshotCategory; if (SSCat != null) { SnapshotItem sItem = SSCat.GetSelectedItem(); xTitle = toolStripComboBoxX.SelectedItem as string; yTitle = toolStripComboBoxY.SelectedItem as string; dxList = sItem != null?sItem.GetDoubleArray(xTitle) : null; dyList = sItem != null?sItem.GetDoubleArray(yTitle) : null; SSCat.XAxis = xTitle; SSCat.YAxis = yTitle; double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; if (dxList != null) { foreach (var v in dxList) { if (chkNum(v)) { minX = Math.Min(minX, v); maxX = Math.Max(maxX, v); } } } if (dyList != null) { foreach (var v in dyList) { if (chkNum(v)) { minY = Math.Min(minY, v); maxY = Math.Max(maxY, v); } } } if (minX == double.MaxValue) { minX = 0; maxX = 1; } if (minY == double.MaxValue) { minY = 0; maxY = 1; } if (minX == maxX) { minX -= 1; maxX += 1; } else { var d = (maxX - minX) / 10; minX -= d; maxX += d; } if (minY == maxY) { minY -= 1; maxY += 1; } { var d = (maxY - minY) / 10; minY -= d; maxY += d; } chartViewer1.XAuto = false; chartViewer1.YAuto = false; if (SSCat.XAxisAuto) { if (SSCat.XPolarity == Polarity.Normal) { chartViewer1.XLeft = minX; chartViewer1.XRight = maxX; } else { chartViewer1.XLeft = maxX; chartViewer1.XRight = minX; } } else { if (SSCat.XPolarity == Polarity.Normal) { chartViewer1.XLeft = SSCat.XAxisMin; chartViewer1.XRight = SSCat.XAxisMax; } else { chartViewer1.XLeft = SSCat.XAxisMax; chartViewer1.XRight = SSCat.XAxisMin; } } if (SSCat.YAxisAuto) { if (SSCat.YPolarity == Polarity.Normal) { chartViewer1.YTop = maxY; chartViewer1.YBottom = minY; } else { chartViewer1.YTop = minY; chartViewer1.YBottom = maxY; } } else { if (SSCat.YPolarity == Polarity.Normal) { chartViewer1.YTop = SSCat.YAxisMax; chartViewer1.YBottom = SSCat.YAxisMin; } else { chartViewer1.YTop = SSCat.YAxisMin; chartViewer1.YBottom = SSCat.YAxisMax; } } chartViewer1.XAxisTitle = xTitle; chartViewer1.YAxisTitle = yTitle; chartViewer1.Title = SSCat.Name + " : " + (sItem != null ? sItem.FormattedTime : "*"); chartViewer1.Title2 = yTitle + " vs " + xTitle; SSCat.WriteSettings(); } }
private static int Comparer(SnapshotItem x, SnapshotItem y) { // give it descending order return(y.Rank.CompareTo(x.Rank)); }
public void OnNext(SnapshotItem data, long sequence, bool endOfBatch) { data.Clear(); }
public void Record(SnapshotItem item) { }