Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature/multi_tenancy] Simplify instantiating Data Object Request/Response builders #2608

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public String id() {
public String tenantId() {
return this.tenantId;
}

/**
* Instantiate a builder for this object
* @return a builder instance
*/
public static Builder builder() {
return new Builder();
}

/**
* Class for constructing a Builder for this Request Object
Expand All @@ -63,7 +71,7 @@ public static class Builder {
/**
* Empty Constructor for the Builder object
*/
public Builder() {}
private Builder() {}

/**
* Add an index to this builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public XContentParser parser() {
return this.parser;
}

/**
* Instantiate a builder for this object
* @return a builder instance
*/
public static Builder builder() {
return new Builder();
}

/**
* Class for constructing a Builder for this Response Object
*/
Expand All @@ -52,7 +60,7 @@ public static class Builder {
/**
* Empty Constructor for the Builder object
*/
public Builder() {}
private Builder() {}

/**
* Add an id to this builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ public FetchSourceContext fetchSourceContext() {
return this.fetchSourceContext;
}

/**
* Instantiate a builder for this object
* @return a builder instance
*/
public static Builder builder() {
return new Builder();
}

/**
* Class for constructing a Builder for this Request Object
*/
Expand All @@ -77,7 +85,7 @@ public static class Builder {
/**
* Empty Constructor for the Builder object
*/
public Builder() {}
private Builder() {}

/**
* Add an index to this builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public Map<String, Object> source() {
return this.source;
}

/**
* Instantiate a builder for this object
* @return a builder instance
*/
public static Builder builder() {
return new Builder();
}

/**
* Class for constructing a Builder for this Response Object
*/
Expand All @@ -67,7 +75,7 @@ public static class Builder {
/**
* Empty Constructor for the Builder object
*/
public Builder() {}
private Builder() {}

/**
* Add an id to this builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public ToXContentObject dataObject() {
return this.dataObject;
}

/**
* Instantiate a builder for this object
* @return a builder instance
*/
public static Builder builder() {
return new Builder();
}

/**
* Class for constructing a Builder for this Request Object
*/
Expand All @@ -75,7 +83,7 @@ public static class Builder {
/**
* Empty Constructor for the Builder object
*/
public Builder() {}
private Builder() {}

/**
* Add an index to this builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public XContentParser parser() {
return this.parser;
}

/**
* Instantiate a builder for this object
* @return a builder instance
*/
public static Builder builder() {
return new Builder();
}

/**
* Class for constructing a Builder for this Response Object
*/
Expand All @@ -52,7 +60,7 @@ public static class Builder {
/**
* Empty Constructor for the Builder object
*/
public Builder() {}
private Builder() {}

/**
* Add an id to this builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public SearchSourceBuilder searchSourceBuilder() {
return this.searchSourceBuilder;
}

/**
* Instantiate a builder for this object
* @return a builder instance
*/
public static Builder builder() {
return new Builder();
}

/**
* Class for constructing a Builder for this Request Object
*/
Expand All @@ -66,7 +74,7 @@ public static class Builder {
/**
* Empty Constructor for the Builder object
*/
public Builder() {}
private Builder() {}

/**
* Add a indices to this builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ public XContentParser parser() {
return this.parser;
}

/**
* Instantiate a builder for this object
* @return a builder instance
*/
public static Builder builder() {
return new Builder();
}

/**
* Class for constructing a Builder for this Response Object
*/
Expand All @@ -38,7 +46,7 @@ public static class Builder {
/**
* Empty Constructor for the Builder object
*/
public Builder() {}
private Builder() {}

/**
* Add aparser to this builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ public ToXContentObject dataObject() {
return this.dataObject;
}

/**
* Instantiate a builder for this object
* @return a builder instance
*/
public static Builder builder() {
return new Builder();
}

/**
* Class for constructing a Builder for this Request Object
*/
Expand All @@ -81,7 +89,7 @@ public static class Builder {
/**
* Empty Constructor for the Builder object
*/
public Builder() {}
private Builder() {}

/**
* Add an index to this builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public XContentParser parser() {
return this.parser;
}

/**
* Instantiate a builder for this object
* @return a builder instance
*/
public static Builder builder() {
return new Builder();
}

/**
* Class for constructing a Builder for this Response Object
*/
Expand All @@ -52,7 +60,7 @@ public static class Builder {
/**
* Empty Constructor for the Builder object
*/
public Builder() {}
private Builder() {}

/**
* Add an id to this builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void setUp() {

@Test
public void testDeleteDataObjectRequest() {
DeleteDataObjectRequest request = new DeleteDataObjectRequest.Builder().index(testIndex).id(testId).tenantId(testTenantId).build();
DeleteDataObjectRequest request = DeleteDataObjectRequest.builder().index(testIndex).id(testId).tenantId(testTenantId).build();

assertEquals(testIndex, request.index());
assertEquals(testId, request.id());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

import org.junit.Before;
import org.junit.Test;
import org.opensearch.action.support.replication.ReplicationResponse.ShardInfo;
import org.opensearch.core.common.Strings;
import org.opensearch.core.index.shard.ShardId;
import org.opensearch.core.xcontent.XContentParser;

import static org.junit.Assert.assertEquals;
Expand All @@ -31,7 +28,7 @@ public void setUp() {

@Test
public void testDeleteDataObjectResponse() {
DeleteDataObjectResponse response = new DeleteDataObjectResponse.Builder().id(testId).parser(testParser).build();
DeleteDataObjectResponse response = DeleteDataObjectResponse.builder().id(testId).parser(testParser).build();

assertEquals(testId, response.id());
assertEquals(testParser, response.parser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void setUp() {

@Test
public void testGetDataObjectRequest() {
GetDataObjectRequest request = new GetDataObjectRequest.Builder()
GetDataObjectRequest request = GetDataObjectRequest.builder()
.index(testIndex)
.id(testId)
.tenantId(testTenantId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void setUp() {

@Test
public void testGetDataObjectResponse() {
GetDataObjectResponse response = new GetDataObjectResponse.Builder().id(testId).parser(testParser).source(testSource).build();
GetDataObjectResponse response = GetDataObjectResponse.builder().id(testId).parser(testParser).source(testSource).build();

assertEquals(testId, response.id());
assertEquals(testParser, response.parser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void setUp() {

@Test
public void testPutDataObjectRequest() {
PutDataObjectRequest request = new PutDataObjectRequest.Builder().index(testIndex).tenantId(testTenantId).dataObject(testDataObject).build();
PutDataObjectRequest request = PutDataObjectRequest.builder().index(testIndex).tenantId(testTenantId).dataObject(testDataObject).build();

assertEquals(testIndex, request.index());
assertEquals(testTenantId, request.tenantId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void setUp() {

@Test
public void testPutDataObjectResponse() {
PutDataObjectResponse response = new PutDataObjectResponse.Builder().id(testId).parser(testParser).build();
PutDataObjectResponse response = PutDataObjectResponse.builder().id(testId).parser(testParser).build();

assertEquals(testId, response.id());
assertEquals(testParser, response.parser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void setUp() {

@Test
public void testGetDataObjectRequest() {
SearchDataObjectRequest request = new SearchDataObjectRequest.Builder()
SearchDataObjectRequest request = SearchDataObjectRequest.builder()
.indices(testIndices)
.tenantId(testTenantId)
.searchSourceBuilder(testSearchSourceBuilder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void setUp() {

@Test
public void testSearchDataObjectResponse() {
SearchDataObjectResponse response = new SearchDataObjectResponse.Builder().parser(testParser).build();
SearchDataObjectResponse response = SearchDataObjectResponse.builder().parser(testParser).build();

assertEquals(testParser, response.parser());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void setUp() {

@Test
public void testUpdateDataObjectRequest() {
UpdateDataObjectRequest request = new UpdateDataObjectRequest.Builder().index(testIndex).id(testId).tenantId(testTenantId).dataObject(testDataObject).build();
UpdateDataObjectRequest request = UpdateDataObjectRequest.builder().index(testIndex).id(testId).tenantId(testTenantId).dataObject(testDataObject).build();

assertEquals(testIndex, request.index());
assertEquals(testId, request.id());
Expand All @@ -50,7 +50,7 @@ public void testUpdateDataObjectRequest() {

@Test
public void testUpdateDataObjectMapRequest() {
UpdateDataObjectRequest request = new UpdateDataObjectRequest.Builder().index(testIndex).id(testId).tenantId(testTenantId).dataObject(testDataObjectMap).build();
UpdateDataObjectRequest request = UpdateDataObjectRequest.builder().index(testIndex).id(testId).tenantId(testTenantId).dataObject(testDataObjectMap).build();

assertEquals(testIndex, request.index());
assertEquals(testId, request.id());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void setUp() {

@Test
public void testUpdateDataObjectResponse() {
UpdateDataObjectResponse response = new UpdateDataObjectResponse.Builder().id(testId).parser(testParser).build();
UpdateDataObjectResponse response = UpdateDataObjectResponse.builder().id(testId).parser(testParser).build();

assertEquals(testId, response.id());
assertEquals(testParser, response.parser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<Delete
boolean isSuperAdmin = isSuperAdminUserWrapper(clusterService, client);

FetchSourceContext fetchSourceContext = new FetchSourceContext(true, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY);
GetDataObjectRequest getDataObjectRequest = new GetDataObjectRequest.Builder()
GetDataObjectRequest getDataObjectRequest = GetDataObjectRequest
.builder()
.index(ML_AGENT_INDEX)
.id(agentId)
.tenantId(tenantId)
Expand Down Expand Up @@ -131,7 +132,8 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<Delete
try {
sdkClient
.deleteDataObjectAsync(
new DeleteDataObjectRequest.Builder()
DeleteDataObjectRequest
.builder()
.index(deleteRequest.index())
.id(deleteRequest.id())
.tenantId(tenantId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<MLAgen
boolean isSuperAdmin = isSuperAdminUserWrapper(clusterService, client);

FetchSourceContext fetchSourceContext = new FetchSourceContext(true, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY);
GetDataObjectRequest getDataObjectRequest = new GetDataObjectRequest.Builder()
GetDataObjectRequest getDataObjectRequest = GetDataObjectRequest
.builder()
.index(ML_AGENT_INDEX)
.id(agentId)
.tenantId(tenantId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void registerAgent(MLAgent agent, ActionListener<MLRegisterAgentResponse

sdkClient
.putDataObjectAsync(
new PutDataObjectRequest.Builder().index(ML_AGENT_INDEX).dataObject(mlAgent).build(),
PutDataObjectRequest.builder().index(ML_AGENT_INDEX).dataObject(mlAgent).build(),
client.threadPool().executor(GENERAL_THREAD_POOL)
)
.whenComplete((r, throwable) -> {
Expand Down
Loading
Loading