-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yingjian Wu
committed
Jun 10, 2024
1 parent
c54dbda
commit fcaa0c0
Showing
14 changed files
with
1,380 additions
and
16 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...ommon-server/src/main/java/com/netflix/metacat/common/server/model/BaseRelEntityInfo.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,32 @@ | ||
package com.netflix.metacat.common.server.model; | ||
|
||
import lombok.Data; | ||
|
||
/** | ||
* Base class to represent relation entity. | ||
*/ | ||
@Data | ||
public abstract class BaseRelEntityInfo { | ||
private String name; | ||
private String relationType; | ||
private String uuid; | ||
|
||
/** | ||
Empty Constructor. | ||
*/ | ||
public BaseRelEntityInfo() { | ||
|
||
} | ||
|
||
/** | ||
Constructor with all params. | ||
@param name name of the entity | ||
@param relationType type of the relation | ||
@param uuid uuid of the entity | ||
*/ | ||
public BaseRelEntityInfo(final String name, final String relationType, final String uuid) { | ||
this.name = name; | ||
this.relationType = relationType; | ||
this.uuid = uuid; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
metacat-common-server/src/main/java/com/netflix/metacat/common/server/model/ChildInfo.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,23 @@ | ||
package com.netflix.metacat.common.server.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
/** | ||
* ChildInfo. | ||
*/ | ||
@EqualsAndHashCode(callSuper = true) | ||
@AllArgsConstructor | ||
@Data | ||
public class ChildInfo extends BaseRelEntityInfo { | ||
/** | ||
Constructor with all params. | ||
@param name name of the entity | ||
@param relationType type of the relation | ||
@param uuid uuid of the entity | ||
*/ | ||
public ChildInfo(final String name, final String relationType, final String uuid) { | ||
super(name, relationType, uuid); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
metacat-common-server/src/main/java/com/netflix/metacat/common/server/model/ParentInfo.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,29 @@ | ||
package com.netflix.metacat.common.server.model; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
/** | ||
* ParentInfo. | ||
*/ | ||
@EqualsAndHashCode(callSuper = true) | ||
@Data | ||
public class ParentInfo extends BaseRelEntityInfo { | ||
|
||
/** | ||
Empty Constructor. | ||
*/ | ||
public ParentInfo() { | ||
|
||
} | ||
|
||
/** | ||
Constructor with all params. | ||
@param name name of the entity | ||
@param relationType type of the relation | ||
@param uuid uuid of the entity | ||
*/ | ||
public ParentInfo(final String name, final String relationType, final String uuid) { | ||
super(name, relationType, uuid); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
.../java/com/netflix/metacat/common/server/usermetadata/ParentChildRelMetadataConstants.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,46 @@ | ||
package com.netflix.metacat.common.server.usermetadata; | ||
|
||
/** | ||
* ParentChildRelMetadataConstants. | ||
* | ||
* @author yingjianw | ||
*/ | ||
public final class ParentChildRelMetadataConstants { | ||
/** | ||
* During create, top level key specified in DefinitionMetadata that indicate the parent table name. | ||
*/ | ||
public static final String PARENTNAME = "root_table_name"; | ||
/** | ||
* During create, top level key specified in DefinitionMetadata that indicates the parent table uuid. | ||
*/ | ||
public static final String PARENTUUID = "root_table_uuid"; | ||
/** | ||
* During create, top level key specified in DefinitionMetadata that indicates the child table uuid. | ||
*/ | ||
public static final String CHILDUUID = "child_table_uuid"; | ||
|
||
/** | ||
* During create, top level key specified in DefinitionMetadata that indicates relationType. | ||
*/ | ||
public static final String RELATIONTYPE = "relationType"; | ||
|
||
/** | ||
* During get, top level key specified in DefinitionMetadata that indicates the parent child infos. | ||
*/ | ||
public static final String PARENTCHILDRELINFO = "parentChildRelationInfo"; | ||
|
||
/** | ||
* During get, the nested key specified in DefinitionMetadata[PARENTCHILDRELINFO] that indicates parent infos. | ||
*/ | ||
public static final String PARENTINFOS = "parentInfos"; | ||
|
||
/** | ||
* During get, the nested key specified in DefinitionMetadata[PARENTCHILDRELINFO] that indicates child infos. | ||
*/ | ||
public static final String CHILDINFOS = "childInfos"; | ||
|
||
private ParentChildRelMetadataConstants() { | ||
|
||
} | ||
|
||
} |
96 changes: 96 additions & 0 deletions
96
...in/java/com/netflix/metacat/common/server/usermetadata/ParentChildRelMetadataService.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,96 @@ | ||
package com.netflix.metacat.common.server.usermetadata; | ||
import com.netflix.metacat.common.QualifiedName; | ||
import com.netflix.metacat.common.server.model.ChildInfo; | ||
import com.netflix.metacat.common.server.model.ParentInfo; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* Parent-Child Relationship Metadata Service API. | ||
* | ||
* @author yingjianw | ||
*/ | ||
public interface ParentChildRelMetadataService { | ||
/** | ||
* Establishes a parent-child relationship with a specified relation type. | ||
* Currently, exceptions are thrown in the following cases: | ||
* 1. Attempting to create a child table as the parent of another child table. | ||
* 2. Attempting to create a parent table on top of a parent table | ||
* 3. A child table having more than one parent. | ||
* | ||
* @param parentName the name of the parent entity | ||
* @param parentUUID the uuid of the parent | ||
* @param childName the name of the child entity | ||
* @param childUUID the uuid of the child | ||
* @param relationType the type of the relationship | ||
*/ | ||
void createParentChildRelation( | ||
QualifiedName parentName, | ||
String parentUUID, | ||
QualifiedName childName, | ||
String childUUID, | ||
String relationType | ||
); | ||
|
||
/** | ||
* Deletes a parent-child relationship with a specified relation type. | ||
* This function is only called in the recovery process when | ||
* we first create the parent-child relationship but fail to create the table. | ||
* | ||
* @param parentName the name of the parent entity | ||
* @param parentUUID the uuid of the parent | ||
* @param childName the name of the child entity | ||
* @param childUUID the uuid of the child | ||
* @param type the type of the relationship | ||
*/ | ||
void deleteParentChildRelation( | ||
QualifiedName parentName, | ||
String parentUUID, | ||
QualifiedName childName, | ||
String childUUID, | ||
String type | ||
); | ||
|
||
/** | ||
* Renames `oldName` to `newName` in the parentChildRelationship store. | ||
* This involves two steps: | ||
* 1. Rename all records where the child is `oldName` to `newName` | ||
* 2. Rename all records where the parent is `oldName` to `newName` | ||
* | ||
* @param oldName the current name to be renamed | ||
* @param newName the new name to rename to | ||
*/ | ||
void rename( | ||
QualifiedName oldName, | ||
QualifiedName newName | ||
); | ||
|
||
/** | ||
* Removes the entity from the parentChildRelationship store. | ||
* This involves two steps: | ||
* 1. drop all records where the child column = `name` | ||
* 2. drop all records where the parent column = `name` | ||
* @param name the name of the entity to drop | ||
*/ | ||
void drop( | ||
QualifiedName name | ||
); | ||
|
||
/** | ||
* get the set of parent for the input name. | ||
* @param name name | ||
* @return parentInfo | ||
*/ | ||
Set<ParentInfo> getParents( | ||
QualifiedName name | ||
); | ||
|
||
/** | ||
* get the set of children for the input name. | ||
* @param name name | ||
* @return a set of ChildInfo | ||
*/ | ||
Set<ChildInfo> getChildren( | ||
QualifiedName name | ||
); | ||
} |
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
Oops, something went wrong.