Skip to content

Commit

Permalink
Merge branch 'feature/multi_tenancy' into multi_tenancy_2
Browse files Browse the repository at this point in the history
Signed-off-by: arjunkumargiri <142054468+arjunkumargiri@users.noreply.github.com>
  • Loading branch information
arjunkumargiri authored Jul 8, 2024
2 parents c332aa5 + 18e8048 commit 052aac4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ public void registerMLRemoteModel(
*/
modelGroupSourceMap.put(MLModelGroup.LATEST_VERSION_FIELD, updatedVersion);
modelGroupSourceMap.put(MLModelGroup.LAST_UPDATED_TIME_FIELD, Instant.now().toEpochMilli());
UpdateDataObjectRequest updateDataObjectRequest = new UpdateDataObjectRequest.Builder()
UpdateDataObjectRequest updateDataObjectRequest = UpdateDataObjectRequest
.builder()
.index(ML_MODEL_GROUP_INDEX)
.id(modelGroupId)
.tenantId(mlRegisterModelInput.getTenantId())
Expand Down Expand Up @@ -584,7 +585,8 @@ private void indexRemoteModel(
.tenantId(registerModelInput.getTenantId())
.build();

PutDataObjectRequest putModelMetaRequest = new PutDataObjectRequest.Builder()
PutDataObjectRequest putModelMetaRequest = PutDataObjectRequest
.builder()
.index(ML_MODEL_INDEX)
.id(Boolean.TRUE.equals(registerModelInput.getIsHidden()) ? modelName : null)
.tenantId(registerModelInput.getTenantId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ public Collection<Object> createComponents(

// Get the injected SdkClient instance from the injector
SdkClient sdkClient = injector.getInstance(SdkClient.class);

mlIndicesHandler = new MLIndicesHandler(clusterService, client);
encryptor = new EncryptorImpl(clusterService, client, mlIndicesHandler);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public CompletionStage<GetDataObjectResponse> getDataObjectAsync(GetDataObjectRe
.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, simulatedGetResponse)
)
.getSourceAsMap();
return new GetDataObjectResponse.Builder().id(request.id()).parser(parser).source(sourceAsMap).build();
return GetDataObjectResponse.builder().id(request.id()).parser(parser).source(sourceAsMap).build();
} catch (IOException e) {
// Rethrow unchecked exception on XContent parsing error
throw new OpenSearchStatusException("Failed to parse response", RestStatus.INTERNAL_SERVER_ERROR);
Expand Down Expand Up @@ -207,7 +207,7 @@ public CompletionStage<UpdateDataObjectResponse> updateDataObjectAsync(UpdateDat
dynamoDbClient.updateItem(updateItemRequest);

String simulatedUpdateResponse = simulateOpenSearchResponse(request.index(), request.id(), source, Map.of("found", true));
return new UpdateDataObjectResponse.Builder().id(request.id()).parser(createParser(simulatedUpdateResponse)).build();
return UpdateDataObjectResponse.builder().id(request.id()).parser(createParser(simulatedUpdateResponse)).build();
} catch (IOException e) {
log.error("Error updating {} in {}: {}", request.id(), request.index(), e.getMessage(), e);
// Rethrow unchecked exception on update IOException
Expand Down Expand Up @@ -246,7 +246,7 @@ public CompletionStage<DeleteDataObjectResponse> deleteDataObjectAsync(DeleteDat
null,
Map.of("result", "deleted")
);
return new DeleteDataObjectResponse.Builder().id(request.id()).parser(createParser(simulatedDeleteResponse)).build();
return DeleteDataObjectResponse.builder().id(request.id()).parser(createParser(simulatedDeleteResponse)).build();
} catch (IOException e) {
// Rethrow unchecked exception on XContent parsing error
throw new OpenSearchStatusException("Failed to parse response", RestStatus.INTERNAL_SERVER_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public CompletionStage<PutDataObjectResponse> putDataObjectAsync(PutDataObjectRe
)
.actionGet();
log.info("Creation status for id {}: {}", indexResponse.getId(), indexResponse.getResult());
return new PutDataObjectResponse.Builder().id(indexResponse.getId()).parser(createParser(indexResponse)).build();
return PutDataObjectResponse.builder().id(indexResponse.getId()).parser(createParser(indexResponse)).build();
} catch (IOException e) {
// Rethrow unchecked exception on XContent parsing error
throw new OpenSearchStatusException(
Expand Down Expand Up @@ -135,10 +135,10 @@ public CompletionStage<UpdateDataObjectResponse> updateDataObjectAsync(UpdateDat
.actionGet();
if (updateResponse == null) {
log.info("Null UpdateResponse");
return new UpdateDataObjectResponse.Builder().id(request.id()).parser(null).build();
return UpdateDataObjectResponse.builder().id(request.id()).parser(null).build();
}
log.info("Update status for id {}: {}", updateResponse.getId(), updateResponse.getResult());
return new UpdateDataObjectResponse.Builder().id(updateResponse.getId()).parser(createParser(updateResponse)).build();
return UpdateDataObjectResponse.builder().id(updateResponse.getId()).parser(createParser(updateResponse)).build();
} catch (IOException e) {
// Rethrow unchecked exception on XContent parsing error
throw new OpenSearchStatusException(
Expand All @@ -156,7 +156,7 @@ public CompletionStage<DeleteDataObjectResponse> deleteDataObjectAsync(DeleteDat
log.info("Deleting {} from {}", request.id(), request.index());
DeleteResponse deleteResponse = client.delete(new DeleteRequest(request.index(), request.id())).actionGet();
log.info("Deletion status for id {}: {}", deleteResponse.getId(), deleteResponse.getResult());
return new DeleteDataObjectResponse.Builder().id(deleteResponse.getId()).parser(createParser(deleteResponse)).build();
return DeleteDataObjectResponse.builder().id(deleteResponse.getId()).parser(createParser(deleteResponse)).build();
} catch (IOException e) {
// Rethrow unchecked exception on XContent parsing error
throw new OpenSearchStatusException(
Expand All @@ -174,7 +174,7 @@ public CompletionStage<SearchDataObjectResponse> searchDataObjectAsync(SearchDat
SearchResponse searchResponse = client.search(new SearchRequest(request.indices(), request.searchSourceBuilder())).actionGet();
log.info("Search returned {} hits", searchResponse.getHits().getTotalHits());
try {
return new SearchDataObjectResponse.Builder().parser(createParser(searchResponse)).build();
return SearchDataObjectResponse.builder().parser(createParser(searchResponse)).build();
} catch (IOException e) {
// Rethrow unchecked exception on XContent parsing error
throw new OpenSearchStatusException(
Expand Down

0 comments on commit 052aac4

Please sign in to comment.