-
Notifications
You must be signed in to change notification settings - Fork 155
Feature/spline 684 data retention 2 #1113
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a3fcaca
#684 data retention - original code from PR#762 - brought up to date …
dk1844 6451f9c
#684 data retention - update to reflect logic from https://gist.githu…
dk1844 14cc8a0
Merge branch 'develop' into feature/spline-684-data-retention-2
dk1844 3555bd8
Merge branch 'develop' into feature/spline-684-data-retention-2
dk1844 c5e7a36
#684 minor updates
dk1844 e366788
#684 Sonar/Codacy code quality updates
dk1844 f97c309
Merge branch 'develop' into feature/spline-684-data-retention-2
dk1844 26cfa2c
#684 prune db time measurment logging added
dk1844 9ea591b
Merge branch 'develop' into feature/spline-684-data-retention-2
dk1844 f79f318
Merge remote-tracking branch 'origin/feature/spline-684-data-retentio…
dk1844 74c0236
db prune - stage1 option A, stage 2 option A applied
dk1844 70345e5
review suggestions applied 1
dk1844 35d97d0
#684 dataSourceKeysInAffectsDependsUseArray in one query + toArray fix
dk1844 1bfb6be
#684 PR review - logging update
dk1844 1f9c46e
Merge branch 'develop' into feature/spline-684-data-retention-2
dk1844 fb72253
#684 indentation fix
dk1844 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
admin/src/main/scala/za/co/absa/spline/admin/DateTimeUtils.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * Copyright 2022 ABSA Group Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package za.co.absa.spline.admin | ||
|
|
||
| import java.time.format.{DateTimeFormatter, DateTimeFormatterBuilder} | ||
| import java.time.temporal.ChronoField | ||
| import java.time.{ZoneId, ZonedDateTime} | ||
| import scala.util.{Failure, Success, Try} | ||
| import scala.util.control.NonFatal | ||
|
|
||
| object DateTimeUtils { | ||
|
|
||
| private val ZonedDateTimeRegexp = (s"" + | ||
| "^" + | ||
| """([\dT:.+\-]+?)""".r + // local datetime | ||
| """(Z|[+\-]\d\d:\d\d)?""".r + // timezone offset | ||
| """(?:\[([\w/+\-]+)])?""".r + // timezone name | ||
| "$").r | ||
|
|
||
| private val ZonedDateTimeFormatter = new DateTimeFormatterBuilder() | ||
| .parseCaseInsensitive() | ||
| .append(DateTimeFormatter.ISO_LOCAL_DATE) | ||
| .optionalStart() | ||
| .appendLiteral('T') | ||
| .append(DateTimeFormatter.ISO_LOCAL_TIME) | ||
| .optionalEnd() | ||
| .parseDefaulting(ChronoField.HOUR_OF_DAY, 0) | ||
| .toFormatter(); | ||
|
|
||
| def parseZonedDateTime(s: String, defaultZoneId: ZoneId = ZoneId.systemDefault): ZonedDateTime = | ||
| Try { | ||
| val ZonedDateTimeRegexp(ldt, tzOffset, tzId) = s | ||
| val maybeTzIds = Seq(tzId, tzOffset).map(Option.apply) | ||
|
|
||
| require(!maybeTzIds.forall(_.isDefined), "Either timezone ID or offset should be specified, not both") | ||
|
|
||
| val tz = maybeTzIds | ||
| .collectFirst({ case Some(v) => ZoneId.of(v) }) | ||
| .getOrElse(defaultZoneId) | ||
|
|
||
| ZonedDateTime.parse(ldt, ZonedDateTimeFormatter.withZone(tz)) | ||
|
cerveada marked this conversation as resolved.
|
||
| } match { | ||
| case Success(zonedTime) => zonedTime | ||
| case Failure(nfe@NonFatal(_)) => throw new IllegalArgumentException(s"Cannot parse zoned datetime: $s", nfe) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
admin/src/main/scala/za/co/absa/spline/arango/DataRetentionManager.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Copyright 2022 ABSA Group Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package za.co.absa.spline.arango | ||
|
|
||
|
|
||
| import com.arangodb.async.ArangoDatabaseAsync | ||
| import za.co.absa.spline.persistence.ArangoImplicits._ | ||
|
|
||
| import scala.concurrent.{ExecutionContext, Future} | ||
|
|
||
| class DataRetentionManager(db: ArangoDatabaseAsync)(implicit ec: ExecutionContext) { | ||
|
|
||
| def pruneBefore(timestamp: Long): Future[Unit] = { | ||
| db.restClient.delete(s"spline/admin/data/before/$timestamp") | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
ZonedDateTime.parseallows both offset and name at the same time . I think it's good idea to accept all inputs that are valid forZonedDateTime.parseThere 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.
The issue with allowing only geographical zone id is that it is ambiguous. Not unique.
This is the day and hour of change from summer time to winter time:
Another interesting behaviour (not so relevant for us though) is this:
When no geographical zone id is provided the ZonedDateTime will stay in the same offset.
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 agreed to solve this as part of other ticket #1139