Generic socket custom-command seam, shared archive path/fill logic, and typed-value support#39
Open
ritchiecarroll wants to merge 4 commits into
Open
Generic socket custom-command seam, shared archive path/fill logic, and typed-value support#39ritchiecarroll wants to merge 4 commits into
ritchiecarroll wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three related, low-level capabilities that support openHistorian's day-sharded event-details feature (see Related PRs), all designed to be backward compatible:
BitConverthelpers used by openHistorian's typedHistorianValue.SnapDB intentionally has no knowledge of "event details" — openHistorian plugs into the generic seam.
1. Generic socket custom-command facility
ServerCommand.RunCustomCommand = 8andServerResponsevaluesCustomCommandResult/CustomCommandNotSupported/CustomCommandError.SnapServer.RegisterCustomCommand(name, Func<byte[],byte[]>)/UnregisterCustomCommand/ internalTryGetCustomCommand— a thread-safe handler registry.SnapStreamingServer.ProcessRootLevelCommands(root level, since handlers are process-scoped). A known command with no registered handler respondsCustomCommandNotSupportedwithout dropping the connection.SnapClient.RunCustomCommand(name, request)—virtualon the base, overridden bySnapStreamingClient(over the socket; throws if used while connected to a database) and the in-processSnapServer.Client(direct invoke).CustomCommandNotSupportedExceptionso callers can detect and degrade gracefully.Backward compatibility
defaultcase, returnsUnknownCommand, and drops that connection. The client surfaces this asCustomCommandNotSupportedException, so callers can degrade. (Use a dedicated connection for custom commands so a drop never disrupts data reads — openHistorian's client does this.)2. Shared archive path/fill logic + configurable fill method
ArchivePathHelperconsolidates directory-layout and write-path selection logic that was duplicated acrossArchiveInitializerandSimplifiedArchiveInitializer:GetRelativeDirectory(time, method)— dated sub-path (pure).GetPath(root, time, method)— combine + create.GetPathWithEnoughSpace(paths, estimatedSize, desiredRemainingSpace, fillMethod, seed)— disk-space-aware selection.ArchiveDirectoryFillMethod { Sequential, RoundRobin }, plumbed throughArchiveInitializerSettings.FillMethod,SimplifiedArchiveInitializerSettings.FillMethod, andAdvancedServerDatabaseConfig.FillMethod.YearThenMonthlayout now usesPath.Combineinstead of a literal\separator (cross-platform; identical output on Windows).Reviewer / tester considerations
Sequential, which preserves the historical first-fill behavior (fill the first write directory until it lacks space, then advance). The previous code's comment claimed round-robin but actually behaved as sequential first-fill; behavior is unchanged unlessFillMethod = RoundRobinis configured.DirectoryFillMethodconnection-string parameter (see openHistorian PR). Multi-drive deployments should verify expected file distribution after choosing a mode.ArchiveInitializerSettings/SimplifiedArchiveInitializerSettingsnow write a fill-method field. A v2-aware build reads old v1 streams (defaulting toSequential); older builds cannot read v2 streams. Relevant only where these settings are persisted/transferred across mixed versions.3. Typed-value BitConvert helpers
BitConvert.ToDouble(ulong)andBitConvert.ToUInt64(double)added to support openHistorian's typedHistorianValue(64-bit value encodings).Reviewer / tester considerations (overall)
"GetEventDetails"), or (b)FillMethod = RoundRobinis configured.Developmentbuilds consume these via theGemstone.SnapDBpackage, so this must be published before those builds pick up the feature.Testing
The custom-command path (client ⇄ server framing, registry, graceful degradation) is exercised end-to-end by openHistorian's
EventDetailsSocketTests, including a live TCP round-trip throughSnapStreamingClient/SnapStreamingServer.Related PRs
This change is part of an event-details feature spanning three repositories: