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
14da0a10
Commit
14da0a10
authored
7 years ago
by
gakin
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-4761 OpenbisSync wrap up full-sync feature
SVN: 38114
parent
d545b539
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/HarvesterMaintenanceTask.java
+44
-21
44 additions, 21 deletions
.../dss/plugins/sync/harvester/HarvesterMaintenanceTask.java
with
44 additions
and
21 deletions
datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/sync/harvester/HarvesterMaintenanceTask.java
+
44
−
21
View file @
14da0a10
...
@@ -91,16 +91,27 @@ public class HarvesterMaintenanceTask<T extends DataSetInformation> implements I
...
@@ -91,16 +91,27 @@ public class HarvesterMaintenanceTask<T extends DataSetInformation> implements I
private
DataSetProcessingContext
context
;
private
DataSetProcessingContext
context
;
private
Date
lastIncSyncTimestamp
;
private
Date
lastFullSyncTimestamp
;
private
File
harvesterConfigFile
;
private
File
harvesterConfigFile
;
private
IMailClient
mailClient
;
private
IMailClient
mailClient
;
private
String
dataStoreCode
;
private
String
dataStoreCode
;
class
Timestamps
{
final
Date
lastIncSyncTimestamp
;
final
Date
lastFullSyncTimestamp
;
Timestamps
(
Date
lastIncSyncTimestamp
,
Date
lastFullSyncTimestamp
)
{
super
();
this
.
lastIncSyncTimestamp
=
lastIncSyncTimestamp
;
this
.
lastFullSyncTimestamp
=
lastFullSyncTimestamp
;
}
}
@Override
@Override
public
void
setUp
(
String
pluginName
,
Properties
properties
)
public
void
setUp
(
String
pluginName
,
Properties
properties
)
{
{
...
@@ -152,13 +163,28 @@ public class HarvesterMaintenanceTask<T extends DataSetInformation> implements I
...
@@ -152,13 +163,28 @@ public class HarvesterMaintenanceTask<T extends DataSetInformation> implements I
String
fileName
=
config
.
getLastSyncTimestampFileName
();
String
fileName
=
config
.
getLastSyncTimestampFileName
();
File
lastSyncTimestampFile
=
new
File
(
fileName
);
File
lastSyncTimestampFile
=
new
File
(
fileName
);
loadCutOffTimeStamps
(
lastSyncTimestampFile
);
Timestamps
timestamps
=
loadCutOffTimeStamps
(
lastSyncTimestampFile
);
Date
cutOffTimestamp
=
lastIncSyncTimestamp
;
Date
cutOffTimestamp
=
timestamps
.
lastIncSyncTimestamp
;
boolean
isFullSync
=
lastSyncTimestampFile
.
exists
()
==
false
||
isTimeForFullSync
(
config
);
boolean
isFullSync
=
lastSyncTimestampFile
.
exists
()
==
false
||
isTimeForFullSync
(
config
,
timestamps
.
lastFullSyncTimestamp
);
operationLog
.
info
(
"Last incremental sync timestamp: "
+
timestamps
.
lastIncSyncTimestamp
);
operationLog
.
info
(
"Last full sync timestamp: "
+
timestamps
.
lastFullSyncTimestamp
);
if
(
isFullSync
==
true
)
if
(
isFullSync
==
true
)
{
{
cutOffTimestamp
=
new
Date
(
0L
);
cutOffTimestamp
=
new
Date
(
0L
);
if
(
lastSyncTimestampFile
.
exists
()
==
false
)
{
operationLog
.
info
(
"Performing a full initial sync"
);
}
else
{
operationLog
.
info
(
"Performing a full sync as a minimum of "
+
config
.
getFullSyncInterval
()
+
" day(s) have elapsed since last full sync."
);
}
}
else
{
operationLog
.
info
(
"Performing an incremental sync"
);
}
}
String
notSyncedEntitiesFileName
=
config
.
getNotSyncedEntitiesFileName
();
String
notSyncedEntitiesFileName
=
config
.
getNotSyncedEntitiesFileName
();
Set
<
String
>
notSyncedDataSetCodes
=
getNotSyncedDataSetCodes
(
notSyncedEntitiesFileName
);
Set
<
String
>
notSyncedDataSetCodes
=
getNotSyncedDataSetCodes
(
notSyncedEntitiesFileName
);
...
@@ -180,16 +206,16 @@ public class HarvesterMaintenanceTask<T extends DataSetInformation> implements I
...
@@ -180,16 +206,16 @@ public class HarvesterMaintenanceTask<T extends DataSetInformation> implements I
}
}
operationLog
.
info
(
"Saving the timestamp of sync start to file"
);
operationLog
.
info
(
"Saving the timestamp of sync start to file"
);
lastIncSyncTimestamp
=
newCutOffTimestamp
;
Date
newLastIncSyncTimestamp
=
newCutOffTimestamp
;
Date
newLastFullSyncTimestamp
=
timestamps
.
lastFullSyncTimestamp
;
if
(
isFullSync
==
true
)
if
(
isFullSync
==
true
)
{
{
l
astFullSyncTimestamp
=
newCutOffTimestamp
;
newL
astFullSyncTimestamp
=
newCutOffTimestamp
;
}
}
saveSyncTimestamp
(
lastSyncTimestampFile
);
saveSyncTimestamp
(
lastSyncTimestampFile
,
newLastIncSyncTimestamp
,
newLastFullSyncTimestamp
);
operationLog
.
info
(
this
.
getClass
()
+
" finished executing."
);
operationLog
.
info
(
this
.
getClass
()
+
" finished executing."
);
}
catch
(
Exception
e
)
}
catch
(
Exception
e
)
{
{
operationLog
.
error
(
"Sync failed: "
,
e
);
operationLog
.
error
(
"Sync failed: "
,
e
);
...
@@ -198,25 +224,22 @@ public class HarvesterMaintenanceTask<T extends DataSetInformation> implements I
...
@@ -198,25 +224,22 @@ public class HarvesterMaintenanceTask<T extends DataSetInformation> implements I
}
}
}
}
private
void
loadCutOffTimeStamps
(
File
lastSyncTimestampFile
)
throws
IOException
,
ParseException
private
Timestamps
loadCutOffTimeStamps
(
File
lastSyncTimestampFile
)
throws
IOException
,
ParseException
{
{
if
(
lastSyncTimestampFile
.
exists
())
if
(
lastSyncTimestampFile
.
exists
())
{
{
ConfigReader
reader
=
new
ConfigReader
(
lastSyncTimestampFile
);
ConfigReader
reader
=
new
ConfigReader
(
lastSyncTimestampFile
);
String
incSyncTimestampStr
=
reader
.
getString
(
TIMESTAMPS_SECTION_HEADER
,
LAST_INCREMENTAL_SYNC_TIMESTAMP
,
null
,
true
);
String
incSyncTimestampStr
=
reader
.
getString
(
TIMESTAMPS_SECTION_HEADER
,
LAST_INCREMENTAL_SYNC_TIMESTAMP
,
null
,
true
);
String
fullSyncTimestampStr
=
reader
.
getString
(
TIMESTAMPS_SECTION_HEADER
,
LAST_FULL_SYNC_TIMESTAMP
,
incSyncTimestampStr
,
false
);
String
fullSyncTimestampStr
=
reader
.
getString
(
TIMESTAMPS_SECTION_HEADER
,
LAST_FULL_SYNC_TIMESTAMP
,
incSyncTimestampStr
,
false
);
return
new
Timestamps
(
formatter
.
parse
(
incSyncTimestampStr
),
formatter
.
parse
(
fullSyncTimestampStr
));
lastIncSyncTimestamp
=
formatter
.
parse
(
incSyncTimestampStr
);
lastFullSyncTimestamp
=
formatter
.
parse
(
fullSyncTimestampStr
);
}
}
else
else
{
{
lastIncSyncTimestamp
=
new
Date
(
0L
);
return
new
Timestamps
(
new
Date
(
0L
),
new
Date
(
0L
));
lastFullSyncTimestamp
=
new
Date
(
0L
);
}
}
}
}
private
boolean
isTimeForFullSync
(
SyncConfig
config
)
throws
IOException
,
ParseException
private
boolean
isTimeForFullSync
(
SyncConfig
config
,
Date
lastFullSyncTimestamp
)
throws
IOException
,
ParseException
{
{
if
(
config
.
isFullSyncEnabled
())
if
(
config
.
isFullSyncEnabled
())
{
{
...
@@ -336,11 +359,11 @@ public class HarvesterMaintenanceTask<T extends DataSetInformation> implements I
...
@@ -336,11 +359,11 @@ public class HarvesterMaintenanceTask<T extends DataSetInformation> implements I
}
}
}
}
private
void
saveSyncTimestamp
(
File
lastSyncTimestampFile
)
private
void
saveSyncTimestamp
(
File
lastSyncTimestampFile
,
Date
newLastIncSyncTimestamp
,
Date
newLastFullSyncTimestamp
)
{
{
FileUtilities
.
writeToFile
(
lastSyncTimestampFile
,
"["
+
TIMESTAMPS_SECTION_HEADER
+
"]"
);
FileUtilities
.
writeToFile
(
lastSyncTimestampFile
,
"["
+
TIMESTAMPS_SECTION_HEADER
+
"]"
);
FileUtilities
.
appendToFile
(
lastSyncTimestampFile
,
"\n"
,
true
);
FileUtilities
.
appendToFile
(
lastSyncTimestampFile
,
"\n"
,
true
);
FileUtilities
.
appendToFile
(
lastSyncTimestampFile
,
LAST_INCREMENTAL_SYNC_TIMESTAMP
+
" = "
+
formatter
.
format
(
l
astIncSyncTimestamp
),
true
);
FileUtilities
.
appendToFile
(
lastSyncTimestampFile
,
LAST_INCREMENTAL_SYNC_TIMESTAMP
+
" = "
+
formatter
.
format
(
newL
astIncSyncTimestamp
),
true
);
FileUtilities
.
appendToFile
(
lastSyncTimestampFile
,
LAST_FULL_SYNC_TIMESTAMP
+
" = "
+
formatter
.
format
(
l
astFullSyncTimestamp
),
true
);
FileUtilities
.
appendToFile
(
lastSyncTimestampFile
,
LAST_FULL_SYNC_TIMESTAMP
+
" = "
+
formatter
.
format
(
newL
astFullSyncTimestamp
),
true
);
}
}
}
}
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