Skip to content

Introduce actor based concurrent conversion #71

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

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a88e6c4
Fixing dependency versions
ckittl Aug 26, 2021
53df4f5
Update gradle wrapper version
ckittl Aug 26, 2021
fb525a8
Introduce akka dependencies
ckittl Aug 26, 2021
f49dcf1
Drafting protocol
ckittl Aug 26, 2021
692245a
First protocol for conversion coordination
ckittl Aug 26, 2021
ea140df
Introduce a mutator
ckittl Aug 26, 2021
c69b42d
Shutting down mutators
ckittl Aug 26, 2021
e74b2c9
Download and read in SimBench data sets
ckittl Aug 26, 2021
9ff9318
Make GridConverter an actor
ckittl Aug 27, 2021
4cb8db1
Convert branches
ckittl Aug 27, 2021
53bbe70
Filter islanded nodes
ckittl Aug 27, 2021
0adb4da
Converting node results
ckittl Aug 27, 2021
77461ea
Updating protocol
ckittl Aug 27, 2021
a894358
Simplify protocol
ckittl Aug 27, 2021
6f9ef08
Spawn a ResConverter and it's worker pool
ckittl Aug 27, 2021
f6a734f
Ping pong between converter and ResConverter
ckittl Aug 27, 2021
eaf3eed
Convert and write time series
ckittl Aug 27, 2021
58349d7
Shutdown converter after res have been converted (for testing purposes)
ckittl Aug 27, 2021
cb43568
Some minor fixes
ckittl Aug 27, 2021
07718c2
Persist all the remaining things
ckittl Aug 27, 2021
908aaa7
Generify the messages received by the worker
ckittl Aug 29, 2021
b8a477c
Generifying ShuntConverterMessage
ckittl Aug 29, 2021
26a4f01
Converting loads
ckittl Aug 29, 2021
8991fd1
Convert power plants
ckittl Aug 29, 2021
80a20d5
Only start participant converters, if models are available
ckittl Aug 29, 2021
fe41d5d
Fix grid converter test
ckittl Aug 29, 2021
443839b
Test correct amount of converted models
ckittl Aug 29, 2021
d73dffb
Adding to CHANGELOG
ckittl Aug 30, 2021
0743b93
Improve documentation
ckittl Aug 31, 2021
53e4220
Improve logging in test
ckittl Aug 31, 2021
fa39f20
Actually not providing switches if asked to omit them
ckittl Sep 1, 2021
232179e
Actually registering the completed runs
ckittl Sep 1, 2021
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Actor-based implementation for better concurrency

## [1.0.0] - 2021-08-03
### Added
Expand Down
26 changes: 18 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ext {

scalaVersion = '2.13'
scalaBinaryVersion = '2.13.6'
tscfgVersion = '0.9.986'
tscfgVersion = '0.9.993'
slf4jVersion = '1.7.32'

scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator //location of script plugins
Expand Down Expand Up @@ -64,11 +64,11 @@ dependencies {
implementation 'tech.units:indriya:2.1.2'

// logging
implementation 'org.apache.logging.log4j:log4j-api:+' // log4j
implementation 'org.apache.logging.log4j:log4j-core:+' // log4j
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:+' // log4j -> slf4j
implementation 'org.apache.logging.log4j:log4j-api:2.14.1' // log4j
implementation 'org.apache.logging.log4j:log4j-core:2.14.1' // log4j
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.14.1' // log4j -> slf4j

implementation "com.typesafe.scala-logging:scala-logging_${scalaVersion}:+" // akka scala logging
implementation "com.typesafe.scala-logging:scala-logging_${scalaVersion}:3.9.4" // akka scala logging
implementation "org.slf4j:log4j-over-slf4j:${slf4jVersion}" // slf4j -> log4j

// NEW scala libs //
Expand All @@ -82,21 +82,31 @@ dependencies {
testImplementation "org.pegdown:pegdown:1.6.0" // HTML report for scalatest
implementation 'org.mockito:mockito-core:3.11.2' // mocking framework

// akka actor system //
implementation platform("com.typesafe.akka:akka-bom_${scalaVersion}:2.6.14")
implementation "com.typesafe.akka:akka-actor-typed_${scalaVersion}"
implementation "com.typesafe.akka:akka-stream_${scalaVersion}"
testImplementation "com.typesafe.akka:akka-actor-testkit-typed_${scalaVersion}"

// config //
implementation 'com.typesafe:config:+'
implementation 'com.typesafe:config:1.4.1'
implementation "com.github.carueda:tscfg_2.13:${tscfgVersion}"

// cmd args parser //
implementation "com.github.scopt:scopt_${scalaVersion}:+"

/* Handling compressed archives */
implementation "org.apache.commons:commons-compress:+"
implementation "org.apache.commons:commons-compress:1.21"
}

wrapper {
gradleVersion = '7.1.1'
gradleVersion = '7.2'
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

tasks.withType(Javadoc){
options.encoding = 'UTF-8'
}
56 changes: 56 additions & 0 deletions docs/diagrams/protocol/protocol.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@startuml

participant Main
participant Coordinator
participant Converter
participant GridConverter
participant ResConverter
collections ResConverterWorker
participant Mutator

Main -> Coordinator: Start(Config)
== Init ==
Coordinator --[#blue]> Converter: <font color=blue>spawn & watch</font>
Coordinator -> Converter: Init(...)
Converter --[#blue]> Mutator: <font color=blue>spawn & watch</font>
Converter -> Mutator: Init(Config)
Converter <- Mutator: Ready
Coordinator <- Converter: ConverterInitialized
Coordinator -> Converter: Convert(String)

== Converting grid structure ==
Converter --[#blue]> GridConverter: <font color=blue>spawn & watch</font>
Converter -> GridConverter: ConvertGridStructure(...)
Converter <- GridConverter: GridStructureConverted(...)
note left: Now all other entities\ncan be converted (not)\nconsidering islanded\nnodes

== Converting participants ==
Converter --[#blue]> ResConverter: <font color=blue>spawn & watch</font>
Converter -> ResConverter: Init(...)
ResConverter --[#blue]> ResConverterWorker: <font color=blue>spawn & watch</font>
Converter <- ResConverter: ResConverterReady
Converter -> ResConverter: Convert(...)
ResConverter -> ResConverterWorker: Convert(...)
ResConverterWorker -> Mutator: PersistTimeSeries(...)
activate Mutator
ResConverterWorker <- Mutator: TimeSeriesPersisted(...)
ResConverter <- ResConverterWorker: Converted(...)
ResConverter --[#blue]> ResConverterWorker: <font color=blue>terminate</font>
ResConverter <--[#blue] ResConverterWorker
Converter <- ResConverter: ResConverted(...)

== Mutate Grid structure ==
Converter -> Mutator: PersistGridStructure(...)
Converter -> Mutator: PersistTimeSeriesMapping(...)
Converter -> Mutator: PersistNodalResults(...)
Converter <- Mutator: GridStructurePersisted(...)
Converter <- Mutator: TimeSeriesMappingPersisted(...)
Converter <- Mutator: NodalResultsPersisted(...)

== Shutdown ==
Converter -> Mutator: Shutdown
Converter <- Mutator: Done
deactivate Mutator

Coordinator <- Converter: Converted(String)
@enduml
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ case "`uname`" in
Darwin* )
darwin=true
;;
MINGW* )
MSYS* | MINGW* )
msys=true
;;
NONSTOP* )
Expand Down Expand Up @@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
21 changes: 3 additions & 18 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,29 +64,14 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config-template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ io {
}
conversion {
removeSwitches = "Boolean" | false
participantWorkersPerType = "Int" | 20
}
Loading