vitruv-tools / Vitruv

View-based Development and Model Consistency Framework
http://vitruv.tools
Eclipse Public License 1.0
14 stars 19 forks source link

Support Propagating Changes to Multiple Resources #412

Closed jGleitz closed 3 years ago

jGleitz commented 3 years ago

This seems to work with all tests, ~except for one: OperationRequiredRoleMappingTransformationTest#testChangeOperationRequiredRole~

Changes:

jGleitz commented 3 years ago

corresponding application change: https://github.com/vitruv-tools/Vitruv-Applications-ComponentBasedSystems/pull/118

jGleitz commented 3 years ago

I fixed the failing test. This was actually an error in the production code, however, I don’t know why we didn’t discover it sooner.

jGleitz commented 3 years ago

I updated this branch to match the latest master. It is ready for review.

jGleitz commented 3 years ago

This PR contains a weird race condition where models are not saved if you don’t debug through the code slowly enough.

HeikoKlare commented 3 years ago

That sounds really strange. I hope that the race condition is actually "only" an issue of this PR and was not introduced by a recent one, which we did not recognize before merging it? At least, those PRs changed synchronization behavior and placement of the save operation for the VirtualModel.

jGleitz commented 3 years ago

It seems to affect only the Commonalities, which could mean that the IntermediateResourceBridgeI hack broke.

jGleitz commented 3 years ago

‘Fixed’ it by mimicking the old behaviour more closely. Somehow this error occurred when recording separately for every ChangePropagationSpecification

was not introduced by a recent one, which we did not recognize before merging it?

No, it was specific to this PR. I still don’t understand why the issue sometimes did not occur when debugging, though.

jGleitz commented 3 years ago
  1. The tests failed because sometimes changes for inverse references ended up in the resulting changes of change propagation. I am not quite sure why, but I have also not fixed it.
  2. The problem I ‘fixed’ as per comment https://github.com/vitruv-tools/Vitruv/pull/412#issuecomment-777095982 was actually that the ResourceRepository did not create copies of the lists it hands out. I fixed that and went back to trusting ChangePropagationSpecifications regarding which domain was changed
  3. I first simplified AtomicEmfChangeRecorder because it contained quite some convoluted code.
  4. Then I removed AtomicEmfChangeRecorder’s functionality of removing create changes that are followed by a delete. I had multiple reasons for this change:
    1. I found the logic very hard to understand. So much so that I suspected it of having a bug, without being able to figure out whether it was really a bug or intended behaviour.
    2. I suspected the whole approach to be wrong (what happens to modifications between the create and the delete?
    3. For all the reasons I could think of that would require this logic, change recording was the wrong spot to do it. If for example, this is an optimization for change propagation, the VSUM should apply it before propagating the changes.
    4. Nothing broke when I removed the logic.

All tests pass now, as far as I can see.

jGleitz commented 3 years ago

Okay, so now I have pushed two more changes:

This means that this PR now also requires a change to the Java domain: https://github.com/vitruv-tools/Vitruv-Domains-ComponentBasedSystems/pull/86

All in all, this PR has gotten pretty big. I didn’t anticipate that supporting changes to multiple resources would result in so many changes to the framework. Neither was I planning to do yet another big refactoring. But hey, I think the framework improved quite a bit with this.

This should hopefully be the final state and ready for review.

jGleitz commented 3 years ago

Bildschirmfoto vom 2021-02-12 23-21-21 :+1:

jGleitz commented 3 years ago

:angry:. I made sure to check all tests, but forgot about the transitive change tests. The errors are cryptic and I have no idea what’s going wrong. The Commonalities and Mappings Tests work fine, though.

jGleitz commented 3 years ago

After rebasing on #419, this PR only fails the Transactional tests. A lot of those failures are related to the TUID mechanism that causes bad unloads. So I propose to wait with this PR until we migrated entirely to UUIDs.

jGleitz commented 3 years ago

I merged this branch with master and it is now ready for review.

jGleitz commented 3 years ago

Regarding whether composite changes should take a List or a Collection: I used the most general interface possible (Iterable is not possible because we'll just size when copying).

The collection will be copied and internally will always be a List. The current state allows to pass on something like a LinkedHashSet. That would not be possible if a List was required.

So I don't object to changing to List, but I also don't see the need.

HeikoKlare commented 3 years ago

To me, it'a bit weird that one can pass an unordered collection to a change which then becomes an order assigned, which is then also used to compare the changes. If an order is important (and in my opinion it is important for changes), it should already be clarified when passing it to a composite change. We may also pass an Iterable instead of a List to cover your issue with LinkedHashSet. I do not understand you point why this should not be possible. We take the Iterable and internally store it in a List, like we do now for the passed Collection?

jGleitz commented 3 years ago

I do not understand you point why this should not be possible.

It’s possible but more cumbersome. The nice thing about List#copyOf is that it doesn’t create a copy if the list is already read-only. But List#copyOf only takes a Collection.

To me, it'a bit weird that one can pass an unordered collection to a change which then becomes an order assigned, which is then also used to compare the changes.

We may also pass an Iterable instead of a List

Those two statements are somewhat contradictory since Collection inherits from Iterable. So in both cases, Collection and Iterable, we’d just make a copy of the collection in the order of iteration.

jGleitz commented 3 years ago

I changed the constructors to take a List. The factories still take an Iterable. Should I change this too?

HeikoKlare commented 3 years ago

For me, it's fine to accept an Iterable, so you can keep it as it is.

jGleitz commented 3 years ago

@HeikoKlare I pushed some more cleanup:

HeikoKlare commented 3 years ago

Perfect, thanks! All changes are fine for me. I make a final run of the applications against these changes and merge them afterwards.