diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt new file mode 100644 index 0000000000000000000000000000000000000000..7cf56f8452949e387a186aa8f8c962e1ee1aad15 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumNestedGroupsLoadGeneratorReplicaPatcher.kt @@ -0,0 +1,20 @@ +package theodolite.patcher + +import io.fabric8.kubernetes.api.model.KubernetesResource +import io.fabric8.kubernetes.api.model.apps.Deployment +import kotlin.math.pow + +private const val NUM_SENSORS = 4.0 +private const val LOAD_GEN_MAX_RECORDS = 150000 + +class NumNestedGroupsLoadGeneratorReplicaPatcher(private val k8sResource: KubernetesResource) : AbstractPatcher(k8sResource) { + override fun <String> patch(value: String) { + if (k8sResource is Deployment) { + if (value is kotlin.String) { + val approxNumSensors = NUM_SENSORS.pow(Integer.parseInt(value).toDouble()) + val loadGenInstances = (approxNumSensors + LOAD_GEN_MAX_RECORDS -1) / LOAD_GEN_MAX_RECORDS + this.k8sResource.spec.replicas = loadGenInstances.toInt() + } + } + } +} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt new file mode 100644 index 0000000000000000000000000000000000000000..6f2ebcb8b1eb37801c7f6bb2f28c251a07ae44e8 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/NumSensorsLoadGeneratorReplicaPatcher.kt @@ -0,0 +1,17 @@ +package theodolite.patcher + +import io.fabric8.kubernetes.api.model.KubernetesResource +import io.fabric8.kubernetes.api.model.apps.Deployment + +private const val LOAD_GEN_MAX_RECORDS = 150000 + +class NumSensorsLoadGeneratorReplicaPatcher(private val k8sResource: KubernetesResource) : AbstractPatcher(k8sResource) { + override fun <String> patch(value: String) { + if (k8sResource is Deployment) { + if (value is kotlin.String) { + val loadGenInstances = (Integer.parseInt(value) + LOAD_GEN_MAX_RECORDS - 1) / LOAD_GEN_MAX_RECORDS + this.k8sResource.spec.replicas = loadGenInstances + } + } + } +} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherFactory.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherFactory.kt index 5b1274ea6f57b8bd0594ddf8b6c1f3410b3fa107..2ee1f6c7b46322cb0f8de03c37aabe64ccf0ba5a 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherFactory.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherFactory.kt @@ -30,6 +30,8 @@ class PatcherFactory { k8sResources.filter { it.first == patcherDefinition.resource }.map { resource -> resource.second }[0] return when (patcherDefinition.type) { "ReplicaPatcher" -> ReplicaPatcher(resource) + "NumNestedGroupsLoadGeneratorReplicaPatcher" -> NumNestedGroupsLoadGeneratorReplicaPatcher(resource) + "NumSensorsLoadGeneratorReplicaPatcher" -> NumSensorsLoadGeneratorReplicaPatcher(resource) "EnvVarPatcher" -> EnvVarPatcher(resource, patcherDefinition.container, patcherDefinition.variableName) "NodeSelectorPatcher" -> NodeSelectorPatcher(resource, patcherDefinition.variableName) "ResourceLimitPatcher" -> ResourceLimitPatcher(