Skip to content

Commit

Permalink
Merge branch 'release27'
Browse files Browse the repository at this point in the history
  • Loading branch information
NTDLS committed Oct 22, 2024
2 parents de0f34d + 6efb469 commit 3dcf18e
Show file tree
Hide file tree
Showing 21 changed files with 87 additions and 40 deletions.
8 changes: 4 additions & 4 deletions @Installers/Settings/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"ListenPort": 6858,
"DataRootPath": "C:\\Katzebase\\Root",
"TransactionDataPath": "C:\\Katzebase\\Transaction",
"LogDirectory": "C:\\Katzebase\\Logs",
"DataRootPath": ".\\Data\\Root",
"TransactionDataPath": ".\\Data\\Transaction",
"LogDirectory": ".\\Data\\Logs",
"FlushLog": true,
"DefaultDocumentPageSize": 100,
"HealthMonitoringEnabled": true,
"HealthMonitoringCheckpointSeconds": 600,
"HealthMonitoringInstanceLevelEnabled": false,
"HealthMonitoringInstanceLevelTimeToLiveSeconds": 600,
"MaxIdleConnectionSeconds": 600,
"MaxIdleConnectionSeconds": 30,
"DefaultIndexPartitions": 100,
"LockWaitTimeoutSeconds": 0,
"DeferredIOEnabled": true,
Expand Down
4 changes: 2 additions & 2 deletions @Installers/Setup.Iss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Setup]
;-- Main Setup Information
AppName = Katzebase Server
AppVerName = Katzebase Server 0.26.0
AppVerName = Katzebase Server 0.27.0
AppCopyright = Copyright © 2024 NetworkDLS.
DefaultDirName = {commonpf}\NetworkDLS\Katzebase
DefaultGroupName = Katzebase
Expand All @@ -17,7 +17,7 @@
AppPublisher = NetworkDLS
AppPublisherURL = http://www.NetworkDLS.com/
AppUpdatesURL = http://www.NetworkDLS.com/
AppVersion = 0.26.0
AppVersion = 0.27.0

[Components]
Name: "Server"; Description: "Server"; Types: Full Compact Custom;
Expand Down
22 changes: 21 additions & 1 deletion NTDLS.Katzebase.Api/KbClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NTDLS.Katzebase.Api.Exceptions;
using NTDLS.Katzebase.Api.Management;
using NTDLS.Katzebase.Api.Models;
using NTDLS.Katzebase.Api.Payloads;
using NTDLS.ReliableMessaging;
using System.Diagnostics;
using System.Security.Cryptography;
Expand All @@ -20,6 +21,7 @@ public class KbClient : IDisposable
public event CommunicationExceptionEvent? OnCommunicationException;

private TimeSpan _queryTimeout = TimeSpan.FromSeconds(30);
private Thread? _heartbeatThread;

public TimeSpan QueryTimeout
{
Expand Down Expand Up @@ -157,6 +159,9 @@ public void Connect(string hostname, int port, string username, string passwordH
ServerConnectionId = reply.ConnectionId;
ProcessId = reply.ProcessId;

_heartbeatThread = new Thread(HeartbeatThread);
_heartbeatThread.Start();

var sessionInfo = new KbSessionInfo
{
ConnectionId = ServerConnectionId,
Expand All @@ -172,8 +177,24 @@ public void Connect(string hostname, int port, string username, string passwordH
}
}

private void HeartbeatThread()
{
var lastCheckInTime = DateTime.UtcNow;

while (IsConnected)
{
if ((DateTime.UtcNow - lastCheckInTime).TotalSeconds >= KbConstants.HeartbeatSeconds)
{
Connection?.Notify(new KbNotifySessionHeartbeat());
lastCheckInTime = DateTime.UtcNow;
}
Thread.Sleep(100);
}
}

void Disconnect()
{
_heartbeatThread = null;
try
{
try
Expand Down Expand Up @@ -227,7 +248,6 @@ protected virtual void Dispose(bool disposing)
}

disposed = true;

}

#endregion
Expand Down
1 change: 1 addition & 0 deletions NTDLS.Katzebase.Api/KbConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public static class KbConstants
{
public static string FriendlyName = "Katzebase";
public const int HeartbeatSeconds = 15;

public enum KbLogSeverity
{
Expand Down
2 changes: 1 addition & 1 deletion NTDLS.Katzebase.Api/NTDLS.Katzebase.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Nullable>enable</Nullable>
<Company>NetworkDLS</Company>
<Copyright>Copyright © 2024 NetworkDLS</Copyright>
<Version>0.26.0</Version>
<Version>0.27.0</Version>
<Authors>NetworkDLS</Authors>
<ApplicationIcon>Media\IconFull.ico</ApplicationIcon>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
Expand Down
12 changes: 12 additions & 0 deletions NTDLS.Katzebase.Api/Payloads/KbQuerySessionHeartbeat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using NTDLS.Katzebase.Api.Payloads.Response;
using NTDLS.ReliableMessaging;

namespace NTDLS.Katzebase.Api.Payloads
{
public class KbNotifySessionHeartbeat : IRmNotification
{
public KbNotifySessionHeartbeat()
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ public KbQueryServerCloseSessionReply CloseSession(RmContext context, KbQuerySer
}
}

public void Heartbeat(RmContext context, KbNotifySessionHeartbeat param)
{
//The call to GetSession() will update the LastCheckInTime.
_core.Sessions.GetSession(context.ConnectionId);
}

public KbQueryServerTerminateProcessReply TerminateSession(RmContext context, KbQueryServerTerminateProcess param)
{
var session = _core.Sessions.GetSession(context.ConnectionId);
Expand Down
28 changes: 14 additions & 14 deletions NTDLS.Katzebase.Engine/Interactions/Management/SessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,24 @@ public bool TryCloseByProcessID(ulong processId)
// For this reason, we will "try lock" with a timeout, if we fail to remove the session now - it will be
// automatically retried by the HeartbeatManager.
var wasLockObtained = _collection.TryWrite(100, (obj) =>
{
var session = obj.FirstOrDefault(o => o.Value.ProcessId == processId).Value;
if (session != null)
{
obj.Remove(session.ConnectionId);
}
});
var session = obj.FirstOrDefault(o => o.Value.ProcessId == processId).Value;
if (session != null)
{
obj.Remove(session.ConnectionId);
}
});

if (wasLockObtained == false)
if (wasLockObtained)
{
LogManager.Warning($"Lock timeout expired while removing session. The task will be deferred to the heartbeat manager.");
return true;
}

return wasLockObtained;
}
else
{
_collection.TryWrite(100, (obj) =>

LogManager.Warning($"Lock timeout expired while removing session. The task will be deferred to the heartbeat manager.");

//We can TryRead here (instead of TryWrite) because we are not modifying the collection, just a value within it.
_collection.TryRead(100, (obj) =>
{
var session = obj.FirstOrDefault(o => o.Value.ProcessId == processId).Value;
if (session != null)
Expand All @@ -168,7 +168,7 @@ public bool TryCloseByProcessID(ulong processId)
session.IsExpired = true;
}
});
}

return false;
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ internal bool TryCloseByProcessID(ulong processId)
if (transaction != null)
{
transaction.Rollback();

obj.Remove(transaction);
}
});
Expand Down
2 changes: 1 addition & 1 deletion NTDLS.Katzebase.Engine/NTDLS.Katzebase.Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Nullable>enable</Nullable>
<Company>NetworkDLS</Company>
<Copyright>Copyright © 2024 NetworkDLS</Copyright>
<Version>0.26.0</Version>
<Version>0.27.0</Version>
<Authors>NetworkDLS</Authors>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<UseWindowsForms>true</UseWindowsForms>
<Company>NetworkDLS</Company>
<Copyright>Copyright © 2024 NetworkDLS</Copyright>
<Version>0.26.0</Version>
<Version>0.27.0</Version>
<Authors>NetworkDLS</Authors>
</PropertyGroup>

Expand Down
10 changes: 5 additions & 5 deletions NTDLS.Katzebase.Management/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>Icon.ico</ApplicationIcon>
<Version>0.26.0</Version>
<Version>0.27.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion NTDLS.Katzebase.Parsers/NTDLS.Katzebase.Parsers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Company>NetworkDLS</Company>
<Copyright>Copyright © 2024 NetworkDLS</Copyright>
<Version>0.26.0</Version>
<Version>0.27.0</Version>
<Authors>NetworkDLS</Authors>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Company>NetworkDLS</Company>
<Copyright>Copyright © 2024 NetworkDLS</Copyright>
<Version>0.26.0</Version>
<Version>0.27.0</Version>
<Authors>NetworkDLS</Authors>

</PropertyGroup>
Expand Down
10 changes: 10 additions & 0 deletions NTDLS.Katzebase.SQLServerMigration/Forms/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ private void ExportSQLServerTableToKatzebase(SelectedImportObject item, string t

#endregion

if (_isCancelPending)
{
return;
}

#region Import Inexes.

if (item.ImportIndexes)
Expand All @@ -493,6 +498,11 @@ private void ExportSQLServerTableToKatzebase(SelectedImportObject item, string t

foreach (var sourceIndex in sourceIndexes)
{
if (_isCancelPending)
{
return;
}

if (client.Schema.Indexes.Exists(item.TargetServerSchema, sourceIndex.Key.EnsureNotNull()) == false)
{
var targetIndex = new KbIndex(sourceIndex.Key.EnsureNotNull())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Company>NetworkDLS</Company>
<Copyright>Copyright © 2024 NetworkDLS</Copyright>
<Version>0.26.0</Version>
<Version>0.27.0</Version>
<Authors>NetworkDLS</Authors>
<ApplicationIcon>Icon.ico</ApplicationIcon>
<StartupObject>NTDLS.Katzebase.SQLServerMigration.Program</StartupObject>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion NTDLS.Katzebase.Server/NTDLS.Katzebase.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Company>NetworkDLS</Company>
<Copyright>Copyright © 2024 NetworkDLS</Copyright>
<Version>0.26.0</Version>
<Version>0.27.0</Version>
<Authors>NetworkDLS</Authors>
<ApplicationIcon>Icon.ico</ApplicationIcon>
<OutputType>Exe</OutputType>
Expand Down
2 changes: 1 addition & 1 deletion NTDLS.Katzebase.Server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"HealthMonitoringCheckpointSeconds": 600,
"HealthMonitoringInstanceLevelEnabled": false,
"HealthMonitoringInstanceLevelTimeToLiveSeconds": 600,
"MaxIdleConnectionSeconds": 60,
"MaxIdleConnectionSeconds": 30,
"DefaultIndexPartitions": 100,
"LockWaitTimeoutSeconds": 0,
"DeferredIOEnabled": true,
Expand Down
2 changes: 1 addition & 1 deletion NTDLS.Katzebase.Shared/NTDLS.Katzebase.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Company>NetworkDLS</Company>
<Copyright>Copyright © 2024 NetworkDLS</Copyright>
<Version>0.26.0</Version>
<Version>0.27.0</Version>
<Authors>NetworkDLS</Authors>
</PropertyGroup>

Expand Down

0 comments on commit 3dcf18e

Please sign in to comment.