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
No related branches found
No related tags found
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
Hide 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,86 +10,77 @@ import theodolite.benchmark.KubernetesBenchmark
...
@@ -10,86 +10,77 @@ import theodolite.benchmark.KubernetesBenchmark
private
val
logger
=
KotlinLogging
.
logger
{}
private
val
logger
=
KotlinLogging
.
logger
{}
class
TheodoliteController
(
val
client
:
NamespacedKubernetesClient
,
class
TheodoliteController
(
val
informerBenchmarkExecution
:
SharedInformer
<
BenchmarkExecution
>,
val
client
:
NamespacedKubernetesClient
,
val
informerBenchmarkType
:
SharedInformer
<
KubernetesBenchmark
>
)
{
val
informerBenchmarkExecution
:
SharedInformer
<
BenchmarkExecution
>,
val
informerBenchmarkType
:
SharedInformer
<
KubernetesBenchmark
>
var
execution
:
BenchmarkExecution
?
=
null
)
{
var
benchmarkType
:
KubernetesBenchmark
?
=
null
var
execution
:
BenchmarkExecution
?
=
null
var
benchmarkType
:
KubernetesBenchmark
?
=
null
var
executor
:
TheodoliteExecutor
?
=
null
var
executor
:
TheodoliteExecutor
?
=
null
var
updated
:
Boolean
=
true
var
updated
:
Boolean
=
true
/**
public
fun
create
(){
* Adds the EventHandler to kubernetes
*/
fun
create
()
{
informerBenchmarkExecution
.
addEventHandler
(
object
:
ResourceEventHandler
<
BenchmarkExecution
>
{
informerBenchmarkExecution
.
addEventHandler
(
object
:
ResourceEventHandler
<
BenchmarkExecution
>
{
override
fun
onAdd
(
webServer
:
BenchmarkExecution
)
{
override
fun
onAdd
(
benchmarkExecution
:
BenchmarkExecution
)
{
execution
=
webServer
execution
=
benchmarkExecution
}
}
override
fun
onUpdate
(
webServer
:
BenchmarkExecution
,
newWebServer
:
BenchmarkExecution
)
{
override
fun
onUpdate
(
oldExecution
:
BenchmarkExecution
,
newExecution
:
BenchmarkExecution
)
{
println
(
"hello there update"
)
execution
=
newExecution
execution
=
newWebServer
updated
=
true
updated
=
true
shutdown
()
shutdown
()
}
}
override
fun
onDelete
(
webServer
:
BenchmarkExecution
,
b
:
Boolean
)
{
override
fun
onDelete
(
benchmarkExecution
:
BenchmarkExecution
,
b
:
Boolean
)
{
println
(
"delted"
)
shutdown
()
shutdown
()
}
}
})
})
informerBenchmarkType
.
addEventHandler
(
object
:
ResourceEventHandler
<
KubernetesBenchmark
>
{
informerBenchmarkType
.
addEventHandler
(
object
:
ResourceEventHandler
<
KubernetesBenchmark
>
{
override
fun
onAdd
(
webServer
:
KubernetesBenchmark
)
{
override
fun
onAdd
(
kubernetesBenchmark
:
KubernetesBenchmark
)
{
benchmarkType
=
webServer
benchmarkType
=
kubernetesBenchmark
println
(
"hello there add"
)
println
(
webServer
.
name
)
}
}
override
fun
onUpdate
(
webServer
:
KubernetesBenchmark
,
newWebServer
:
KubernetesBenchmark
)
{
override
fun
onUpdate
(
oldBenchmark
:
KubernetesBenchmark
,
newBenchmark
:
KubernetesBenchmark
)
{
benchmarkType
=
newWebServer
benchmarkType
=
newBenchmark
println
(
"hello there update"
)
updated
=
true
updated
=
true
shutdown
()
shutdown
()
}
}
override
fun
onDelete
(
webServer
:
KubernetesBenchmark
,
b
:
Boolean
)
{
override
fun
onDelete
(
kubernetesBenchmark
:
KubernetesBenchmark
,
b
:
Boolean
)
{
println
(
"delted"
)
println
(
webServer
.
name
)
shutdown
()
shutdown
()
}
}
})
})
}
}
fun
run
(){
fun
run
()
{
while
(
true
){
while
(
true
)
{
try
{
try
{
reconcile
()
reconcile
()
}
}
catch
(
e
:
InterruptedException
)
{
catch
(
e
:
InterruptedException
){
logger
.
error
{
"$e"
}
logger
.
error
{
"$e "
}
}
}
}
}
}
}
@Synchronized
@Synchronized
private
fun
reconcile
()
{
private
fun
reconcile
()
{
val
localExecution
=
this
.
execution
val
localExecution
=
this
.
execution
val
localType
=
this
.
benchmarkType
val
localType
=
this
.
benchmarkType
if
(
localType
is
KubernetesBenchmark
&&
localExecution
is
BenchmarkExecution
&&
updated
){
executor
=
TheodoliteExecutor
(
config
=
localExecution
,
kubernetesBenchmark
=
localType
)
if
(
localType
is
KubernetesBenchmark
&&
localExecution
is
BenchmarkExecution
&&
updated
)
{
executor
=
TheodoliteExecutor
(
config
=
localExecution
,
kubernetesBenchmark
=
localType
)
executor
!!
.
run
()
executor
!!
.
run
()
updated
=
false
updated
=
false
}
}
}
}
private
fun
shutdown
(){
private
fun
shutdown
()
{
Shutdown
(
benchmarkExecution
=
execution
!!
,
benchmark
=
benchmarkType
!!
).
run
()
}
}
}
}
\ No newline at end of file
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