public override string ToString() { return(StartTime.ToString().PadRight(22, ' ') + " " + EndTime.ToString().PadRight(22, ' ') + " " + ProtocolFormatter(Protocol, FlagAA).PadRight(8, ' ') + " " + StateFormatter(state).PadRight(12, ' ') + " " + PartitionId.PadRight(3, ' ') + " " + LocalPort.ToString().PadRight(5 + 5, ' ') + " " + ForeignPort.ToString().PadRight(5 + 5, ' ') + " " + ForeignIp.ToString().PadRight(15, ' ') //Inbound + " " + InboundByte.ToString().PadRight(20, ' ') + " " + InboundIBBK.ToString().PadRight(20, ' ') + " " + InboundByteDup.ToString().PadRight(20, ' ') + " " + InboundIBBKDup.ToString().PadRight(20, ' ') + " " + EfficiencyFormatter(InboundEfficiency).PadRight(6 + 7, ' ') //Outbound + " " + OutboundByte.ToString().PadRight(20, ' ') + " " + OutboundIBBK.ToString().PadRight(20, ' ') + " " + OutboundByteDup.ToString().PadRight(20, ' ') + " " + OutboundIBBKDup.ToString().PadRight(20, ' ') + " " + EfficiencyFormatter(OutboundEfficiency).PadRight(6 + 8, ' ') //RECVs/SENDs + " " + RcvdSocket.ToString().PadRight(20, ' ') + " " + SendSocket.ToString().PadRight(20, ' ') + " " + MaxRecvWindow.ToString().PadRight(10 + 3, ' ') + " " + MaxSendWindow.ToString().PadRight(10 + 3, ' ') + " " + RecvWindowClosed.ToString().PadRight(20, ' ') //Other + " " + Retransmitted.ToString().PadRight(20, ' ') + " " + InRetransmitMode.ToString().PadRight(20, ' ') + " " + HighestDepth.ToString().PadRight(20, ' ') + " " + Sws.ToString().PadRight(20, ' ')); //+ " " + LocalCallFormatter(localCall).PadRight(3 + 4, ' ') }
/// <inheritdoc/> public override Task <IFilterResult> Filter(CommittedEvent @event, PartitionId partitionId, EventProcessorId eventProcessorId, string failureReason, uint retryCount, ExecutionContext executionContext, CancellationToken cancellationToken) => Filter(@event, partitionId, eventProcessorId, executionContext, cancellationToken);
static FailingPartitionState failing_partition(PartitionId partition_id) => result.FailingPartitions[partition_id];
/// <inheritdoc/> public abstract Task <IFilterResult> Filter(CommittedEvent @event, PartitionId partitionId, EventProcessorId eventProcessorId, CancellationToken cancellationToken);
protected bool Equals(InstanceIdentifier other) { return(PartitionId.Equals(other.PartitionId) && InstanceId == other.InstanceId); }
private WatermarkMap FilterOutNotExistingDCs(IEnumerable <ReplicationCursor> adReplicationCursorCollection, PartitionId partitionId) { WatermarkMap watermarkMap = new WatermarkMap(); ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 336, "FilterOutNotExistingDCs", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\Sync\\BackSync\\MergePageToken.cs"); WatermarkMap watermarkMap2 = null; ADServer adserver = topologyConfigurationSession.FindDCByInvocationId(base.WatermarksInvocationId); if (adserver != null) { topologyConfigurationSession.DomainController = adserver.DnsHostName; watermarkMap2 = SyncConfiguration.GetReplicationCursors(topologyConfigurationSession); } foreach (ReplicationCursor replicationCursor in adReplicationCursorCollection) { if (watermarkMap2 == null || watermarkMap2.ContainsKey(replicationCursor.SourceInvocationId)) { watermarkMap[replicationCursor.SourceInvocationId] = replicationCursor.UpToDatenessUsn; } } return(watermarkMap); }
// Token: 0x060012D4 RID: 4820 RVA: 0x0003D290 File Offset: 0x0003B490 internal static string CreateKeyForPsws(SecurityIdentifier userSid, Microsoft.Exchange.Configuration.Core.AuthenticationType authenticationType, PartitionId partitionId) { ExAssert.RetailAssert(userSid != null, "The user sid is invalid (null)."); return(string.Format("{0}:{1}:{2}", authenticationType, partitionId, userSid.Value)); }
/// <summary> /// Serializes the object to JSON. /// </summary> /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param> /// <param name="value">The object to serialize to JSON.</param> public static void Serialize(JsonWriter writer, PartitionId value) { writer.WriteValue(value.ToString()); }
public ISession OpenSession(ShardId shardId, PartitionId partitionId) { var factory = GetSessionFactory(shardId); return(OpenSession(factory, shardId, partitionId)); }
bool TryGetKey(ProjectionEventSelector eventSelector, CommittedEvent @event, PartitionId partition, out ProjectionKey key) => PartitionIsKey(eventSelector.KeySelectorType, partition, out key) || EventSourceIsKey(eventSelector.KeySelectorType, @event.EventSource, out key) || PropertyIsKey(eventSelector.KeySelectorType, @event.Content, eventSelector.KeySelectorExpression, out key) || StaticIsKey(eventSelector.KeySelectorType, eventSelector.StaticKey, out key) || OccurredIsKey(eventSelector.KeySelectorType, eventSelector.OccurredFormat, @event.Occurred, out key);
public bool TryGetFor(ProjectionDefinition projectionDefinition, CommittedEvent @event, PartitionId partition, out ProjectionKey key) { key = null; var eventSelector = projectionDefinition.Events.FirstOrDefault(_ => _.EventType == @event.Type.Id); return(eventSelector != null && TryGetKey(eventSelector, @event, partition, out key)); }
// Token: 0x06000013 RID: 19 RVA: 0x00002980 File Offset: 0x00000B80 internal static bool TryResolveCurrentUserInLocalForest(IPrincipal user, TraceSource traceSrc, out string tenantName) { tenantName = null; ADRawEntry adrawEntry = null; if (user != null) { SecurityIdentifier securityIdentifier = null; PartitionId partitionId = null; GenericSidIdentity genericSidIdentity = user.Identity as GenericSidIdentity; if (genericSidIdentity != null) { securityIdentifier = genericSidIdentity.Sid; if (!string.IsNullOrEmpty(genericSidIdentity.PartitionId)) { PartitionId.TryParse(genericSidIdentity.PartitionId, out partitionId); } } else { WindowsIdentity windowsIdentity = user.Identity as WindowsIdentity; if (windowsIdentity != null) { securityIdentifier = windowsIdentity.User; } } if (securityIdentifier != null) { Logger.LogVerbose(traceSrc, "User sid is {0}.", new object[] { securityIdentifier.ToString() }); try { adrawEntry = UserTokenStaticHelper.GetADRawEntry(partitionId, null, securityIdentifier); goto IL_11E; } catch (TransientException exception) { Logger.LogError(LiveIdRedirectionModule.eventLogger, traceSrc, "Failed to map user sid to an AD-Account with the following transient error {0}.", exception, new ExEventLog.EventTuple?(TaskEventLogConstants.Tuple_LiveIdRedirection_FailedWindowsIdMapping), securityIdentifier.ToString()); goto IL_11E; } catch (DataSourceOperationException exception2) { Logger.LogError(LiveIdRedirectionModule.eventLogger, traceSrc, "Failed to map user sid to an AD-Account with the following error {0}.", exception2, new ExEventLog.EventTuple?(TaskEventLogConstants.Tuple_LiveIdRedirection_FailedWindowsIdMapping), securityIdentifier.ToString()); goto IL_11E; } catch (DataValidationException exception3) { Logger.LogError(LiveIdRedirectionModule.eventLogger, traceSrc, "Failed to map user sid to an AD-Account with the following error {0}.", exception3, new ExEventLog.EventTuple?(TaskEventLogConstants.Tuple_LiveIdRedirection_FailedWindowsIdMapping), securityIdentifier.ToString()); goto IL_11E; } } Logger.LogWarning(traceSrc, "Identity in the context is not valid. It should be either GenericSidIdentity or WindowsIdentity."); } else { Logger.LogWarning(traceSrc, "Context.User is null."); } IL_11E: if (adrawEntry != null) { Logger.LogVerbose(traceSrc, "User SMTP address resolved from AD {0}.", new object[] { (SmtpAddress)adrawEntry[ADRecipientSchema.WindowsLiveID] }); ADObjectId adobjectId = (ADObjectId)adrawEntry[ADObjectSchema.OrganizationalUnitRoot]; if (adobjectId != null) { tenantName = adobjectId.Name; Logger.LogVerbose(traceSrc, "User Tenant Name resolved from AD {0}.", new object[] { tenantName }); } } return adrawEntry != null; }
async Task <IProcessingResult> HandleResult(IFilterResult result, CommittedEvent @event, PartitionId partitionId, CancellationToken cancellationToken) { _logger.HandleFilterResult(Identifier, Scope, @event.Type.Id, partitionId); if (!result.Succeeded) { _logger.FailedToFilterEvent(Identifier, Scope, @event.Type.Id); return(result); } if (!result.IsIncluded) { return(result); } _logger.FilteredEventIsIncluded(Identifier, Scope, @event.Type.Id, partitionId, Definition.TargetStream); try { await _eventsToStreamsWriter.Write(@event, Scope, Definition.TargetStream, result.Partition, cancellationToken).ConfigureAwait(false); return(result); } catch (Exception ex) { return(new FailedFiltering($"Failed to write filtered event to stream {ex}", true, TimeSpan.FromSeconds(10))); } }
internal static void ValidateCertificateSubject(MultiValuedProperty <X509Identifier> certificateSubjects, PartitionId partitionId, ADObjectId excludeObjectId, Task.TaskErrorLoggingDelegate errorLogger) { if (errorLogger == null) { throw new ArgumentNullException("errorLogger"); } ADSessionSettings sessionSettings; if (partitionId != null) { sessionSettings = ADSessionSettings.FromAllTenantsPartitionId(partitionId); } else { sessionSettings = ADSessionSettings.FromRootOrgScopeSet(); } IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.PartiallyConsistent, sessionSettings, 220, "ValidateCertificateSubject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\LinkedUser\\NewLinkedUser.cs"); tenantOrRootOrgRecipientSession.UseGlobalCatalog = true; if (certificateSubjects != null && certificateSubjects.Count != 0) { foreach (X509Identifier x509Identifier in certificateSubjects) { QueryFilter queryFilter = ADUser.GetCertificateMatchFilter(x509Identifier); if (excludeObjectId != null) { queryFilter = new AndFilter(new QueryFilter[] { queryFilter, new ComparisonFilter(ComparisonOperator.NotEqual, ADObjectSchema.Id, excludeObjectId) }); } ADRecipient[] array = tenantOrRootOrgRecipientSession.Find(null, QueryScope.SubTree, queryFilter, null, 1); if (array != null && array.Length > 0) { errorLogger(new RecipientTaskException(Strings.ErrorDuplicateCertificateSubject(x509Identifier.ToString())), ErrorCategory.InvalidArgument, excludeObjectId); } } } }
/// <inheritdoc/> public mongoDB.StreamEvent ToStoreStreamEvent(CommittedEvent committedEvent, StreamPosition streamPosition, PartitionId partition) => new mongoDB.StreamEvent( streamPosition, partition, committedEvent.ExecutionContext.ToStoreRepresentation(), committedEvent.GetStreamEventMetadata(), committedEvent.GetAggregateMetadata(), committedEvent.GetEventHorizonMetadata(), BsonDocument.Parse(committedEvent.Content));
/// <inheritdoc/> public async Task Write(CommittedEvent @event, ScopeId scope, StreamId stream, PartitionId partition, CancellationToken cancellationToken) { _logger.Trace("Writing Event: {EventLogSequenceNumber} to Stream: {Stream} in Scope: {Scope}", @event.EventLogSequenceNumber, stream, scope); await Write( await _streams.Get(scope, stream, cancellationToken).ConfigureAwait(false), _streamFilter, streamPosition => @event is CommittedExternalEvent externalEvent? _eventConverter.ToStoreStreamEvent(externalEvent, streamPosition, partition) : _eventConverter.ToStoreStreamEvent(@event, streamPosition, partition), cancellationToken).ConfigureAwait(false); }
/// <summary> /// Initializes a new instance of the <see cref="StreamEventInWrongPartition"/> class. /// </summary> /// <param name="event">The <see cref="StreamEvent"/> with the wrong <see cref="PartitionId"/>.</param> /// <param name="expectedPartitionId">The expected <see cref="PartitionId"/>.</param> public StreamEventInWrongPartition(StreamEvent @event, PartitionId expectedPartitionId) : base($"Expected Event at Position: {@event.Position} in Stream: '{@event.Stream}' to be in Partition: '{expectedPartitionId}' but was in Partition: {@event.Partition}") { }
internal static ADRawEntry FindUserEntry(SecurityIdentifier userSid, WindowsIdentity windowsIdentity, SerializedIdentity serializedIdentity, PartitionId partitionId) { ADRawEntry result; using (new MonitoredScope("FindUserEntry", "FindUserEntry", AuthZLogHelper.AuthZPerfMonitors)) { ADSessionSettings sessionSettings; if (partitionId != null) { sessionSettings = ADSessionSettings.FromAllTenantsPartitionId(partitionId); } else { sessionSettings = ADSessionSettings.FromRootOrgScopeSet(); } IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, sessionSettings, 817, "FindUserEntry", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\rbac\\ExchangeAuthorizationPlugin.cs"); ADRawEntry adrawEntry = tenantOrRootOrgRecipientSession.FindMiniRecipientBySid <MiniRecipient>(userSid, ExchangeRunspaceConfiguration.userPropertyArray); if (adrawEntry == null && VariantConfiguration.InvariantNoFlightingSnapshot.CmdletInfra.ServiceAccountForest.Enabled) { adrawEntry = PartitionDataAggregator.GetMiniRecipientFromUserId(userSid, ExchangeRunspaceConfiguration.userPropertyArray, ConsistencyMode.IgnoreInvalid); } if (adrawEntry == null) { ExTraceGlobals.AccessDeniedTracer.TraceWarning <SecurityIdentifier, string>(0L, "EAP.FindUserEntry user {0} could not be found in AD, partitionId: {1}", userSid, (partitionId == null) ? "null" : partitionId.ToString()); adrawEntry = ExchangeRunspaceConfiguration.TryFindComputer(userSid); } if (adrawEntry == null && (windowsIdentity != null || serializedIdentity != null)) { ExTraceGlobals.AccessDeniedTracer.TraceWarning <SecurityIdentifier>(0L, "EAP.FindUserEntry computer {0} could not be found in AD", userSid); IIdentity identity = (windowsIdentity != null) ? windowsIdentity : serializedIdentity; ICollection <SecurityIdentifier> groupAccountsSIDs = identity.GetGroupAccountsSIDs(); tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 850, "FindUserEntry", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\rbac\\ExchangeAuthorizationPlugin.cs"); List <ADObjectId> list = null; if (ExchangeRunspaceConfiguration.TryFindLinkedRoleGroupsBySidList(tenantOrRootOrgRecipientSession, groupAccountsSIDs, identity.Name, out list)) { adrawEntry = new ADUser { RemotePowerShellEnabled = true }; } } result = adrawEntry; } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="SuccessfulFiltering"/> class. /// </summary> /// <param name="isIncluded">Is event included in filter.</param> /// <param name="partitionId">The <see cref="PartitionId" /> />.</param> public SuccessfulFiltering(bool isIncluded, PartitionId partitionId) { IsIncluded = isIncluded; Partition = partitionId; IsPartitioned = true; }
async Task <StreamProcessorState> RemoveFailingPartition(IStreamProcessorId streamProcessorId, StreamProcessorState oldState, PartitionId partition, CancellationToken cancellationToken) { var newFailingPartitions = oldState.FailingPartitions; newFailingPartitions.Remove(partition); var newState = new StreamProcessorState(oldState.Position, newFailingPartitions, oldState.LastSuccessfullyProcessed); oldState.FailingPartitions.Remove(partition); await PersistNewState(streamProcessorId, newState, cancellationToken).ConfigureAwait(false); return(newState); }
static void Main(string[] args) { string folderPath = @"<FolderPath>"; string connectionString = File.ReadAllText(folderPath + "connectionString.txt"); string containerName = File.ReadAllLines(folderPath + "containerName.txt")[0]; // A simple local test for application with one service and one partition. string backupPolicyName = "bp2"; DateTime startDateTime = DateTime.Now - TimeSpan.FromMinutes(1); DateTime endDateTime = DateTime.Now + TimeSpan.FromMinutes(4); string[] backupPolicyNameList = new string[] { "bp0", "bp1", "bp2", "bp3" }; Uri clusterUrl = new Uri(@"http://azureicmspydev.fareast.corp.microsoft.com:19080"); var client = new ServiceFabricHttpClient(clusterUrl); ApplicationName appName = new ApplicationName("fabric:/Stateful1Application"); string appId = "Stateful1Application"; string serviceId = "Stateful1Application/Stateful1"; ServiceName serviceName = new ServiceName("fabric:/Stateful1Application/Stateful1"); EnableBackupDescription enableBackupDescription = new EnableBackupDescription(backupPolicyName); List <string> partitionIdList = new List <string>(); var serviceInfoList = client.Services.GetServiceInfoListAsync(appId).GetAwaiter().GetResult(); foreach (var serviceInfo in serviceInfoList.Data) { Console.WriteLine("{0}: FindingThe partitions for service {1}", DateTime.UtcNow, serviceInfo.Id); var servicePartitionInfoList = client.Partitions.GetPartitionInfoListAsync(serviceInfo.Id).GetAwaiter().GetResult(); foreach (var servicePartitionInfo in servicePartitionInfoList.Data) { partitionIdList.Add(servicePartitionInfo.PartitionInformation.Id.ToString()); } } PartitionId partitionId = new PartitionId(new Guid(partitionIdList[0])); try { // Create a storage account and add the connection string and container name here. Task <BackupProgressInfo> backupProgressInfoTask = client.BackupRestore.GetPartitionBackupProgressAsync(partitionId); List <DateTime?> timeSpanList = new List <DateTime?>(); timeSpanList.Add(DateTime.UtcNow); TimeSpan.Parse("12:20:00"); FrequencyBasedBackupScheduleDescription newBackupScheduleDescription = new FrequencyBasedBackupScheduleDescription(TimeSpan.FromMinutes(1)); TimeBasedBackupScheduleDescription timebasedBackupSchedule = new TimeBasedBackupScheduleDescription(BackupScheduleFrequencyType.Daily, (IEnumerable <DateTime?>)timeSpanList); FileShareBackupStorageDescription backupStorageDescription = new FileShareBackupStorageDescription("\\\\bpc1\\backupPolicy2", "fr1"); AzureBlobBackupStorageDescription azureBlobStorageDescription = new AzureBlobBackupStorageDescription(connectionString, containerName, "fr2"); int counter = 0; foreach (var bpn in backupPolicyNameList) { if (counter % 2 != 0) { BackupPolicyDescription addingBackupPolicyDescription = new BackupPolicyDescription(bpn, true, 10, timebasedBackupSchedule, backupStorageDescription); try { client.BackupRestore.CreateBackupPolicyAsync(addingBackupPolicyDescription).GetAwaiter().GetResult(); } catch (Exception ex) { if (ex.Message == "Fabric Backup Policy already exists.") { continue; } else { throw ex; } } } else { BasicRetentionPolicyDescription rtd = new BasicRetentionPolicyDescription(TimeSpan.FromHours(2)); BackupPolicyDescription addingBackupPolicyDescription = new BackupPolicyDescription(bpn, true, 10, newBackupScheduleDescription, azureBlobStorageDescription, rtd); try { client.BackupRestore.CreateBackupPolicyAsync(addingBackupPolicyDescription).GetAwaiter().GetResult(); } catch (Exception ex) { if (ex.Message == "Fabric Backup Policy already exists.") { continue; } else { throw ex; } } } counter++; } // Updating bp1 with retention. BasicRetentionPolicyDescription rtdnew = new BasicRetentionPolicyDescription(TimeSpan.FromHours(4)); BackupPolicyDescription addingBackupPolicyDescriptionWithRetention = new BackupPolicyDescription("bp1", true, 10, timebasedBackupSchedule, backupStorageDescription, rtdnew); client.BackupRestore.UpdateBackupPolicyAsync(addingBackupPolicyDescriptionWithRetention, "bp1").GetAwaiter().GetResult(); var backupPolicybp1 = client.BackupRestore.GetBackupPolicyByNameAsync("bp1").GetAwaiter().GetResult(); Console.WriteLine("backupPolicybp1 is {0}", backupPolicybp1.Name); Console.WriteLine("backupPolicybp1's retentiontype is {0}", backupPolicybp1.RetentionPolicy.RetentionPolicyType.ToString()); var backupPolicylist = client.BackupRestore.GetBackupPolicyListAsync().GetAwaiter().GetResult(); if (backupPolicylist.Data.Count() != 4) { throw new Exception("Backup Policy count should be 4"); } client.BackupRestore.DeleteBackupPolicyAsync("bp1").GetAwaiter().GetResult(); backupPolicylist = client.BackupRestore.GetBackupPolicyListAsync().GetAwaiter().GetResult(); if (backupPolicylist.Data.Count() != 3) { throw new Exception("Backup Policy count should be 3"); } client.BackupRestore.EnableApplicationBackupAsync(appId, enableBackupDescription).GetAwaiter().GetResult(); enableBackupDescription = new EnableBackupDescription(backupPolicyNameList[0]); client.BackupRestore.EnableServiceBackupAsync(serviceId, enableBackupDescription).GetAwaiter().GetResult(); enableBackupDescription = new EnableBackupDescription(backupPolicyNameList[2]); Task.Delay(TimeSpan.FromMinutes(2)); var allBackupEnablements = client.BackupRestore.GetAllEntitiesBackedUpByPolicyAsync(backupPolicyName).GetAwaiter().GetResult(); if (allBackupEnablements.Data.Count() != 2) { throw new Exception("Here all the enablements should be 2."); } client.BackupRestore.EnablePartitionBackupAsync(partitionId, enableBackupDescription).GetAwaiter().GetResult(); allBackupEnablements = client.BackupRestore.GetAllEntitiesBackedUpByPolicyAsync(backupPolicyName).GetAwaiter().GetResult(); if (allBackupEnablements.Data.Count() != 3) { throw new Exception("Here all the enablements should be 3."); } System.Threading.Thread.Sleep(20000); var getPartitionBackupProgress = client.BackupRestore.GetPartitionBackupProgressAsync(partitionId).GetAwaiter().GetResult(); Console.WriteLine("BackupState of partitionID {0}, is {1}", partitionId, getPartitionBackupProgress.BackupState); var bpZero = client.BackupRestore.GetBackupPolicyByNameAsync("bp3").GetAwaiter().GetResult(); if (bpZero.Schedule.ScheduleKind != BackupScheduleKind.TimeBased) { throw new Exception("Schedule kind must be Time based."); } var getServiceBackupListAsync = client.BackupRestore.GetServiceBackupListAsync(serviceId).GetAwaiter().GetResult(); var getPartitionBackupListAsync = client.BackupRestore.GetPartitionBackupListAsync(partitionId).GetAwaiter().GetResult(); BackupPolicyDescription addingNewBackupPolicyDescription = new BackupPolicyDescription("bp0", true, 20, newBackupScheduleDescription, backupStorageDescription); client.BackupRestore.UpdateBackupPolicyAsync(addingNewBackupPolicyDescription, "bp0").GetAwaiter().GetResult(); bpZero = client.BackupRestore.GetBackupPolicyByNameAsync("bp0").GetAwaiter().GetResult(); if (bpZero.Schedule.ScheduleKind != BackupScheduleKind.FrequencyBased) { throw new Exception("Schedule kind must be frequency based."); } var getPartitionBackupConfiguationInfo = client.BackupRestore.GetPartitionBackupConfigurationInfoAsync(partitionId).GetAwaiter().GetResult(); if (getPartitionBackupConfiguationInfo.PolicyName != backupPolicyName) { throw new Exception("Configured policy name is not correct."); } client.BackupRestore.SuspendPartitionBackupAsync(partitionId).GetAwaiter().GetResult(); var getParititionBackupConfiguationInfo = client.BackupRestore.GetPartitionBackupConfigurationInfoAsync(partitionId).GetAwaiter().GetResult(); if (getParititionBackupConfiguationInfo.SuspensionInfo.IsSuspended == null || getParititionBackupConfiguationInfo.SuspensionInfo.IsSuspended == false) { throw new Exception("The partition is not suspended till now which is not correct."); } client.BackupRestore.ResumePartitionBackupAsync(partitionId).GetAwaiter().GetResult(); getParititionBackupConfiguationInfo = client.BackupRestore.GetPartitionBackupConfigurationInfoAsync(partitionId).GetAwaiter().GetResult(); if (getParititionBackupConfiguationInfo.SuspensionInfo.IsSuspended != null && getParititionBackupConfiguationInfo.SuspensionInfo.IsSuspended == true) { throw new Exception("We have resumed the partition backup. but it is not reflected here."); } client.BackupRestore.SuspendApplicationBackupAsync(appId).GetAwaiter().GetResult(); var getServiceBackupConfiguationInfo = client.BackupRestore.GetServiceBackupConfigurationInfoAsync(serviceId).GetAwaiter().GetResult(); if (getServiceBackupConfiguationInfo.Data.Count() != 2) { throw new Exception("Expected service backup mapping is 2"); } if (getServiceBackupConfiguationInfo.Data.First().SuspensionInfo.IsSuspended != true) { throw new Exception("backup suspension inherited from application level. Which is not working here."); } var getAppBackupConfiguationInfo = client.BackupRestore.GetApplicationBackupConfigurationInfoAsync(appId).GetAwaiter().GetResult(); if (getAppBackupConfiguationInfo.Data.Count() != 3) { throw new Exception("Expected service backup mapping is 3"); } if (getAppBackupConfiguationInfo.Data.First().SuspensionInfo.IsSuspended != true) { throw new Exception("backup suspension inherited from application level. Which is not working here."); } client.BackupRestore.ResumeApplicationBackupAsync(appId).GetAwaiter().GetResult(); client.BackupRestore.SuspendServiceBackupAsync(serviceId).GetAwaiter().GetResult(); getServiceBackupConfiguationInfo = client.BackupRestore.GetServiceBackupConfigurationInfoAsync(serviceId).GetAwaiter().GetResult(); if (getServiceBackupConfiguationInfo.Data.Count() != 2) { throw new Exception("Expected service backup mapping is 2"); } client.BackupRestore.ResumeServiceBackupAsync(serviceId).GetAwaiter().GetResult(); client.BackupRestore.ResumePartitionBackupAsync(partitionId).GetAwaiter().GetResult(); DisableBackupDescription disableBackupDescription = new DisableBackupDescription(false); client.BackupRestore.DisablePartitionBackupAsync(partitionId).GetAwaiter().GetResult(); allBackupEnablements = client.BackupRestore.GetAllEntitiesBackedUpByPolicyAsync(backupPolicyName).GetAwaiter().GetResult(); if (allBackupEnablements.Data.Count() != 2) { throw new Exception("Here all the enablements should be 2."); } ApplicationBackupEntity applicationBackupEntity = new ApplicationBackupEntity(appName); GetBackupByStorageQueryDescription getBackupByStorageQueryDescription = new GetBackupByStorageQueryDescription(backupStorageDescription, applicationBackupEntity); var getBackupFromBackupLocations = client.BackupRestore.GetBackupsFromBackupLocationAsync(getBackupByStorageQueryDescription).GetAwaiter().GetResult(); Console.WriteLine("BackupCount {0}", getBackupFromBackupLocations.Data.Count()); getAppBackupConfiguationInfo = client.BackupRestore.GetApplicationBackupConfigurationInfoAsync(appId).GetAwaiter().GetResult(); if (getAppBackupConfiguationInfo.Data.First().PolicyName != backupPolicyName) { throw new Exception("Configured policy name is not correct."); } getServiceBackupConfiguationInfo = client.BackupRestore.GetServiceBackupConfigurationInfoAsync(serviceId).GetAwaiter().GetResult(); client.BackupRestore.DisableServiceBackupAsync(serviceId).GetAwaiter().GetResult(); var getApplicationBackupList = client.BackupRestore.GetApplicationBackupListAsync(appId, 120).GetAwaiter().GetResult(); if (getApplicationBackupList.ContinuationToken.Next) { throw new Exception("continutionToken received must be null"); } getApplicationBackupList = client.BackupRestore.GetApplicationBackupListAsync(appId, 120, false, null, null, null, 10).GetAwaiter().GetResult(); if (getApplicationBackupList.Data.Count() > 10) { throw new Exception("the count should be less than 10"); } getApplicationBackupList = client.BackupRestore.GetApplicationBackupListAsync(appId, 120, false, startDateTime, endDateTime, null).GetAwaiter().GetResult(); foreach (var backupEnumeration in getApplicationBackupList.Data) { string path = backupEnumeration.BackupLocation; string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path); DateTime fileDateTime = DateTime.ParseExact(fileNameWithoutExtension + "Z", "yyyy-MM-dd HH.mm.ssZ", CultureInfo.InvariantCulture); if (fileDateTime < startDateTime || fileDateTime > endDateTime) { throw new Exception("DateTime filter is not working"); } } BackupInfo latestBackupInfo = client.BackupRestore.GetPartitionBackupListAsync(partitionId, 60, true).GetAwaiter().GetResult().Data.ToList()[0]; DateTime partitionReqStartTime = DateTime.UtcNow; RestorePartitionDescription restorePartitionDescription = new RestorePartitionDescription(latestBackupInfo.BackupId, latestBackupInfo.BackupLocation); client.BackupRestore.RestorePartitionAsync(partitionId, restorePartitionDescription).GetAwaiter().GetResult(); while (true) { var restoreProgress = client.BackupRestore.GetPartitionRestoreProgressAsync(partitionId).GetAwaiter().GetResult(); if (restoreProgress.RestoreState == RestoreState.Success || restoreProgress.RestoreState == RestoreState.Failure || restoreProgress.RestoreState == RestoreState.Timeout) { Console.WriteLine(string.Format("{0}: Restore stress for partitions {1} is completed with the restoreState is {2}", DateTime.UtcNow, partitionId, restoreProgress.RestoreState.ToString())); //Console.WriteLine("{0}: Restore stress for partitions {1} is completed with the restoreState is {2}", DateTime.UtcNow, partitionId, restoreProgress.RestoreState.ToString()); break; } else { if (restoreProgress.RestoreState == RestoreState.Accepted) { Console.WriteLine(string.Format("{0}: restoreState is Accepted of partitionId {1}, so increasing counter {2} and waiting for restore to complete.", DateTime.UtcNow, partitionId, counter)); counter++; } } Task.Delay(20000).GetAwaiter().GetResult(); } BackupPartitionDescription bpd = new BackupPartitionDescription(backupStorageDescription); client.BackupRestore.BackupPartitionAsync(partitionId, bpd).GetAwaiter().GetResult(); var backupPartitionProgress = client.BackupRestore.GetPartitionBackupProgressAsync(partitionId).GetAwaiter().GetResult(); Console.WriteLine("BackupProgress for the partition {0}, is {1}", partitionId.ToString(), backupPartitionProgress.BackupState); Console.WriteLine("APIs are working correctly"); } finally { try { DisableBackupDescription disableBackupDescription = new DisableBackupDescription(false); client.BackupRestore.DisableApplicationBackupAsync(appId, 60, disableBackupDescription).GetAwaiter().GetResult(); } catch { } try { client.BackupRestore.DisableServiceBackupAsync(serviceId).GetAwaiter().GetResult(); } catch { } try { client.BackupRestore.DisablePartitionBackupAsync(partitionId).GetAwaiter().GetResult(); } catch { } } }
internal static partial void FilteringEventAgain(this ILogger logger, EventProcessorId filter, ScopeId scope, ArtifactId eventType, PartitionId partition, uint retryCount, FailureReason failureReason);
private bool TrySelectDomainController(ITopologyConfigurationSession session, string domainControllerFqdn, PartitionId partitionId, bool checkSuitability, out Guid resultInvocationId) { ExTraceGlobals.ActiveDirectoryTracer.TraceDebug <string>((long)base.TenantExternalDirectoryId.GetHashCode(), "MergePageToken.TrySelectDomainController dc {0}", domainControllerFqdn); resultInvocationId = Guid.Empty; string text; LocalizedString localizedString; if (checkSuitability && !SuitabilityVerifier.IsServerSuitableIgnoreExceptions(domainControllerFqdn, false, null, out text, out localizedString)) { ExTraceGlobals.ActiveDirectoryTracer.TraceWarning <string, string>((long)base.TenantExternalDirectoryId.GetHashCode(), "DC {0} is not available for Tenant Full Backsync, error {1}", domainControllerFqdn, localizedString.ToString()); return(false); } ITopologyConfigurationSession configSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainControllerFqdn, true, ConsistencyMode.IgnoreInvalid, null, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId), 461, "TrySelectDomainController", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\Sync\\BackSync\\MergePageToken.cs"); WatermarkMap replicationCursors = SyncConfiguration.GetReplicationCursors(configSession, false, true); if (replicationCursors.ContainsAllChanges(base.Watermarks)) { Guid invocationIdByFqdn = session.GetInvocationIdByFqdn(domainControllerFqdn); long num; if (base.Watermarks.TryGetValue(invocationIdByFqdn, out num)) { base.ObjectUpdateSequenceNumber = num + 1L; base.TombstoneUpdateSequenceNumber = num + 1L; base.InvocationId = invocationIdByFqdn; if (base.UseContainerizedUsnChangedIndex) { base.SoftDeletedObjectUpdateSequenceNumber = num + 1L; } ExTraceGlobals.ActiveDirectoryTracer.TraceDebug((long)base.TenantExternalDirectoryId.GetHashCode(), "DC {0}({1})has all changes reported by the Tenant Full Sync Watermarks for {2} and CAN be used. \r\nFull sync watermarks: \r\n{3}\r\nDC replication cursors: \r\n{4}", new object[] { domainControllerFqdn, base.InvocationId, base.TenantExternalDirectoryId, base.Watermarks.SerializeToString(), replicationCursors.SerializeToString() }); resultInvocationId = invocationIdByFqdn; return(true); } ExTraceGlobals.ActiveDirectoryTracer.TraceDebug((long)base.TenantExternalDirectoryId.GetHashCode(), "DC {0}({1})has all changes reported by the Tenant Full Sync Watermarks for {2} but cannot be used since its invocationId is not part of the TFS watermarks. \r\nFull sync watermarks: \r\n{3}\r\n", new object[] { domainControllerFqdn, base.InvocationId, base.TenantExternalDirectoryId, base.Watermarks.SerializeToString() }); } else { ExTraceGlobals.ActiveDirectoryTracer.TraceDebug((long)base.TenantExternalDirectoryId.GetHashCode(), "DC {0} does not have all changes reported by the Tenant Full Sync Watermarks for {1} and cannot be used. \r\nFull sync watermarks: \r\n{2}\r\nDC replication cursors: \r\n{3}", new object[] { domainControllerFqdn, base.TenantExternalDirectoryId, base.Watermarks.SerializeToString(), replicationCursors.SerializeToString() }); } return(false); }
internal static partial void HandleFilterResult(this ILogger logger, EventProcessorId filter, ScopeId scope, ArtifactId eventType, PartitionId partition);
internal TenantRelocationSyncPartitionData(OrganizationId sourceTenantOrganizationId, ADObjectId sourcePartitionRoot, PartitionId sourcePartionId) { this.OrganizationId = sourceTenantOrganizationId; this.PartitionRoot = sourcePartitionRoot; this.PartitionId = sourcePartionId; this.PartitionConfigNcRoot = this.PartitionRoot.GetChildId("Configuration"); this.IsConfigurationUnitUnderConfigNC = this.TenantConfigurationUnit.IsDescendantOf(this.PartitionConfigNcRoot); this.TenantConfigurationUnitRoot = this.TenantConfigurationUnit.Parent; }
internal static partial void FilteredEventIsIncluded(this ILogger logger, EventProcessorId filter, ScopeId scope, ArtifactId eventType, PartitionId partition, StreamId stream);
/// <inheritdoc/> public abstract Task <IFilterResult> Filter(CommittedEvent @event, PartitionId partitionId, EventProcessorId eventProcessorId, string failureReason, uint retryCount, CancellationToken cancellationToken);
internal void RebindDataSessionToDataObjectPartitionRidMasterIncludeRetiredTenants(PartitionId partitionId) { string ridMasterName = ForestTenantRelocationsCache.GetRidMasterName(partitionId); if (this.DomainController != null) { string value = this.DomainController.ToString().Split(new char[] { '.' })[0] + "."; if (!ridMasterName.StartsWith(value, StringComparison.OrdinalIgnoreCase)) { ForestTenantRelocationsCache.Reset(); base.WriteError(new InvalidOperationException(Strings.ErrorMustWriteToRidMaster(ridMasterName)), ErrorCategory.InvalidOperation, ridMasterName); } } ADSessionSettings adsessionSettings = ADSessionSettings.FromAllTenantsPartitionId(partitionId); adsessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants; adsessionSettings.RetiredTenantModificationAllowed = true; this.dataSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ridMasterName, false, ConsistencyMode.PartiallyConsistent, adsessionSettings, 1125, "RebindDataSessionToDataObjectPartitionRidMasterIncludeRetiredTenants", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\DataAccessTask.cs"); }
protected override void WriteResult(IConfigurable dataObject) { TaskLogger.LogEnter(new object[] { dataObject.Identity, dataObject }); ADOrganizationConfig adorganizationConfig = dataObject as ADOrganizationConfig; if (adorganizationConfig != null) { int?num = this.RetrieveSCLJunkThreshold(adorganizationConfig.Id); if (num != null) { adorganizationConfig.SCLJunkThreshold = num.Value; } this.FillTaskPopulatedFields(adorganizationConfig); MultiValuedProperty <OrganizationSummaryEntry> multiValuedProperty = new MultiValuedProperty <OrganizationSummaryEntry>(); foreach (OrganizationSummaryEntry organizationSummaryEntry in adorganizationConfig.OrganizationSummary) { if (OrganizationSummaryEntry.IsValidKeyForCurrentRelease(organizationSummaryEntry.Key)) { multiValuedProperty.Add(organizationSummaryEntry.Clone()); } } multiValuedProperty.ResetChangeTracking(); adorganizationConfig.OrganizationSummary = multiValuedProperty; adorganizationConfig.ResetChangeTracking(); } ADSessionSettings sessionSettings; if (this.AccountPartition == null) { sessionSettings = ADSessionSettings.RescopeToSubtree(base.OrgWideSessionSettings); } else { PartitionId partitionId = RecipientTaskHelper.ResolvePartitionId(this.AccountPartition, new Task.TaskErrorLoggingDelegate(base.WriteError)); sessionSettings = ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId); } IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, sessionSettings, 109, "WriteResult", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\organization\\GetOrganization.cs"); tenantOrRootOrgRecipientSession.UseConfigNC = true; ADMicrosoftExchangeRecipient admicrosoftExchangeRecipient = MailboxTaskHelper.FindMicrosoftExchangeRecipient(tenantOrRootOrgRecipientSession, (IConfigurationSession)base.DataSession); if (admicrosoftExchangeRecipient == null) { if (adorganizationConfig.SharedConfigurationInfo == null) { if (!this.IsOnlyGatewayServerRoleExist()) { this.WriteError(new InvalidOperationException(Strings.ErrorMicrosoftExchangeRecipientNotFound), ErrorCategory.ReadError, adorganizationConfig.Identity, false); } else { base.WriteVerbose(Strings.MicrosoftExchangeRecipientNotFoundOnGatewayServerRole); } } } else { ValidationError[] array = admicrosoftExchangeRecipient.Validate(); for (int i = 0; i < array.Length; i++) { this.WriteWarning(array[i].Description); } adorganizationConfig.MicrosoftExchangeRecipientEmailAddresses = admicrosoftExchangeRecipient.EmailAddresses; adorganizationConfig.MicrosoftExchangeRecipientReplyRecipient = admicrosoftExchangeRecipient.ForwardingAddress; adorganizationConfig.MicrosoftExchangeRecipientEmailAddressPolicyEnabled = admicrosoftExchangeRecipient.EmailAddressPolicyEnabled; adorganizationConfig.MicrosoftExchangeRecipientPrimarySmtpAddress = admicrosoftExchangeRecipient.PrimarySmtpAddress; adorganizationConfig.ResetChangeTracking(); } bool flag = !OrganizationId.ForestWideOrgId.Equals(adorganizationConfig.OrganizationId); if (flag) { MultiValuedProperty <string> multiValuedProperty2 = this.AcceptedDomainNamesGetter(adorganizationConfig); if (multiValuedProperty2 != null) { adorganizationConfig.AcceptedDomainNames = multiValuedProperty2; } } if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled) { adorganizationConfig.HierarchicalAddressBookRoot = this.GetHierarchicalAddressBookRootFromOU(adorganizationConfig.OrganizationId.OrganizationalUnit); } base.WriteResult(new OrganizationConfig(adorganizationConfig, flag)); TaskLogger.LogExit(); }
public static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Required arguments: <project-id> <message>"); return; } var projectId = args[0]; var text = args[1]; Console.WriteLine($"Using projectId = {projectId}; text = {text}"); var client = DatastoreClient.Create(); var partitionId = new PartitionId { ProjectId = projectId }; // First insert the message var entity = new Entity { Key = new Key { PartitionId = partitionId, Path = { new PathElement { Kind = "message" } } }, ["created"] = DateTime.UtcNow, ["text"] = args[1], }; var transaction = client.BeginTransaction(projectId).Transaction; var commitResponse = client.Commit(projectId, Mode.TRANSACTIONAL, transaction, new[] { entity.ToInsert() }); var insertedKey = commitResponse.MutationResults[0].Key; Console.WriteLine($"Inserted entity with key {insertedKey}"); Console.WriteLine(); // Check we can look it up... var lookupResponse = client.Lookup(projectId, null, new[] { insertedKey }); if (lookupResponse.Found.Count == 1) { var retrieved = lookupResponse.Found[0]; Console.WriteLine($"Looked up entity: {retrieved}"); Console.WriteLine(); } else { Console.WriteLine("Unable to look up inserted entity!"); Console.WriteLine(); } // Then list the first page of messages // TODO: Hook into page-streaming... var query = new Query { Limit = 20, Order = { new PropertyOrder { Direction = Direction.DESCENDING, Property = new PropertyReference{ Name = "created" } } }, Kind = { new KindExpression { Name = "message" } } }; var result = client.RunQuery(projectId, partitionId, null, query); Console.WriteLine("Query results:"); foreach (var resultEntity in result.Batch.EntityResults.Select(er => er.Entity)) { var created = (DateTime)resultEntity["created"]; var resultText = (string)resultEntity["text"]; Console.WriteLine($"{created:yyyy-MM-dd'T'HH:mm:ss'Z'}: {resultText}"); } }