Skip to content

Commit 96096a3

Browse files
author
Doug Schmidt
committed
PF-1244 - Fixed the broken -Wait=false logic in PointZilla
Now you can just queue points without waiting for the append to complete, just like most telemetry systems.
1 parent 37bc655 commit 96096a3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

TimeSeries/PublicApis/SdkExamples/PointZilla/PointsAppender.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void AppendPoints()
125125
numberOfPointsDeleted += result.NumberOfPointsDeleted;
126126
++batchIndex;
127127

128-
if (result.AppendStatus != AppendStatusCode.Completed)
128+
if (!ValidStatusCodesByWaitMode[Context.Wait].Contains(result.AppendStatus))
129129
throw new ExpectedException($"Unexpected append status={result.AppendStatus}");
130130
}
131131

@@ -135,10 +135,19 @@ public void AppendPoints()
135135
numberOfNotesAppended += AppendNotes(client, timeSeries);
136136

137137
var batchText = isBatched ? $" using {"append".ToQuantity(pointBatches.Count)}" : "";
138-
Log.Info($"Appended {"point".ToQuantity(numberOfPointsAppended)} and {"note".ToQuantity(numberOfNotesAppended)} (deleting {"point".ToQuantity(numberOfPointsDeleted)} and {"note".ToQuantity(numberOfNotesDeleted)}) in {stopwatch.ElapsedMilliseconds / 1000.0:F1} seconds{batchText}.");
138+
var waitText = Context.Wait ? string.Empty : " (without waiting for appends to complete)";
139+
140+
Log.Info($"Appended {"point".ToQuantity(numberOfPointsAppended)} and {"note".ToQuantity(numberOfNotesAppended)} (deleting {"point".ToQuantity(numberOfPointsDeleted)} and {"note".ToQuantity(numberOfNotesDeleted)}) in {stopwatch.ElapsedMilliseconds / 1000.0:F1} seconds{batchText}{waitText}.");
139141
}
140142
}
141143

144+
private static readonly Dictionary<bool, HashSet<AppendStatusCode>> ValidStatusCodesByWaitMode =
145+
new Dictionary<bool, HashSet<AppendStatusCode>>
146+
{
147+
{ true, new HashSet<AppendStatusCode> { AppendStatusCode.Completed } },
148+
{ false, new HashSet<AppendStatusCode> { AppendStatusCode.Completed, AppendStatusCode.Pending } },
149+
};
150+
142151
private void AdjustNotes()
143152
{
144153
if (Context.IgnoreNotes)
@@ -304,7 +313,7 @@ private TimeSeriesAppendStatus AppendPointBatch(IAquariusClient client, TimeSeri
304313
return client.Acquisition.RequestAndPollUntilComplete(
305314
acquisition => appendResponse,
306315
(acquisition, response) => acquisition.Get(new GetTimeSeriesAppendStatus { AppendRequestIdentifier = response.AppendRequestIdentifier }),
307-
polledStatus => polledStatus.AppendStatus != AppendStatusCode.Pending,
316+
polledStatus => !Context.Wait || polledStatus.AppendStatus != AppendStatusCode.Pending,
308317
null,
309318
Context.AppendTimeout);
310319
}

0 commit comments

Comments
 (0)