-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### What changes were proposed in this pull request? Add REST API for adding partition ### Why are the changes needed? Fix: #1774 ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? UTs added
- Loading branch information
Showing
5 changed files
with
188 additions
and
1 deletion.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
common/src/main/java/com/datastrato/gravitino/dto/requests/AddPartitionsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
package com.datastrato.gravitino.dto.requests; | ||
|
||
import com.datastrato.gravitino.dto.rel.partitions.PartitionDTO; | ||
import com.datastrato.gravitino.rest.RESTRequest; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.google.common.base.Preconditions; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
import lombok.extern.jackson.Jacksonized; | ||
|
||
@Getter | ||
@EqualsAndHashCode | ||
@ToString | ||
@Builder | ||
@Jacksonized | ||
public class AddPartitionsRequest implements RESTRequest { | ||
|
||
@JsonProperty("partitions") | ||
private final PartitionDTO[] partitions; | ||
|
||
public AddPartitionsRequest() { | ||
this(null); | ||
} | ||
|
||
public AddPartitionsRequest(PartitionDTO[] partitions) { | ||
this.partitions = partitions; | ||
} | ||
|
||
@Override | ||
public void validate() throws IllegalArgumentException { | ||
Preconditions.checkArgument(partitions != null, "partitions must not be null"); | ||
Preconditions.checkArgument( | ||
partitions.length == 1, "Haven't yet implemented multiple partitions"); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
common/src/main/java/com/datastrato/gravitino/dto/responses/PartitionListResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
package com.datastrato.gravitino.dto.responses; | ||
|
||
import com.datastrato.gravitino.dto.rel.partitions.PartitionDTO; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@ToString | ||
@EqualsAndHashCode(callSuper = true) | ||
public class PartitionListResponse extends BaseResponse { | ||
|
||
@JsonProperty("partitions") | ||
private final PartitionDTO[] partitions; | ||
|
||
public PartitionListResponse(PartitionDTO[] partitions) { | ||
super(0); | ||
this.partitions = partitions; | ||
} | ||
|
||
// This is the constructor that is used by Jackson deserializer | ||
public PartitionListResponse() { | ||
super(); | ||
this.partitions = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters