You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/08/07 03:45:17 UTC

[GitHub] [lucene-solr] anshumg commented on a change in pull request #1720: SOLR-14712 Standardize RPC calls in Solr

anshumg commented on a change in pull request #1720:
URL: https://github.com/apache/lucene-solr/pull/1720#discussion_r466802599



##########
File path: solr/solrj/src/java/org/apache/solr/common/util/HttpRpc.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.solr.common.util;
+
+import org.apache.solr.client.solrj.SolrRequest;
+
+import java.util.Map;
+
+/**Abstract out HTTP aspects of the request

Review comment:
       New line ?

##########
File path: solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
##########
@@ -478,4 +479,11 @@ public Builder getThis() {
       return this;
     }
   }
+
+  private final RpcFactory factory = null;//TODO

Review comment:
       You don't intend to commit this, right?

##########
File path: solr/solrj/src/java/org/apache/solr/common/util/CallRouter.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.solr.common.util;
+
+public interface CallRouter {
+    /**
+     * send to a specific node. usually admin requests
+     */
+    CallRouter toNode(String nodeName);
+
+    /**
+     * Make a request to any replica of the shard of type
+     */
+    CallRouter toShard(String collection, String shard, ReplicaType type);
+
+    /**
+     * Identify the shard using the route key and send the request to a given replica type
+     */
+    CallRouter toShard(String collection, ReplicaType type, String routeKey);

Review comment:
       can we reorder this so the decision maker for the routing i.e. routeKey is the 2nd param like `CallRouter toShard(String collection, String shard, ReplicaType type);` ?

##########
File path: solr/solrj/src/java/org/apache/solr/common/util/RpcFactory.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.solr.common.util;
+
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.CommonParams;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.function.Function;
+
+/**A factory that creates any type of RPC calls in Solr
+ * This is designed to create low level access to the RPC mechanism.
+ * This is agnostic of Solr documents or other internal concepts of Solr
+ * But it knows certain things
+ * a) how to locate a Solr core/replica
+ * b) basic HTTP access,
+ * c) serialization/deserialization is the responsibility of the code that is making a request
+ *
+ */
+public interface RpcFactory {
+
+    CallRouter createCallRouter();
+
+    HttpRpc createHttpRpc();
+
+
+    interface ResponseConsumer {
+        /**Allows this impl to add request params/http headers before the request is fired
+         */
+        default void setRpc(HttpRpc rpc){};

Review comment:
       unnecessary ;

##########
File path: solr/solrj/src/java/org/apache/solr/common/util/RpcFactory.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.solr.common.util;
+
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.CommonParams;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.function.Function;
+
+/**A factory that creates any type of RPC calls in Solr
+ * This is designed to create low level access to the RPC mechanism.
+ * This is agnostic of Solr documents or other internal concepts of Solr
+ * But it knows certain things
+ * a) how to locate a Solr core/replica
+ * b) basic HTTP access,
+ * c) serialization/deserialization is the responsibility of the code that is making a request
+ *
+ */
+public interface RpcFactory {
+
+    CallRouter createCallRouter();
+
+    HttpRpc createHttpRpc();
+
+
+    interface ResponseConsumer {
+        /**Allows this impl to add request params/http headers before the request is fired
+         */
+        default void setRpc(HttpRpc rpc){};
+
+        /**Process the response.
+         * Ensure that the whole stream is eaten up before this method returns
+         * The stream will be closed after the method returns
+         */
+        Object accept(InputStream is) throws IOException;
+    }
+
+    /**Provide the payload stream
+     *
+     */
+    interface InputSupplier {
+        void write(OutputStream os) throws IOException;

Review comment:
       Would it ever throw IOException?

##########
File path: solr/solrj/src/java/org/apache/solr/common/util/RpcFactory.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.solr.common.util;
+
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.CommonParams;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.function.Function;
+
+/**A factory that creates any type of RPC calls in Solr
+ * This is designed to create low level access to the RPC mechanism.
+ * This is agnostic of Solr documents or other internal concepts of Solr
+ * But it knows certain things
+ * a) how to locate a Solr core/replica
+ * b) basic HTTP access,
+ * c) serialization/deserialization is the responsibility of the code that is making a request
+ *
+ */
+public interface RpcFactory {
+
+    CallRouter createCallRouter();
+
+    HttpRpc createHttpRpc();
+
+
+    interface ResponseConsumer {
+        /**Allows this impl to add request params/http headers before the request is fired
+         */
+        default void setRpc(HttpRpc rpc){};
+
+        /**Process the response.
+         * Ensure that the whole stream is eaten up before this method returns
+         * The stream will be closed after the method returns
+         */
+        Object accept(InputStream is) throws IOException;
+    }
+
+    /**Provide the payload stream
+     *
+     */
+    interface InputSupplier {
+        void write(OutputStream os) throws IOException;
+
+        String getContentType();
+    }
+
+
+    class RPCException extends SolrException {
+
+        public RPCException(ErrorCode code, String msg) {
+            super(code, msg);
+        }
+    }
+    /** Consumer of header data
+     */
+    interface HeaderConsumer {
+        /**Allows this impl to add request params/http headers before the request is fired
+         */
+        default void setRpc(HttpRpc rpc){};

Review comment:
       we can remove the `;` from here too

##########
File path: solr/solrj/src/java/org/apache/solr/common/util/CallRouter.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.solr.common.util;
+
+public interface CallRouter {
+    /**
+     * send to a specific node. usually admin requests
+     */
+    CallRouter toNode(String nodeName);
+
+    /**
+     * Make a request to any replica of the shard of type
+     */
+    CallRouter toShard(String collection, String shard, ReplicaType type);
+
+    /**
+     * Identify the shard using the route key and send the request to a given replica type
+     */
+    CallRouter toShard(String collection, ReplicaType type, String routeKey);
+
+    /**
+     * Make a request to a specific replica
+     */
+    CallRouter toReplica(String collection, String replicaName);
+
+    /**
+     * To any Solr node  that may host this collection
+     */
+    CallRouter toCollection(String collection);
+
+    CallRouter toCore(String node, String core);

Review comment:
       Missed comment?

##########
File path: solr/solrj/src/java/org/apache/solr/common/util/RpcFactory.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.solr.common.util;
+
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.CommonParams;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.function.Function;
+
+/**A factory that creates any type of RPC calls in Solr
+ * This is designed to create low level access to the RPC mechanism.
+ * This is agnostic of Solr documents or other internal concepts of Solr
+ * But it knows certain things
+ * a) how to locate a Solr core/replica
+ * b) basic HTTP access,
+ * c) serialization/deserialization is the responsibility of the code that is making a request
+ *
+ */
+public interface RpcFactory {
+
+    CallRouter createCallRouter();
+
+    HttpRpc createHttpRpc();
+
+
+    interface ResponseConsumer {
+        /**Allows this impl to add request params/http headers before the request is fired

Review comment:
       New line?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org