-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename splitStateToDisk to spillStateToDisk (#1904)
* Rename splitStateToDisk to spillStateToDisk * Add migration * Rename label * Review Co-authored-by: Damian Święcki <dsw@touk.pl>
- Loading branch information
Showing
16 changed files
with
151 additions
and
30 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
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
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
Binary file modified
BIN
-602 Bytes
(99%)
...Process initially clean should open properites from tips panel [Linux] #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions
33
ui/server/src/main/scala/db/migration/V1_030__SpillStateToDisk.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,33 @@ | ||
package db.migration | ||
|
||
import io.circe._ | ||
import pl.touk.nussknacker.ui.db.migration.ProcessJsonMigration | ||
|
||
trait V1_030__SpillStateToDisk extends ProcessJsonMigration { | ||
|
||
override def updateProcessJson(jsonProcess: Json): Option[Json] = | ||
V1_030__SpillStateToDisk.renameSpillStateToDisk(jsonProcess) | ||
} | ||
|
||
object V1_030__SpillStateToDisk { | ||
|
||
final val emptyAdditionalBranches = Json.fromValues(List.empty) | ||
|
||
private[migration] def renameSpillStateToDisk(jsonProcess: Json): Option[Json] = { | ||
val typeSpecificDataCursor = jsonProcess.hcursor.downField("metaData").downField("typeSpecificData") | ||
val updatedTypeSpecificData = typeSpecificDataCursor | ||
.withFocus { typeSpecificData => | ||
val splitStateToDisk = typeSpecificData.hcursor.downField("splitStateToDisk").focus | ||
splitStateToDisk match { | ||
case Some(oldValue) => | ||
return typeSpecificDataCursor.withFocus { json => | ||
json.mapObject(_.add("spillStateToDisk", oldValue)) | ||
.hcursor.downField("splitStateToDisk").delete.top.get | ||
}.top | ||
case None => typeSpecificData | ||
} | ||
} | ||
updatedTypeSpecificData.top | ||
} | ||
|
||
} |
88 changes: 88 additions & 0 deletions
88
ui/server/src/test/scala/db/migration/V1_030__SpillStateToDiskSpec.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,88 @@ | ||
package db.migration | ||
|
||
import io.circe.Json | ||
import org.scalatest.{FlatSpec, Matchers} | ||
import pl.touk.nussknacker.engine.api.CirceUtil | ||
|
||
class V1_030__SpillStateToDiskSpec extends FlatSpec with Matchers { | ||
|
||
private lazy val expectedJsonWithSpillStateToDisk = { | ||
val rawJsonString = | ||
"""{ | ||
| "metaData": { | ||
| "id": "empty-2", | ||
| "typeSpecificData": { | ||
| "parallelism": 1, | ||
| "spillStateToDisk": true, | ||
| "useAsyncInterpretation": null, | ||
| "checkpointIntervalInSeconds": null, | ||
| "type": "StreamMetaData" | ||
| } | ||
| } | ||
|} | ||
|""".stripMargin | ||
Some(CirceUtil.decodeJsonUnsafe[Json](rawJsonString, "Invalid json string.")) | ||
} | ||
|
||
private lazy val expectedJsonWithoutSpillStateToDisk = { | ||
val rawJsonString = | ||
"""{ | ||
| "metaData": { | ||
| "id": "empty-2", | ||
| "typeSpecificData": { | ||
| "parallelism": 1, | ||
| "useAsyncInterpretation": null, | ||
| "checkpointIntervalInSeconds": null, | ||
| "type": "StreamMetaData" | ||
| } | ||
| } | ||
|} | ||
|""".stripMargin | ||
Some(CirceUtil.decodeJsonUnsafe[Json](rawJsonString, "Invalid json string.")) | ||
} | ||
|
||
it should "convert exists splitStateToDisk to spillStateToDisk" in { | ||
val rawJsonString = | ||
""" | ||
|{ | ||
| "metaData": { | ||
| "id": "empty-2", | ||
| "typeSpecificData": { | ||
| "parallelism": 1, | ||
| "splitStateToDisk": true, | ||
| "useAsyncInterpretation": null, | ||
| "checkpointIntervalInSeconds": null, | ||
| "type": "StreamMetaData" | ||
| } | ||
| } | ||
|} | ||
|""".stripMargin | ||
|
||
val oldJson = CirceUtil.decodeJsonUnsafe[Json](rawJsonString, "Invalid json string.") | ||
val converted = V1_030__SpillStateToDisk.renameSpillStateToDisk(oldJson) | ||
|
||
converted shouldBe expectedJsonWithSpillStateToDisk | ||
} | ||
|
||
it should "do noting when property not specified" in { | ||
val rawJsonString = | ||
""" | ||
|{ | ||
| "metaData": { | ||
| "id": "empty-2", | ||
| "typeSpecificData": { | ||
| "parallelism": 1, | ||
| "useAsyncInterpretation": null, | ||
| "checkpointIntervalInSeconds": null, | ||
| "type": "StreamMetaData" | ||
| } | ||
| } | ||
|} | ||
|""".stripMargin | ||
|
||
val oldJson = CirceUtil.decodeJsonUnsafe[Json](rawJsonString, "Invalid json string.") | ||
val converted = V1_030__SpillStateToDisk.renameSpillStateToDisk(oldJson) | ||
|
||
converted shouldBe expectedJsonWithoutSpillStateToDisk | ||
} | ||
} |
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