Skip to content

Commit

Permalink
experiment description
Browse files Browse the repository at this point in the history
  • Loading branch information
zambrovski committed Jan 17, 2024
1 parent b0a4626 commit ad24cd0
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 26 deletions.
9 changes: 5 additions & 4 deletions .docker/config/axonserver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ axoniq:
axonserver:
name: eventstore-transformations-local
hostname: localhost
#standalone: true
autocluster:
first:
contexts: default
standalone: true
accesscontrol:
enabled: false
devmode:
enabled: true
event:
segment-size: 1000000 # 1mb
snapshot:
segment-size: 1000000 # 1mb
108 changes: 92 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,109 @@
# axon-event-transformation-example

Template repository for usage in organizations: toolisticon, holunda-io, holixon...
# Axon Event Transformation Example

[![incubating](https://img.shields.io/badge/lifecycle-INCUBATING-orange.svg)](https://github.com/holisticon#open-source-lifecycle)
[![Build Status](https://github.com/holixon/axon-event-transformation-example/workflows/Development%20branches/badge.svg)](https://github.com/holixon/axon-event-transformation-example/actions)
[![sponsored](https://img.shields.io/badge/sponsoredBy-Holisticon-RED.svg)](https://holisticon.de/)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.holixon.example.axon-event-transformation/axon-event-transformation-example/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.holixon.example.axon-event-transformation/axon-event-transformation-example)

This repository is a **template repository** designed to be a template for the next project.
## Experiment

### Setup

- Size of event file set to 1000000 bytes (977kb).
- We consider only event storage (no snapshot files, no nindex files, no global-index-00000.xref)
- The size of the snapshot file can be set-up via property
- The size of the index file seems to be 2097152 bytes (approx 2mb) for event segment files of default size (256mb) and for a drastically reduced event segment size of 977k.
- The size of global-index-00000.xref is 64mb

Event payload:

```json
{
"sensorId": "temp1",
"values": {
"2025-01-16": {
"value": 23.363865,
"unit": "°C"
},
"2025-01-17": {
"value": 23.188648,
"unit": "°C"
},
another 363 values for dates
}
}
```
A single JSON payload consumes 16415 bytes in total (netto)
Based on file names of event files (00000000000000000175.events, 00000000000000000233.events) 58 update events match into a 977kb file resulting in 16845 bytes (brutto).

356 event consume 16845 * 365 = 6148425 brutto (splitting), resulting in not quite full 7 segments per batch run.

### Empty event store

## Things to change after usage of template
977K Jan 17 22:40 00000000000000000000.events

To change the following values, modify the placeholders in `setup.sh` and run it.
This is a one-time operation, you can safely delete the `setup.sh` file afterwards.
### First batch run (1 create sensor event + 365 update events)

Of course, you can also edit manually .... and do not forget to change this `README.md` with YOUR project specific information :-).
977K Jan 17 22:44 00000000000000000000.events
977K Jan 17 22:45 00000000000000000059.events
977K Jan 17 22:45 00000000000000000117.events
977K Jan 17 22:45 00000000000000000175.events
977K Jan 17 22:45 00000000000000000233.events
977K Jan 17 22:45 00000000000000000291.events
977K Jan 17 22:45 00000000000000000349.events

### Maven pom.xml
### Second batch run (further 365 update events starting from "2024-01-17T21:48:22.384553762Z")

* Maven coordinates: `groupId`, `artifactId` and `version`
* Main description: `name`, `url`, `description`
* SCM: `connection`, `url`, `developerConnection`
977K Jan 17 22:44 00000000000000000000.events
977K Jan 17 22:45 00000000000000000059.events
977K Jan 17 22:45 00000000000000000117.events
977K Jan 17 22:45 00000000000000000175.events
977K Jan 17 22:45 00000000000000000233.events
977K Jan 17 22:45 00000000000000000291.events
977K Jan 17 22:48 00000000000000000349.events
977K Jan 17 22:48 00000000000000000407.events
977K Jan 17 22:48 00000000000000000465.events
977K Jan 17 22:48 00000000000000000523.events
977K Jan 17 22:48 00000000000000000581.events
977K Jan 17 22:48 00000000000000000639.events
977K Jan 17 22:48 00000000000000000697.events

### Issue Template
### Cleanup (delete all update events created before "2024-01-17T21:48:22.384553762Z")

* correct the URL to repo
3,9K Jan 17 22:50 00000000000000000000_00003.events
977K Jan 17 22:44 00000000000000000000.events
3,6K Jan 17 22:50 00000000000000000059_00003.events
977K Jan 17 22:45 00000000000000000059.events
3,6K Jan 17 22:50 00000000000000000117_00003.events
977K Jan 17 22:45 00000000000000000117.events
3,6K Jan 17 22:50 00000000000000000175_00003.events
977K Jan 17 22:45 00000000000000000175.events
3,6K Jan 17 22:50 00000000000000000233_00003.events
977K Jan 17 22:45 00000000000000000233.events
3,6K Jan 17 22:50 00000000000000000291_00003.events
977K Jan 17 22:45 00000000000000000291.events
668K Jan 17 22:50 00000000000000000349_00003.events
977K Jan 17 22:48 00000000000000000349.events
977K Jan 17 22:48 00000000000000000407.events
977K Jan 17 22:48 00000000000000000465.events
977K Jan 17 22:48 00000000000000000523.events
977K Jan 17 22:48 00000000000000000581.events
977K Jan 17 22:48 00000000000000000639.events
977K Jan 17 22:48 00000000000000000697.events

### Issue Labels
### Compacting

* Check the release-notes.yml for details, but create the following labels: Type: dependencies, Type: bug, Type: documentation, Type: question, Type: enhancement
3,9K Jan 17 22:50 00000000000000000000_00003.events
3,6K Jan 17 22:50 00000000000000000059_00003.events
3,6K Jan 17 22:50 00000000000000000117_00003.events
3,6K Jan 17 22:50 00000000000000000175_00003.events
3,6K Jan 17 22:50 00000000000000000233_00003.events
3,6K Jan 17 22:50 00000000000000000291_00003.events
668K Jan 17 22:50 00000000000000000349_00003.events
977K Jan 17 22:48 00000000000000000407.events
977K Jan 17 22:48 00000000000000000465.events
977K Jan 17 22:48 00000000000000000523.events
977K Jan 17 22:48 00000000000000000581.events
977K Jan 17 22:48 00000000000000000639.events
977K Jan 17 22:48 00000000000000000697.events

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.5"

services:
axonserver:
image: axoniq/axonserver:2023.2.1-jdk-11
image: axoniq/axonserver:2023.2.2-jdk-11
container_name: eventstore-transformations-axonserver
ports:
- "8024:8024"
Expand Down
12 changes: 10 additions & 2 deletions src/main/kotlin/adapter/in/MeasurementController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.springframework.http.ResponseEntity
import org.springframework.http.ResponseEntity.noContent
import org.springframework.http.ResponseEntity.ok
import org.springframework.web.bind.annotation.*
import java.time.Instant
import java.time.LocalTime
import java.time.OffsetDateTime
import java.time.ZoneOffset
Expand Down Expand Up @@ -55,8 +56,15 @@ class MeasurementController(
}

@PostMapping(value = ["/batch"])
fun batchUpdate(): ResponseEntity<Void> {
fun batchUpdate(): ResponseEntity<ExecutionTimeDto> {
val before = Instant.now()
generateRandomBatchUpdateInPort.runBatchUpdate()
return noContent().build()
val after = Instant.now()
return ok(ExecutionTimeDto(start = before, end = after))
}

data class ExecutionTimeDto(
val start: Instant,
val end: Instant
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import io.holixon.example.axon.event.transformation.adapter.out.event.Measuremen
import mu.KLogging
import org.axonframework.config.ProcessingGroup
import org.axonframework.eventhandling.EventHandler
import org.axonframework.eventhandling.Timestamp
import org.springframework.stereotype.Component
import java.time.Instant

@Component
@ProcessingGroup(value = "measurements")
Expand All @@ -14,8 +16,8 @@ class MeasurementProjector(
companion object : KLogging()

@EventHandler(payloadType = MeasurementsUpdatedEvent::class)
fun on(event: MeasurementsUpdatedEvent) {
logger.info { "Received measurement updated event" }
fun on(event: MeasurementsUpdatedEvent, @Timestamp time: Instant) {
logger.trace { "Received measurement updated event at $time" }
event.values.forEach { (date, measurement) ->
measurementRepository.save(
sensorId = event.sensorId,
Expand Down
7 changes: 6 additions & 1 deletion src/main/kotlin/infrastructure/EventCleanup.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package io.holixon.example.axon.event.transformation.infrastructure

import io.axoniq.axonserver.connector.AxonServerConnection
import io.axoniq.axonserver.connector.event.transformation.Appender
import io.axoniq.axonserver.connector.event.transformation.EventTransformation
import io.axoniq.axonserver.connector.event.transformation.event.EventSources
import io.axoniq.axonserver.connector.event.transformation.event.EventTransformer
import io.axoniq.axonserver.grpc.event.EventWithToken
import mu.KLogging
import org.axonframework.axonserver.connector.AxonServerConfiguration
import org.springframework.stereotype.Component
Expand Down Expand Up @@ -36,7 +39,9 @@ class EventCleanup(
logger.debug { "Event: ${eventWithToken.event.payload.type}" }
eventWithToken.event.payload.type == eventFQDN && eventWithToken.event.timestamp < deleteUntil.toEpochMilli()
}
.transform("Deleting events until $deleteUntil") { event, appender -> appender.deleteEvent(event.token) }
.transform("Deleting events until $deleteUntil") { event, appender ->
appender.deleteEvent(event.token)
}
.execute { connection.eventTransformationChannel() }
.get()
} catch (e: Exception) {
Expand Down

0 comments on commit ad24cd0

Please sign in to comment.