yifan-c commented on code in PR #200: URL: https://github.com/apache/cassandra-sidecar/pull/200#discussion_r1980447296
########## server/src/main/java/org/apache/cassandra/sidecar/modules/CassandraOperationsModule.java: ########## @@ -0,0 +1,189 @@ +/* + * 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 com.google.inject.AbstractModule; +import com.google.inject.multibindings.ProvidesIntoMap; +import org.apache.cassandra.sidecar.handlers.ConnectedClientStatsHandler; +import org.apache.cassandra.sidecar.handlers.GossipInfoHandler; +import org.apache.cassandra.sidecar.handlers.KeyspaceRingHandler; +import org.apache.cassandra.sidecar.handlers.KeyspaceSchemaHandler; +import org.apache.cassandra.sidecar.handlers.ListOperationalJobsHandler; +import org.apache.cassandra.sidecar.handlers.NodeDecommissionHandler; +import org.apache.cassandra.sidecar.handlers.OperationalJobHandler; +import org.apache.cassandra.sidecar.handlers.RingHandler; +import org.apache.cassandra.sidecar.handlers.RouteBuilder; +import org.apache.cassandra.sidecar.handlers.SchemaHandler; +import org.apache.cassandra.sidecar.handlers.StreamStatsHandler; +import org.apache.cassandra.sidecar.handlers.TokenRangeReplicaMapHandler; +import org.apache.cassandra.sidecar.handlers.cassandra.NodeSettingsHandler; +import org.apache.cassandra.sidecar.modules.multibindings.KeyClassMapKey; +import org.apache.cassandra.sidecar.modules.multibindings.VertxRouteMapKeys; +import org.apache.cassandra.sidecar.routes.VertxRoute; + +/** + * Provides the capability to query and invoke Cassandra operations + */ +public class CassandraOperationsModule extends AbstractModule +{ + @ProvidesIntoMap + @KeyClassMapKey(VertxRouteMapKeys.CassandraConnectedClientStatsRouteKey.class) + VertxRoute cassandraConnectedClientStatsRoute(RouteBuilder.Factory factory, + ConnectedClientStatsHandler connectedClientStatsHandler) + { + return factory.builderForRoute() + .handler(connectedClientStatsHandler) + .build(); + } + + @ProvidesIntoMap + @KeyClassMapKey(VertxRouteMapKeys.CassandraOperationalJobRouteKey.class) + VertxRoute cassandraOperationalJobRoute(RouteBuilder.Factory factory, + OperationalJobHandler operationalJobHandler) + { + return factory.builderForRoute() + .handler(operationalJobHandler) + .build(); + } + + @ProvidesIntoMap + @KeyClassMapKey(VertxRouteMapKeys.ListCassandraOperationalJobRouteKey.class) + VertxRoute listCassandraOperationalJobRoute(RouteBuilder.Factory factory, + ListOperationalJobsHandler listOperationalJobsHandler) + { + return factory.builderForRoute() + .handler(listOperationalJobsHandler) + .build(); + } + + @ProvidesIntoMap + @KeyClassMapKey(VertxRouteMapKeys.CassandraNodeDecommissionRouteKey.class) + VertxRoute cassandraNodeDecommissionRoute(RouteBuilder.Factory factory, + NodeDecommissionHandler nodeDecommissionHandler) + { + return factory.builderForRoute() + .handler(nodeDecommissionHandler) + .build(); + } + + @ProvidesIntoMap + @KeyClassMapKey(VertxRouteMapKeys.CassandraStreamStatsRouteKey.class) + VertxRoute cassandraStreamStatsRoute(RouteBuilder.Factory factory, + StreamStatsHandler streamStatsHandler) + { + return factory.builderForRoute() + .handler(streamStatsHandler) + .build(); + } + + @ProvidesIntoMap + @KeyClassMapKey(VertxRouteMapKeys.CassandraNodeSettingsRouteKey.class) + VertxRoute cassandraNodeSettings(RouteBuilder.Factory factory, + NodeSettingsHandler nodeSettingsHandler) + { + // Node settings endpoint is not Access protected. Any user who can log in into Cassandra is able to view + // node settings information. Since sidecar and cassandra share list of authenticated identities, sidecar's + // authenticated users can also read node settings information. + return factory.builderForUnprotectedRoute() + .handler(nodeSettingsHandler) + .build(); + } + + @ProvidesIntoMap + @KeyClassMapKey(VertxRouteMapKeys.AllKeyspacesSchemaRouteKey.class) + VertxRoute cassandraSchemaRoute(RouteBuilder.Factory factory, + SchemaHandler schemaHandler) + { + return factory.builderForRoute() Review Comment: Cassandra related operations, i.e. trigger task or retrieving information, are grouped in the same module. If splitting the module up helps with readability, we can do that in the future. -- 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: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org