-
Notifications
You must be signed in to change notification settings - Fork 15
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
[WIP] REP-45 Add option to delete replication data through UI #52
Conversation
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.
Some questions and comments left.
@@ -249,9 +267,18 @@ public ReplicatorConfig getConfigForId(String id) { | |||
return siteFields; | |||
} | |||
|
|||
public ListField<ReplicationField> getReplications() { | |||
public ListField<ReplicationField> getReplications(boolean filterDeleted) { |
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.
✏️ We should move part of this method into the ReplicatorConfigManager
as objects(boolean includeDeleted)
if (filterDeleted) { | ||
configManager | ||
.objects() | ||
.filter(c -> !c.isDeleted()) |
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.
.filter(c -> !c.isDeleted()) | |
.filter(((Predicate<ReplicatorConfig>)ReplicationConfig::isDeleted).negate()) |
try { | ||
configManager.remove(id); | ||
ReplicatorConfig config = configManager.get(id); |
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.
❓ Should we modify updateReplication()
setConfigSuspended()
above to check if the config was deleted before deciding to update it? Same thing anywhere else we get a config to update it.
❓ Should we first check here if the object has already been deleted before changing it?
replication-api-impl/src/main/java/org/codice/ditto/replication/api/impl/Metacards.java
Show resolved
Hide resolved
...-api-impl/src/main/java/org/codice/ditto/replication/api/impl/data/ReplicatorConfigImpl.java
Show resolved
Hide resolved
|
||
Optional<ReplicationItem> getItem(String id, String source, String destination); | ||
Optional<ReplicationItem> getItem(String metacardId, String source, String destination); | ||
|
||
List<ReplicationItem> getItemsForConfig(String configId, int startIndex, int pageSize) |
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.
❗️ That start index is concerning. Are we guaranteed that items are always returned in the same order on every queries and that new ones are only added at the end? What about if some are deleted, wouldn't that starting index be impacted and suddenly miss or skip items?
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.
I had similar concerns. I haven't investigated it too much yet though but I will take a closer look.
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.
Pretty sure the index and page size are passed directly on to solr so as long as it is doing it's job we are ok. When we switch out the backend we will need to make sure that is still the case with whatever we use.
* @return if {@code true}, delete the associated data replicated by this {@code | ||
* ReplicatorConfig}, otherwise retain the data. | ||
*/ | ||
boolean deleteData(); |
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.
boolean deleteData(); | |
boolean shouldDeleteData(); |
replication-api/src/main/java/org/codice/ditto/replication/api/data/ReplicatorConfig.java
Show resolved
Hide resolved
...-api/src/main/java/org/codice/ditto/replication/api/persistence/ReplicatorConfigManager.java
Outdated
Show resolved
Hide resolved
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.
I think I might've already asked this question before but why do we have to mark the configs as deleted rather than just deleting them directly?
@@ -249,9 +267,18 @@ public ReplicatorConfig getConfigForId(String id) { | |||
return siteFields; | |||
} | |||
|
|||
public ListField<ReplicationField> getReplications() { | |||
public ListField<ReplicationField> getReplications(boolean filterDeleted) { |
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.
✏️ at first glance I wasn't sure if this meant filter out deleted replications or apply a filter so that I just get deleted replications. excludeDeleted
or something similar might be more clear.
...ation-api-impl/src/main/java/org/codice/ditto/replication/api/impl/MetacardConfigLoader.java
Outdated
Show resolved
Hide resolved
.map(Result::getMetacard) | ||
.map(Metacard::getId) | ||
.collect(Collectors.toSet()); | ||
} |
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.
❓ Instead of creating this new method, why not use the getTypeForFilter() method in the calling class and passing in the filter and getId function?
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.
TBH I copy pasted this from the config delete command.
...api-impl/src/main/java/org/codice/ditto/replication/api/impl/ReplicationItemManagerImpl.java
Outdated
Show resolved
Hide resolved
.../main/java/org/codice/ditto/replication/admin/query/sites/persist/DeleteReplicationSite.java
Show resolved
Hide resolved
I need to close this PR and open it against 0.2.x. |
@kcover Because if a config replicates millions of resources, it could take quite awhile to delete, and we would not want to block the UI for that. |
What does this PR do?
More tests coming.
Who is reviewing it (please choose AT LEAST two reviewers that need to approve the PR before it can get merged)?
@clockard @paouelle @kcover @mcalcote
How should this be tested? (List steps with links to updated documentation)
Any background context you want to provide?
What are the relevant tickets?
Fixes #45
Screenshots (if appropriate)
Checklist: