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


##########
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
+{
+    public DefaultCloudMetadataServiceSnitch() throws IOException
+    {
+        this(new SnitchProperties());
+    }
+
+    public DefaultCloudMetadataServiceSnitch(SnitchProperties properties) 
throws IOException

Review Comment:
   I don't this that is really necessary. 
   
   I can do this though.
   
       public DefaultCloudMetadataServiceSnitch(String url) throws IOException
       {
           this(new SnitchProperties(Pair.create(METADATA_URL_PROPERTY, url)));
       }
   
   If you look how the response is parsed etc, we also need dc suffix 
propagated and in case like I did it it would not be parsed from property file.
   
   I can also do this
   
       public DefaultCloudMetadataServiceSnitch(SnitchProperties properties, 
String url) throws IOException
       {
           this(properties, new DefaultCloudMetadataServiceConnector(url));
       }
   
   But why would you do that if it is going to be taken from `properties` 
anyway as we need them?



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