You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "mlbiscoc (via GitHub)" <gi...@apache.org> on 2023/05/02 20:21:51 UTC

[GitHub] [solr] mlbiscoc opened a new pull request, #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

mlbiscoc opened a new pull request, #1620:
URL: https://github.com/apache/solr/pull/1620

   https://issues.apache.org/jira/browse/SOLR-16470
   
   <!--
   _(If you are a project committer then you may remove some/all of the following template.)_
   
   Before creating a pull request, please file an issue in the ASF Jira system for Solr:
   
   * https://issues.apache.org/jira/projects/SOLR
   
   For something minor (i.e. that wouldn't be worth putting in release notes), you can skip JIRA. 
   To create a Jira issue, you will need to create an account there first.
   
   The title of the PR should reference the Jira issue number in the form:
   
   * SOLR-####: <short description of problem or changes>
   
   SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
   
   Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
   
   
   # Description
   
   **This PR is still a WIP and is a draft.**
   
   Create a V2 equivalent API for the replication "GET indexversion"
   
   V1
   `/solr/{coreName}/replication?command=indexversion`
   
   V2
   `/api/core/{coreName}/replication/indexversion`
   
   # Solution
   
   Created a new CoreReplicationAPI class using JAS-RX framework exposing the new V2 endpoint. The new V2 endpoint is injected with the `coreContainer` to retrieve the replicationHandler to retrieve the indexversion. Then updated the V1 endpoint to use SolrJerseyResponse. 
   
   # Tests
   
   Wrote new Unit test CoreReplicationAPITest that will mock a response from the replicationHandler for the new V2 api. 
   # Checklist
   
   Please review the following and check all that apply:
   
   - [ ] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
   - [ ] I have created a Jira issue and added the issue ID to my pull request title.
   - [ ] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [ ] I have developed this patch against the `main` branch.
   - [ ] I have run `./gradlew check`.
   - [ ] I have added tests for my changes.
   - [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
   


-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] gerlowskija commented on a diff in pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on code in PR #1620:
URL: https://github.com/apache/solr/pull/1620#discussion_r1192313804


##########
solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java:
##########
@@ -798,6 +777,38 @@ private void getFileList(SolrParams solrParams, SolrQueryResponse rsp) {
     }
   }
 
+  public CoreReplicationAPI.IndexVersionResponse getIndexVersionResponse() throws IOException {

Review Comment:
   [0] I know we're reliant on a few fields (`indexCommitPoint`, `replicationEnabled`, `reserveCommitDuration`) in this class, but IMO we'd be better off moving this method over to CoreReplicationAPI and creating getters for any ReplicationHandler fields that we need.
   
   From an abstraction perspective it leaks some ReplicationHandler details, which isn't ideal.  But that's a temporary situation as we move the remaining api's/commands out of the RH here and into CoreReplicationAPI.
   
   (This is largely opinion though - if you'd rather keep this here for now that's also fine.)



##########
solr/core/src/java/org/apache/solr/core/CoreContainer.java:
##########
@@ -813,6 +814,7 @@ public void load() {
       registerV2ApiIfEnabled(packageLoader.getPackageAPI().readAPI);
       registerV2ApiIfEnabled(ZookeeperReadAPI.class);
     }
+    registerV2ApiIfEnabled(CoreReplicationAPI.class);

Review Comment:
   [-1] Typically we only register "container-level" APIs (i.e. those APIs that aren't specific to an individual core) here in CoreContainer.  So we can probably drop this line here.
   
   For core-level APIs, it's sufficient to mention them in the `getJerseyResources` method on the RequestHandler itself, as I can see you already did below 👍 



##########
solr/core/src/java/org/apache/solr/handler/replication/package-info.java:
##########
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
+/** V2 API implementations for "replication" APIs. */
+package org.apache.solr.handler.replication;

Review Comment:
   [0] If you want to create a package specifically for the APIs we're pulling out of ReplicationHandler, that's fine by me.  But:
   
   1.  Could you add 'api' to the package name somewhere?  (e.g. `o.a.s.handler.api.replication`). That's the convention I've tried to follow elsewhere.
   2. Do you envision each ReplicationHandler API/command its own class, or do you imagine multiple of them going into CoreReplicationAPI?  If the former, maybe we should rename CoreReplicationAPI to be more specific (e.g. `GetIndexVersionAPI`?). If the latter, maybe we don't need a separate package for this code after all?



##########
solr/solr-ref-guide/modules/deployment-guide/pages/user-managed-index-replication.adoc:
##########
@@ -378,9 +378,26 @@ http://_leader_host:port_/solr/_core_name_/replication?command=disablereplicatio
 `indexversion`::
 Return the version of the latest replicatable index on the specified leader or follower.
 +
+====
+[.tab-label]*V1 API*
+
 [source,bash]
+----
 http://_host:port_/solr/_core_name_/replication?command=indexversion
 
+----
+====
++
+====
+[.tab-label]*V2 API*
+
+[source,bash]
+----
+http://_host:port_/api/_core_name_/replication/indexversion

Review Comment:
   [-1] L396 should be `http://_host:port_/api/cores/_core_name_/replication/indexversion` I think. (The "/cores" segment is missing)



##########
solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java:
##########
@@ -1464,6 +1475,11 @@ public void inform(SolrCore core) {
     log.info("Commits will be reserved for {} ms", reserveCommitDuration);
   }
 
+  @Override

Review Comment:
   [0] This method itself is great, but we also need to enable v2 APIs by overriding `registerV2` to return true.  (Currently, ReplicationHandler is inheriting a `registerV2` implementation from `RequestHandlerBase` that returns false.)
   
   The method impl here should just be:
   
   ```
     @Override
     public Boolean registerV2() {
       return Boolean.TRUE;
     }
   ```



##########
solr/core/src/java/org/apache/solr/handler/replication/CoreReplicationAPI.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.handler.replication;
+
+import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_READ_PERM;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.Parameter;
+import java.io.IOException;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+@Path("/core/{coreName}/replication")
+public class CoreReplicationAPI extends ReplicationAPIBase {
+
+  @Inject
+  public CoreReplicationAPI(
+      CoreContainer coreContainer, SolrQueryRequest req, SolrQueryResponse rsp) {

Review Comment:
   [-1] We can inject the `SolrCore` directly in the constructor here, which should save us from having to look it up from the CoreContainer later on.  See `SchemaNameAPI` as an example.



##########
solr/core/src/java/org/apache/solr/handler/replication/CoreReplicationAPI.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.handler.replication;
+
+import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_READ_PERM;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.Parameter;
+import java.io.IOException;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+@Path("/core/{coreName}/replication")

Review Comment:
   [-1] The pattern we've established for collection/core APIs is `/cores/{coreName}/....`.  (Note that 'cores' in the first path segment is plural.)  Looks like we need an 's' at the end of the first path segment for us to stick with that pattern. 



##########
solr/core/src/test/org/apache/solr/handler/replication/CoreReplicationAPITest.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.handler.replication;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import io.opentracing.noop.NoopSpan;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Unit tests for {@link CoreReplicationAPI} */
+public class CoreReplicationAPITest extends SolrTestCaseJ4 {
+
+  private CoreReplicationAPI coreReplicationAPI;
+  private CoreContainer mockCoreContainer;
+  private ReplicationHandler mockReplicationHandler;
+  private static final String coreName = "test";
+  private SolrQueryRequest mockQueryRequest;
+  private SolrQueryResponse queryResponse;
+
+  @BeforeClass
+  public static void ensureWorkingMockito() {
+    assumeWorkingMockito();
+  }
+
+  @Before
+  public void setUp() throws Exception {
+    super.setUp();
+    setUpMocks();
+    mockQueryRequest = mock(SolrQueryRequest.class);
+    when(mockQueryRequest.getSpan()).thenReturn(NoopSpan.INSTANCE);
+    queryResponse = new SolrQueryResponse();
+    coreReplicationAPI = new CoreReplicationAPI(mockCoreContainer, mockQueryRequest, queryResponse);
+  }
+
+  @Test
+  public void testGetIndexVersion() throws Exception {
+    CoreReplicationAPI.IndexVersionResponse expected =
+        new CoreReplicationAPI.IndexVersionResponse(123L, 123L, "testGeneration");
+    when(mockReplicationHandler.getIndexVersionResponse()).thenReturn(expected);
+
+    CoreReplicationAPI.IndexVersionResponse response =
+        coreReplicationAPI.IndexVersionResponse(coreName);
+    assertEquals(response.indexVersion, expected.indexVersion);
+    assertEquals(response.generation, expected.generation);
+    assertEquals(response.status, expected.status);

Review Comment:
   [0] Tiny nit, but I think the "expected" value is supposed to be the first argument to `assertEquals`.  (Otherwise the error message that gets produced on assertion-failure has the actual/expected values backwards.)



##########
solr/core/src/java/org/apache/solr/handler/replication/ReplicationAPIBase.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.handler.replication;
+
+import java.io.IOException;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** A common parent for "replication" (i.e. replication-level) APIs. */
+public abstract class ReplicationAPIBase extends JerseyResource {
+
+  protected final CoreContainer coreContainer;
+  protected final SolrQueryRequest solrQueryRequest;
+  protected final SolrQueryResponse solrQueryResponse;
+
+  public ReplicationAPIBase(
+      CoreContainer coreContainer,
+      SolrQueryRequest solrQueryRequest,
+      SolrQueryResponse solrQueryResponse) {
+    this.coreContainer = coreContainer;
+    this.solrQueryRequest = solrQueryRequest;
+    this.solrQueryResponse = solrQueryResponse;
+  }
+
+  protected CoreReplicationAPI.GetIndexResponse fetchIndexVersion(String coreName)
+      throws IOException {
+
+    if (coreContainer.getCore(coreName) == null) {
+      throw new SolrException(
+          SolrException.ErrorCode.BAD_REQUEST, "Solr core " + coreName + " does not exist");
+    }
+
+    ReplicationHandler replicationHandler =
+        (ReplicationHandler)
+            coreContainer.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);

Review Comment:
   I couldn't find a viable alternative here to the approach you chose, so LGTM for now.
   
   Longer term I think we can refactor some of the logic out of ReplicationHandler so that we can make do here without looking it up, but that'll take more time and isn't something we should target for this PR.



-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] gerlowskija commented on a diff in pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on code in PR #1620:
URL: https://github.com/apache/solr/pull/1620#discussion_r1191615909


##########
solr/core/src/java/org/apache/solr/handler/replication/ReplicationAPIBase.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.handler.replication;
+
+import java.io.IOException;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** A common parent for "replication" (i.e. replication-level) APIs. */
+public abstract class ReplicationAPIBase extends JerseyResource {
+
+  protected final CoreContainer coreContainer;
+  protected final SolrQueryRequest solrQueryRequest;
+  protected final SolrQueryResponse solrQueryResponse;
+
+  public ReplicationAPIBase(
+      CoreContainer coreContainer,
+      SolrQueryRequest solrQueryRequest,
+      SolrQueryResponse solrQueryResponse) {
+    this.coreContainer = coreContainer;
+    this.solrQueryRequest = solrQueryRequest;
+    this.solrQueryResponse = solrQueryResponse;
+  }
+
+  protected CoreReplicationAPI.GetIndexResponse fetchIndexVersion(String coreName)
+      throws IOException {
+
+    if (coreContainer.getCore(coreName) == null) {
+      throw new SolrException(
+          SolrException.ErrorCode.BAD_REQUEST, "Solr core " + coreName + " does not exist");
+    }
+
+    ReplicationHandler replicationHandler =
+        (ReplicationHandler)
+            coreContainer.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);

Review Comment:
   Hmm...it'd really be ideal if we could move the logic into the v2 API class, rather than looking up the request-handler, but I agree it's not always easy or feasible to do.
   
   I'll play with it a bit to see if I can come up with some alternative.  If I can't though, what you've done here looks 👍  to me.  (With the small quibble that we should be able to "inject" the SolrCore the same way we're injecting the SolrQueryRequest, etc. rather than going to the CoreContainer to look it up by name)



-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] mlbiscoc commented on a diff in pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #1620:
URL: https://github.com/apache/solr/pull/1620#discussion_r1192677449


##########
solr/core/src/java/org/apache/solr/handler/replication/CoreReplicationAPI.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.handler.replication;
+
+import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_READ_PERM;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.Parameter;
+import java.io.IOException;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+@Path("/core/{coreName}/replication")
+public class CoreReplicationAPI extends ReplicationAPIBase {
+
+  @Inject
+  public CoreReplicationAPI(
+      CoreContainer coreContainer, SolrQueryRequest req, SolrQueryResponse rsp) {

Review Comment:
   Changed to inject the `SolrCore` and register the api by overriding `registerV2`



-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] mlbiscoc commented on a diff in pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #1620:
URL: https://github.com/apache/solr/pull/1620#discussion_r1192657177


##########
solr/core/src/java/org/apache/solr/handler/replication/CoreReplicationAPI.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.handler.replication;
+
+import static org.apache.solr.client.solrj.impl.BinaryResponseParser.BINARY_CONTENT_TYPE_V2;
+import static org.apache.solr.security.PermissionNameProvider.Name.CORE_READ_PERM;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.Parameter;
+import java.io.IOException;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.jersey.PermissionName;
+import org.apache.solr.jersey.SolrJerseyResponse;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+@Path("/core/{coreName}/replication")

Review Comment:
   Thanks for letting me know. I changes the path so it is now `cores` instead.



-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] mlbiscoc commented on a diff in pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #1620:
URL: https://github.com/apache/solr/pull/1620#discussion_r1192654571


##########
solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java:
##########
@@ -798,6 +777,38 @@ private void getFileList(SolrParams solrParams, SolrQueryResponse rsp) {
     }
   }
 
+  public CoreReplicationAPI.IndexVersionResponse getIndexVersionResponse() throws IOException {

Review Comment:
   Personally I wouldn't create public getters for those fields just for the V2 API. If at some point all the logic is moved then that should go in that PR.
   
   But if you feel strongly about it, I can definitely move it just lmk.



-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] mlbiscoc commented on a diff in pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #1620:
URL: https://github.com/apache/solr/pull/1620#discussion_r1191689969


##########
solr/core/src/java/org/apache/solr/handler/replication/ReplicationAPIBase.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.handler.replication;
+
+import java.io.IOException;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** A common parent for "replication" (i.e. replication-level) APIs. */
+public abstract class ReplicationAPIBase extends JerseyResource {
+
+  protected final CoreContainer coreContainer;
+  protected final SolrQueryRequest solrQueryRequest;
+  protected final SolrQueryResponse solrQueryResponse;
+
+  public ReplicationAPIBase(
+      CoreContainer coreContainer,
+      SolrQueryRequest solrQueryRequest,
+      SolrQueryResponse solrQueryResponse) {
+    this.coreContainer = coreContainer;
+    this.solrQueryRequest = solrQueryRequest;
+    this.solrQueryResponse = solrQueryResponse;
+  }
+
+  protected CoreReplicationAPI.GetIndexResponse fetchIndexVersion(String coreName)
+      throws IOException {
+
+    if (coreContainer.getCore(coreName) == null) {
+      throw new SolrException(
+          SolrException.ErrorCode.BAD_REQUEST, "Solr core " + coreName + " does not exist");
+    }
+
+    ReplicationHandler replicationHandler =
+        (ReplicationHandler)
+            coreContainer.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);

Review Comment:
   Hi Jason, thanks for the review! Glad most of it looks good.
   
   As for your comment on injecting the SolrCore, I'm not sure how this would be done in this API. The user specifies the `coreName` for which the API then uses to retrieve the SolrCore from the coreContainer. 
   
   Maybe I need to read more on Solr's Jersey Injections, but how would you inject the SolrCore in the constructor without knowing what `coreName` the user was asking for that is specified in the URI path?



-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] gerlowskija merged pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija merged PR #1620:
URL: https://github.com/apache/solr/pull/1620


-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] mlbiscoc commented on pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on PR #1620:
URL: https://github.com/apache/solr/pull/1620#issuecomment-1542205015

   Has anyone had a chance to review this for any fixes or improvements I could do to this PR?


-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] mlbiscoc commented on pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on PR #1620:
URL: https://github.com/apache/solr/pull/1620#issuecomment-1546119925

   @gerlowskija I believe I have addressed all your comments above. Please feel free to review again if you think any other changes are necessary.


-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] gerlowskija commented on pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on PR #1620:
URL: https://github.com/apache/solr/pull/1620#issuecomment-1551469373

   Alright, changes look great!  I'm going to make a few tweaks, mostly to method names and Javadoc and then aim to merge later today after I get a clean test run.
   
   Thanks @mlbiscoc !


-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] mlbiscoc commented on a diff in pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #1620:
URL: https://github.com/apache/solr/pull/1620#discussion_r1192656511


##########
solr/core/src/java/org/apache/solr/handler/replication/package-info.java:
##########
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
+/** V2 API implementations for "replication" APIs. */
+package org.apache.solr.handler.replication;

Review Comment:
   I was going for the latter to put `filecontent` and `filelist` inside of this class as well. After some thought I agree it probably doesn't need it's own package so I moved it into admin/api.



-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] gerlowskija commented on pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on PR #1620:
URL: https://github.com/apache/solr/pull/1620#issuecomment-1551865664

   Thanks again @mlbiscoc - let me know if you decide to pick up any other v2 API tickets that need review!


-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] mlbiscoc commented on a diff in pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #1620:
URL: https://github.com/apache/solr/pull/1620#discussion_r1183021546


##########
solr/core/src/java/org/apache/solr/handler/replication/ReplicationAPIBase.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.handler.replication;
+
+import java.io.IOException;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** A common parent for "replication" (i.e. replication-level) APIs. */
+public abstract class ReplicationAPIBase extends JerseyResource {
+
+  protected final CoreContainer coreContainer;
+  protected final SolrQueryRequest solrQueryRequest;
+  protected final SolrQueryResponse solrQueryResponse;
+
+  public ReplicationAPIBase(
+      CoreContainer coreContainer,
+      SolrQueryRequest solrQueryRequest,
+      SolrQueryResponse solrQueryResponse) {
+    this.coreContainer = coreContainer;
+    this.solrQueryRequest = solrQueryRequest;
+    this.solrQueryResponse = solrQueryResponse;
+  }
+
+  protected CoreReplicationAPI.GetIndexResponse fetchIndexVersion(String coreName)
+      throws IOException {
+
+    if (coreContainer.getCore(coreName) == null) {
+      throw new SolrException(
+          SolrException.ErrorCode.BAD_REQUEST, "Solr core " + coreName + " does not exist");
+    }
+
+    ReplicationHandler replicationHandler =
+        (ReplicationHandler)
+            coreContainer.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);

Review Comment:
   @gerlowskija This is my first attempt and progress at creating a new V2 api for indexversion and would love your feedback. One of the issues I ran into was this replicationHandler being called in the V2 endpoint. 
   
   It wasn't entirely obvious to me on how to move the replicationHandler logic into the v2 API as there were a few fields that were needed inside the replicationHandler in order to retrieve the indexversion because of race conditions. So I retrieved the handler from the core but I'm not sure if this is the best solution.
   
   Was hoping I could get some guidance on this?



##########
solr/core/src/java/org/apache/solr/handler/replication/ReplicationAPIBase.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.handler.replication;
+
+import java.io.IOException;
+import org.apache.solr.api.JerseyResource;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/** A common parent for "replication" (i.e. replication-level) APIs. */
+public abstract class ReplicationAPIBase extends JerseyResource {
+
+  protected final CoreContainer coreContainer;
+  protected final SolrQueryRequest solrQueryRequest;
+  protected final SolrQueryResponse solrQueryResponse;
+
+  public ReplicationAPIBase(
+      CoreContainer coreContainer,
+      SolrQueryRequest solrQueryRequest,
+      SolrQueryResponse solrQueryResponse) {
+    this.coreContainer = coreContainer;
+    this.solrQueryRequest = solrQueryRequest;
+    this.solrQueryResponse = solrQueryResponse;
+  }
+
+  protected CoreReplicationAPI.GetIndexResponse fetchIndexVersion(String coreName)
+      throws IOException {
+
+    if (coreContainer.getCore(coreName) == null) {
+      throw new SolrException(
+          SolrException.ErrorCode.BAD_REQUEST, "Solr core " + coreName + " does not exist");
+    }
+
+    ReplicationHandler replicationHandler =
+        (ReplicationHandler)
+            coreContainer.getCore(coreName).getRequestHandler(ReplicationHandler.PATH);

Review Comment:
   @gerlowskija This is my first attempt and current progress at creating a new V2 api for indexversion and would love your feedback. One of the issues I ran into was this replicationHandler being called in the V2 endpoint. 
   
   It wasn't entirely obvious to me on how to move the replicationHandler logic into the v2 API as there were a few fields that were needed inside the replicationHandler in order to retrieve the indexversion because of race conditions. So I retrieved the handler from the core but I'm not sure if this is the best solution.
   
   Was hoping I could get some guidance on this?



-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] mlbiscoc commented on a diff in pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #1620:
URL: https://github.com/apache/solr/pull/1620#discussion_r1192657522


##########
solr/solr-ref-guide/modules/deployment-guide/pages/user-managed-index-replication.adoc:
##########
@@ -378,9 +378,26 @@ http://_leader_host:port_/solr/_core_name_/replication?command=disablereplicatio
 `indexversion`::
 Return the version of the latest replicatable index on the specified leader or follower.
 +
+====
+[.tab-label]*V1 API*
+
 [source,bash]
+----
 http://_host:port_/solr/_core_name_/replication?command=indexversion
 
+----
+====
++
+====
+[.tab-label]*V2 API*
+
+[source,bash]
+----
+http://_host:port_/api/_core_name_/replication/indexversion

Review Comment:
   Ah nice catch on the missed typo by me. Fixed



-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] gerlowskija commented on pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on PR #1620:
URL: https://github.com/apache/solr/pull/1620#issuecomment-1544570124

   Hi @mlbiscoc - thanks for the PR!  Sorry for the delay in reviewing, I didn't see it right away.  But will set it to review it now!


-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] mlbiscoc commented on a diff in pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #1620:
URL: https://github.com/apache/solr/pull/1620#discussion_r1192656846


##########
solr/core/src/test/org/apache/solr/handler/replication/CoreReplicationAPITest.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.handler.replication;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import io.opentracing.noop.NoopSpan;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Unit tests for {@link CoreReplicationAPI} */
+public class CoreReplicationAPITest extends SolrTestCaseJ4 {
+
+  private CoreReplicationAPI coreReplicationAPI;
+  private CoreContainer mockCoreContainer;
+  private ReplicationHandler mockReplicationHandler;
+  private static final String coreName = "test";
+  private SolrQueryRequest mockQueryRequest;
+  private SolrQueryResponse queryResponse;
+
+  @BeforeClass
+  public static void ensureWorkingMockito() {
+    assumeWorkingMockito();
+  }
+
+  @Before
+  public void setUp() throws Exception {
+    super.setUp();
+    setUpMocks();
+    mockQueryRequest = mock(SolrQueryRequest.class);
+    when(mockQueryRequest.getSpan()).thenReturn(NoopSpan.INSTANCE);
+    queryResponse = new SolrQueryResponse();
+    coreReplicationAPI = new CoreReplicationAPI(mockCoreContainer, mockQueryRequest, queryResponse);
+  }
+
+  @Test
+  public void testGetIndexVersion() throws Exception {
+    CoreReplicationAPI.IndexVersionResponse expected =
+        new CoreReplicationAPI.IndexVersionResponse(123L, 123L, "testGeneration");
+    when(mockReplicationHandler.getIndexVersionResponse()).thenReturn(expected);
+
+    CoreReplicationAPI.IndexVersionResponse response =
+        coreReplicationAPI.IndexVersionResponse(coreName);
+    assertEquals(response.indexVersion, expected.indexVersion);
+    assertEquals(response.generation, expected.generation);
+    assertEquals(response.status, expected.status);

Review Comment:
   Swapped the arguments to correct assertion.



-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] gerlowskija commented on pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on PR #1620:
URL: https://github.com/apache/solr/pull/1620#issuecomment-1549790158

   Awesome, thanks for the quick turnaround @mlbiscoc !  Will review shortly


-- 
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: issues-unsubscribe@solr.apache.org

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


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


[GitHub] [solr] gerlowskija commented on a diff in pull request #1620: SOLR-16470: Create V2 equivalent of V1 Replication: Get IndexVersion

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on code in PR #1620:
URL: https://github.com/apache/solr/pull/1620#discussion_r1195254352


##########
solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java:
##########
@@ -798,6 +777,38 @@ private void getFileList(SolrParams solrParams, SolrQueryResponse rsp) {
     }
   }
 
+  public CoreReplicationAPI.IndexVersionResponse getIndexVersionResponse() throws IOException {

Review Comment:
   Definitely don't feel strongly about it; it's fine as-is 👍 



-- 
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: issues-unsubscribe@solr.apache.org

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


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