Skip to content

Commit

Permalink
KUDU-3090 Support backing up ownership info
Browse files Browse the repository at this point in the history
Change-Id: I963db0a36cd4b7f080944ed46fc4119b1e055143
Reviewed-on: http://gerrit.cloudera.org:8080/16126
Tested-by: Kudu Jenkins
Reviewed-by: Grant Henke <[email protected]>
  • Loading branch information
attilabukor committed Jul 10, 2020
1 parent 5981301 commit fad779c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions java/kudu-backup-common/src/main/protobuf/backup.proto
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,6 @@ message TableMetadataPB {
// This is validation only and not used when creating the restored table.
// This is useful for detecting dropped and added partitions.
map<string, PartitionMetadataPB> tablets = 11;
// The owner of the table.
string table_owner = 12;
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ object TableMetadata {
(id, metadata)
}

TableMetadataPB
val builder = TableMetadataPB
.newBuilder()
.setVersion(MetadataVersion)
.setFromMs(fromMs)
Expand All @@ -104,7 +104,8 @@ object TableMetadata {
.setNumReplicas(table.getNumReplicas)
.setPartitions(getPartitionSchemaMetadata(table))
.putAllTablets(tablets.asJava)
.build()
.setTableOwner(table.getOwner)
builder.build()
}

private def getTypeAttributesMetadata(col: ColumnSchema): ColumnTypeAttributesMetadataPB = {
Expand Down Expand Up @@ -329,6 +330,7 @@ object TableMetadata {
def getCreateTableOptionsWithoutRangePartitions(metadata: TableMetadataPB): CreateTableOptions = {
val schema = getKuduSchema(metadata)
val options = new CreateTableOptions()
options.setOwner(metadata.getTableOwner)
options.setNumReplicas(metadata.getNumReplicas)
metadata.getPartitions.getHashPartitionsList.asScala.foreach { hp =>
options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,8 @@ class TestKuduBackup extends KuduTestSuite {
def validateTablesMatch(tableA: String, tableB: String): Unit = {
val tA = kuduClient.openTable(tableA)
val tB = kuduClient.openTable(tableB)
assertEquals(tA.getOwner, tB.getOwner)
assertNotEquals("", tA.getOwner);
assertEquals(tA.getNumReplicas, tB.getNumReplicas)
assertTrue(schemasMatch(tA.getSchema, tB.getSchema))
assertTrue(partitionSchemasMatch(tA.getPartitionSchema, tB.getPartitionSchema))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ public CreateTableOptions randomCreateTableOptions(Schema schema) {
}
}
}

options.setOwner("random-" + random.nextInt(1000000));
return options;
}

Expand Down

0 comments on commit fad779c

Please sign in to comment.