andresbeckruiz commented on code in PR #256: URL: https://github.com/apache/cassandra-sidecar/pull/256#discussion_r2353592918
########## server/src/main/java/org/apache/cassandra/sidecar/modules/LifecycleModule.java: ########## @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.sidecar.modules; + +import java.util.HashMap; +import java.util.Map; + +import com.google.inject.AbstractModule; +import com.google.inject.Provides; +import com.google.inject.Singleton; +import com.google.inject.multibindings.ProvidesIntoMap; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.PUT; +import jakarta.ws.rs.Path; +import org.apache.cassandra.sidecar.cluster.instance.InstanceMetadata; +import org.apache.cassandra.sidecar.common.ApiEndpointsV1; +import org.apache.cassandra.sidecar.common.response.LifecycleInfoResponse; +import org.apache.cassandra.sidecar.config.LifecycleConfiguration; +import org.apache.cassandra.sidecar.config.ParameterizedClassConfiguration; +import org.apache.cassandra.sidecar.config.SidecarConfiguration; +import org.apache.cassandra.sidecar.exceptions.ConfigurationException; +import org.apache.cassandra.sidecar.handlers.LifecycleInfoHandler; +import org.apache.cassandra.sidecar.handlers.LifecycleUpdateHandler; +import org.apache.cassandra.sidecar.lifecycle.LifecycleProvider; +import org.apache.cassandra.sidecar.lifecycle.ProcessLifecycleProvider; +import org.apache.cassandra.sidecar.modules.multibindings.KeyClassMapKey; +import org.apache.cassandra.sidecar.modules.multibindings.VertxRouteMapKeys; +import org.apache.cassandra.sidecar.routes.RouteBuilder; +import org.apache.cassandra.sidecar.routes.VertxRoute; +import org.eclipse.microprofile.openapi.annotations.Operation; +import org.eclipse.microprofile.openapi.annotations.media.Content; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; +import org.jetbrains.annotations.NotNull; + +/** + * Provides the telemetry capability + */ +public class LifecycleModule extends AbstractModule +{ + @Provides + @Singleton + LifecycleProvider lifecycleProvider(SidecarConfiguration sidecarConfiguration) + { + LifecycleConfiguration lifecycleConfiguration = sidecarConfiguration.lifecycleConfiguration(); + if (!lifecycleConfiguration.enabled()) + { + return getNoopProvider(); + } + + ParameterizedClassConfiguration providerClass = lifecycleConfiguration.lifecycleProvider(); + if (providerClass == null) + { + throw new ConfigurationException("Lifecycle management is enabled, but provider not set."); + } + + if (providerClass.className().equalsIgnoreCase(ProcessLifecycleProvider.class.getName())) + { + Map<String, String> params = new HashMap<>(); Review Comment: No reason, simplified this section. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

