Skip to content

Commit

Permalink
Merge branch 'v5.4' of github.com:ravendb/ravendb into v6.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Raven.Server/Commercial/LicenseManager.cs
#	src/Raven.Server/RavenServer.cs
#	src/Raven.Studio/typescript/viewmodels/database/indexes/indexes.ts
#	src/Raven.Studio/wwwroot/App/views/database/tasks/editPeriodicBackupTask.html
#	src/Raven.Studio/wwwroot/App/views/manage/editServerWideBackup.html
#	src/Raven.Studio/wwwroot/App/views/manage/editServerWideExternalReplication.html
  • Loading branch information
arekpalinski committed Apr 17, 2024
2 parents 16e6fde + 48fb9b6 commit 6e1b1ce
Show file tree
Hide file tree
Showing 31 changed files with 111 additions and 325 deletions.
6 changes: 6 additions & 0 deletions src/Raven.Client/Http/HttpCompressionAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@ internal static async Task<string> ReadAsStringWithZstdSupportAsync(this HttpCon
#endif
}

#if NET6_0_OR_GREATER
internal static async Task<Stream> ReadAsStreamWithZstdSupportAsync(this HttpContent httpContent, CancellationToken cancellationToken = default)
{
var contentStream = await httpContent.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
#else
internal static async Task<Stream> ReadAsStreamWithZstdSupportAsync(this HttpContent httpContent)
{
var contentStream = await httpContent.ReadAsStreamAsync().ConfigureAwait(false);
#endif
var contentStreamType = contentStream.GetType();
#if FEATURE_BROTLI_SUPPORT
if (contentStreamType == typeof(BrotliStream))
Expand Down
20 changes: 10 additions & 10 deletions src/Raven.Server/Commercial/LicenseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,33 +553,33 @@ public async Task TryActivateLicenseAsync(bool throwOnActivationFailure)
}
}

public static async Task<HttpResponseMessage> GetUpdatedLicenseResponseMessage(License currentLicense, TransactionContextPool contextPool)
public static async Task<HttpResponseMessage> GetUpdatedLicenseResponseMessage(License currentLicense, TransactionContextPool contextPool, CancellationToken token)
{
var leaseLicenseInfo = GetLeaseLicenseInfo(currentLicense, contextPool);

var response = await ApiHttpClient.Instance.PostAsync("/api/v2/license/lease",
new StringContent(JsonConvert.SerializeObject(leaseLicenseInfo), Encoding.UTF8, "application/json"))
new StringContent(JsonConvert.SerializeObject(leaseLicenseInfo), Encoding.UTF8, "application/json"), token)
.ConfigureAwait(false);

return response;
}

public async Task<License> GetUpdatedLicense(License currentLicense)
{
var response = await GetUpdatedLicenseResponseMessage(currentLicense, _serverStore.ContextPool).ConfigureAwait(false);
var response = await GetUpdatedLicenseResponseMessage(currentLicense, _serverStore.ContextPool, _serverStore.ServerShutdown).ConfigureAwait(false);
if (response.IsSuccessStatusCode == false)
return null;

var leasedLicense = await ConvertResponseToLeasedLicense(response).ConfigureAwait(false);
var leasedLicense = await ConvertResponseToLeasedLicense(response, _serverStore.ServerShutdown).ConfigureAwait(false);
return leasedLicense.License;
}

public static async Task<LeasedLicense> ConvertResponseToLeasedLicense(HttpResponseMessage httpResponseMessage)
public static async Task<LeasedLicense> ConvertResponseToLeasedLicense(HttpResponseMessage httpResponseMessage, CancellationToken token)
{
var leasedLicenseAsStream = await httpResponseMessage.Content.ReadAsStreamWithZstdSupportAsync().ConfigureAwait(false);
var leasedLicenseAsStream = await httpResponseMessage.Content.ReadAsStreamWithZstdSupportAsync(token).ConfigureAwait(false);
using (var context = JsonOperationContext.ShortTermSingleUse())
{
var json = await context.ReadForMemoryAsync(leasedLicenseAsStream, "leased license info");
var json = await context.ReadForMemoryAsync(leasedLicenseAsStream, "leased license info", token);
var leasedLicense = JsonDeserializationServer.LeasedLicense(json);
return leasedLicense;
}
Expand Down Expand Up @@ -670,7 +670,7 @@ private static StudioConfiguration.StudioEnvironment GetStudioEnvironment(Transa
return (null, false);
}

var response = await GetUpdatedLicenseResponseMessage(currentLicense, _serverStore.ContextPool).ConfigureAwait(false);
var response = await GetUpdatedLicenseResponseMessage(currentLicense, _serverStore.ContextPool, _serverStore.ServerShutdown).ConfigureAwait(false);

if (response.IsSuccessStatusCode == false)
{
Expand All @@ -680,12 +680,12 @@ private static StudioConfiguration.StudioEnvironment GetStudioEnvironment(Transa
if (license != null)
return (license, false);

var responseString = await response.Content.ReadAsStringWithZstdSupportAsync().ConfigureAwait(false);
var responseString = await response.Content.ReadAsStringWithZstdSupportAsync(_serverStore.ServerShutdown).ConfigureAwait(false);
AddLeaseLicenseError($"status code: {response.StatusCode}, response: {responseString}");
return (null, false);
}

var leasedLicense = await ConvertResponseToLeasedLicense(response).ConfigureAwait(false);
var leasedLicense = await ConvertResponseToLeasedLicense(response, _serverStore.ServerShutdown).ConfigureAwait(false);
var newLicense = leasedLicense.License;
var licenseChanged = newLicense.Equals(currentLicense) == false;

Expand Down
14 changes: 7 additions & 7 deletions src/Raven.Server/RavenServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3049,8 +3049,7 @@ private static void VerifyLicenseVersion(LicenseStatus licenseStatus, License li
if (licenseStatus.Version.Major >= 6)
{
serverStore.LicenseManager.OnBeforeInitialize += () =>
serverStore.LicenseManager.ActivateAsync(licenseFromApi, RaftIdGenerator.NewId(), fromApi: true)
.Wait(serverStore.ServerShutdown);
AsyncHelpers.RunSync(() => serverStore.LicenseManager.TryActivateLicenseAsync(throwOnActivationFailure: serverStore.Server.ThrowOnLicenseActivationFailure));
return;
}
}
Expand All @@ -3063,8 +3062,8 @@ private static void VerifyLicenseVersion(LicenseStatus licenseStatus, License li
if (licenseStatus.Version.Major >= 6)
{
serverStore.LicenseManager.OnBeforeInitialize += () =>
serverStore.LicenseManager.TryActivateLicenseAsync(throwOnActivationFailure: serverStore.Server.ThrowOnLicenseActivationFailure)
.Wait(serverStore.ServerShutdown);
AsyncHelpers.RunSync(() =>
serverStore.LicenseManager.TryActivateLicenseAsync(throwOnActivationFailure: serverStore.Server.ThrowOnLicenseActivationFailure));
return;
}
}
Expand All @@ -3080,9 +3079,9 @@ private static async Task<License> GetLicenseFromApi(License license, Transactio
{
try
{
var response = await LicenseManager.GetUpdatedLicenseResponseMessage(license, contextPool)
var response = await LicenseManager.GetUpdatedLicenseResponseMessage(license, contextPool, CancellationToken.None)
.ConfigureAwait(false);
var leasedLicense = await LicenseManager.ConvertResponseToLeasedLicense(response)
var leasedLicense = await LicenseManager.ConvertResponseToLeasedLicense(response, CancellationToken.None)
.ConfigureAwait(false);
return leasedLicense.License;
}
Expand Down Expand Up @@ -3110,7 +3109,8 @@ private static void VerifyLicenseExpiration(LicenseStatus licenseStatus, ServerS
var localLicenseStatus = LicenseManager.GetLicenseStatus(localLicense);
if (localLicenseStatus.Expiration >= RavenVersionAttribute.Instance.ReleaseDate)
{
serverStore.LicenseManager.OnBeforeInitialize += () => serverStore.LicenseManager.TryActivateLicenseAsync(throwOnActivationFailure: serverStore.Server.ThrowOnLicenseActivationFailure).Wait(serverStore.ServerShutdown);
serverStore.LicenseManager.OnBeforeInitialize += () => AsyncHelpers.RunSync(() =>
serverStore.LicenseManager.TryActivateLicenseAsync(throwOnActivationFailure: serverStore.Server.ThrowOnLicenseActivationFailure));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class editElasticSearchEtlTask extends shardViewModelBase {

view = require("views/database/tasks/editElasticSearchEtlTask.html");
connectionStringView = require("views/database/settings/connectionStringElasticSearch.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

static readonly scriptNamePrefix = "Script_";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class editExternalReplicationTask extends shardViewModelBase {
view = require("views/database/tasks/editExternalReplicationTask.html");
connectionStringView = require("views/database/settings/connectionStringRaven.html");
certificateUploadInfoForOngoingTasks = require("views/partial/certificateUploadInfoForOngoingTasks.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

editedExternalReplication = ko.observable<ongoingTaskReplicationEditModel>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class editKafkaEtlTask extends viewModelBase {
view = require("views/database/tasks/editKafkaEtlTask.html");
optionsPerQueueEtlView = require("views/database/tasks/optionsPerQueueEtl.html");
connectionStringView = require("views/database/settings/connectionStringKafka.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

static readonly scriptNamePrefix = "Script_";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class editOlapEtlTask extends shardViewModelBase {
connectionStringOlapView = require("views/database/settings/connectionStringOlap.html");
backupConfigurationView = require("views/partial/backupConfigurationScript.html");
backupDestinationLocalView = require("views/partial/backupDestinationLocal.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

static readonly scriptNamePrefix = "Script_";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class editPeriodicBackupTask extends shardViewModelBase {
backupDestinationsView = require("views/partial/backupDestinations.html");
backupConfigurationView = require("views/partial/backupConfigurationScript.html");
backupDestinationTestCredentialsView = require("views/partial/backupDestinationTestCredentialsResults.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection_ForBackup.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

periodicInfoHubView: ReactInKnockout<typeof EditPeriodicBackupTaskInfoHub>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class editRabbitMqEtlTask extends viewModelBase {
view = require("views/database/tasks/editRabbitMqEtlTask.html");
optionsPerQueueEtlView = require("views/database/tasks/optionsPerQueueEtl.html");
connectionStringView = require("views/database/settings/connectionStringRabbitMq.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

static readonly scriptNamePrefix = "Script_";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class editRavenEtlTask extends shardViewModelBase {
view = require("views/database/tasks/editRavenEtlTask.html");
connectionStringView = require("views/database/settings/connectionStringRaven.html")
certificateUploadInfoForOngoingTasks = require("views/partial/certificateUploadInfoForOngoingTasks.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

static readonly scriptNamePrefix = "Script_";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { EditReplicationHubInfoHub } from "viewmodels/database/tasks/EditReplica
class editReplicationHubTask extends shardViewModelBase {

view = require("views/database/tasks/editReplicationHubTask.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

editedHubTask = ko.observable<ongoingTaskReplicationHubEditModel>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class editReplicationSinkTask extends shardViewModelBase {

view = require("views/database/tasks/editReplicationSinkTask.html");
connectionStringView = require("views/database/settings/connectionStringRaven.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

editedSinkTask = ko.observable<ongoingTaskReplicationSinkEditModel>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class editSqlEtlTask extends shardViewModelBase {

view = require("views/database/tasks/editSqlEtlTask.html");
connectionStringView = require("views/database/settings/connectionStringSql.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

static readonly scriptNamePrefix = "Script_";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class editSubscriptionTask extends shardViewModelBase {
languageService: rqlLanguageService;

view = require("views/database/tasks/editSubscriptionTask.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

infoHubView: ReactInKnockout<typeof EditSubscriptionTaskInfoHub>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class editServerWideBackup extends viewModelBase {
backupDestinationsView = require("views/partial/backupDestinations.html");
backupConfigurationView = require("views/partial/backupConfigurationScript.html");
backupDestinationTestCredentialsView = require("views/partial/backupDestinationTestCredentialsResults.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection_ForBackup.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

infoHubView: ReactInKnockout<typeof EditServerWideBackupInfoHub>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class editServerWideExternalReplication extends viewModelBase {

view = require("views/manage/editServerWideExternalReplication.html");
certificateUploadInfoForOngoingTasks = require("views/partial/certificateUploadInfoForOngoingTasks.html");
pinResponsibleNodeButtonsScriptView = require("views/partial/pinResponsibleNodeButtonsScript.html");
taskResponsibleNodeSectionView = require("views/partial/taskResponsibleNodeSection.html");
pinResponsibleNodeTextScriptView = require("views/partial/pinResponsibleNodeTextScript.html");

infoHubView: ReactInKnockout<typeof EditServerWideExternalReplicationInfoHub>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,7 @@ <h2 data-bind="text: $root.isAddingNewElasticSearchEtlTask() ? 'New Elasticsearc
<label for="responsibleNode">Set responsible node</label>
</div>
</div>
<div data-bind="validationElement: mentorNode, collapse: manualChooseMentor">
<div class="form-group" data-bind="css: { 'margin-bottom-xs': mentorNode() }">
<div>
<label class="control-label">Responsible Node</label>
</div>
<div class="flex-grow">
<button class="btn btn-block dropdown-toggle text-left" type="button" data-toggle="dropdown">
<span data-bind="text: mentorNode() ? 'Node ' + mentorNode() : 'Select responsible node'"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" data-bind="foreach: $root.possibleMentors">
<li><a href="#" data-bind="text: 'Node ' + $data, click: $parent.mentorNode.bind($parent.mentorNode, $data)"></a></li>
</ul>
<span class="help-block" data-bind="validationMessage: mentorNode"></span>
</div>
<div data-bind="compose: $root.pinResponsibleNodeButtonsScriptView"></div>
</div>
<div data-bind="visible: mentorNode">
<div class="form-group small">
<label class="control-label">&nbsp;</label>
<div class="flex-grow" data-bind="compose: $root.pinResponsibleNodeTextScriptView"></div>
</div>
</div>
</div>
<div data-bind="compose: $root.taskResponsibleNodeSectionView"></div>
<div class="form-group">
<label class="control-label">&nbsp;</label>
<div class="toggle">
Expand Down
Loading

0 comments on commit 6e1b1ce

Please sign in to comment.