-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve documentation and performance of CSync #283
Open
Enquier
wants to merge
7
commits into
develop
Choose a base branch
from
bugfix/performance
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+106
−65
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d8f7cae
add enriched svg capability back to MDK
Enquier 60ca27d
replace twcId inside svg
Enquier 90a2420
minor tweaks for 2021x compatibility
Enquier 9f8b5cd
continue to improve runner documentation and performance
Enquier 136eccd
fix javafx
Enquier 83dc174
fix branch validation/twcIds
Enquier eb74079
Merge commit '50f44ca842999b7ef106b0c33b00755a926ea6d7' into bugfix/p…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
import com.nomagic.magicdraw.openapi.uml.SessionManager; | ||
import com.nomagic.task.ProgressStatus; | ||
import com.nomagic.task.RunnableWithProgress; | ||
import com.nomagic.ui.ProgressStatusRunner; | ||
import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; | ||
import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ValueSpecification; | ||
import org.openmbee.mdk.api.incubating.MDKConstants; | ||
|
@@ -59,12 +60,16 @@ public DeltaSyncRunner(boolean shouldCommit, boolean shouldCommitDeletes, boolea | |
this.shouldCommit = shouldCommit; | ||
this.shouldCommitDeletes = shouldCommitDeletes; | ||
this.shouldUpdate = shouldUpdate; | ||
} | ||
|
||
} | ||
@SuppressWarnings("unchecked") | ||
@Override | ||
public void run(ProgressStatus progressStatus) { | ||
progressStatus.setDescription("Initializing"); | ||
progressStatus.setDescription("Coordinated Sync: Initializing"); | ||
progressStatus.setCurrent(0); | ||
progressStatus.setIndeterminate(false); | ||
progressStatus.setMax(15); | ||
progressStatus.cancelIfCanceled(); | ||
if (ProjectUtilities.isFromEsiServer(project.getPrimaryProject()) && EsiUtils.getLoggedUserName() == null) { | ||
Utils.guilog("[WARNING] You need to be logged in to Teamwork Cloud first. Skipping sync. All changes will be persisted in the model and re-attempted in the next sync."); | ||
return; | ||
|
@@ -78,9 +83,13 @@ public void run(ProgressStatus progressStatus) { | |
Utils.guilog("[ERROR] An error occurred while validating credentials. Credentials will be cleared. Skipping sync. All changes will be persisted in the model and re-attempted in the next sync. Reason: " + e.getMessage()); | ||
return; | ||
} | ||
progressStatus.increase(); | ||
progressStatus.setDescription("Coordinated Sync: Project Validation"); | ||
progressStatus.cancelIfCanceled(); | ||
|
||
ProjectValidator pv = new ProjectValidator(project); | ||
pv.validate(); | ||
ProgressStatusRunner.runWithProgressStatus(pv, "Coordinated Sync: Project Validation", true, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the reason why it's starting a new runner instead of calling pv.run(progressStatus) because it's changing to indeterminate? |
||
|
||
if (pv.hasErrors()) { | ||
Application.getInstance().getGUILog().log("[WARNING] Coordinated Sync can not complete and will be skipped."); | ||
return; | ||
|
@@ -90,9 +99,12 @@ public void run(ProgressStatus progressStatus) { | |
Utils.displayValidationWindow(project, pv.getValidationSuite(), "Coordinated Sync Pre-Condition Validation"); | ||
return; | ||
} | ||
|
||
BranchValidator bv = new BranchValidator(project); | ||
bv.validate(null, false); | ||
progressStatus.increase(); | ||
progressStatus.setDescription("Coordinated Sync: Branch Validation"); | ||
progressStatus.cancelIfCanceled(); | ||
|
||
BranchValidator bv = new BranchValidator(project, false); | ||
ProgressStatusRunner.runWithProgressStatus(bv, "Coordinated Sync: Branch Validation", true, 0); | ||
if (bv.hasErrors()) { | ||
Application.getInstance().getGUILog().log("[WARNING] Coordinated sync can not complete and will be skipped."); | ||
return; | ||
|
@@ -102,15 +114,16 @@ public void run(ProgressStatus progressStatus) { | |
Utils.displayValidationWindow(project, bv.getValidationSuite(), "Coordinated Sync Pre-Condition Validation"); | ||
return; | ||
} | ||
|
||
progressStatus.increase(); | ||
LocalDeltaTransactionCommitListener listener = LocalDeltaProjectEventListenerAdapter.getProjectMapping(project).getLocalDeltaTransactionCommitListener(); | ||
|
||
// UPDATE LOCKS | ||
|
||
listener.setDisabled(true); | ||
|
||
// UPDATE MMS CHANGELOG | ||
|
||
progressStatus.setDescription("Coordinated Sync: Updating Server Changelog"); | ||
progressStatus.cancelIfCanceled(); | ||
try { | ||
if (!MMSDeltaProjectEventListenerAdapter.getProjectMapping(project).update()) { | ||
Application.getInstance().getGUILog().log("[WARNING] MMS history is unavailable. Skipping sync. All changes will be re-attempted in the next sync."); | ||
|
@@ -121,9 +134,10 @@ public void run(ProgressStatus progressStatus) { | |
e.printStackTrace(); | ||
return; | ||
} | ||
|
||
progressStatus.increase(); | ||
// BUILD COMPLETE LOCAL CHANGELOG | ||
|
||
progressStatus.setDescription("Coordinated Sync: Building Local Changelog"); | ||
progressStatus.cancelIfCanceled(); | ||
Changelog<String, Element> persistedLocalChangelog = new Changelog<>(); | ||
Collection<SyncElement> persistedLocalSyncElements = SyncElements.getAllByType(project, SyncElement.Type.LOCAL); | ||
for (SyncElement syncElement : persistedLocalSyncElements) { | ||
|
@@ -154,8 +168,10 @@ else if (value instanceof Element) { | |
localUpdated = localChangelog.get(Changelog.ChangeType.UPDATED), | ||
localDeleted = localChangelog.get(Changelog.ChangeType.DELETED); | ||
|
||
progressStatus.increase(); | ||
// BUILD COMPLETE MMS CHANGELOG | ||
|
||
progressStatus.setDescription("Coordinated Sync: Building Server Changelog"); | ||
progressStatus.cancelIfCanceled(); | ||
Changelog<String, Void> persistedMmsChangelog = new Changelog<>(); | ||
Collection<SyncElement> persistedMmsSyncElements = SyncElements.getAllByType(project, SyncElement.Type.MMS); | ||
for (SyncElement syncElement : persistedMmsSyncElements) { | ||
|
@@ -177,9 +193,9 @@ else if (value instanceof Element) { | |
Map<String, ObjectNode> mmsJsons = new HashMap<>(elementIdsToGet.size()); | ||
|
||
// Get latest json for element added/changed from MMS | ||
|
||
progressStatus.increase(); | ||
if (!elementIdsToGet.isEmpty()) { | ||
progressStatus.setDescription("Getting " + elementIdsToGet.size() + " added/changed element" + (elementIdsToGet.size() != 1 ? "s" : "") + " from MMS"); | ||
progressStatus.setDescription("Coordinated Sync: Getting " + elementIdsToGet.size() + " added/changed element" + (elementIdsToGet.size() != 1 ? "s" : "") + " from MMS"); | ||
File responseFile; | ||
ObjectNode response; | ||
try { | ||
|
@@ -220,8 +236,8 @@ else if (value instanceof Element) { | |
} | ||
|
||
// NEW CONFLICT DETECTION | ||
|
||
progressStatus.setDescription("Detecting conflicts"); | ||
progressStatus.increase(); | ||
progressStatus.setDescription("Coordinated Sync: Detecting conflicts"); | ||
Map<String, Pair<Changelog.Change<Element>, Changelog.Change<Void>>> conflictedChanges = new LinkedHashMap<>(), | ||
unconflictedChanges = new LinkedHashMap<>(); | ||
localChangelog.findConflicts(mmsChangelog, (change, change2) -> change != null && change2 != null, conflictedChanges, unconflictedChanges); | ||
|
@@ -305,13 +321,13 @@ else if (shouldUpdate && mmsChange != null) { | |
} | ||
|
||
// POINT OF NO RETURN | ||
|
||
progressStatus.increase(); | ||
// COMMIT UNCONFLICTED CREATIONS AND UPDATES TO MMS | ||
String projectId = Converters.getIProjectToIdConverter().apply(project.getPrimaryProject()); | ||
String refId = MDUtils.getBranchId(project); | ||
boolean shouldLogNoLocalChanges = shouldCommit; | ||
if (shouldCommit && !localElementsToPost.isEmpty()) { | ||
progressStatus.setDescription("Committing creations and updates to MMS"); | ||
progressStatus.setDescription("Coordinated Sync: Committing creations and updates to MMS"); | ||
LinkedList<ObjectNode> postElements = new LinkedList<>(); | ||
for (Element element : localElementsToPost.values()) { | ||
ObjectNode elementObjectNode = Converters.getElementToJsonConverter().apply(element, project); | ||
|
@@ -345,12 +361,12 @@ else if (shouldUpdate && mmsChange != null) { | |
shouldLogNoLocalChanges = false; | ||
} | ||
} | ||
|
||
progressStatus.increase(); | ||
// COMMIT UNCONFLICTED DELETIONS TO MMS | ||
// NEEDS TO BE AFTER LOCAL; EX: MOVE ELEMENT OUT ON MMS, DELETE OWNER LOCALLY, WHAT HAPPENS? | ||
|
||
if (shouldCommit && shouldCommitDeletes && !deleteElements.isEmpty()) { | ||
progressStatus.setDescription("Committing deletions to MMS"); | ||
progressStatus.setDescription("Coordinated Sync: Committing deletions to MMS"); | ||
try { | ||
File file = MMSUtils.createEntityFile(this.getClass(), ContentType.APPLICATION_JSON, deleteElements, MMSUtils.JsonBlobType.ELEMENT_ID); | ||
HttpRequestBase elementsDeleteRequest = MMSUtils.prepareEndpointBuilderBasicJsonDeleteRequest(MMSElementsEndpoint.builder(), project, file) | ||
|
@@ -373,15 +389,15 @@ else if (shouldUpdate && mmsChange != null) { | |
} | ||
|
||
// OUTPUT RESULT OF LOCAL CHANGES | ||
|
||
progressStatus.increase(); | ||
if (shouldLogNoLocalChanges) { | ||
Application.getInstance().getGUILog().log("[INFO] No local changes to commit to MMS."); | ||
} | ||
|
||
// ADD CREATED ELEMENTS LOCALLY FROM MMS | ||
// CHANGE UPDATED ELEMENTS LOCALLY FROM MMS | ||
// REMOVE DELETED ELEMENTS LOCALLY FROM MMS | ||
|
||
progressStatus.increase(); | ||
if (shouldUpdate) { | ||
listener.setDisabled(true); | ||
|
||
|
@@ -401,8 +417,8 @@ else if (shouldUpdate && mmsChange != null) { | |
} | ||
|
||
// HANDLE CONFLICTS | ||
|
||
progressStatus.setDescription("Finishing up"); | ||
progressStatus.increase(); | ||
progressStatus.setDescription("Coordinated Sync: Finishing up"); | ||
|
||
Set<Element> localConflictedElements = new HashSet<>(); | ||
Set<ObjectNode> mmsConflictedElements = new HashSet<>(); | ||
|
@@ -422,7 +438,7 @@ else if (shouldUpdate && mmsChange != null) { | |
} | ||
|
||
ElementValidator elementValidator = new ElementValidator("CSync Conflict Validation", ElementValidator.buildElementPairs(localConflictedElements, project), mmsConflictedElements, project); | ||
elementValidator.run(progressStatus); | ||
ProgressStatusRunner.runWithProgressStatus(elementValidator, "Element Validation", true, 0); | ||
if (!elementValidator.getInvalidElements().isEmpty()) { | ||
Application.getInstance().getGUILog().log("[INFO] There are potential conflicts in " + elementValidator.getInvalidElements().size() + " element" + (elementValidator.getInvalidElements().size() != 1 ? "s" : "") + " between MMS and local changes. Please resolve them and re-sync."); | ||
vss.add(elementValidator.getValidationSuite()); | ||
|
@@ -447,7 +463,7 @@ else if (shouldUpdate && mmsChange != null) { | |
} | ||
|
||
// CLEAR IN-MEMORY AND PERSIST UNPROCESSED & FAILURES | ||
|
||
progressStatus.increase(); | ||
listener.setDisabled(true); | ||
Project project = Application.getInstance().getProject(); | ||
if (!SessionManager.getInstance().isSessionCreated(project)) { | ||
|
@@ -502,7 +518,7 @@ else if (shouldUpdate && mmsChange != null) { | |
|
||
SessionManager.getInstance().closeSession(project); | ||
listener.setDisabled(false); | ||
|
||
progressStatus.increase(); | ||
// SUCCESS | ||
failure = false; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think this is completely implemented? the parsed doc isn't used anywhere, there's no mms-cf attr added, and should have a try catch surrounding it in case jsoup fails, also it'll lead to a diff since the output on mms will then be different to the model, think this should commented out and revisited later