Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
35f2b77c
Commit
35f2b77c
authored
8 years ago
by
juanf
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-3617 : Maintenance task to find orphan datasets in archivers, compare DB with FS
SVN: 36631
parent
8445d47d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/MultiDataSetArchiverOrphanFinderTask.java
+57
-16
57 additions, 16 deletions
...lserver/plugins/MultiDataSetArchiverOrphanFinderTask.java
with
57 additions
and
16 deletions
datastore_server/source/java/ch/systemsx/cisd/etlserver/plugins/MultiDataSetArchiverOrphanFinderTask.java
+
57
−
16
View file @
35f2b77c
...
@@ -52,7 +52,7 @@ public class MultiDataSetArchiverOrphanFinderTask implements IMaintenanceTask
...
@@ -52,7 +52,7 @@ public class MultiDataSetArchiverOrphanFinderTask implements IMaintenanceTask
{
{
operationLog
.
info
(
MultiDataSetArchiverOrphanFinderTask
.
class
.
getSimpleName
()
+
" Started"
);
operationLog
.
info
(
MultiDataSetArchiverOrphanFinderTask
.
class
.
getSimpleName
()
+
" Started"
);
// 1.Directories
// 1.Directories
.
operationLog
.
info
(
"1.Directories, obtain archiver directory."
);
operationLog
.
info
(
"1.Directories, obtain archiver directory."
);
String
destination
=
DataStoreServer
.
getConfigParameters
().
getProperties
().
getProperty
(
"archiver.final-destination"
,
null
);
String
destination
=
DataStoreServer
.
getConfigParameters
().
getProperties
().
getProperty
(
"archiver.final-destination"
,
null
);
if
(
destination
==
null
)
if
(
destination
==
null
)
...
@@ -66,32 +66,40 @@ public class MultiDataSetArchiverOrphanFinderTask implements IMaintenanceTask
...
@@ -66,32 +66,40 @@ public class MultiDataSetArchiverOrphanFinderTask implements IMaintenanceTask
return
;
return
;
}
}
// 2.Database
// 2.
1
Database
.
operationLog
.
info
(
"2.1 Database, obtain a list of the multi dataset containers on the database."
);
operationLog
.
info
(
"2.1 Database, obtain a list of the multi dataset containers on the database."
);
IMultiDataSetArchiverReadonlyQueryDAO
readonlyQuery
=
MultiDataSetArchiverDataSourceUtil
.
getReadonlyQueryDAO
();
IMultiDataSetArchiverReadonlyQueryDAO
readonlyQuery
=
MultiDataSetArchiverDataSourceUtil
.
getReadonlyQueryDAO
();
List
<
MultiDataSetArchiverContainerDTO
>
containerDTOs
=
readonlyQuery
.
listContainers
();
List
<
MultiDataSetArchiverContainerDTO
>
containerDTOs
=
readonlyQuery
.
listContainers
();
Set
<
String
>
multiDatasetsContainersOnDB
=
new
HashSet
<
String
>();
Set
<
String
>
multiDatasetsContainersOnDB
=
new
HashSet
<
String
>();
for
(
MultiDataSetArchiverContainerDTO
containerDTO
:
containerDTOs
)
if
(
containerDTOs
!=
null
)
{
{
multiDatasetsContainersOnDB
.
add
(
containerDTO
.
getPath
());
for
(
MultiDataSetArchiverContainerDTO
containerDTO
:
containerDTOs
)
{
multiDatasetsContainersOnDB
.
add
(
containerDTO
.
getPath
().
toLowerCase
());
}
}
}
operationLog
.
info
(
"2.2 Database, obtain a list of the archived datasets on the database."
);
operationLog
.
info
(
"2.2 Database, obtain a list of the archived datasets on the database."
);
IEncapsulatedOpenBISService
service
=
ServiceProvider
.
getOpenBISService
();
IEncapsulatedOpenBISService
service
=
ServiceProvider
.
getOpenBISService
();
List
<
SimpleDataSetInformationDTO
>
presentDTOs
=
service
.
listPhysicalDataSetsByArchivingStatus
(
null
,
Boolean
.
TRUE
);
List
<
SimpleDataSetInformationDTO
>
presentDTOs
=
service
.
listPhysicalDataSetsByArchivingStatus
(
null
,
Boolean
.
TRUE
);
Set
<
String
>
presentInArchiveOnDB
=
new
HashSet
<
String
>();
Set
<
String
>
presentInArchiveOnDB
=
new
HashSet
<
String
>();
for
(
SimpleDataSetInformationDTO
presentDTO
:
presentDTOs
)
if
(
presentDTOs
!=
null
)
{
{
presentInArchiveOnDB
.
add
(
presentDTO
.
getDataSetCode
());
for
(
SimpleDataSetInformationDTO
presentDTO
:
presentDTOs
)
{
presentInArchiveOnDB
.
add
(
presentDTO
.
getDataSetCode
().
toLowerCase
());
}
}
}
// 3.Verify if the files on destination are on multi dataset archiver containers or a normal archived dataset
// 3.Verify if the files on destination are on multi dataset archiver containers or a normal archived dataset
.
operationLog
.
info
(
"3.Verify if the files on destination are on multi dataset archiver containers or a normal archived dataset."
);
operationLog
.
info
(
"3.Verify if the files on destination are on multi dataset archiver containers or a normal archived dataset."
);
File
[]
filesOnDisk
=
new
File
(
destination
).
listFiles
();
File
[]
filesOnDisk
=
new
File
(
destination
).
listFiles
();
List
<
File
>
notFounds
=
new
ArrayList
<
File
>();
Set
<
String
>
presentInArchiveFS
=
new
HashSet
<
String
>();
List
<
File
>
onFSandNotDB
=
new
ArrayList
<
File
>();
for
(
File
file
:
filesOnDisk
)
for
(
File
file
:
filesOnDisk
)
{
{
if
(
multiDatasetsContainersOnDB
.
contains
(
file
.
getName
()))
presentInArchiveFS
.
add
(
file
.
getName
().
toLowerCase
());
// To be used in step 4
if
(
multiDatasetsContainersOnDB
.
contains
(
file
.
getName
().
toLowerCase
()))
{
{
operationLog
.
info
(
"Found multi dataset archiver container: "
+
file
.
getName
());
operationLog
.
info
(
"Found multi dataset archiver container: "
+
file
.
getName
());
}
else
if
((
file
.
getName
().
toLowerCase
().
endsWith
(
".tar"
)
||
}
else
if
((
file
.
getName
().
toLowerCase
().
endsWith
(
".tar"
)
||
...
@@ -101,20 +109,53 @@ public class MultiDataSetArchiverOrphanFinderTask implements IMaintenanceTask
...
@@ -101,20 +109,53 @@ public class MultiDataSetArchiverOrphanFinderTask implements IMaintenanceTask
operationLog
.
info
(
"Found archived dataset: "
+
file
.
getName
());
operationLog
.
info
(
"Found archived dataset: "
+
file
.
getName
());
}
else
}
else
{
{
notFounds
.
add
(
file
);
onFSandNotDB
.
add
(
file
);
operationLog
.
info
(
"Not Found file: "
+
file
.
getName
());
operationLog
.
info
(
"Not Found on DB for FS: "
+
file
.
getName
());
}
}
// 4.Verify if the datasets archived on the database are on the file system.
operationLog
.
info
(
"4.Verify if the datasets archived on the database are on the file system."
);
List
<
String
>
multiOnDBandNotFS
=
new
ArrayList
<
String
>();
for
(
String
multiDatasetsContainerOnDB
:
multiDatasetsContainersOnDB
)
{
if
(!
presentInArchiveFS
.
contains
(
multiDatasetsContainerOnDB
))
{
operationLog
.
info
(
"Multi - Not Found in FS for DB: "
+
multiDatasetsContainerOnDB
);
multiOnDBandNotFS
.
add
(
multiDatasetsContainerOnDB
);
}
}
List
<
String
>
singleOnDBandNotFS
=
new
ArrayList
<
String
>();
for
(
String
presentOnDB
:
presentInArchiveOnDB
)
{
String
fileNameTar
=
presentOnDB
+
".tar"
;
String
fileNameZip
=
presentOnDB
+
".zip"
;
if
(!
presentInArchiveFS
.
contains
(
fileNameTar
)
&&
!
presentInArchiveFS
.
contains
(
fileNameZip
))
{
operationLog
.
info
(
"Single - Not Found in FS for DB: "
+
presentOnDB
);
singleOnDBandNotFS
.
add
(
presentOnDB
);
}
}
}
}
// 4.Send email with not found files.
// 4.Send email with not found files.
operationLog
.
info
(
"
4
.Send email with not found files."
);
operationLog
.
info
(
"
5
.Send email with not found files."
);
if
(
notFounds
.
size
()
>
0
)
if
(
onFSandNotDB
.
size
()
>
0
)
{
{
String
subject
=
"openBIS MultiDataSetArchiverOrphanFinderTask found files"
;
String
subject
=
"openBIS MultiDataSetArchiverOrphanFinderTask found files"
;
String
content
=
"Found "
+
notFounds
.
size
()
+
" files by MultiDataSetArchiverOrphanFinderTask:\n"
;
String
content
=
""
;
for
(
File
notFound
:
notFounds
)
for
(
File
notFound
:
onFSandNotDB
)
{
content
+=
"Found on FS not in DB:"
+
notFound
.
getName
()
+
"\t"
+
notFound
.
length
()
+
"\n"
;
}
for
(
String
notFound
:
multiOnDBandNotFS
)
{
content
+=
"Found on DB not in FS - Multi dataset archiver:"
+
notFound
+
"\n"
;
}
for
(
String
notFound
:
singleOnDBandNotFS
)
{
{
content
+=
notFound
.
getName
()
+
"\t
"
+
notFound
.
length
()
+
"\n"
;
content
+=
"Found on DB not in FS - dataset archiver:
"
+
notFound
+
"\n"
;
}
}
for
(
EMailAddress
recipient
:
emailAddresses
)
for
(
EMailAddress
recipient
:
emailAddresses
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment