Skip to content

Commit

Permalink
Merge pull request #128 from microsoft/sf_10_1
Browse files Browse the repository at this point in the history
10_1 updates
  • Loading branch information
jeffj6123 authored Jan 5, 2024
2 parents 1a24444 + fe5c642 commit 07ccdd8
Show file tree
Hide file tree
Showing 15 changed files with 342 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ internal class DeactivationIntentConverter
{
obj = DeactivationIntent.RemoveData;
}
else if (string.Compare(value, "RemoveNode", StringComparison.OrdinalIgnoreCase) == 0)
{
obj = DeactivationIntent.RemoveNode;
}

return obj;
}
Expand All @@ -60,6 +64,9 @@ public static void Serialize(JsonWriter writer, DeactivationIntent? value)
case DeactivationIntent.RemoveData:
writer.WriteStringValue("RemoveData");
break;
case DeactivationIntent.RemoveNode:
writer.WriteStringValue("RemoveNode");
break;
default:
throw new ArgumentException($"Invalid value {value.ToString()} for enum type DeactivationIntent");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ internal static ServiceLoadMetricDescription GetFromJsonProperties(JsonReader re
var primaryDefaultLoad = default(int?);
var secondaryDefaultLoad = default(int?);
var auxiliaryDefaultLoad = default(int?);
var maximumLoad = default(int?);
var defaultLoad = default(int?);

do
Expand All @@ -63,6 +64,10 @@ internal static ServiceLoadMetricDescription GetFromJsonProperties(JsonReader re
{
auxiliaryDefaultLoad = reader.ReadValueAsInt();
}
else if (string.Compare("MaximumLoad", propName, StringComparison.OrdinalIgnoreCase) == 0)
{
maximumLoad = reader.ReadValueAsInt();
}
else if (string.Compare("DefaultLoad", propName, StringComparison.OrdinalIgnoreCase) == 0)
{
defaultLoad = reader.ReadValueAsInt();
Expand All @@ -80,6 +85,7 @@ internal static ServiceLoadMetricDescription GetFromJsonProperties(JsonReader re
primaryDefaultLoad: primaryDefaultLoad,
secondaryDefaultLoad: secondaryDefaultLoad,
auxiliaryDefaultLoad: auxiliaryDefaultLoad,
maximumLoad: maximumLoad,
defaultLoad: defaultLoad);
}

Expand Down Expand Up @@ -109,6 +115,11 @@ internal static void Serialize(JsonWriter writer, ServiceLoadMetricDescription o
writer.WriteProperty(obj.AuxiliaryDefaultLoad, "AuxiliaryDefaultLoad", JsonWriterExtensions.WriteIntValue);
}

if (obj.MaximumLoad != null)
{
writer.WriteProperty(obj.MaximumLoad, "MaximumLoad", JsonWriterExtensions.WriteIntValue);
}

if (obj.DefaultLoad != null)
{
writer.WriteProperty(obj.DefaultLoad, "DefaultLoad", JsonWriterExtensions.WriteIntValue);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------

namespace Microsoft.ServiceFabric.Client.Http.Serialization
{
using System;
using System.Collections.Generic;
using Microsoft.ServiceFabric.Common;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

/// <summary>
/// Converter for <see cref="ServiceSensitivityDescription" />.
/// </summary>
internal class ServiceSensitivityDescriptionConverter
{
/// <summary>
/// Deserializes the JSON representation of the object.
/// </summary>
/// <param name="reader">The <see cref="T: Newtonsoft.Json.JsonReader" /> to read from.</param>
/// <returns>The object Value.</returns>
internal static ServiceSensitivityDescription Deserialize(JsonReader reader)
{
return reader.Deserialize(GetFromJsonProperties);
}

/// <summary>
/// Gets the object from Json properties.
/// </summary>
/// <param name="reader">The <see cref="T: Newtonsoft.Json.JsonReader" /> to read from, reader must be placed at first property.</param>
/// <returns>The object Value.</returns>
internal static ServiceSensitivityDescription GetFromJsonProperties(JsonReader reader)
{
var primaryDefaultSensitivity = default(int?);
var secondaryDefaultSensitivity = default(int?);
var auxiliaryDefaultSensitivity = default(int?);
var isMaximumSensitivity = default(bool?);

do
{
var propName = reader.ReadPropertyName();
if (string.Compare("PrimaryDefaultSensitivity", propName, StringComparison.OrdinalIgnoreCase) == 0)
{
primaryDefaultSensitivity = reader.ReadValueAsInt();
}
else if (string.Compare("SecondaryDefaultSensitivity", propName, StringComparison.OrdinalIgnoreCase) == 0)
{
secondaryDefaultSensitivity = reader.ReadValueAsInt();
}
else if (string.Compare("AuxiliaryDefaultSensitivity", propName, StringComparison.OrdinalIgnoreCase) == 0)
{
auxiliaryDefaultSensitivity = reader.ReadValueAsInt();
}
else if (string.Compare("IsMaximumSensitivity", propName, StringComparison.OrdinalIgnoreCase) == 0)
{
isMaximumSensitivity = reader.ReadValueAsBool();
}
else
{
reader.SkipPropertyValue();
}
}
while (reader.TokenType != JsonToken.EndObject);

return new ServiceSensitivityDescription(
primaryDefaultSensitivity: primaryDefaultSensitivity,
secondaryDefaultSensitivity: secondaryDefaultSensitivity,
auxiliaryDefaultSensitivity: auxiliaryDefaultSensitivity,
isMaximumSensitivity: isMaximumSensitivity);
}

/// <summary>
/// Serializes the object to JSON.
/// </summary>
/// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param>
/// <param name="obj">The object to serialize to JSON.</param>
internal static void Serialize(JsonWriter writer, ServiceSensitivityDescription obj)
{
// Required properties are always serialized, optional properties are serialized when not null.
writer.WriteStartObject();
if (obj.PrimaryDefaultSensitivity != null)
{
writer.WriteProperty(obj.PrimaryDefaultSensitivity, "PrimaryDefaultSensitivity", JsonWriterExtensions.WriteIntValue);
}

if (obj.SecondaryDefaultSensitivity != null)
{
writer.WriteProperty(obj.SecondaryDefaultSensitivity, "SecondaryDefaultSensitivity", JsonWriterExtensions.WriteIntValue);
}

if (obj.AuxiliaryDefaultSensitivity != null)
{
writer.WriteProperty(obj.AuxiliaryDefaultSensitivity, "AuxiliaryDefaultSensitivity", JsonWriterExtensions.WriteIntValue);
}

if (obj.IsMaximumSensitivity != null)
{
writer.WriteProperty(obj.IsMaximumSensitivity, "IsMaximumSensitivity", JsonWriterExtensions.WriteBoolValue);
}

writer.WriteEndObject();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ internal static StatefulServiceDescription GetFromJsonProperties(JsonReader read
var dropSourceReplicaOnMove = default(bool?);
var replicaLifecycleDescription = default(ReplicaLifecycleDescription);
var auxiliaryReplicaCount = default(int?);
var serviceSensitivityDescription = default(ServiceSensitivityDescription);

do
{
Expand Down Expand Up @@ -172,6 +173,10 @@ internal static StatefulServiceDescription GetFromJsonProperties(JsonReader read
{
auxiliaryReplicaCount = reader.ReadValueAsInt();
}
else if (string.Compare("ServiceSensitivityDescription", propName, StringComparison.OrdinalIgnoreCase) == 0)
{
serviceSensitivityDescription = ServiceSensitivityDescriptionConverter.Deserialize(reader);
}
else
{
reader.SkipPropertyValue();
Expand Down Expand Up @@ -206,7 +211,8 @@ internal static StatefulServiceDescription GetFromJsonProperties(JsonReader read
servicePlacementTimeLimitSeconds: servicePlacementTimeLimitSeconds,
dropSourceReplicaOnMove: dropSourceReplicaOnMove,
replicaLifecycleDescription: replicaLifecycleDescription,
auxiliaryReplicaCount: auxiliaryReplicaCount);
auxiliaryReplicaCount: auxiliaryReplicaCount,
serviceSensitivityDescription: serviceSensitivityDescription);
}

/// <summary>
Expand Down Expand Up @@ -322,6 +328,11 @@ internal static void Serialize(JsonWriter writer, StatefulServiceDescription obj
writer.WriteProperty(obj.AuxiliaryReplicaCount, "AuxiliaryReplicaCount", JsonWriterExtensions.WriteIntValue);
}

if (obj.ServiceSensitivityDescription != null)
{
writer.WriteProperty(obj.ServiceSensitivityDescription, "ServiceSensitivityDescription", ServiceSensitivityDescriptionConverter.Serialize);
}

writer.WriteEndObject();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ internal static StatefulServiceUpdateDescription GetFromJsonProperties(JsonReade
var dropSourceReplicaOnMove = default(bool?);
var replicaLifecycleDescription = default(ReplicaLifecycleDescription);
var auxiliaryReplicaCount = default(int?);
var serviceSensitivityDescription = default(ServiceSensitivityDescription);

do
{
Expand Down Expand Up @@ -132,6 +133,10 @@ internal static StatefulServiceUpdateDescription GetFromJsonProperties(JsonReade
{
auxiliaryReplicaCount = reader.ReadValueAsInt();
}
else if (string.Compare("ServiceSensitivityDescription", propName, StringComparison.OrdinalIgnoreCase) == 0)
{
serviceSensitivityDescription = ServiceSensitivityDescriptionConverter.Deserialize(reader);
}
else
{
reader.SkipPropertyValue();
Expand All @@ -158,7 +163,8 @@ internal static StatefulServiceUpdateDescription GetFromJsonProperties(JsonReade
servicePlacementTimeLimitSeconds: servicePlacementTimeLimitSeconds,
dropSourceReplicaOnMove: dropSourceReplicaOnMove,
replicaLifecycleDescription: replicaLifecycleDescription,
auxiliaryReplicaCount: auxiliaryReplicaCount);
auxiliaryReplicaCount: auxiliaryReplicaCount,
serviceSensitivityDescription: serviceSensitivityDescription);
}

/// <summary>
Expand Down Expand Up @@ -262,6 +268,11 @@ internal static void Serialize(JsonWriter writer, StatefulServiceUpdateDescripti
writer.WriteProperty(obj.AuxiliaryReplicaCount, "AuxiliaryReplicaCount", JsonWriterExtensions.WriteIntValue);
}

if (obj.ServiceSensitivityDescription != null)
{
writer.WriteProperty(obj.ServiceSensitivityDescription, "ServiceSensitivityDescription", ServiceSensitivityDescriptionConverter.Serialize);
}

writer.WriteEndObject();
}
}
Expand Down
15 changes: 12 additions & 3 deletions src/Microsoft.ServiceFabric.Common/Generated/DeactivationIntent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,27 @@ namespace Microsoft.ServiceFabric.Common
public enum DeactivationIntent
{
/// <summary>
/// Indicates that the node should be paused. The value is 1.
/// Indicates that the node should be paused. You might specify this setting to debug replicas that run on the node.
/// The value is 1.
/// </summary>
Pause,

/// <summary>
/// Indicates that the intent is for the node to be restarted after a short period of time. The value is 2.
/// Indicates that the intent is for the node to be restarted after a short period of time. You might specify this
/// setting when a node restart is required for installing a patch. The value is 2.
/// </summary>
Restart,

/// <summary>
/// Indicates the intent is for the node to remove data. The value is 3.
/// Indicates the intent is for the node to remove data. You might specify this setting when the hard disk is being
/// reimaged. The value is 3.
/// </summary>
RemoveData,

/// <summary>
/// Indicates that the data on the node is to be permanently lost. You might specify this setting when the node is
/// being removed from the cluster. The value is 4.
/// </summary>
RemoveNode,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial class DeactivationIntentDescription
/// </summary>
/// <param name="deactivationIntent">Describes the intent or reason for deactivating the node. The possible values are
/// following.
/// . Possible values include: 'Pause', 'Restart', 'RemoveData'</param>
/// . Possible values include: 'Pause', 'Restart', 'RemoveData', 'RemoveNode'</param>
/// <param name="deactivationDescription">Describes the reason or more information about node deactivation. Maximum
/// number of characters allowed is 200.</param>
public DeactivationIntentDescription(
Expand All @@ -31,7 +31,7 @@ public DeactivationIntentDescription(

/// <summary>
/// Gets the intent or reason for deactivating the node. The possible values are following.
/// . Possible values include: 'Pause', 'Restart', 'RemoveData'
/// . Possible values include: 'Pause', 'Restart', 'RemoveData', 'RemoveNode'
/// </summary>
public DeactivationIntent? DeactivationIntent { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public partial class ServiceLoadMetricDescription
/// this service creates for this metric when it is a Secondary replica.</param>
/// <param name="auxiliaryDefaultLoad">Used only for Stateful services. The default amount of load, as a number, that
/// this service creates for this metric when it is an Auxiliary replica.</param>
/// <param name="maximumLoad">Sets the upper bound on the service load to support collocation of multiple max
/// sensitivity replicas. Loads reported above this value will be ignored.</param>
/// <param name="defaultLoad">Used only for Stateless services. The default amount of load, as a number, that this
/// service creates for this metric.</param>
public ServiceLoadMetricDescription(
Expand All @@ -38,6 +40,7 @@ public ServiceLoadMetricDescription(
int? primaryDefaultLoad = default(int?),
int? secondaryDefaultLoad = default(int?),
int? auxiliaryDefaultLoad = default(int?),
int? maximumLoad = default(int?),
int? defaultLoad = default(int?))
{
name.ThrowIfNull(nameof(name));
Expand All @@ -46,6 +49,7 @@ public ServiceLoadMetricDescription(
this.PrimaryDefaultLoad = primaryDefaultLoad;
this.SecondaryDefaultLoad = secondaryDefaultLoad;
this.AuxiliaryDefaultLoad = auxiliaryDefaultLoad;
this.MaximumLoad = maximumLoad;
this.DefaultLoad = defaultLoad;
}

Expand Down Expand Up @@ -82,6 +86,12 @@ public ServiceLoadMetricDescription(
/// </summary>
public int? AuxiliaryDefaultLoad { get; }

/// <summary>
/// Gets sets the upper bound on the service load to support collocation of multiple max sensitivity replicas. Loads
/// reported above this value will be ignored.
/// </summary>
public int? MaximumLoad { get; }

/// <summary>
/// Gets used only for Stateless services. The default amount of load, as a number, that this service creates for this
/// metric.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------

namespace Microsoft.ServiceFabric.Common
{
using System;
using System.Collections.Generic;

/// <summary>
/// Describes sensitivities for different types of replicas.
/// </summary>
public partial class ServiceSensitivityDescription
{
/// <summary>
/// Initializes a new instance of the ServiceSensitivityDescription class.
/// </summary>
/// <param name="primaryDefaultSensitivity">Default sensitivity for a primary replica.</param>
/// <param name="secondaryDefaultSensitivity">Default sensitivity for a secondary replica.</param>
/// <param name="auxiliaryDefaultSensitivity">Default sensitivity for an auxiliary replica.</param>
/// <param name="isMaximumSensitivity">Denotes whether the sensitivities should be set to maximum. If true, other
/// values are ignored.</param>
public ServiceSensitivityDescription(
int? primaryDefaultSensitivity = default(int?),
int? secondaryDefaultSensitivity = default(int?),
int? auxiliaryDefaultSensitivity = default(int?),
bool? isMaximumSensitivity = default(bool?))
{
this.PrimaryDefaultSensitivity = primaryDefaultSensitivity;
this.SecondaryDefaultSensitivity = secondaryDefaultSensitivity;
this.AuxiliaryDefaultSensitivity = auxiliaryDefaultSensitivity;
this.IsMaximumSensitivity = isMaximumSensitivity;
}

/// <summary>
/// Gets default sensitivity for a primary replica.
/// </summary>
public int? PrimaryDefaultSensitivity { get; }

/// <summary>
/// Gets default sensitivity for a secondary replica.
/// </summary>
public int? SecondaryDefaultSensitivity { get; }

/// <summary>
/// Gets default sensitivity for an auxiliary replica.
/// </summary>
public int? AuxiliaryDefaultSensitivity { get; }

/// <summary>
/// Gets denotes whether the sensitivities should be set to maximum. If true, other values are ignored.
/// </summary>
public bool? IsMaximumSensitivity { get; }
}
}
Loading

0 comments on commit 07ccdd8

Please sign in to comment.