/// <summary> /// Creates <see cref="JobBlockingPolicyManager"/>. /// Specify <see cref="oldVersionedPropertyStore"/> when IS is used in a multi-tenant cluster (E.g. RP cluster) /// where each IS service communicates with one FC. In that case, we want individual job blocking policies for each IS service. /// If this parameter is <c>null</c>, then the same job blocking policy is shared across all IS services in a multi-tenant cluster. /// </summary> public static async Task <IJobBlockingPolicyManager> CreateAsync( TraceType traceType, IVersionedPropertyStore versionedPropertyStore, IVersionedPropertyStore oldVersionedPropertyStore = null) { traceType.Validate("traceType"); versionedPropertyStore.Validate("versionedPropertyStore"); traceType.WriteInfo("Starting creation of {0}", typeof(JobBlockingPolicyManager).Name); var manager = new JobBlockingPolicyManager(versionedPropertyStore); var activityId = Guid.NewGuid(); var versionedKeyValue = await ReadPropertyAsync(traceType, versionedPropertyStore, activityId).ConfigureAwait(false); if (versionedKeyValue == null) { string defaultPolicyValue = JobBlockingPolicy.BlockNone.ToString(); if (oldVersionedPropertyStore != null) { var oldVersionedKeyValue = await ReadPropertyAsync(traceType, oldVersionedPropertyStore, activityId).ConfigureAwait(false); if (oldVersionedKeyValue != null) { defaultPolicyValue = oldVersionedKeyValue.Value; } traceType.WriteInfo( "{0} properties '{1}={2}' and '{3}' {4} newer versioned property store.", oldVersionedKeyValue != null ? "Migrating" : "Creating", PolicyPropertyName, defaultPolicyValue, PolicyVersionName, oldVersionedKeyValue != null ? "to" : "in"); } try { await versionedPropertyStore.UpdateValueAsync( activityId, PolicyPropertyName, PolicyVersionName, defaultPolicyValue).ConfigureAwait(false); } catch (FabricException ex) { if (ex.ErrorCode != FabricErrorCode.WriteConflict) { traceType.WriteError("Properties '{0}' and '{1}' could not be updated. Exception: {2}", PolicyPropertyName, PolicyVersionName, ex); throw; } } } traceType.WriteInfo("Successfully created {0}", typeof(JobBlockingPolicyManager).Name); return(manager); }
public static COMException CreateException(this TraceType traceType, NativeTypes.FABRIC_ERROR_CODE error, string format, params object[] args) { string message = string.Format(CultureInfo.InvariantCulture, format, args); var exception = new COMException(message, (int)error); traceSource.WriteExceptionAsWarningWithId(traceType.Name, traceType.Id, exception, string.Empty); return(exception); }
public LinearRetryPolicy( TraceType traceType, TimeSpan deltaBackoff, int maxAttempts) { traceType.ThrowIfNull("traceType"); this.traceType = traceType; this.DeltaBackoff = deltaBackoff; this.MaxAttempts = maxAttempts; }
private VersionedPropertyStore( TraceType traceType, Uri storeName, IPropertyManagerWrapper propertyManager, IRetryPolicyFactory retryPolicyFactory) { this.traceType = traceType; this.storeName = storeName; this.propertyManager = propertyManager; this.retryPolicyFactory = retryPolicyFactory; }
public LinearRetryPolicyFactory( TraceType traceType, int backoffPeriodInMilliseconds, int maxRetryAttempts, Func <Exception, bool> shouldRetry) { traceType.ThrowIfNull("traceType"); shouldRetry.ThrowIfNull("shouldRetry"); this.traceType = traceType; this.backoffPeriodInMilliseconds = backoffPeriodInMilliseconds; this.maxRetryAttempts = maxRetryAttempts; this.shouldRetry = shouldRetry; }
public static async Task <IVersionedPropertyStore> CreateAsync( Guid activityId, TraceType traceType, Uri storeName, IPropertyManagerWrapper propertyManager, IRetryPolicyFactory retryPolicyFactory) { traceType.Validate("traceType"); storeName.Validate("storeName"); propertyManager.Validate("propertyManager"); retryPolicyFactory.Validate("retryPolicyFactory"); var store = new VersionedPropertyStore(traceType, storeName, propertyManager, retryPolicyFactory); await store.InitializeStoreNameAsync(activityId).ConfigureAwait(false); return(store); }
/// <summary> /// Writes an aggregated event for consumption by listeners (e.g. TraceViewer). /// Here, the typeNameSuffix and key parameter combination has to be distinct for each event. /// If they are the same, then DCA will forward only the last event. /// So, don't use this for dumping snapshot views. (i.e. poll every x seconds and dump state) /// Instead use this for dumping state changes where you can tolerate loss of this message downstream. /// </summary> /// <remarks> /// Also, use this only for low volume data since DCA has to handle a distinct Id each time at the VM level. /// </remarks> /// <example> /// traceType.WriteAggregatedEvent( /// "CompletedRepairTask" /// "Azure/PlatformMaintenance/1e56e313-0e1e-47d0-85f2-9f75e4833a4f/4/5644" /// "{0}", /// repairTask.ToJson()); /// </example> public static void WriteAggregatedEvent( this TraceType traceType, string typeNameSuffix, string key, string format, params object[] args) { traceType.Validate("traceType"); typeNameSuffix.Validate("typeNameSuffix"); key.Validate("key"); // E.g. WARP-Prod-CDM-CDM05PrdApp01@CompletedRepairTask@Azure/PlatformMaintenance/1e56e313-0e1e-47d0-85f2-9f75e4833a4f/4/5644 string id = "{0}@{1}@{2}".ToString(traceType.Id, typeNameSuffix, key); string message = string.Format(CultureInfo.InvariantCulture, format, args); // this shows up in TraceViewer under the Type column as // InfrastructureServiceAggregatedEvent@WARP-Prod-CDM-CDM05PrdApp01@CompletedRepairTask@Azure/PlatformMaintenance/1e56e313-0e1e-47d0-85f2-9f75e4833a4f/4/5644 FabricEvents.Events.InfrastructureServiceAggregatedEvent(id, message); }
private static async Task <IVersionedKeyValue> ReadPropertyAsync( TraceType traceType, IVersionedPropertyStore versionedPropertyStore, Guid activityId) { try { var versionedKeyValue = await versionedPropertyStore .GetValueAsync(activityId, PolicyPropertyName, PolicyVersionName, false) .ConfigureAwait(false); return(versionedKeyValue); } catch (FabricElementNotFoundException ex) { traceType.WriteInfo( "Properties '{0}' and '{1}' not found. These need to be created. Exception: {2}", PolicyPropertyName, PolicyVersionName, ex); } return(null); }
public ConfigSection(TraceType traceType, IConfigStore configStore, string configSectionName) { this.traceType = traceType.Validate("traceType"); this.ConfigStore = configStore.Validate("configStore"); this.Name = configSectionName.Validate("configSectionName"); }
public static void ConsoleWriteLine(this TraceType traceType, string format, params object[] args) { traceSource.WriteInfoWithId(traceType.Name, traceType.Id, format, args); Console.WriteLine(format, args); }
public static void WriteError(this TraceType traceType, string format, params object[] args) { traceSource.WriteErrorWithId(traceType.Name, traceType.Id, format, args); ConditionalConsoleWriteLine(format, args); }
public ServiceFabricQueryClient(TraceType traceType) { this.traceType = traceType.Validate("traceType"); }
public CommandHandler(TraceType traceType) { this.traceType = traceType.Validate("traceType"); Commands = new Dictionary <string, CommandHandlerEntry>(StringComparer.OrdinalIgnoreCase); }