Skip to content
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

[NU-1923] Rename source 'periodic' to 'sample generator' #7368

Merged
merged 8 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class DefaultModelMigrations extends ProcessMigrations {
GroupByMigration,
SinkExpressionMigration,
RequestResponseSinkValidationModeMigration,
DecisionTableParameterNamesMigration
DecisionTableParameterNamesMigration,
PeriodicToSampleGeneratorMigration
)
.processMigrations

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package pl.touk.nussknacker.defaultmodel.migrations

import pl.touk.nussknacker.engine.api.MetaData
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 PeriodicToSampleGeneratorMigration extends NodeMigration {

override val description: String = "Change name of component: periodic -> sample-generator"

override def migrateNode(metaData: MetaData): PartialFunction[node.NodeData, node.NodeData] = {
case n @ Source(_, ref @ SourceRef("periodic", _), _) =>
n.copy(ref = ref.copy(typ = "sample-generator"))
}

}
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.PeriodicToSampleGeneratorMigration
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 PeriodicToSampleGeneratorSpec extends AnyFreeSpecLike with Matchers {

"PeriodicToSampleGeneratorMigration should be applied" in {
val metaData = MetaData("test", StreamMetaData(Some(1)))
val beforeMigration = Source(
id = "periodic",
ref = SourceRef(
typ = "periodic",
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 = "periodic",
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 migrated = PeriodicToSampleGeneratorMigration.migrateNode(metaData)(beforeMigration)

migrated shouldBe expectedAfterMigration
}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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("periodic")
cy.getNode("sample-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 periodic source", () => {
it("should display sample-generator source", () => {
cy.visitNewProcess(NAME).as("processName");
cy.contains(/^sources$/)
.should("exist")
.scrollIntoView();
cy.layoutScenario();
cy.get("[data-testid='component:periodic']")
cy.get("[data-testid='component:sample-generator']")
.should("be.visible")
.drag("#nk-graph-main", {
target: {
Expand All @@ -29,7 +29,7 @@ describe("Node window", () => {
force: true,
});

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

// TODO: fix validation display in node windows
cy.intercept("POST", "/api/nodes/*/validation").as("validation");
Expand Down
4 changes: 2 additions & 2 deletions designer/client/cypress/fixtures/aggregations.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
},
"nodes": [
{
"id": "periodic",
"id": "sample-generator",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
4 changes: 2 additions & 2 deletions designer/client/cypress/fixtures/counts.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
},
"nodes": [
{
"id": "periodic",
"id": "sample-generator",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"id": "subscriber alerts",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down Expand Up @@ -65,7 +65,7 @@
{
"id": "audit - all events",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
{
"id": "subscriber alerts",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down Expand Up @@ -160,7 +160,7 @@
{
"id": "audit - all events",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"id": "source",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"id": "source",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"id": "source",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"id": "source",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
},
"nodes": [
{
"id": "periodic",
"id": "sample-generator",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
},
"nodes": [
{
"id": "source",
"id": "sample-generator",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"id": "source",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"id": "input Kafka topic with json content",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
},
"nodes": [
{
"id": "periodic",
"id": "sample-generator",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
4 changes: 2 additions & 2 deletions designer/client/cypress/fixtures/table.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
},
"nodes": [
{
"id": "periodic",
"id": "sample-generator",
"ref": {
"typ": "periodic",
"typ": "sample-generator",
"parameters": [
{
"name": "period",
Expand Down
1 change: 1 addition & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* [#7341](https://github.com/TouK/nussknacker/pull/7341) Added possibility to choose presets and define lists for Integer typed parameter inputs in fragments.
* [#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.
* [#7368](https://github.com/TouK/nussknacker/pull/7368) Component rename: `periodic` to `sample-generator`

## 1.18

Expand Down
3 changes: 3 additions & 0 deletions docs/MigrationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ To see the biggest differences please consult the [changelog](Changelog.md).
* [#7347](https://github.com/TouK/nussknacker/pull/7347) All calls to `org.apache.flink.api.common.functions.RichFunction.open(Configuration)`,
which is deprecated, were replaced with calls to `org.apache.flink.api.common.functions.RichFunction.open(OpenContext)`

### Code API changes
* [#7368](https://github.com/TouK/nussknacker/pull/7368) Renamed `PeriodicSourceFactory` to `SampleGeneratorSourceFactory`

## In version 1.18.0

### Configuration changes
Expand Down
4 changes: 2 additions & 2 deletions docs/developers_guide/Components.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ The main limitations of this method are:
- Component can only add value of fixed type to ValidationContext.

Examples:
- [Service](https://github.com/TouK/nussknacker/blob/staging/engine/flink/management/dev-model/src/main/scala/pl/touk/nussknacker/engine/management/sample/service/MultipleParamsService.scala#L8),
- [SourceFactory](https://github.com/TouK/nussknacker/blob/staging/engine/flink/components/base/src/main/scala/pl/touk/nussknacker/engine/flink/util/transformer/PeriodicSourceFactory.scala#L25)
- [Service](https://github.com/TouK/nussknacker/blob/staging/engine/flink/management/dev-model/src/main/scala/pl/touk/nussknacker/engine/management/sample/service/MultipleParamsService.scala#L10),
- [SourceFactory](https://github.com/TouK/nussknacker/blob/staging/engine/flink/components/base/src/main/scala/pl/touk/nussknacker/engine/flink/util/transformer/SampleGeneratorSourceFactory.scala#L51)

### ContextTransformation

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#periodic) and its [implementation](https://github.com/TouK/nussknacker/blob/staging/engine/flink/components/base/src/main/scala/pl/touk/nussknacker/engine/flink/util/transformer/PeriodicSourceFactory.scala)
- [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)
- [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
4 changes: 2 additions & 2 deletions docs/scenarios_authoring/DataSourcesAndSinks.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ Holds event in the node until
The `key` parameter will be removed in the future release of Nussknacker, for the time being, configure it to `#inputMeta.key`.

 
### Periodic
### Sample generator

**(Flink engine only)**

![periodic_window](img/periodic.png)
![sample_generator_window](img/sample-generator.png)

This source provides functionality of sending a number of given events in a periodic way. It's mainly used for testing.

Expand Down
Binary file removed docs/scenarios_authoring/img/periodic.png
Binary file not shown.
Binary file added docs/scenarios_authoring/img/sample-generator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import pl.touk.nussknacker.engine.testing.LocalModelData
import pl.touk.nussknacker.engine.testmode.ResultsCollectingListenerHolder
import pl.touk.nussknacker.test.PatientScalaFutures

class PeriodicSourceFactorySpec extends AnyFunSuite with FlinkSpec with PatientScalaFutures with Matchers with Inside {
class SampleGeneratorSourceFactorySpec extends AnyFunSuite with FlinkSpec with PatientScalaFutures with Matchers with Inside {

test("should produce results for each element in list") {
val sinkId = "sinkId"
Expand All @@ -29,8 +29,8 @@ class PeriodicSourceFactorySpec extends AnyFunSuite with FlinkSpec with PatientS
val scenario = ScenarioBuilder
.streaming("test")
.source(
"periodic",
"periodic",
"sample-generator",
"sample-generator",
"period" -> "T(java.time.Duration).ofSeconds(1)".spel,
"count" -> "1".spel,
"value" -> s"'$input'".spel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import pl.touk.nussknacker.engine.flink.util.transformer.aggregate.sampleTransfo
TumblingAggregateTransformer
}
import pl.touk.nussknacker.engine.flink.util.transformer.join.{FullOuterJoinTransformer, SingleSideJoinTransformer}
import pl.touk.nussknacker.engine.flink.util.transformer.{PeriodicSourceFactory, UnionWithMemoTransformer}
import pl.touk.nussknacker.engine.flink.util.transformer.{SampleGeneratorSourceFactory, UnionWithMemoTransformer}
import pl.touk.nussknacker.engine.util.config.DocsConfig

class FlinkBaseUnboundedComponentProvider extends ComponentProvider {
Expand Down Expand Up @@ -39,7 +39,9 @@ object FlinkBaseUnboundedComponentProvider {

// When adding/changing stateful components, corresponding changes should be done in LiteBaseComponentProvider!
val statelessComponents = List(
ComponentDefinition("periodic", PeriodicSourceFactory).withRelativeDocs("DataSourcesAndSinks#periodic"),
ComponentDefinition("sample-generator", SampleGeneratorSourceFactory).withRelativeDocs(
"DataSourcesAndSinks#sample-generator"
),
)

val statefulComponents = List(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import javax.validation.constraints.Min
import scala.jdk.CollectionConverters._

// TODO: add testing capabilities
object PeriodicSourceFactory
extends PeriodicSourceFactory(
object SampleGeneratorSourceFactory
extends SampleGeneratorSourceFactory(
new StandardTimestampWatermarkHandler[AnyRef](
WatermarkStrategy
.forMonotonousTimestamps()
Expand All @@ -41,7 +41,7 @@ object PeriodicSourceFactory
)
)

class PeriodicSourceFactory(timestampAssigner: TimestampWatermarkHandler[AnyRef])
class SampleGeneratorSourceFactory(timestampAssigner: TimestampWatermarkHandler[AnyRef])
extends SourceFactory
with UnboundedStreamComponent {

Expand Down
Loading