Skip to content

Commit

Permalink
Merge branch 'createpitservice' of github.com:bharath-techie/OpenSear…
Browse files Browse the repository at this point in the history
…ch into deletepitservice
  • Loading branch information
bharath-techie committed Jul 19, 2022
2 parents 97c4f77 + 987cb57 commit 9497923
Show file tree
Hide file tree
Showing 31 changed files with 166 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@

package org.opensearch.benchmark.time;

import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Benchmark;

import java.util.concurrent.TimeUnit;

Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ allprojects {
task.reproducibleFileOrder = true
if (task instanceof SymbolicLinkPreservingTar) {
// Replace file timestamps with latest Git revision date (if available)
task.lastModifiedTimestamp = gitRevisionDate
task.lastModifiedTimestamp = gitRevisionDate
}
}

Expand Down Expand Up @@ -359,7 +359,8 @@ allprojects {
project.javadoc.dependsOn "${upstreamProject.path}:javadoc"
String externalLinkName = upstreamProject.archivesBaseName
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + externalLinkName.replaceAll('\\.', '/') + '/' + dep.version
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${upstreamProject.buildDir}/docs/javadoc/"
String projectRelativePath = project.relativePath(upstreamProject.buildDir)
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${projectRelativePath}/docs/javadoc/"
}
}
boolean hasShadow = project.plugins.hasPlugin(ShadowPlugin)
Expand Down
12 changes: 12 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: "70...100"
status:
project:
default:
target: 70% # the required coverage value
threshold: 1% # the leniency in hitting the target
2 changes: 1 addition & 1 deletion distribution/packages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ tasks.register('buildRpm', Rpm) {
}

tasks.register('buildNoJdkRpm', Rpm) {
configure(commonRpmConfig(true, 'x64'))
configure(commonRpmConfig(false, 'x64'))
}

Closure dpkgExists = { it -> new File('/bin/dpkg-deb').exists() || new File('/usr/bin/dpkg-deb').exists() || new File('/usr/local/bin/dpkg-deb').exists() }
Expand Down
7 changes: 7 additions & 0 deletions gradle/formatting.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ allprojects {
eclipse().configFile rootProject.file('buildSrc/formatterConfig.xml')
trimTrailingWhitespace()

custom 'Refuse wildcard imports', {
// Wildcard imports can't be resolved; fail the build
if (it =~ /\s+import .*\*;/) {
throw new AssertionError("Do not use wildcard imports. 'spotlessApply' cannot resolve this issue.")
}
}

// See DEVELOPER_GUIDE.md for details of when to enable this.
if (System.getProperty('spotless.paddedcell') != null) {
paddedCell()
Expand Down
6 changes: 4 additions & 2 deletions gradle/missing-javadoc.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ allprojects {
classpath = sourceSets.main.compileClasspath
srcDirSet = sourceSets.main.java

outputDir = project.javadoc.destinationDir
outputDir = file("${project.buildDir}/tmp/missingJavadoc/")
}
}
}
Expand Down Expand Up @@ -183,6 +183,7 @@ configure(project(":server")) {
}
}

@CacheableTask
class MissingJavadocTask extends DefaultTask {
@InputFiles
@SkipWhenEmpty
Expand Down Expand Up @@ -227,7 +228,8 @@ class MissingJavadocTask extends DefaultTask {
@Input
def executable

@Input
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
def taskResources

/** Utility method to recursively collect all tasks with same name like this one that we depend on */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@

import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.RuntimeMetaData;
import org.antlr.v4.runtime.Vocabulary;
import org.antlr.v4.runtime.VocabularyImpl;
import org.antlr.v4.runtime.RuleContext;
import org.antlr.v4.runtime.atn.ATN;
import org.antlr.v4.runtime.atn.ATNDeserializer;
import org.antlr.v4.runtime.atn.LexerATNSimulator;
import org.antlr.v4.runtime.atn.PredictionContextCache;

import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.*;

@SuppressWarnings({ "all", "warnings", "unchecked", "unused", "cast" })
abstract class PainlessLexer extends Lexer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,25 @@
*/
package org.opensearch.painless.antlr;

import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.*;
import org.antlr.v4.runtime.atn.PredictionContextCache;
import org.antlr.v4.runtime.atn.ParserATNSimulator;
import org.antlr.v4.runtime.atn.ATN;
import org.antlr.v4.runtime.atn.ATNDeserializer;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.RuntimeMetaData;
import org.antlr.v4.runtime.Vocabulary;
import org.antlr.v4.runtime.VocabularyImpl;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.NoViableAltException;
import org.antlr.v4.runtime.FailedPredicateException;
import org.antlr.v4.runtime.RuleContext;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
import java.util.List;

@SuppressWarnings({ "all", "warnings", "unchecked", "unused", "cast" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@

import org.apache.lucene.tests.util.English;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.*;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.action.search.MultiSearchResponse;
import org.opensearch.action.search.SearchType;
import org.opensearch.action.search.SearchRequestBuilder;
import org.opensearch.action.search.ShardSearchFailure;
import org.opensearch.common.settings.Settings;
import org.opensearch.index.query.QueryBuilder;
import org.opensearch.index.query.QueryBuilders;
Expand All @@ -44,7 +48,11 @@
import org.opensearch.search.sort.SortOrder;
import org.opensearch.test.OpenSearchIntegTestCase;

import java.util.*;
import java.util.List;
import java.util.Arrays;
import java.util.Map;
import java.util.HashSet;
import java.util.Set;

import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.greaterThan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.Strings;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.NamedWriteableRegistry;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.unit.TimeValue;
Expand Down Expand Up @@ -53,41 +54,38 @@ public class CreatePitController {
private final ClusterService clusterService;
private final TransportSearchAction transportSearchAction;
private final NamedWriteableRegistry namedWriteableRegistry;
private final Task task;
private final ActionListener<CreatePitResponse> listener;
private final CreatePitRequest request;
private final PitService pitService;
private static final Logger logger = LogManager.getLogger(CreatePitController.class);
public static final Setting<TimeValue> PIT_INIT_KEEP_ALIVE = Setting.positiveTimeSetting(
"pit.init.keep_alive",
"point_in_time.init.keep_alive",
timeValueSeconds(30),
Setting.Property.NodeScope
);

@Inject
public CreatePitController(
CreatePitRequest request,
SearchTransportService searchTransportService,
ClusterService clusterService,
TransportSearchAction transportSearchAction,
NamedWriteableRegistry namedWriteableRegistry,
Task task,
ActionListener<CreatePitResponse> listener,
PitService pitService
) {
this.searchTransportService = searchTransportService;
this.clusterService = clusterService;
this.transportSearchAction = transportSearchAction;
this.namedWriteableRegistry = namedWriteableRegistry;
this.task = task;
this.listener = listener;
this.request = request;
this.pitService = pitService;
}

/**
* This method creates PIT reader context
*/
public void executeCreatePit(StepListener<SearchResponse> createPitListener, ActionListener<CreatePitResponse> updatePitIdListener) {
public void executeCreatePit(
CreatePitRequest request,
Task task,
StepListener<SearchResponse> createPitListener,
ActionListener<CreatePitResponse> updatePitIdListener
) {
SearchRequest searchRequest = new SearchRequest(request.getIndices());
searchRequest.preference(request.getPreference());
searchRequest.routing(request.getRouting());
Expand Down Expand Up @@ -235,7 +233,11 @@ private StepListener<BiFunction<String, String, DiscoveryNode>> getConnectionLoo
.filter(ctx -> Strings.isEmpty(ctx.getClusterAlias()) == false)
.map(SearchContextIdForNode::getClusterAlias)
.collect(Collectors.toSet());
return SearchUtils.getConnectionLookupListener(searchTransportService.getRemoteClusterService(), state, clusters);
return (StepListener<BiFunction<String, String, DiscoveryNode>>) SearchUtils.getConnectionLookupListener(
searchTransportService.getRemoteClusterService(),
state,
clusters
);
}

private ActionListener<UpdatePitContextResponse> getGroupedListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@
*
* @opensearch.internal
*/
public final class SearchContextIdForNode implements Writeable {
final class SearchContextIdForNode implements Writeable {
private final String node;
private final ShardSearchContextId searchContextId;
private final String clusterAlias;

public SearchContextIdForNode(@Nullable String clusterAlias, String node, ShardSearchContextId searchContextId) {
SearchContextIdForNode(@Nullable String clusterAlias, String node, ShardSearchContextId searchContextId) {
this.node = node;
this.clusterAlias = clusterAlias;
this.searchContextId = searchContextId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.action.search;

import org.opensearch.action.ActionListener;
import org.opensearch.action.StepListener;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.node.DiscoveryNode;
Expand All @@ -26,7 +27,7 @@ public SearchUtils() {}
/**
* Get connection lookup listener for list of clusters passed
*/
public static StepListener<BiFunction<String, String, DiscoveryNode>> getConnectionLookupListener(
public static ActionListener<BiFunction<String, String, DiscoveryNode>> getConnectionLookupListener(
RemoteClusterService remoteClusterService,
ClusterState state,
Set<String> clusters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class TransportCreatePitAction extends HandledTransportAction<CreatePitRe
private final TransportSearchAction transportSearchAction;
private final NamedWriteableRegistry namedWriteableRegistry;
private final PitService pitService;
private final CreatePitController createPitController;

@Inject
public TransportCreatePitAction(
Expand All @@ -51,13 +52,16 @@ public TransportCreatePitAction(
TransportSearchAction transportSearchAction,
NamedWriteableRegistry namedWriteableRegistry,
PitService pitService
NamedWriteableRegistry namedWriteableRegistry,
CreatePitController createPitController
) {
super(CreatePitAction.NAME, transportService, actionFilters, in -> new CreatePitRequest(in));
this.transportService = transportService;
this.searchTransportService = searchTransportService;
this.clusterService = clusterService;
this.transportSearchAction = transportSearchAction;
this.namedWriteableRegistry = namedWriteableRegistry;
this.createPitController = createPitController;
this.pitService = pitService;
}

Expand All @@ -83,7 +87,7 @@ protected void doExecute(Task task, CreatePitRequest request, ActionListener<Cre
);
listener.onFailure(e);
});
controller.executeCreatePit(createPitListener, updatePitIdListener);
createPitController.executeCreatePit(request, task, createPitListener, updatePitIdListener);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ public void ensureCanFlush() {

/**
* Reads operations from the translog
* @param location
* @param location location of translog
* @return the translog operation
* @throws IOException
* @throws IOException throws an IO exception
*/
@Override
public Translog.Operation readOperation(Translog.Location location) throws IOException {
Expand All @@ -296,9 +296,9 @@ public Translog.Operation readOperation(Translog.Location location) throws IOExc

/**
* Adds an operation to the translog
* @param operation
* @param operation operation to add to translog
* @return the location in the translog
* @throws IOException
* @throws IOException throws an IO exception
*/
@Override
public Translog.Location add(Translog.Operation operation) throws IOException {
Expand Down Expand Up @@ -396,8 +396,8 @@ public String getTranslogUUID() {

/**
*
* @param localCheckpointOfLastCommit
* @param flushThreshold
* @param localCheckpointOfLastCommit local checkpoint reference of last commit to translog
* @param flushThreshold threshold to flush to translog
* @return if the translog should be flushed
*/
public boolean shouldPeriodicallyFlush(long localCheckpointOfLastCommit, long flushThreshold) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ public interface TranslogManager {
* Reads operations for the translog
* @param location the location in the translog
* @return the translog operation
* @throws IOException
* @throws IOException throws an IO exception when reading the file fails
*/
Translog.Operation readOperation(Translog.Location location) throws IOException;

/**
* Adds an operation to the translog
* @param operation
* @param operation to add to translog
* @return the location in the translog
* @throws IOException
* @throws IOException throws an IO exception if adding an operation fails
*/
Translog.Location add(Translog.Operation operation) throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
* This setting will help validate the max keep alive that can be set during creation or extension for a PIT reader context
*/
public static final Setting<TimeValue> MAX_PIT_KEEPALIVE_SETTING = Setting.positiveTimeSetting(
"pit.max_keep_alive",
"point_in_time.max_keep_alive",
timeValueHours(24),
Property.NodeScope,
Property.Dynamic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Releasable updatePitIdAndKeepAlive(long keepAliveInMillis, String pitId,
setPitId(pitId);
setCreationTime(createTime);
return Releasables.releaseOnce(() -> {
getLastAccessTime().updateAndGet(curr -> Math.max(curr, nowInMillis()));
updateLastAccessTime();
getRefCounted().decRef();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ protected AbstractRefCounted getRefCounted() {
return refCounted;
}

protected AtomicLong getLastAccessTime() {
return lastAccessTime;
protected void updateLastAccessTime() {
this.lastAccessTime.updateAndGet(curr -> Math.max(curr, nowInMillis()));
}

protected long nowInMillis() {
Expand Down
Loading

0 comments on commit 9497923

Please sign in to comment.