tihom88 commented on code in PR #2173:
URL: https://github.com/apache/jackrabbit-oak/pull/2173#discussion_r1999171492
##########
oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporterTest.java:
##########
@@ -142,6 +144,50 @@ public void switchLanes() throws Exception{
assertEquals(AsyncLaneSwitcher.getTempLaneName("async"),
idxb.getString(ASYNC_PROPERTY_NAME));
}
+ @Test
+ public void switchLanesLuceneToElastic() throws Exception{
+ NodeBuilder builder = store.getRoot().builder();
+ builder.child("idx-a").setProperty("type", "elasticsearch");
+ builder.child("idx-a").setProperty("async", "elastic-async");
+
+ store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+ createIndexDirs("/idx-a");
+
+ builder.child("idx-a").setProperty("type", "lucene");
+ builder.child("idx-a").setProperty("async", asList("async", "nrt"),
Type.STRINGS);
+
+ store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+
+ IndexImporter importer = new IndexImporter(store,
temporaryFolder.getRoot(), provider, NOOP_LOCK);
+ importer.switchLanes();
+
+ NodeState idxa = NodeStateUtils.getNode(store.getRoot(), "/idx-a");
+ assertEquals(AsyncLaneSwitcher.getTempLaneName("elastic-async"),
idxa.getString(ASYNC_PROPERTY_NAME));
+ assertEquals(idxa.getStrings(ASYNC_PREVIOUS),
List.of("elastic-async"));
+ }
+
+ @Test
+ public void switchLanesElasticToLucene() throws Exception{
+ NodeBuilder builder = store.getRoot().builder();
+ builder.child("idx-a").setProperty("type", "lucene");
+ builder.child("idx-a").setProperty("async", List.of("async"),
Type.STRINGS);
+
+ store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+ createIndexDirs("/idx-a");
+
+ builder.child("idx-a").setProperty("type", "elasticsearch");
+ builder.child("idx-a").setProperty("async", List.of("elastic-async"),
Type.STRINGS);
+
+ store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+
+ IndexImporter importer = new IndexImporter(store,
temporaryFolder.getRoot(), provider, NOOP_LOCK);
+ importer.switchLanes();
+
+ NodeState idxa = NodeStateUtils.getNode(store.getRoot(), "/idx-a");
+ assertEquals(AsyncLaneSwitcher.getTempLaneName("async"),
idxa.getString(ASYNC_PROPERTY_NAME));
+ assertEquals(idxa.getStrings(ASYNC_PREVIOUS), List.of("async"));
Review Comment:
Please also add an assertion on "type" also.
##########
oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporterTest.java:
##########
@@ -142,6 +144,50 @@ public void switchLanes() throws Exception{
assertEquals(AsyncLaneSwitcher.getTempLaneName("async"),
idxb.getString(ASYNC_PROPERTY_NAME));
}
+ @Test
+ public void switchLanesLuceneToElastic() throws Exception{
+ NodeBuilder builder = store.getRoot().builder();
+ builder.child("idx-a").setProperty("type", "elasticsearch");
+ builder.child("idx-a").setProperty("async", "elastic-async");
+
+ store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+ createIndexDirs("/idx-a");
+
+ builder.child("idx-a").setProperty("type", "lucene");
+ builder.child("idx-a").setProperty("async", asList("async", "nrt"),
Type.STRINGS);
+
+ store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+
+ IndexImporter importer = new IndexImporter(store,
temporaryFolder.getRoot(), provider, NOOP_LOCK);
+ importer.switchLanes();
+
+ NodeState idxa = NodeStateUtils.getNode(store.getRoot(), "/idx-a");
+ assertEquals(AsyncLaneSwitcher.getTempLaneName("elastic-async"),
idxa.getString(ASYNC_PROPERTY_NAME));
Review Comment:
Please also add an assertion on "type" also.
##########
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporter.java:
##########
@@ -200,6 +208,20 @@ void switchLanes() throws CommitFailedException {
if (!indexInfo.newIndex) {
NodeBuilder idxBuilder =
NodeStoreUtils.childBuilder(builder, indexInfo.indexPath);
indexPathsToUpdate.add(indexInfo.indexPath);
+ String idxBuilderType =
idxBuilder.getString(TYPE_PROPERTY_NAME);
+
+ // check if provided index definitions is of different
type than existing one
+ // also check if one of them is an elasticsearch type
+ if (idxBuilderType != null &&
+ !idxBuilderType.equals(indexInfo.type) &&
+ (idxBuilderType.equals(TYPE_ELASTICSEARCH) ||
indexInfo.type.equals(TYPE_ELASTICSEARCH))) {
Review Comment:
Do we need this logic for elastic search? i think whatever be the async
lane's value, we should update that in new index. Be it lucene or elastic.
--
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]