Skip to content

Commit

Permalink
rename source 'sample-generator' to 'event-generator' and 'period' to…
Browse files Browse the repository at this point in the history
… 'schedule'
  • Loading branch information
mslabek committed Jan 27, 2025
1 parent 8096bed commit 5af67e7
Show file tree
Hide file tree
Showing 27 changed files with 149 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class DefaultModelMigrations extends ProcessMigrations {
// 100 -> NewMigration,
// Newly added migrations should be in the hundreds: 100, 200, 300 and so on. We do this because
// many ProcessMigrations can be loaded using SPI, and we want to avoid overlapping numbers when merging.
100 -> SampleGeneratorToEventGeneratorAndPeriodToScheduleParameter
)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package pl.touk.nussknacker.defaultmodel.migrations

import pl.touk.nussknacker.engine.api.MetaData
import pl.touk.nussknacker.engine.api.parameter.ParameterName
import pl.touk.nussknacker.engine.graph.node
import pl.touk.nussknacker.engine.graph.node.Source
import pl.touk.nussknacker.engine.graph.source.SourceRef
import pl.touk.nussknacker.engine.migration.NodeMigration

object SampleGeneratorToEventGeneratorAndPeriodToScheduleParameter extends NodeMigration {

override val description: String = "Change name of component: sample-generator -> event-generator " +
"and its parameter: period -> schedule"

override def migrateNode(metaData: MetaData): PartialFunction[node.NodeData, node.NodeData] = {
case source @ Source(_, ref @ SourceRef("sample-generator", _), _) =>
source.copy(ref =
ref.copy(
typ = "event-generator",
parameters = ref.parameters.map { param =>
param.name.value match {
case "period" => param.copy(name = ParameterName("schedule"))
case _ => param
}
}
)
)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package pl.touk.nussknacker.defaultModel.migrations

import org.scalatest.freespec.AnyFreeSpecLike
import org.scalatest.matchers.should.Matchers
import pl.touk.nussknacker.defaultmodel.migrations.SampleGeneratorToEventGeneratorAndPeriodToScheduleParameter
import pl.touk.nussknacker.engine.api.parameter.ParameterName
import pl.touk.nussknacker.engine.api.{MetaData, StreamMetaData}
import pl.touk.nussknacker.engine.graph.evaluatedparam.Parameter
import pl.touk.nussknacker.engine.graph.node.Source
import pl.touk.nussknacker.engine.graph.source.SourceRef
import pl.touk.nussknacker.engine.spel.SpelExtension._

class SampleGeneratorToEventGeneratorAndPeriodicToScheduleSpec extends AnyFreeSpecLike with Matchers {

"PeriodicToSampleGeneratorMigration should be applied" in {
val metaData = MetaData("test", StreamMetaData(Some(1)))
val beforeMigration = Source(
id = "sample-generator",
ref = SourceRef(
typ = "sample-generator",
parameters = List(
Parameter(ParameterName("period"), "T(java.time.Duration).parse('PT1M')".spel),
Parameter(ParameterName("count"), "1".spel),
Parameter(ParameterName("value"), "1".spel),
)
)
)
val expectedAfterMigration = Source(
id = "sample-generator",
ref = SourceRef(
typ = "event-generator",
parameters = List(
Parameter(ParameterName("schedule"), "T(java.time.Duration).parse('PT1M')".spel),
Parameter(ParameterName("count"), "1".spel),
Parameter(ParameterName("value"), "1".spel),
)
)
)

val migrated = SampleGeneratorToEventGeneratorAndPeriodToScheduleParameter.migrateNode(metaData)(beforeMigration)

migrated shouldBe expectedAfterMigration
}

}
2 changes: 1 addition & 1 deletion designer/client/cypress/e2e/counts.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("Counts", () => {
.click();
cy.get("[data-testid=window]").contains(/^ok$/i).click();

cy.getNode("sample-generator")
cy.getNode("event-generator")
.parent()
.matchImage({ screenshotConfig: { padding: 16 } });
});
Expand Down
6 changes: 3 additions & 3 deletions designer/client/cypress/e2e/nodeWindow.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ describe("Node window", () => {
cy.viewport(1600, 800);
});

it("should display sample-generator source", () => {
it("should display event-generator source", () => {
cy.visitNewProcess(NAME).as("processName");
cy.contains(/^sources$/)
.should("exist")
.scrollIntoView();
cy.layoutScenario();
cy.get("[data-testid='component:sample-generator']")
cy.get("[data-testid='component:event-generator']")
.should("be.visible")
.drag("#nk-graph-main", {
target: {
Expand All @@ -29,7 +29,7 @@ describe("Node window", () => {
force: true,
});

cy.getNode("sample-generator").dblclick();
cy.getNode("event-generator").dblclick();

// TODO: fix validation display in node windows
cy.intercept("POST", "/api/nodes/*/validation").as("validation");
Expand Down
6 changes: 3 additions & 3 deletions designer/client/cypress/fixtures/aggregations.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
},
"nodes": [
{
"id": "sample-generator",
"id": "event-generator",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down
6 changes: 3 additions & 3 deletions designer/client/cypress/fixtures/counts.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
},
"nodes": [
{
"id": "sample-generator",
"id": "event-generator",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1S')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
{
"id": "subscriber alerts",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down Expand Up @@ -65,10 +65,10 @@
{
"id": "audit - all events",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@
{
"id": "subscriber alerts",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down Expand Up @@ -160,10 +160,10 @@
{
"id": "audit - all events",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
{
"id": "source",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
{
"id": "source",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
{
"id": "source",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
{
"id": "source",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
},
"nodes": [
{
"id": "sample-generator",
"id": "event-generator",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
},
"nodes": [
{
"id": "sample-generator",
"id": "event-generator",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
{
"id": "source",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
{
"id": "input Kafka topic with json content",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
},
"nodes": [
{
"id": "sample-generator",
"id": "event-generator",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('PT1M')"
Expand Down
6 changes: 3 additions & 3 deletions designer/client/cypress/fixtures/table.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
},
"nodes": [
{
"id": "sample-generator",
"id": "event-generator",
"ref": {
"typ": "sample-generator",
"typ": "event-generator",
"parameters": [
{
"name": "period",
"name": "schedule",
"expression": {
"language": "spel",
"expression": "T(java.time.Duration).parse('P1D')"
Expand Down
7 changes: 4 additions & 3 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
* [#7356](https://github.com/TouK/nussknacker/pull/7356) Integers converted to BigDecimals have scale 18,
this fixes issue with unexpected low scale when performing division on BigDecimals which were created in such conversion.
* [#7379](https://github.com/TouK/nussknacker/pull/7379) Removed CustomAction mechanism.
* Changes to `periodic` component (renamed to `sample-generator`):
* [#7368](https://github.com/TouK/nussknacker/pull/7368) Component rename: `periodic` to `sample-generator`
* [#7373](https://github.com/TouK/nussknacker/pull/7373) Improvements to `period` editor
* Changes to `periodic` component (renamed to `event-generator`):
* [#TODO](https://github.com/TouK/nussknacker/pull/TODO) Component rename: `periodic` to `event-generator`
* [#TODO](https://github.com/TouK/nussknacker/pull/TODO) Parameter rename: `period` to `schedule`
* [#7373](https://github.com/TouK/nussknacker/pull/7373) Improvements to `schedule` editor
* [#7376](https://github.com/TouK/nussknacker/pull/7376) Previously, when count was > 1, the value was evaluated once
and emitted times count. For example: if the value was evaluated to be a random UUID and count was 5, one UUID was
generated and emitted 5 times. Now in one count batch each value is evaluated separately.
Expand Down
2 changes: 1 addition & 1 deletion docs/MigrationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ To see the biggest differences please consult the [changelog](Changelog.md).
`deploymentConfig.scenarioTesting.reuseMiniClusterForScenarioStateVerification` to `false`
### Code API changes
* [#7368](https://github.com/TouK/nussknacker/pull/7368) Renamed `PeriodicSourceFactory` to `SampleGeneratorSourceFactory`
* [#7368](https://github.com/TouK/nussknacker/pull/7368) [#TODO](https://github.com/TouK/nussknacker/pull/TODO) Renamed `PeriodicSourceFactory` to `EventGeneratorSourceFactory`
* [#7364](https://github.com/TouK/nussknacker/pull/7364) The DeploymentManager must implement `def schedulingSupport: SchedulingSupport`. If support not added, then `NoSchedulingSupport` should be used.
## In version 1.18.0
Expand Down
2 changes: 1 addition & 1 deletion docs/developers_guide/FlinkComponents.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Your Nussknacker source component specification should be a [SourceFactory](http
returning your source implementation.

### Examples
- [Periodic source](../scenarios_authoring/DataSourcesAndSinks.md#sample-generator) and its [implementation](https://github.com/TouK/nussknacker/blob/staging/engine/flink/components/base/src/main/scala/pl/touk/nussknacker/engine/flink/util/transformer/SampleGeneratorSourceFactory.scala)
- [Periodic source](../scenarios_authoring/DataSourcesAndSinks.md#event-generator) and its [implementation](https://github.com/TouK/nussknacker/blob/staging/engine/flink/components/base/src/main/scala/pl/touk/nussknacker/engine/flink/util/transformer/SampleGeneratorSourceFactory.scala)
- [FlinkKafkaSource](https://github.com/TouK/nussknacker/blob/staging/engine/flink/kafka-components-utils/src/main/scala/pl/touk/nussknacker/engine/kafka/source/flink/FlinkKafkaSource.scala)
and its factory returning the source implementation along with the fixed specification (e.g. based on a Scala case class) [KafkaSourceFactory](https://github.com/TouK/nussknacker/blob/staging/utils/kafka-components-utils/src/main/scala/pl/touk/nussknacker/engine/kafka/source/KafkaSourceFactory.scala)
or generic one [UniversalKafkaSourceFactory](https://github.com/TouK/nussknacker/blob/staging/utils/schemed-kafka-components-utils/src/main/scala/pl/touk/nussknacker/engine/schemedkafka/source/UniversalKafkaSourceFactory.scala)
Expand Down
Loading

0 comments on commit 5af67e7

Please sign in to comment.