Search in sources :

Example 1 with BulkUpdateEntitiesResponse

use of org.hypertrace.gateway.service.v1.entity.BulkUpdateEntitiesResponse in project gateway-service by hypertrace.

the class GatewayServiceImpl method bulkUpdateEntities.

@Override
public void bulkUpdateEntities(BulkUpdateEntitiesRequest request, StreamObserver<BulkUpdateEntitiesResponse> responseObserver) {
    LOG.debug("Received request: {}", request);
    try {
        String tenantId = org.hypertrace.core.grpcutils.context.RequestContext.CURRENT.get().getTenantId().orElseThrow(() -> new ServiceException("Tenant id is missing in the request."));
        BulkUpdateEntitiesResponse response = entityService.bulkUpdateEntities(tenantId, request, org.hypertrace.core.grpcutils.context.RequestContext.CURRENT.get().getRequestHeaders());
        LOG.debug("Received response: {}", response);
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    } catch (Exception e) {
        LOG.error("Error while handling bulkUpdateEntities: {}.", request, e);
        responseObserver.onError(e);
    }
}
Also used : ServiceException(com.google.protobuf.ServiceException) BulkUpdateEntitiesResponse(org.hypertrace.gateway.service.v1.entity.BulkUpdateEntitiesResponse) ServiceException(com.google.protobuf.ServiceException)

Example 2 with BulkUpdateEntitiesResponse

use of org.hypertrace.gateway.service.v1.entity.BulkUpdateEntitiesResponse in project gateway-service by hypertrace.

the class EdsEntityUpdater method bulkUpdateEntities.

public BulkUpdateEntitiesResponse bulkUpdateEntities(BulkUpdateEntitiesRequest request, UpdateExecutionContext updateExecutionContext) {
    MultiValuedAttributeOperation multiValuedAttributeOperation = request.getOperation().getMultiValuedAttributeOperation();
    org.hypertrace.entity.query.service.v1.BulkEntityArrayAttributeUpdateRequest updateRequest = org.hypertrace.entity.query.service.v1.BulkEntityArrayAttributeUpdateRequest.newBuilder().setEntityType(request.getEntityType()).addAllEntityIds(request.getEntityIdsList()).setOperation(EntityServiceAndGatewayServiceConverter.convertToBulkEntityArrayAttributeUpdateOperation(multiValuedAttributeOperation.getType())).setAttribute(EntityServiceAndGatewayServiceConverter.convertToQueryColumnIdentifier(multiValuedAttributeOperation.getAttribute())).addAllValues(multiValuedAttributeOperation.getValuesList().stream().map(value -> EntityServiceAndGatewayServiceConverter.convertToQueryLiteral(value)).collect(Collectors.toList())).build();
    eqsClient.bulkUpdateEntityArrayAttribute(updateRequest, updateExecutionContext.getRequestHeaders());
    return BulkUpdateEntitiesResponse.newBuilder().build();
}
Also used : Row(org.hypertrace.entity.query.service.v1.Row) UpdateEntityResponse(org.hypertrace.gateway.service.v1.entity.UpdateEntityResponse) EntityQueryServiceClient(org.hypertrace.entity.query.service.client.EntityQueryServiceClient) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) UpdateEntityRequest(org.hypertrace.gateway.service.v1.entity.UpdateEntityRequest) ResultSetChunk(org.hypertrace.entity.query.service.v1.ResultSetChunk) UpdateOperation(org.hypertrace.entity.query.service.v1.UpdateOperation) EntityServiceAndGatewayServiceConverter(org.hypertrace.gateway.service.common.converters.EntityServiceAndGatewayServiceConverter) LoggerFactory(org.slf4j.LoggerFactory) EntityUpdateRequest(org.hypertrace.entity.query.service.v1.EntityUpdateRequest) Collectors(java.util.stream.Collectors) AttributeMetadataUtil(org.hypertrace.gateway.service.common.util.AttributeMetadataUtil) Entity(org.hypertrace.gateway.service.v1.entity.Entity) BulkUpdateEntitiesResponse(org.hypertrace.gateway.service.v1.entity.BulkUpdateEntitiesResponse) MultiValuedAttributeOperation(org.hypertrace.gateway.service.v1.entity.MultiValuedAttributeOperation) Map(java.util.Map) BulkUpdateEntitiesRequest(org.hypertrace.gateway.service.v1.entity.BulkUpdateEntitiesRequest) SetAttribute(org.hypertrace.entity.query.service.v1.SetAttribute) MultiValuedAttributeOperation(org.hypertrace.gateway.service.v1.entity.MultiValuedAttributeOperation)

Aggregations

BulkUpdateEntitiesResponse (org.hypertrace.gateway.service.v1.entity.BulkUpdateEntitiesResponse)2 ServiceException (com.google.protobuf.ServiceException)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 AttributeMetadata (org.hypertrace.core.attribute.service.v1.AttributeMetadata)1 EntityQueryServiceClient (org.hypertrace.entity.query.service.client.EntityQueryServiceClient)1 EntityUpdateRequest (org.hypertrace.entity.query.service.v1.EntityUpdateRequest)1 ResultSetChunk (org.hypertrace.entity.query.service.v1.ResultSetChunk)1 Row (org.hypertrace.entity.query.service.v1.Row)1 SetAttribute (org.hypertrace.entity.query.service.v1.SetAttribute)1 UpdateOperation (org.hypertrace.entity.query.service.v1.UpdateOperation)1 EntityServiceAndGatewayServiceConverter (org.hypertrace.gateway.service.common.converters.EntityServiceAndGatewayServiceConverter)1 AttributeMetadataUtil (org.hypertrace.gateway.service.common.util.AttributeMetadataUtil)1 BulkUpdateEntitiesRequest (org.hypertrace.gateway.service.v1.entity.BulkUpdateEntitiesRequest)1 Entity (org.hypertrace.gateway.service.v1.entity.Entity)1 MultiValuedAttributeOperation (org.hypertrace.gateway.service.v1.entity.MultiValuedAttributeOperation)1 UpdateEntityRequest (org.hypertrace.gateway.service.v1.entity.UpdateEntityRequest)1 UpdateEntityResponse (org.hypertrace.gateway.service.v1.entity.UpdateEntityResponse)1 Logger (org.slf4j.Logger)1