Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
theodolite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sören Henning
theodolite
Commits
eb1e5fda
Commit
eb1e5fda
authored
4 years ago
by
Lorenz Boguhn
Browse files
Options
Downloads
Patches
Plain Diff
refactor TheodoliteController
parent
edd72048
Branches
Branches containing commit
Tags
Tags containing commit
4 merge requests
!159
Re-implementation of Theodolite with Kotlin/Quarkus
,
!157
Update Graal Image in CI pipeline
,
!106
Introduce a Theodolite operator
,
!83
WIP: Re-implementation of Theodolite with Kotlin/Quarkus
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteController.kt
+35
-44
35 additions, 44 deletions
.../main/kotlin/theodolite/execution/TheodoliteController.kt
with
35 additions
and
44 deletions
theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteController.kt
+
35
−
44
View file @
eb1e5fda
...
...
@@ -10,57 +10,49 @@ import theodolite.benchmark.KubernetesBenchmark
private
val
logger
=
KotlinLogging
.
logger
{}
class
TheodoliteController
(
val
client
:
NamespacedKubernetesClient
,
class
TheodoliteController
(
val
client
:
NamespacedKubernetesClient
,
val
informerBenchmarkExecution
:
SharedInformer
<
BenchmarkExecution
>,
val
informerBenchmarkType
:
SharedInformer
<
KubernetesBenchmark
>
)
{
val
informerBenchmarkType
:
SharedInformer
<
KubernetesBenchmark
>
)
{
var
execution
:
BenchmarkExecution
?
=
null
var
benchmarkType
:
KubernetesBenchmark
?
=
null
var
executor
:
TheodoliteExecutor
?
=
null
var
updated
:
Boolean
=
true
public
fun
create
(){
/**
* Adds the EventHandler to kubernetes
*/
fun
create
()
{
informerBenchmarkExecution
.
addEventHandler
(
object
:
ResourceEventHandler
<
BenchmarkExecution
>
{
override
fun
onAdd
(
webServer
:
BenchmarkExecution
)
{
execution
=
webServer
override
fun
onAdd
(
benchmarkExecution
:
BenchmarkExecution
)
{
execution
=
benchmarkExecution
}
override
fun
onUpdate
(
webServer
:
BenchmarkExecution
,
newWebServer
:
BenchmarkExecution
)
{
println
(
"hello there update"
)
execution
=
newWebServer
override
fun
onUpdate
(
oldExecution
:
BenchmarkExecution
,
newExecution
:
BenchmarkExecution
)
{
execution
=
newExecution
updated
=
true
shutdown
()
}
override
fun
onDelete
(
webServer
:
BenchmarkExecution
,
b
:
Boolean
)
{
println
(
"delted"
)
override
fun
onDelete
(
benchmarkExecution
:
BenchmarkExecution
,
b
:
Boolean
)
{
shutdown
()
}
})
informerBenchmarkType
.
addEventHandler
(
object
:
ResourceEventHandler
<
KubernetesBenchmark
>
{
override
fun
onAdd
(
webServer
:
KubernetesBenchmark
)
{
benchmarkType
=
webServer
println
(
"hello there add"
)
println
(
webServer
.
name
)
override
fun
onAdd
(
kubernetesBenchmark
:
KubernetesBenchmark
)
{
benchmarkType
=
kubernetesBenchmark
}
override
fun
onUpdate
(
webServer
:
KubernetesBenchmark
,
newWebServer
:
KubernetesBenchmark
)
{
benchmarkType
=
newWebServer
println
(
"hello there update"
)
override
fun
onUpdate
(
oldBenchmark
:
KubernetesBenchmark
,
newBenchmark
:
KubernetesBenchmark
)
{
benchmarkType
=
newBenchmark
updated
=
true
shutdown
()
}
override
fun
onDelete
(
webServer
:
KubernetesBenchmark
,
b
:
Boolean
)
{
println
(
"delted"
)
println
(
webServer
.
name
)
override
fun
onDelete
(
kubernetesBenchmark
:
KubernetesBenchmark
,
b
:
Boolean
)
{
shutdown
()
}
})
...
...
@@ -70,8 +62,7 @@ class TheodoliteController(val client : NamespacedKubernetesClient,
while
(
true
)
{
try
{
reconcile
()
}
catch
(
e
:
InterruptedException
){
}
catch
(
e
:
InterruptedException
)
{
logger
.
error
{
"$e"
}
}
}
...
...
@@ -81,8 +72,8 @@ class TheodoliteController(val client : NamespacedKubernetesClient,
private
fun
reconcile
()
{
val
localExecution
=
this
.
execution
val
localType
=
this
.
benchmarkType
if
(
localType
is
KubernetesBenchmark
&&
localExecution
is
BenchmarkExecution
&&
updated
){
if
(
localType
is
KubernetesBenchmark
&&
localExecution
is
BenchmarkExecution
&&
updated
)
{
executor
=
TheodoliteExecutor
(
config
=
localExecution
,
kubernetesBenchmark
=
localType
)
executor
!!
.
run
()
updated
=
false
...
...
@@ -90,6 +81,6 @@ class TheodoliteController(val client : NamespacedKubernetesClient,
}
private
fun
shutdown
()
{
Shutdown
(
benchmarkExecution
=
execution
!!
,
benchmark
=
benchmarkType
!!
).
run
()
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment