Skip to content

Commit d1d7004

Browse files
committed
qs
1 parent 8ed4c8b commit d1d7004

File tree

17 files changed

+56
-54
lines changed

17 files changed

+56
-54
lines changed

components-api/src/main/scala/pl/touk/nussknacker/engine/ModelConfig.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object ModelConfig {
3838

3939
final case class Enabled(
4040
maxNumberOfSamples: Int,
41-
frequencyWindowInSeconds: Int,
41+
throughputTimeWindowInSeconds: Int,
4242
) extends LiveDataPreviewMode
4343

4444
}
@@ -47,7 +47,7 @@ object ModelConfig {
4747
if (config.getOrElse("liveDataPreview.enabled", false)) {
4848
LiveDataPreviewMode.Enabled(
4949
maxNumberOfSamples = config.getOrElse("liveDataPreview.maxNumberOfSamples", 10),
50-
frequencyWindowInSeconds = config.getOrElse("liveDataPreview.frequencyWindowInSeconds", 60),
50+
throughputTimeWindowInSeconds = config.getOrElse("liveDataPreview.throughputTimeWindowInSeconds", 60),
5151
)
5252
} else {
5353
LiveDataPreviewMode.Disabled

designer/deployment-manager-api/src/main/scala/pl/touk/nussknacker/engine/api/deployment/DeploymentManager.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ object LiveDataPreviewSupported {
109109

110110
final case class LiveDataPreview(
111111
liveDataSamples: TestResults[Json],
112-
nodeTransitionFrequency: Map[NodeTransition, BigDecimal],
112+
nodeTransitionThroughput: Map[NodeTransition, BigDecimal],
113113
)
114114

115115
}

designer/server/src/main/scala/pl/touk/nussknacker/ui/api/ManagementResources.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class ManagementResources(
217217
mapResultsToHttpResponse(
218218
ResultsWithCountsDto.from(
219219
resultsWithCounts = value,
220-
nodeTransitionFrequency = None,
220+
nodeTransitionThroughput = None,
221221
skipResultsPerNode = SkipResultsPerNode(skipResultsPerNode),
222222
skipResultsPerTransition = SkipResultsPerTransition(skipResultsPerTransition)
223223
)

designer/server/src/main/scala/pl/touk/nussknacker/ui/api/ScenarioTestingApiHttpService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class ScenarioTestingApiHttpService(
240240
)
241241
} yield ResultsWithCountsDto.from(
242242
resultsWithCounts,
243-
Some(liveDataPreview.nodeTransitionFrequency),
243+
Some(liveDataPreview.nodeTransitionThroughput),
244244
skipResultsPerNode.getOrElse(SkipResultsPerNode(false)),
245245
skipResultsPerTransition.getOrElse(SkipResultsPerTransition(false))
246246
)

designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/scenarioTesting/Dtos.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,21 +201,21 @@ object Dtos {
201201
final case class ResultsWithCountsDto(
202202
results: TestResultsDto,
203203
counts: Map[String, NodeCount],
204-
nodeTransitionFrequency: Option[List[NodeTransitionFrequencyDto]],
204+
nodeTransitionThroughput: Option[List[NodeTransitionThroughputDto]],
205205
)
206206

207207
object ResultsWithCountsDto {
208208

209209
def from(
210210
resultsWithCounts: ResultsWithCounts,
211-
nodeTransitionFrequency: Option[Map[NodeTransition, BigDecimal]],
211+
nodeTransitionThroughput: Option[Map[NodeTransition, BigDecimal]],
212212
skipResultsPerNode: SkipResultsPerNode,
213213
skipResultsPerTransition: SkipResultsPerTransition
214214
): ResultsWithCountsDto = {
215215
ResultsWithCountsDto(
216216
results = TestResultsDto.from(resultsWithCounts.results, skipResultsPerNode, skipResultsPerTransition),
217217
counts = resultsWithCounts.counts,
218-
nodeTransitionFrequency = nodeTransitionFrequency.map(NodeTransitionFrequency.from),
218+
nodeTransitionThroughput = nodeTransitionThroughput.map(NodeTransitionThroughput.from),
219219
)
220220
}
221221

@@ -260,17 +260,17 @@ object Dtos {
260260
results: List[ResultContext[Json]]
261261
)
262262

263-
final case class NodeTransitionFrequencyDto(
263+
final case class NodeTransitionThroughputDto(
264264
sourceNodeId: String,
265265
destinationNodeId: Option[String],
266-
frequency: BigDecimal,
266+
throughput: BigDecimal,
267267
)
268268

269-
object NodeTransitionFrequency {
269+
object NodeTransitionThroughput {
270270

271-
def from(nodeTransitionFrequency: Map[NodeTransition, BigDecimal]): List[NodeTransitionFrequencyDto] = {
272-
nodeTransitionFrequency.map { case (k, v) =>
273-
NodeTransitionFrequencyDto(k.sourceNodeId, k.destinationNodeId, v)
271+
def from(nodeTransitionThroughput: Map[NodeTransition, BigDecimal]): List[NodeTransitionThroughputDto] = {
272+
nodeTransitionThroughput.map { case (k, v) =>
273+
NodeTransitionThroughputDto(k.sourceNodeId, k.destinationNodeId, v)
274274
}.toList
275275
}
276276

@@ -284,7 +284,7 @@ object Dtos {
284284
implicit def nodeTransitionResultSchema: Schema[NodeTransitionResult] = Schema.derived
285285
implicit def testResultsSchema: Schema[TestResultsDto] = Schema.derived
286286
implicit def nodeCountSchema: Schema[NodeCount] = Schema.anyObject
287-
implicit def nodeTransitionFrequencyDtoSchema: Schema[NodeTransitionFrequencyDto] = Schema.derived
287+
implicit def nodeTransitionThroughputDtoSchema: Schema[NodeTransitionThroughputDto] = Schema.derived
288288
implicit def resultsWithCountsSchema: Schema[ResultsWithCountsDto] = Schema.derived
289289
implicit def typingResultDecoder: Decoder[TypingResult] = Decoder.decodeJson.map(_ => typing.Unknown)
290290
implicit def scenarioGraphSchema: Schema[ScenarioGraph] = Schema.anyObject

designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/scenarioTesting/ScenarioTestingApiEndpoints.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ class ScenarioTestingApiEndpoints(auth: EndpointInput[AuthCredentials]) extends
195195
Any
196196
] =
197197
baseNuApiEndpoint
198-
.summary("Perform test")
199-
.tag("Testing")
198+
.summary("Preview of the data samples currently processed by the scenario")
199+
.tag("Live data")
200200
.get
201-
.in("scenarioTesting" / path[ProcessName]("scenarioName") / "liveData")
201+
.in("liveData" / path[ProcessName]("scenarioName"))
202202
.in(skipResultsPerNodeQueryParam)
203203
.in(skipResultsPerTransitionQueryParam)
204204
.out(statusCode(Ok).and(jsonBody[ResultsWithCountsDto]))

designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/scenarioTesting/TestResultsCodecs.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import pl.touk.nussknacker.engine.testmode.TestProcess.{
99
ResultContext
1010
}
1111
import pl.touk.nussknacker.ui.api.description.scenarioTesting.Dtos.{
12-
NodeTransitionFrequencyDto,
1312
NodeTransitionResult,
13+
NodeTransitionThroughputDto,
1414
ResultsWithCountsDto,
1515
TestResultsDto
1616
}
@@ -60,7 +60,7 @@ object TestResultsCodecs {
6060

6161
}
6262

63-
implicit val nodeTransitionFrequencyDto: Encoder[NodeTransitionFrequencyDto] = deriveConfiguredEncoder
63+
implicit val nodeTransitionThroughputDto: Encoder[NodeTransitionThroughputDto] = deriveConfiguredEncoder
6464

6565
implicit val testResultsDecoder: Decoder[TestResultsDto] =
6666
Decoder.failed(DecodingFailure("Not implemented", List.empty))

designer/server/src/test/scala/pl/touk/nussknacker/ui/api/testing/ScenarioTestingApiHttpServiceSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ trait ScenarioTestingApiHttpServiceSpec
449449
}
450450
.when()
451451
.basicAuthAllPermUser()
452-
.get(s"$nuDesignerHttpAddress/api/scenarioTesting/${exampleScenario.name}/liveData")
452+
.get(s"$nuDesignerHttpAddress/api/liveData/${exampleScenario.name}")
453453
.Then()
454454
.statusCode(StatusCodes.OK.intValue)
455455
.body(

docs-internal/api/nu-designer-openapi.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4574,12 +4574,12 @@ paths:
45744574
security:
45754575
- {}
45764576
- httpAuth: []
4577-
/api/scenarioTesting/{scenarioName}/liveData:
4577+
/api/liveData/{scenarioName}:
45784578
get:
45794579
tags:
4580-
- Testing
4581-
summary: Perform test
4582-
operationId: getApiScenariotestingScenarionameLivedata
4580+
- Live data
4581+
summary: Preview of the data samples currently processed by the scenario
4582+
operationId: getApiLivedataScenarioname
45834583
parameters:
45844584
- name: Nu-Impersonate-User-Identity
45854585
in: header
@@ -6597,37 +6597,37 @@ components:
65976597
type: string
65986598
type:
65996599
$ref: '#/components/schemas/NodeTypes12'
6600-
NodeTransitionFrequencyDto:
6601-
title: NodeTransitionFrequencyDto
6600+
NodeTransitionResult:
6601+
title: NodeTransitionResult
66026602
type: object
66036603
required:
66046604
- sourceNodeId
6605-
- frequency
66066605
properties:
66076606
sourceNodeId:
66086607
type: string
66096608
destinationNodeId:
66106609
type:
66116610
- string
66126611
- 'null'
6613-
frequency:
6614-
type: number
6615-
NodeTransitionResult:
6616-
title: NodeTransitionResult
6612+
results:
6613+
type: array
6614+
items:
6615+
$ref: '#/components/schemas/ResultContext_Json'
6616+
NodeTransitionThroughputDto:
6617+
title: NodeTransitionThroughputDto
66176618
type: object
66186619
required:
66196620
- sourceNodeId
6621+
- throughput
66206622
properties:
66216623
sourceNodeId:
66226624
type: string
66236625
destinationNodeId:
66246626
type:
66256627
- string
66266628
- 'null'
6627-
results:
6628-
type: array
6629-
items:
6630-
$ref: '#/components/schemas/ResultContext_Json'
6629+
throughput:
6630+
type: number
66316631
NodeTypes:
66326632
title: NodeTypes
66336633
type: string
@@ -7104,12 +7104,12 @@ components:
71047104
$ref: '#/components/schemas/TestResultsDto'
71057105
counts:
71067106
$ref: '#/components/schemas/Map_NodeCount'
7107-
nodeTransitionFrequency:
7107+
nodeTransitionThroughput:
71087108
type:
71097109
- array
71107110
- 'null'
71117111
items:
7112-
$ref: '#/components/schemas/NodeTransitionFrequencyDto'
7112+
$ref: '#/components/schemas/NodeTransitionThroughputDto'
71137113
RunDeploymentRequest:
71147114
title: RunDeploymentRequest
71157115
type: object

docs/Changelog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ description: Stay informed with detailed changelogs covering new features, impro
177177
* [#8042](https://github.com/TouK/nussknacker/pull/8042) Merge OpenAPI components into one with multiple services.
178178
* [#8047](https://github.com/TouK/nussknacker/pull/8047) Added functionality of collecting live data samples and node transition frequencies
179179
* live data preview is optional and available for now only for Flink minicluster
180-
* there is a new endpoint `/scenarioTesting/{scenarioName}/liveData`, which returns live data samples and frequencies
180+
* there is a new endpoint `/liveData/{scenarioName}`, which returns live data samples and throughput information
181181
* the functionality can be configured by setting in the 'modelConfig' section of the scenario type:
182182
```hocon
183183
liveDataPreview { // optional config section, functionality disabled by default
184184
enabled: true // disabled by default
185185
maxNumberOfSamples: 20 // max number of latest live data samples that will be returned
186-
frequencyWindowInSeconds: 60 // the time windows, for which the node transition frequency will be calculated
186+
throughputTimeWindowInSeconds: 60 // the time windows, for which the node transition throughput will be calculated
187187
}
188188
```
189189

engine/flink/management/src/it/resources/application.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ modelConfig {
1010
liveDataPreview {
1111
enabled: true
1212
maxNumberOfSamples: 20
13-
frequencyWindowInSeconds: 60
13+
throughputTimeWindowInSeconds: 60
1414
}
1515
}

engine/flink/management/src/it/scala/pl/touk/nussknacker/engine/management/streaming/BaseFlinkDeploymentManagerSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ trait BaseFlinkDeploymentManagerSpec extends AnyFunSuiteLike with Matchers with
8181
LiveDataCollectingListenerHolder.createListenerFor(
8282
processName = processName,
8383
maxNumberOfSamples = 20,
84-
frequencyWindowInSeconds = 60
84+
throughputTimeWindowInSeconds = 60
8585
)
8686
val externalDeploymentIdOpt = deployProcessAndWaitIfRunning(
8787
process = process,

engine/flink/management/src/main/scala/pl/touk/nussknacker/engine/management/jobrunner/FlinkMiniClusterScenarioJobRunner.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ class FlinkMiniClusterScenarioJobRunner(
5252
modelDataProvider.getCurrentModelData().modelConfig.liveDataPreviewMode match {
5353
case LiveDataPreviewMode.Disabled =>
5454
None
55-
case LiveDataPreviewMode.Enabled(maxNumberOfSamples, frequencyWindowInSeconds) =>
55+
case LiveDataPreviewMode.Enabled(maxNumberOfSamples, throughputTimeWindowInSeconds) =>
5656
Some(
5757
LiveDataCollectingListenerHolder.createListenerFor(
5858
command.processVersion.processName,
5959
maxNumberOfSamples,
60-
frequencyWindowInSeconds
60+
throughputTimeWindowInSeconds
6161
)
6262
)
6363
}

engine/flink/management/src/main/scala/pl/touk/nussknacker/engine/management/jobrunner/livedata/LiveDataCollectingListener.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import scala.util.Try
1212
class LiveDataCollectingListener private[livedata] (
1313
processName: ProcessName,
1414
maxNumberOfSamples: Int,
15-
frequencyWindowInSeconds: Int,
15+
throughputTimeWindowInSeconds: Int,
1616
) extends ProcessListener
1717
with Serializable {
1818

@@ -21,7 +21,7 @@ class LiveDataCollectingListener private[livedata] (
2121
private def storage = LiveDataCollectingListenerHolder.storage(
2222
processName = processName,
2323
maxNumberOfSamples = maxNumberOfSamples,
24-
frequencyWindowInSeconds = frequencyWindowInSeconds,
24+
throughputTimeWindowInSeconds = throughputTimeWindowInSeconds,
2525
)
2626

2727
override def nodeEntered(nodeId: String, context: Context, processMetaData: MetaData): Unit = {

engine/flink/management/src/main/scala/pl/touk/nussknacker/engine/management/jobrunner/livedata/LiveDataCollectingListenerHolder.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ object LiveDataCollectingListenerHolder {
1717
def createListenerFor(
1818
processName: ProcessName,
1919
maxNumberOfSamples: Int,
20-
frequencyWindowInSeconds: Int,
20+
throughputTimeWindowInSeconds: Int,
2121
): LiveDataCollectingListener = {
2222
// We want to store and present only the live data from the current deployment,
2323
// so when we start a new job, we discard all old data
2424
cleanResults(processName)
25-
new LiveDataCollectingListener(processName, maxNumberOfSamples, frequencyWindowInSeconds)
25+
new LiveDataCollectingListener(processName, maxNumberOfSamples, throughputTimeWindowInSeconds)
2626
}
2727

2828
def getLiveDataPreview(processName: ProcessName): Option[LiveDataPreview] = {
@@ -36,11 +36,13 @@ object LiveDataCollectingListenerHolder {
3636
private[livedata] def storage(
3737
processName: ProcessName,
3838
maxNumberOfSamples: Int,
39-
frequencyWindowInSeconds: Int,
39+
throughputTimeWindowInSeconds: Int,
4040
): LiveDataCollectingListenerStorage = {
4141
listenerStorages.get(
4242
processName.value,
43-
asJavaFunction((_: String) => new LiveDataCollectingListenerStorage(maxNumberOfSamples, frequencyWindowInSeconds))
43+
asJavaFunction((_: String) =>
44+
new LiveDataCollectingListenerStorage(maxNumberOfSamples, throughputTimeWindowInSeconds)
45+
)
4446
)
4547
}
4648

engine/flink/management/src/main/scala/pl/touk/nussknacker/engine/management/jobrunner/livedata/LiveDataCollectingListenerStorage.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import scala.jdk.CollectionConverters._
1212

1313
private[livedata] class LiveDataCollectingListenerStorage(
1414
maxNumberOfSamples: Int,
15-
frequencyWindowInSeconds: Int,
15+
throughputTimeWindowInSeconds: Int,
1616
) {
1717

1818
private type K = String
@@ -65,7 +65,7 @@ private[livedata] class LiveDataCollectingListenerStorage(
6565
TestResults.aggregate(orderOfResults.asScala.toList.flatMap(key => Option(results.get(key))))
6666

6767
private def getTransitionFrequencies: Map[NodeTransition, BigDecimal] = {
68-
val cutoff = Instant.now().getEpochSecond - frequencyWindowInSeconds
68+
val cutoff = Instant.now().getEpochSecond - throughputTimeWindowInSeconds
6969
val oldestSampleEpochSecond = transitionsByEpochSecond.keys().asScala.min
7070
val newestSampleEpochSecond = transitionsByEpochSecond.keys().asScala.max
7171
val samplingInterval = newestSampleEpochSecond - oldestSampleEpochSecond + 1
@@ -83,7 +83,7 @@ private[livedata] class LiveDataCollectingListenerStorage(
8383
}
8484

8585
private def cleanOldTransitions(currentEpochSecond: Long): Unit = {
86-
val cutoff = currentEpochSecond - frequencyWindowInSeconds
86+
val cutoff = currentEpochSecond - throughputTimeWindowInSeconds
8787
transitionsByEpochSecond
8888
.keySet()
8989
.asScala

nussknacker-dist/src/universal/conf/dev-application.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ scenarioTypes {
134134
liveDataPreview {
135135
enabled: true
136136
maxNumberOfSamples: 20
137-
frequencyWindowInSeconds: 60
137+
throughputTimeWindowInSeconds: 60
138138
}
139139
}
140140

0 commit comments

Comments
 (0)