#620 closed (fixed)
Empty trashcan as job
Reported by: | Fredrik Levander | Owned by: | olle |
---|---|---|---|
Milestone: | Proteios SE 2.10 | Keywords: | |
Cc: |
Description (last modified by )
Emptying of the trash can take a long time, and put a lot of pressure on tomcat and mysql. To avoid problems, it should be executed as a job instead. The current EmptyTrash? action works fine and can be used as a basis, but to minimise dependency problems, the following order should be applied:
Jobs
Spectrum Searches
Files
Directories
Projects
The job should delete as much as possible, and report back deletion failures. The progress reporter should be used, since execution time could be long for this plug-in.
A bonus would be if the empty trash action first checks if there are any spectrum searches in the trash, and if there are, or the total number of trash items is larger that ~10, generate empty trash job. Otherwise trash as now (but with above order).
Change History (19)
comment:1 Changed 14 years ago by
Milestone: | Proteios SE Future Release → Proteios SE 2.10 |
---|
comment:2 Changed 14 years ago by
Owner: | changed from Gregory Vincic to olle |
---|---|
type: | defect → enhancement |
comment:3 Changed 14 years ago by
component: | servlet → plugin |
---|---|
Description: | modified (diff) |
priority: | minor → major |
comment:4 Changed 14 years ago by
Status: | new → assigned |
---|
comment:5 Changed 14 years ago by
Traceability note.
- Latest ticket related to trash can functionality was Ticket #523 (Trashcan updated with separate item class views and links in menus).
comment:6 Changed 14 years ago by
Description: | modified (diff) |
---|
comment:7 Changed 14 years ago by
Note on ticket description and current trash can functionality:
- Of the database items discussed as deletion candidates in the ticket description, current trash can view and emptying functionality only support
Jobs
,Spectrum Searches
,Files
, andDirectories
. whileProjects
are not supported.
comment:8 Changed 14 years ago by
Design discussion, initial:
- In order to facilitate future addition of trash can support for more item classes, the
EmptyTrash
class should be refactored to use a generic method for deleting items of a specific class. TheListTrash
andMainMenu
classes were already updated in changeset [3130] in Ticket #523 (Trashcan updated with separate item class views and links in menus) to make it simple to added trash can support for more item classes.
comment:9 Changed 14 years ago by
(In [3449]) Refs #620. Refs #523. Class/file action/write/EmptyTrash.java in client/servlet/ refactored to to facilitate future addition of trash can support for more item classes:
- New private instance variable
String errorMessage
with
public accessor methods added. This replaces the previous local
variable with the same name in protected method void runMe()
.
- Protected method
void runMe()
updated to call new private
method int deleteItemsOfSpecificClass(Class itemClass)
to
try to delete items of a specific class.
- New private method
int deleteItemsOfSpecificClass(Class itemClass)
added. It tries to delete items of a specific class, and returns the number of deleted items. If some item cannot be deleted, the error message is updated.
comment:10 Changed 14 years ago by
(In [3450]) Refs #620. Refs #523. Class/file action/write/EmptyTrash.java in client/servlet/ updated to facilitate future optional creation of job to empty trash can:
- Protected method
void runMe()
updated by moving commands
for deleting items to new private method void emptyTrashCan()
.
- New private method
void emptyTrashCan()
added.
It calls method int deleteItemsOfSpecificClass(Class itemClass)
to try to delete items of a specific class. Order in which items
are deleted changed to Jobs
, Spectrum Searches
, Files
,
and Directories
.
- Unused imports and code removed.
comment:11 Changed 14 years ago by
Design description:
- The empty trash can action currently shows a message reporting the number of deleted items plus an optional error message. It should be updated to prefix the error message part with "
ERROR:
", in order to clearly indicate that an error has occurred. - The empty trash can action should check the number and type of items marked for removal, and create a job if any
SpectrumSearch
item or more than 10 other items should be removed, otherwise the trash can should be emptied directly. - The plug-in for emptying the trash can should be based on current code for the empty trash can action. However, method
deleteItemsOfSpecificClass(...)
should update the progress reporter to indicate the percent of items processed. - The plug-in for emptying the trash can should set a job response message equal to the message reported by the empty trash can action.
- The estimated execution time for the job should be set to next fastest,
SHORT
.
comment:12 Changed 14 years ago by
(In [3451]) Refs #620. Refs #523. Action to empty trash can now creates a job
if any SpectrumSearch
item or or more than 10 other items should
be removed:
- Class/file action/write/EmptyTrash.java in client/servlet/
updated:
- Protected method
void runMe()
updated to call new private
method
<D extends BasicItem> int getNumberOfTrashItems(DbControl dc, Class<D> itemClass)
to obtain the number of items to remove of a specific class.
If any SpectrumSearch
item or or more than 10 other items should
be removed, new private method void createEmptyTrashCanJob()
is
called to create a job, otherwise private method void emptyTrashCan()
is called.
- New private method
void createEmptyTrashCanJob()
added.
It creates a job using new plug-in class EmptyTrashPlugin
.
- Private method
void emptyTrashCan()
updated to prefix any
error part of the delete message with "ERROR:
".
- New private method
int getTotalNumberOfTrashItems(DbControl dc)
added. It obtains the total number of items in the trash can by
calling new private method
<D extends BasicItem> int getNumberOfTrashItems(DbControl dc, Class<D> itemClass)
.
- New private method
<D extends BasicItem> int getNumberOfTrashItems(DbControl dc, Class<D> itemClass)
added. It obtains the number of items of a specific class in the
trash can.
- New class/file plugins/EmptyTrashPlugin.java in plugin/ added.
- Public method
void run(Request request, Response response, ProgressReporter progress)
calls public method
void execute(Request request, Response response, ProgressReporter progress)
to empty the trash can.
- Public method
void execute(Request request, Response response, ProgressReporter progress)
calls private method
int deleteItemsOfSpecificClass(Class itemClass, ProgressReporter progress,
int startCount, int totalCount)
to remove items of a specific class.
- Private method
int deleteItemsOfSpecificClass(Class itemClass, ProgressReporter progress,
int startCount, int totalCount)
tries to delete items of a specific class, and returns the number
of deleted items. If some item cannot be deleted, the error message
is updated. The progress reporter is updated after each processed
item.
- Private method
int getTotalNumberOfTrashItems(DbControl dc)
obtains the total number of items in the trash can by calling
private method
<D extends BasicItem> int getNumberOfTrashItems(DbControl dc, Class<D> itemClass)
.
- Private method
<D extends BasicItem> int getNumberOfTrashItems(DbControl dc, Class<D> itemClass)
obtains the number of items of a specific class in the trash can.
comment:13 Changed 14 years ago by
Design note:
- A problem with the current design of the empty trash plug-in is that it will try to remove all deleted items at time of execution, which may include items that were not deleted when the job was created.
comment:14 Changed 14 years ago by
It has been possible to delete several thousand trashcan items in one go, so it is fine.
comment:15 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:16 Changed 14 years ago by
(In [3517]) Refs #620. Refs #327. Classes related to emptying trash can updated to remove warnings due to unchecked conversion from unspecified class type:
- Class/file action/write/EmptyTrash.java in client/servlet/
updated:
- Private method
int deleteItemsOfSpecificClass(Class itemClass)
updated by change of type for argument itemClass
from
Class
to Class<? extends BasicItem>
.
- Class/file plugins/EmptyTrashPlugin.java in plugin/ updated:
- Private method
int deleteItemsOfSpecificClass(Class itemClass,
ProgressReporter progress, int startCount, int totalCount)
updated by change of type for argument itemClass
from
Class
to Class<? extends BasicItem>
.
comment:17 Changed 13 years ago by
(In [3953]) Refs #704. Refs #523. Refs #620. Routines for listing, restoring or permanently removing items in the trash should be updated to support project items:
- Class/file gui/MainMenu.java in client/servlet/ updated to add
a menu item for projects in the trash can menu.
- Class/file action/read/ViewHome.java in client/servlet/ updated:
- New valid parameter
VInteger VPROJECTCOUNT
added. - Public method
void runMe()
updated to support project items. - Private method
Form getTrashCanForm(...)
updated with new
argument Integer projectCount
and support for projects in
the form.
- Class/file action/write/EmptyTrash.java in client/servlet/
updated to support project items.
- Class/file plugins/EmptyTrashPlugin.java in plugin/ updated
to support project items.
comment:18 Changed 13 years ago by
(In [3956]) Refs #704. Refs #523. Refs #620. Routines for permanently removing items in the trash updated to repeat attempts to empty the trash can, as long as some item is removed in each attempt, and more items to remove remain:
- Class/file action/write/EmptyTrash.java in client/servlet/ updated:
- Private method
void emptyTrashCan()
updated with new argument
int totalItemCount
and calling new private method
int emptyTrashCanAttempt()
as long as some item is removed in each
attempt, and more items to remove remain.
- New private method
int emptyTrashCanAttempt()
added.
It attempts to permanently remove items, using code previously
in private method void emptyTrashCan()
.
- Class/file plugins/EmptyTrashPlugin.java in plugin/ updated:
- Public method
void execute(Request request, Response response, ProgressReporter progress)
updated to call new private method
int emptyTrashCanAttempt(Request request, Response response,
ProgressReporter progress, int accDeletedCount, int totalItemCount)
as long as some item is removed in each attempt, and more items to
remove remain.
- New private method
int emptyTrashCanAttempt(Request request, Response response,
ProgressReporter progress, int accDeletedCount, int totalItemCount)
added. It attempts to permanently remove items, using code previously
in public method
void execute(Request request, Response response, ProgressReporter progress)
.
comment:19 Changed 10 years ago by
(In [4412]) Refs #798. Refs #620. Refs #46. Classes/files action/write/EmptyTrash.java
in client/servlet/
and plugins/EmptyTrashPlugin.java
in plugin/
have been updated to hopefully avoid errors due to a proxy being associated with two open sessions. The updated routine has the following main steps:
DbControl
objectdc
is used to create anItemResultList<?> itemResultList
from a database query. This is in turn used to create aList<BasicItem<?>> itemList
of the items of interest.DbControl
objectdc
is closed, andList<BasicItem<?>> itemList
is used to loop over the items.- For each item,
DbControl
objectdc2
is created and used to get a new instance of the item from its database id.DbControl
objectdc2
is then used to delete the latter item, the change is committed, andDbControl
objectdc2
is closed. DbControl
objectdc
is created again, and used to generate a list of items still in the database, that is checked against theList<BasicItem<?>> itemList
of items to delete.
Ticket accepted.