private void generateSnapshotForVCSession() { foreach (var setting in m_configurationService.VcCustomSetting.Settings.Setting) { if (setting.SettingKey == "SnapshotStartPoint") { m_sessionLevelSnapshotTime = parseSnapShotStartPoint(setting.SettingValue); } } m_hwmDelta.Reload(); if (m_hwmDelta.Value >= m_sessionLevelSnapshotTime) { // We've already passed snapshot changeset Id, just return. m_sessionlevelSnapshotCompleted = true; return; } ChangeGroup snapshotGroup = createChangeGroupForSnapshot(m_sessionLevelSnapshotTime, 0); m_clearCaseServer.SetConfigSpecForSnapshotStartPoint(m_sessionLevelSnapshotTime); try { foreach (MappingEntry mappingEntry in m_configurationService.Filters) { if (mappingEntry.Cloak) { continue; } string localMappingPath = m_clearCaseServer.GetViewLocalPathFromServerPath(mappingEntry.Path); foreach (string subDirectory in Directory.GetDirectories(localMappingPath, "*", SearchOption.AllDirectories)) { createAddActionForSnapshot(snapshotGroup, subDirectory, true); } foreach (string subFile in Directory.GetFiles(localMappingPath, "*", SearchOption.AllDirectories)) { createAddActionForSnapshot(snapshotGroup, subFile, false); } } } finally { m_clearCaseServer.ResetConfigSpec(); } snapshotGroup.Save(); m_hwmDelta.Update(m_sessionLevelSnapshotTime); m_changeGroupService.PromoteDeltaToPending(); m_sessionlevelSnapshotCompleted = true; }
/// <summary> /// Generate the delta table /// </summary> public void GenerateDeltaTable() { int[] mappedChangesets = getMappedSubversionChanges(); if (null == mappedChangesets || 0 == mappedChangesets.Length) { TraceManager.TraceInformation("There are no changes in the repository '{0}'", m_repository.URI); return; } var pager = new ChangeSetPageManager(m_repository, mappedChangesets, m_configurationManager.ChangesetCacheSize); do { TraceManager.TraceInformation("Analyzing Subversion revision {0} : {1}/{2}", pager.CurrentRevision, pager.CurrentIndex + 1, mappedChangesets.Length); ChangeSet changeSet = pager.Current; if (null != changeSet) { int actions = analyzeChangeset(changeSet, mappedChangesets); TraceManager.TraceInformation("Created {0} actions for subversion revision {1}", actions, pager.CurrentRevision); } else { //TODO Maybe add a conflict here so that the user can decide what to do. This condition should not occur though TraceManager.TraceWarning("Unable to retrieve the change details for revision {0}", pager.CurrentRevision); } m_hwmDelta.Update(pager.CurrentRevision); m_changeGroupService.PromoteDeltaToPending(); }while (pager.MoveNext()); pager.Reset(); }
/// <summary> /// Generates the delta table. /// </summary> public override void GenerateDeltaTable() { string viewName = this.configurationService.Filters[0].Path; TraceManager.TraceInformation("WSSWIT:AP:GenerateDeltaTable:View - {0}", viewName); highWaterMarkDelta.Reload(); GetSharePointTaskUpdates(viewName); highWaterMarkDelta.Update(DateTime.Now); changeGroupService.PromoteDeltaToPending(); }
/// <summary> /// Generate the delta table. /// </summary> public override void GenerateDeltaTable() { TraceManager.TraceInformation("WSSVC:AP:GenerateDeltaTable"); highWaterMarkDelta.Reload(); TraceManager.TraceInformation("\tWSSVC:AP:Initial HighWaterMark {0} ", highWaterMarkDelta.Value); deltaTableStartTime = DateTime.Now; TraceManager.TraceInformation("\tWSSVC:AP:CutOff {0} ", deltaTableStartTime); GetSharePointUpdates(); highWaterMarkDelta.Update(deltaTableStartTime); TraceManager.TraceInformation("\tWSSVC:AP:Updated HighWaterMark {0} ", highWaterMarkDelta.Value); changeGroupService.PromoteDeltaToPending(); }
public override void GenerateDeltaTable() { TraceManager.TraceInformation("POC:AP:GenerateDeltaTable"); m_hwmDelta.Reload(); TraceManager.TraceInformation(" POC:HighWaterMark {0} ", m_hwmDelta.Value); deltaTableStartTime = DateTime.Now; TraceManager.TraceInformation(" POC:CutOff {0} ", deltaTableStartTime); ReadOnlyCollection <MappingEntry> filters = ConfigurationService.Filters; GetPocUpdates(filters[0].Path); m_hwmDelta.Update(deltaTableStartTime); m_changeGroupService.PromoteDeltaToPending(); }
/// <summary> /// Generate the delta table /// </summary> public void GenerateDeltaTable() { // Load the current high water mark from any previous run of this session m_hwmDelta.Reload(); m_renameList = null; m_renameListUpdated = false; // Removing the in-progress change groups created by this side (fils system) m_changeGroupService.RemoveInProgressChangeGroups(); if (m_changeGroupService.GetInProgressMigrationInstructionCount() > 0) { // If there are in-progress migration instructions translated from the other side, mark this delta table as contentcon flict detection only. m_contentConflictDetectionOnly = true; TraceManager.TraceInformation("Migration instruction in progress, the delta table will be generated for content conflict detection only"); } else { m_contentConflictDetectionOnly = false; } DateTime newHighWaterMarkTime = DateTime.Now; List <String> pathsToBeVerified = new List <String>(); int versionToBeSynced = 0; // In a two-way sync, versionToBeSynced is set to the last sync point - either the latest changeset migrated from TFS or the latest changeset migrated to TFS // In one way sync, versionToBeSynced is always set to the GetLatestChangesetId of TFS if (m_hwmLastSyncedTfsChangeset != null) { // m_hwmLastSyncedTfsChangeset is the latest TFS changeset migrated to the file system side. // This highwater mark will be set when TfsFileSystemAnalysisProvider is combined with another provider to form a two-way sync. m_hwmLastSyncedTfsChangeset.Reload(); // m_lastHighWaterMarkMigratedToPeer is the latest TFS changeset migrated from this TfsFileSystemAnalysisProvider. m_lastHighWaterMarkMigratedToPeer.Reload(); versionToBeSynced = m_lastHighWaterMarkMigratedToPeer.Value > m_hwmLastSyncedTfsChangeset.Value ? m_lastHighWaterMarkMigratedToPeer.Value : m_hwmLastSyncedTfsChangeset.Value; } else { versionToBeSynced = m_destinationTfs.GetLatestChangesetId(); } FileSystemVerifier fileSystemVerifier = new FileSystemVerifier(); ChangeGroup changeGroup = m_changeGroupService.CreateChangeGroupForDeltaTable(DateTime.Now.ToString()); populateChangeGroupMetaData(changeGroup); foreach (MappingEntry m in ConfigurationService.Filters) { if (m.Cloak) { continue; } string canonicalPath = removeTrailingSlash(m.Path); fileSystemVerifier.AddPathForVerification(canonicalPath); analyzeFolder(canonicalPath, versionToBeSynced, changeGroup); } if (!fileSystemVerifier.Verify()) { TraceManager.TraceError( "Analysis failed as the local file system state was changed during the analysis phase. No changes were created."); markChangeGroupAsObsolete(changeGroup); return; } if (changeGroup.Actions.Count > 0) { // We only want to promote deltas to pending if we actually created and saved a change group. changeGroup.Save(); m_changeGroupService.PromoteDeltaToPending(); } else { markChangeGroupAsObsolete(changeGroup); } m_lastTfsChangesetAnalyzed.Update(versionToBeSynced); m_hwmDelta.Update(newHighWaterMarkTime); TraceManager.TraceInformation(String.Format(CultureInfo.InvariantCulture, TfsFileSystemResources.UpdatedHighWaterMark, newHighWaterMarkTime)); }
public void GenerateDeltaTable() { try { if (!m_isLoginUserSQLEditor) { ValidateIsSQLEditor(); m_isLoginUserSQLEditor = true; } // load high watermark; as for CQ, we store local time for queries m_hwmDelta.Reload(); DateTime hwmDeltaValue = m_hwmDelta.Value; if (hwmDeltaValue.Equals(default(DateTime))) { hwmDeltaValue = new DateTime(1900, 1, 1); } hwmDeltaValue = hwmDeltaValue.AddSeconds(-1); // go back 1 second as we'll drop the millisec below m_migrationContext.CurrentHWMBaseLine = hwmDeltaValue; // HACK HACK HACK //string hwmDeltaValueStr = hwmDeltaValue.ToString("o"); // using "ISO 8601" DateTime string format string hwmDeltaValueStr = hwmDeltaValue.ToString("u").Replace("Z", ""); // using "ISO 8601" DateTime string format if (hwmDeltaValueStr.LastIndexOf('.') >= 0) { hwmDeltaValueStr = hwmDeltaValueStr.Substring(0, hwmDeltaValueStr.LastIndexOf('.')); // drop the millisec } // HACK HACK HACK DateTime newHwmValue = DateTime.Now; foreach (CQRecordFilter filter in m_filters) { ComputeDeltaPerRecordType(filter, hwmDeltaValueStr); } // persist results and hwm TraceManager.TraceInformation("Promote delta to pending."); m_changeGroupService.PromoteDeltaToPending(); m_hwmDelta.Update(newHwmValue); TraceManager.TraceInformation("Persisted CQ HWM: {0}", ClearQuestConstants.CqRecordHwm); TraceManager.TraceInformation("Updated CQ HWM: {0}", newHwmValue.ToString()); } catch (ClearQuestInsufficientPrivilegeException privEx) { ConflictResolutionResult rslt = UtilityMethods.HandleInsufficientPriviledgeException(privEx, m_conflictManagerService); if (rslt.Resolved) { // todo: currently not expected, as we only enabled manual/skip resolution action } } catch (ClearQuestCOMDllNotFoundException cqComNotFoundEx) { UtilityMethods.HandleCOMDllNotFoundException(cqComNotFoundEx, ErrorManager, m_conflictManagerService); } catch (ClearQuestCOMCallException cqComCallEx) { UtilityMethods.HandleCQComCallException(cqComCallEx, ErrorManager, m_conflictManagerService); } catch (Exception ex) { ErrorManager errMgr = null; if (m_analysisServiceContainer != null) { errMgr = m_analysisServiceContainer.GetService(typeof(ErrorManager)) as ErrorManager; } UtilityMethods.HandleGeneralException(ex, errMgr, m_conflictManagerService); } }
/// <summary> /// Create a changegroup that contains all change actions needed to bring a migration target to the specificed snapshot /// </summary> /// <param name="changeGroupName">The change group name of the snapshot</param> private void generateSnapshotForVCSession() { foreach (var setting in ConfigurationService.VcCustomSetting.Settings.Setting) { if (setting.SettingKey == "SnapshotStartPoint") { m_sessionLevelSnapshotChangeset = parseSnapShotStartPoint(setting.SettingValue); } else if (setting.SettingKey == "SnapshotBatchSize") { try { m_snapshotCheckinBatchSize = int.Parse(setting.SettingValue); } catch (Exception) { // wrong format, use the default batch size } } } m_hwmDelta.Reload(); if (m_hwmDelta.Value >= m_sessionLevelSnapshotChangeset) { // We've already passed snapshot changeset Id, just return. m_sessionlevelSnapshotCompleted = true; return; } VersionSpec snapshotVersionSpec = new ChangesetVersionSpec(m_sessionLevelSnapshotChangeset); List <string> pathsToGet = new List <string>(); foreach (MappingEntry mappingEntry in ConfigurationService.Filters) { if (mappingEntry.Cloak) { continue; } // Always query at one level down the mapping ItemSet itemSet = m_tfsClient.GetItems(mappingEntry.Path, snapshotVersionSpec, RecursionType.OneLevel); Item[] items = itemSet.Items; foreach (Item childItem in items) { // Avoid the item itself. if (!VersionControlPath.Equals(childItem.ServerItem, mappingEntry.Path)) { pathsToGet.Add(childItem.ServerItem); } } } int countDownToCreateNewChangeGroup = m_snapshotCheckinBatchSize; int batchExecutionOrder = m_sessionLevelSnapshotChangeset; ChangeGroup batchGroup = createChangeGroupForSnapshot(m_sessionLevelSnapshotChangeset, batchExecutionOrder); foreach (string path in pathsToGet) { TraceManager.TraceInformation("Getting snapshot at changeset: {0}, path: {1}", m_sessionLevelSnapshotChangeset, path); ItemSet itemSet = m_tfsClient.GetItems(path, snapshotVersionSpec, RecursionType.Full); Item[] items = itemSet.Items; itemSet = null; TraceManager.TraceInformation("Snapshot contains {0} items", items.Length); for (int i = 0; i < items.Length; i++) { // We want to include the situation where a snapshot on a path is the same as the snapshot of the VC session. // In this situation, we want to include the item in the session snapshot changeset. // So we use changesetId + 1 as the reference changeset id. if (IsPathMapped(items[i].ServerItem, m_sessionLevelSnapshotChangeset + 1) == MappingResult.Mapped) { countDownToCreateNewChangeGroup--; if (countDownToCreateNewChangeGroup == 0) { TraceManager.TraceInformation("Saving {0} change actions", m_snapshotCheckinBatchSize); batchGroup.Save(); batchGroup.Actions.Clear(); batchGroup = null; batchExecutionOrder--; batchGroup = createChangeGroupForSnapshot(m_sessionLevelSnapshotChangeset, batchExecutionOrder); countDownToCreateNewChangeGroup = m_snapshotCheckinBatchSize; TraceManager.TraceInformation("Saved {0} change actions", m_snapshotCheckinBatchSize); } batchGroup.CreateAction( WellKnownChangeActionId.Add, new TfsMigrationItem(items[i]), null, items[i].ServerItem, null, null, TfsAnalysisAlgorithms.convertContentType(items[i].ItemType), null); } items[i] = null; // Dispose this object to reduce memory consumption. } } if (batchGroup.Actions.Count > 0) { int numRemainingItems = batchGroup.Actions.Count; TraceManager.TraceInformation("Saving {0} change actions", numRemainingItems); batchGroup.Save(); TraceManager.TraceInformation("Saved {0} change actions", numRemainingItems); } m_hwmDelta.Update(m_sessionLevelSnapshotChangeset); m_changeGroupService.PromoteDeltaToPending(); m_sessionlevelSnapshotCompleted = true; }
private void generateSnapshotForVCSession() { foreach (var setting in m_configurationService.VcCustomSetting.Settings.Setting) { if (setting.SettingKey == "SnapshotStartPoint") { m_sessionLevelSnapshotTime = parseSnapShotStartPoint(setting.SettingValue); } } m_hwmDelta.Reload(); if (m_hwmDelta.Value >= m_sessionLevelSnapshotTime) { // We've already passed snapshot changeset Id, just return. m_sessionlevelSnapshotCompleted = true; return; } ChangeGroup snapshotGroup = createChangeGroupForSnapshot(m_sessionLevelSnapshotTime, 0); m_clearCaseServer.SetConfigSpecForSnapshotStartPoint(m_sessionLevelSnapshotTime); try { foreach (MappingEntry mappingEntry in m_configurationService.Filters) { if (mappingEntry.Cloak) { continue; } string localMappingPath = m_clearCaseServer.GetViewLocalPathFromServerPath(mappingEntry.Path); foreach (string subDirectory in Directory.GetDirectories(localMappingPath, "*", SearchOption.AllDirectories)) { string serverPath = m_clearCaseServer.GetServerPathFromViewLocalPath(subDirectory); snapshotGroup.CreateAction( WellKnownChangeActionId.Add, new ClearCaseMigrationItem( m_clearCaseServer.ViewName, m_clearCaseServer.ApplicationClass.get_Element(serverPath).Version.ExtendedPath, true), null, serverPath, null, null, WellKnownContentType.VersionControlledFolder.ReferenceName, null); } foreach (string subFile in Directory.GetFiles(localMappingPath, "*", SearchOption.AllDirectories)) { string serverPath = m_clearCaseServer.GetServerPathFromViewLocalPath(subFile); snapshotGroup.CreateAction( WellKnownChangeActionId.Add, new ClearCaseMigrationItem( m_clearCaseServer.ViewName, m_clearCaseServer.ApplicationClass.get_Element(serverPath).Version.ExtendedPath, true), null, serverPath, null, null, WellKnownContentType.VersionControlledFile.ReferenceName, null); } } } finally { m_clearCaseServer.ResetConfigSpec(); } snapshotGroup.Save(); m_hwmDelta.Update(m_sessionLevelSnapshotTime); m_changeGroupService.PromoteDeltaToPending(); m_sessionlevelSnapshotCompleted = true; }