-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/54 checkpoint from server (#86)
* AtumAgent fetches AtumContext from the server with Dispatcher using AtumPartitions and optional parent AtumPartitions
- Loading branch information
1 parent
4a6de45
commit 2df96ab
Showing
8 changed files
with
164 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
41 changes: 41 additions & 0 deletions
41
agent/src/main/scala/za/co/absa/atum/agent/model/MeasuresMapper.scala
This file contains 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,41 @@ | ||
/* | ||
* Copyright 2021 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.atum.agent.model | ||
|
||
import za.co.absa.atum.agent.model.Measure._ | ||
|
||
case class UnsupportedMeasureException(msg: String) extends Exception(msg) | ||
|
||
object MeasuresMapper { | ||
|
||
def mapToMeasures(measures: Set[za.co.absa.atum.model.Measure]): Set[za.co.absa.atum.agent.model.Measure] = { | ||
measures.map(createMeasure) | ||
} | ||
|
||
private def createMeasure(measure: za.co.absa.atum.model.Measure): za.co.absa.atum.agent.model.Measure = { | ||
val controlColumn = measure.controlColumns.head | ||
measure.functionName match { | ||
case "RecordCount" => RecordCount(controlColumn) | ||
case "DistinctRecordCount" => DistinctRecordCount(controlColumn) | ||
case "SumOfValuesOfColumn" => SumOfValuesOfColumn(controlColumn) | ||
case "AbsSumOfValuesOfColumn" => AbsSumOfValuesOfColumn(controlColumn) | ||
case "SumOfHashesOfColumn" => SumOfHashesOfColumn(controlColumn) | ||
case unsupportedMeasure => throw UnsupportedMeasureException(s"Measure not supported: $unsupportedMeasure") | ||
} | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
agent/src/test/scala/za/co/absa/atum/agent/AtumAgentTest.scala
This file contains 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,44 @@ | ||
/* | ||
* Copyright 2021 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.atum.agent | ||
|
||
import org.scalatest.funsuite.AnyFunSuiteLike | ||
import za.co.absa.atum.agent.AtumContext.AtumPartitions | ||
|
||
class AtumAgentTest extends AnyFunSuiteLike { | ||
|
||
test("AtumAgent creates AtumContext(s) as expected") { | ||
val atumAgent = new AtumAgent() | ||
val atumPartitions = AtumPartitions("abc" -> "def") | ||
val subPartitions = AtumPartitions("ghi", "jkl") | ||
|
||
val atumContext1 = atumAgent.getOrCreateAtumContext(atumPartitions) | ||
val atumContext2 = atumAgent.getOrCreateAtumContext(atumPartitions) | ||
|
||
// AtumAgent returns expected instance of AtumContext | ||
assert(atumAgent.getOrCreateAtumContext(atumPartitions) == atumContext1) | ||
assert(atumContext1 == atumContext2) | ||
|
||
// AtumSubContext contains expected AtumPartitions | ||
val atumSubContext = atumAgent.getOrCreateAtumSubContext(subPartitions)(atumContext1) | ||
assert(atumSubContext.atumPartitions == (atumPartitions ++ subPartitions)) | ||
|
||
// AtumContext contains reference to expected AtumAgent | ||
assert(atumSubContext.agent == atumAgent) | ||
} | ||
|
||
} |
This file contains 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
24 changes: 24 additions & 0 deletions
24
model/src/main/scala/za/co/absa/atum/model/dto/PartitioningDTO.scala
This file contains 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,24 @@ | ||
/* | ||
* Copyright 2021 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.atum.model.dto | ||
|
||
import za.co.absa.atum.model.Partitioning | ||
|
||
case class PartitioningDTO ( | ||
partitioning: Partitioning, | ||
parentPartitioning: Option[Partitioning] | ||
) |