Skip to content

Commit

Permalink
Merge branch 'main' into updateNetflixGradle
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel (dB.) Doubrovkine <dblock@amazon.com>
  • Loading branch information
dblock committed Jul 17, 2023
2 parents 3d4b2a7 + 7642e43 commit b56042f
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Dependencies
- Bump `org.apache.logging.log4j:log4j-core` from 2.17.1 to 2.20.0 ([#8307](https://github.com/opensearch-project/OpenSearch/pull/8307))
- Bump `io.grpc:grpc-context` from 1.46.0 to 1.56.1 ([#8726](https://github.com/opensearch-project/OpenSearch/pull/8726))
- Bump `com.netflix.nebula:gradle-info-plugin` from 12.1.5 to 12.1.6 ([#8724](https://github.com/opensearch-project/OpenSearch/pull/8724))

### Changed
Expand Down
2 changes: 1 addition & 1 deletion plugins/repository-gcs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ dependencies {
api "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}"
api "commons-codec:commons-codec:${versions.commonscodec}"
api 'org.threeten:threetenbp:1.4.4'
api 'io.grpc:grpc-context:1.46.0'
api 'io.grpc:grpc-context:1.56.1'
api 'io.opencensus:opencensus-api:0.31.1'
api 'io.opencensus:opencensus-contrib-http-util:0.31.1'

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3681b1caf41af1da0c4a3ffec47ab4a3d907c190
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public void testIndexCreationOverLimitForDotIndexesFail() {
assertFalse(clusterState.getMetadata().hasIndex(".test-index"));
}

@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/6287")
public void testCreateIndexWithMaxClusterShardSetting() {
int dataNodes = client().admin().cluster().prepareState().get().getState().getNodes().getDataNodes().size();
ClusterState clusterState = client().admin().cluster().prepareState().get().getState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ protected OpenSearchDirectoryReader refreshIfNeeded(OpenSearchDirectoryReader re
* @param infos {@link SegmentInfos} infos
* @throws IOException - When Refresh fails with an IOException.
*/
public synchronized void updateSegments(SegmentInfos infos) throws IOException {
public void updateSegments(SegmentInfos infos) throws IOException {
// roll over the currentInfo's generation, this ensures the on-disk gen
// is always increased.
infos.updateGeneration(currentInfos);
currentInfos = infos;
maybeRefresh();
maybeRefreshBlocking();
}

public SegmentInfos getSegmentInfos() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.index.engine;

import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.SegmentInfos;
import org.apache.lucene.index.StandardDirectoryReader;
import org.apache.lucene.util.Version;
import org.opensearch.common.lucene.index.OpenSearchDirectoryReader;
import org.opensearch.index.store.Store;

import java.io.IOException;

public class NRTReplicationReaderManagerTests extends EngineTestCase {

public void testCreateNRTreaderManager() throws IOException {
try (final Store store = createStore()) {
store.createEmpty(Version.LATEST);
final DirectoryReader reader = DirectoryReader.open(store.directory());
final SegmentInfos initialInfos = ((StandardDirectoryReader) reader).getSegmentInfos();
NRTReplicationReaderManager readerManager = new NRTReplicationReaderManager(
OpenSearchDirectoryReader.wrap(reader, shardId),
(files) -> {},
(files) -> {}
);
assertEquals(initialInfos, readerManager.getSegmentInfos());
try (final OpenSearchDirectoryReader acquire = readerManager.acquire()) {
assertNull(readerManager.refreshIfNeeded(acquire));
}

// create an updated infos
final SegmentInfos infos_2 = readerManager.getSegmentInfos().clone();
infos_2.changed();

readerManager.updateSegments(infos_2);
assertEquals(infos_2, readerManager.getSegmentInfos());
try (final OpenSearchDirectoryReader acquire = readerManager.acquire()) {
final StandardDirectoryReader standardReader = NRTReplicationReaderManager.unwrapStandardReader(acquire);
assertEquals(infos_2, standardReader.getSegmentInfos());
}
}
}

public void testUpdateSegmentsWhileRefreshing() throws IOException, InterruptedException {
try (final Store store = createStore()) {
store.createEmpty(Version.LATEST);
final DirectoryReader reader = DirectoryReader.open(store.directory());
NRTReplicationReaderManager readerManager = new NRTReplicationReaderManager(
OpenSearchDirectoryReader.wrap(reader, shardId),
(files) -> {},
(files) -> {}
);

final SegmentInfos infos_2 = readerManager.getSegmentInfos().clone();
infos_2.changed();

Thread refreshThread = new Thread(() -> {
try {
readerManager.maybeRefresh();
} catch (IOException e) {
throw new RuntimeException(e);
}
});
Thread updateThread = new Thread(() -> {
try {
readerManager.updateSegments(infos_2);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
refreshThread.start();
updateThread.start();
refreshThread.join();
updateThread.join();
try (final OpenSearchDirectoryReader acquire = readerManager.acquire()) {
final StandardDirectoryReader standardReader = NRTReplicationReaderManager.unwrapStandardReader(acquire);
assertEquals(infos_2.version, standardReader.getSegmentInfos().version);
}
assertEquals(infos_2, readerManager.getSegmentInfos());
}
}
}

0 comments on commit b56042f

Please sign in to comment.