smiklosovic commented on code in PR #2458:
URL: https://github.com/apache/cassandra/pull/2458#discussion_r1257896450


##########
src/java/org/apache/cassandra/locator/DefaultCloudMetadataServiceSnitch.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.locator;
+
+import java.io.IOException;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableMap;
+
+import 
org.apache.cassandra.locator.AbstractCloudMetadataServiceConnector.DefaultCloudMetadataServiceConnector;
+
+import static 
org.apache.cassandra.locator.AbstractCloudMetadataServiceConnector.METADATA_URL_PROPERTY;
+
+/**
+ * Default cloud-based metadata service snitch which parses datacenter and 
rack of a node by
+ * executing GET query for URL configured in cassandra-rackdc.properties under
+ * key {@link AbstractCloudMetadataServiceConnector#METADATA_URL_PROPERTY}. It 
expects HTTP response code 200.
+ * It is not passing any headers to GET request.
+ * <p>
+ * The response will be parsed like following - if the response body is, for 
example "us-central1-a", then
+ * the datacenter will be "us-central1" and rack will be "a". There is value 
of "dc_suffix" key in
+ * cassandra-rackdc.properties appended to datacenter.
+ */
+public class DefaultCloudMetadataServiceSnitch extends 
AbstractCloudMetadataServiceSnitch

Review Comment:
   Yes, I believe it needs to be public. Keep in mind that we might reference 
this snitch in `cassandra.yaml` so we would be able to use this snitch for all 
cloud deployments when the response is parsed in a very opinionated way, for 
free, out of the box. 
   
   If this was not public, then it is not able to be constructed as making it 
package protected would throw:
   
       org.apache.cassandra.exceptions.ConfigurationException: Default 
constructor for snitch class 
       'org.apache.cassandra.locator.MySnitch' is inaccessible.
        at 
org.apache.cassandra.utils.FBUtilities.construct(FBUtilities.java:762)
        at 
org.apache.cassandra.utils.FBUtilities.construct(FBUtilities.java:751)
        at 
org.apache.cassandra.config.DatabaseDescriptor.createEndpointSnitch(DatabaseDescriptor.java:1491)
        at 
org.apache.cassandra.config.DatabaseDescriptor.applySnitch(DatabaseDescriptor.java:1338)
        at 
org.apache.cassandra.config.DatabaseDescriptor.applyAll(DatabaseDescriptor.java:435)
        at 
org.apache.cassandra.config.DatabaseDescriptor.daemonInitialization(DatabaseDescriptor.java:244)
        at 
org.apache.cassandra.config.DatabaseDescriptor.daemonInitialization(DatabaseDescriptor.java:228)
        at 
org.apache.cassandra.service.CassandraDaemon.applyConfig(CassandraDaemon.java:819)
        at 
org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:762)
        at 
org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:890)
   
   With snitch like this (same holds for the DefaultCloudMetadataServiceSnitch)
   
       class MySnitch extends AbstractNetworkTopologySnitch
       {
           @Override
           public String getRack(InetAddressAndPort endpoint)
           {
               return "r1";
           }
   
           @Override
           public String getDatacenter(InetAddressAndPort endpoint)
           {
               return "dc1";
           }
       }
   
   This does not help either
   
       class MySnitch extends AbstractNetworkTopologySnitch
       {
            public MySnitch() {}
            ....
       }
   
   We can not make it final either because `AlibabaCloudSnitch` is extending it.



-- 
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]

Reply via email to