Skip to content

Commit

Permalink
Merge branch 'opensearch-project:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishikesh1159 authored Feb 16, 2022
2 parents 730c958 + c0c7d7a commit eb46b82
Show file tree
Hide file tree
Showing 55 changed files with 581 additions and 701 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,14 @@

public class TermVectorsResponse {
private final String index;
private final String type;
private final String id;
private final long docVersion;
private final boolean found;
private final long tookInMillis;
private final List<TermVector> termVectorList;

public TermVectorsResponse(
String index,
String type,
String id,
long version,
boolean found,
long tookInMillis,
List<TermVector> termVectorList
) {
public TermVectorsResponse(String index, String id, long version, boolean found, long tookInMillis, List<TermVector> termVectorList) {
this.index = index;
this.type = type;
this.id = id;
this.docVersion = version;
this.found = found;
Expand All @@ -75,27 +65,25 @@ public TermVectorsResponse(
"term_vectors",
true,
args -> {
// as the response comes from server, we are sure that args[6] will be a list of TermVector
// as the response comes from server, we are sure that args[5] will be a list of TermVector
@SuppressWarnings("unchecked")
List<TermVector> termVectorList = (List<TermVector>) args[6];
List<TermVector> termVectorList = (List<TermVector>) args[5];
if (termVectorList != null) {
Collections.sort(termVectorList, Comparator.comparing(TermVector::getFieldName));
}
return new TermVectorsResponse(
(String) args[0],
(String) args[1],
(String) args[2],
(long) args[3],
(boolean) args[4],
(long) args[5],
(long) args[2],
(boolean) args[3],
(long) args[4],
termVectorList
);
}
);

static {
PARSER.declareString(constructorArg(), new ParseField("_index"));
PARSER.declareString(constructorArg(), new ParseField("_type"));
PARSER.declareString(optionalConstructorArg(), new ParseField("_id"));
PARSER.declareLong(constructorArg(), new ParseField("_version"));
PARSER.declareBoolean(constructorArg(), new ParseField("found"));
Expand All @@ -118,16 +106,6 @@ public String getIndex() {
return index;
}

/**
* Returns the type for the response
*
* @deprecated Types are in the process of being removed.
*/
@Deprecated
public String getType() {
return type;
}

/**
* Returns the id of the request
* can be NULL if there is no document ID
Expand Down Expand Up @@ -171,7 +149,6 @@ public boolean equals(Object obj) {
if (!(obj instanceof TermVectorsResponse)) return false;
TermVectorsResponse other = (TermVectorsResponse) obj;
return index.equals(other.index)
&& type.equals(other.type)
&& Objects.equals(id, other.id)
&& docVersion == other.docVersion
&& found == other.found
Expand All @@ -181,7 +158,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return Objects.hash(index, type, id, docVersion, found, tookInMillis, termVectorList);
return Objects.hash(index, id, docVersion, found, tookInMillis, termVectorList);
}

public static final class TermVector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public void testFromXContent() throws IOException {
static void toXContent(TermVectorsResponse response, XContentBuilder builder) throws IOException {
builder.startObject();
builder.field("_index", response.getIndex());
builder.field("_type", response.getType());
if (response.getId() != null) {
builder.field("_id", response.getId());
}
Expand Down Expand Up @@ -130,7 +129,6 @@ private static void toXContent(TermVectorsResponse.TermVector tv, XContentBuilde

static TermVectorsResponse createTestInstance() {
String index = randomAlphaOfLength(5);
String type = randomAlphaOfLength(5);
String id = String.valueOf(randomIntBetween(1, 100));
long version = randomNonNegativeLong();
long tookInMillis = randomNonNegativeLong();
Expand All @@ -154,7 +152,7 @@ static TermVectorsResponse createTestInstance() {
);
}
}
TermVectorsResponse tvresponse = new TermVectorsResponse(index, type, id, version, found, tookInMillis, tvList);
TermVectorsResponse tvresponse = new TermVectorsResponse(index, id, version, found, tookInMillis, tvList);
return tvresponse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1719,9 +1719,8 @@ public void testTermVectors() throws Exception {

// tag::term-vectors-response
String index = response.getIndex(); // <1>
String type = response.getType(); // <2>
String id = response.getId(); // <3>
boolean found = response.getFound(); // <4>
String id = response.getId(); // <2>
boolean found = response.getFound(); // <3>
// end::term-vectors-response

if (response.getTermVectorsList() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ static BinaryFieldMapper createQueryBuilderFieldBuilder(BuilderContext context)
}

static RangeFieldMapper createExtractedRangeFieldBuilder(String name, RangeType rangeType, BuilderContext context) {
RangeFieldMapper.Builder builder = new RangeFieldMapper.Builder(name, rangeType, true);
RangeFieldMapper.Builder builder = new RangeFieldMapper.Builder(
name,
rangeType,
true,
hasIndexCreated(context.indexSettings()) ? context.indexCreatedVersion() : null
);
// For now no doc values, because in processQuery(...) only the Lucene range fields get added:
builder.docValues(false);
return builder.build(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ public List<Setting<?>> getSettings() {
AzureStorageSettings.ENDPOINT_SUFFIX_SETTING,
AzureStorageSettings.TIMEOUT_SETTING,
AzureStorageSettings.MAX_RETRIES_SETTING,
AzureStorageSettings.PROXY_TYPE_SETTING,
AzureStorageSettings.PROXY_HOST_SETTING,
AzureStorageSettings.PROXY_PORT_SETTING,
AzureStorageSettings.CONNECT_TIMEOUT_SETTING,
AzureStorageSettings.WRITE_TIMEOUT_SETTING,
AzureStorageSettings.READ_TIMEOUT_SETTING,
AzureStorageSettings.RESPONSE_TIMEOUT_SETTING
AzureStorageSettings.RESPONSE_TIMEOUT_SETTING,
AzureStorageSettings.PROXY_TYPE_SETTING,
AzureStorageSettings.PROXY_HOST_SETTING,
AzureStorageSettings.PROXY_PORT_SETTING,
AzureStorageSettings.PROXY_USERNAME_SETTING,
AzureStorageSettings.PROXY_PASSWORD_SETTING
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import com.azure.core.http.HttpRequest;
import com.azure.core.http.HttpResponse;
import com.azure.core.http.ProxyOptions;
import com.azure.core.http.ProxyOptions.Type;
import com.azure.core.http.netty.NettyAsyncHttpClientBuilder;
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.core.util.Configuration;
Expand All @@ -66,12 +65,11 @@
import org.opensearch.common.unit.ByteSizeValue;
import org.opensearch.common.unit.TimeValue;

import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URISyntaxException;
import java.security.InvalidKeyException;
import java.time.Duration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -169,15 +167,20 @@ private ClientState buildClient(AzureStorageSettings azureStorageSettings, BiCon
final NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup(new NioThreadFactory());
final NettyAsyncHttpClientBuilder clientBuilder = new NettyAsyncHttpClientBuilder().eventLoopGroup(eventLoopGroup);

final Proxy proxy = azureStorageSettings.getProxy();
if (proxy != null) {
final Type type = Arrays.stream(Type.values())
.filter(t -> t.toProxyType().equals(proxy.type()))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("Unsupported proxy type: " + proxy.type()));

clientBuilder.proxy(new ProxyOptions(type, (InetSocketAddress) proxy.address()));
}
SocketAccess.doPrivilegedVoidException(() -> {
final ProxySettings proxySettings = azureStorageSettings.getProxySettings();
if (proxySettings != ProxySettings.NO_PROXY_SETTINGS) {
if (proxySettings.isAuthenticated()) {
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(proxySettings.getUsername(), proxySettings.getPassword().toCharArray());
}
});
}
clientBuilder.proxy(new ProxyOptions(proxySettings.getType().toProxyType(), proxySettings.getAddress()));
}
});

final TimeValue connectTimeout = azureStorageSettings.getConnectTimeout();
if (connectTimeout != null) {
Expand Down
Loading

0 comments on commit eb46b82

Please sign in to comment.