Skip to content

Commit

Permalink
Rename Glue API calls stats
Browse files Browse the repository at this point in the history
  • Loading branch information
homar authored and losipiuk committed Feb 22, 2022
1 parent ae713b7 commit 707e231
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 42 deletions.
Expand Up @@ -291,7 +291,7 @@ public Optional<Database> getDatabase(String databaseName)
public List<String> getAllDatabases()
{
try {
return stats.getGetAllDatabases().call(() -> {
return stats.getGetDatabases().call(() -> {
List<String> databaseNames = getPaginatedResults(
glueClient::getDatabases,
new GetDatabasesRequest().withCatalogId(catalogId),
Expand Down Expand Up @@ -448,7 +448,7 @@ private void updatePartitionStatisticsBatch(Table table, Map<String, Function<Pa
public List<String> getAllTables(String databaseName)
{
try {
return stats.getGetAllTables().call(() -> {
return stats.getGetTables().call(() -> {
List<String> tableNames = getPaginatedResults(
glueClient::getTables,
new GetTablesRequest()
Expand Down Expand Up @@ -548,7 +548,7 @@ public void dropDatabase(String databaseName, boolean deleteData)
}

try {
stats.getDropDatabase().call(() ->
stats.getDeleteDatabase().call(() ->
glueClient.deleteDatabase(new DeleteDatabaseRequest().withCatalogId(catalogId).withName(databaseName)));
}
catch (EntityNotFoundException e) {
Expand All @@ -569,7 +569,7 @@ public void renameDatabase(String databaseName, String newDatabaseName)
try {
Database database = getDatabase(databaseName).orElseThrow(() -> new SchemaNotFoundException(databaseName));
DatabaseInput renamedDatabase = GlueInputConverter.convertDatabase(database).withName(newDatabaseName);
stats.getRenameDatabase().call(() ->
stats.getUpdateDatabase().call(() ->
glueClient.updateDatabase(new UpdateDatabaseRequest()
.withCatalogId(catalogId)
.withName(databaseName)
Expand Down Expand Up @@ -614,7 +614,7 @@ public void dropTable(String databaseName, String tableName, boolean deleteData)
Table table = getExistingTable(databaseName, tableName);

try {
stats.getDropTable().call(() ->
stats.getDeleteTable().call(() ->
glueClient.deleteTable(new DeleteTableRequest()
.withCatalogId(catalogId)
.withDatabaseName(databaseName)
Expand Down Expand Up @@ -651,7 +651,7 @@ public void replaceTable(String databaseName, String tableName, Table newTable,
{
try {
TableInput newTableInput = GlueInputConverter.convertTable(newTable);
stats.getReplaceTable().call(() ->
stats.getUpdateTable().call(() ->
glueClient.updateTable(new UpdateTableRequest()
.withCatalogId(catalogId)
.withDatabaseName(databaseName)
Expand Down Expand Up @@ -690,7 +690,7 @@ public void setTableOwner(String databaseName, String tableName, HivePrincipal p
TableInput newTableInput = GlueInputConverter.convertTable(table);
newTableInput.setOwner(principal.getName());

stats.getReplaceTable().call(() ->
stats.getUpdateTable().call(() ->
glueClient.updateTable(new UpdateTableRequest()
.withCatalogId(catalogId)
.withDatabaseName(databaseName)
Expand Down Expand Up @@ -960,7 +960,7 @@ private List<Partition> batchGetPartition(Table table, List<String> partitionNam
public void addPartitions(String databaseName, String tableName, List<PartitionWithStatistics> partitions)
{
try {
stats.getAddPartitions().call(() -> {
stats.getCreatePartitions().call(() -> {
List<Future<BatchCreatePartitionResult>> futures = new ArrayList<>();

for (List<PartitionWithStatistics> partitionBatch : Lists.partition(partitions, BATCH_CREATE_PARTITION_MAX_PAGE_SIZE)) {
Expand Down Expand Up @@ -1023,7 +1023,7 @@ public void dropPartition(String databaseName, String tableName, List<String> pa
.orElseThrow(() -> new PartitionNotFoundException(new SchemaTableName(databaseName, tableName), parts));

try {
stats.getDropPartition().call(() ->
stats.getDeletePartition().call(() ->
glueClient.deletePartition(new DeletePartitionRequest()
.withCatalogId(catalogId)
.withDatabaseName(databaseName)
Expand All @@ -1045,7 +1045,7 @@ public void alterPartition(String databaseName, String tableName, PartitionWithS
{
try {
PartitionInput newPartition = convertPartition(partition);
stats.getAlterPartition().call(() ->
stats.getUpdatePartition().call(() ->
glueClient.updatePartition(new UpdatePartitionRequest()
.withCatalogId(catalogId)
.withDatabaseName(databaseName)
Expand Down
Expand Up @@ -27,24 +27,24 @@

public class GlueMetastoreStats
{
private final GlueMetastoreApiStats getAllDatabases = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats getDatabases = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats getDatabase = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats getAllTables = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats getTables = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats getTable = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats getAllViews = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats createDatabase = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats dropDatabase = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats renameDatabase = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats deleteDatabase = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats updateDatabase = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats createTable = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats dropTable = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats replaceTable = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats deleteTable = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats updateTable = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats getPartitionNames = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats getPartitions = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats getPartition = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats getPartitionByName = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats addPartitions = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats dropPartition = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats alterPartition = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats createPartitions = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats deletePartition = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats updatePartition = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats getColumnStatisticsForTable = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats getColumnStatisticsForPartition = new GlueMetastoreApiStats();
private final GlueMetastoreApiStats updateColumnStatisticsForTable = new GlueMetastoreApiStats();
Expand All @@ -65,9 +65,9 @@ public class GlueMetastoreStats

@Managed
@Nested
public GlueMetastoreApiStats getGetAllDatabases()
public GlueMetastoreApiStats getGetDatabases()
{
return getAllDatabases;
return getDatabases;
}

@Managed
Expand All @@ -79,9 +79,9 @@ public GlueMetastoreApiStats getGetDatabase()

@Managed
@Nested
public GlueMetastoreApiStats getGetAllTables()
public GlueMetastoreApiStats getGetTables()
{
return getAllTables;
return getTables;
}

@Managed
Expand All @@ -107,16 +107,16 @@ public GlueMetastoreApiStats getCreateDatabase()

@Managed
@Nested
public GlueMetastoreApiStats getDropDatabase()
public GlueMetastoreApiStats getDeleteDatabase()
{
return dropDatabase;
return deleteDatabase;
}

@Managed
@Nested
public GlueMetastoreApiStats getRenameDatabase()
public GlueMetastoreApiStats getUpdateDatabase()
{
return renameDatabase;
return updateDatabase;
}

@Managed
Expand All @@ -128,16 +128,16 @@ public GlueMetastoreApiStats getCreateTable()

@Managed
@Nested
public GlueMetastoreApiStats getDropTable()
public GlueMetastoreApiStats getDeleteTable()
{
return dropTable;
return deleteTable;
}

@Managed
@Nested
public GlueMetastoreApiStats getReplaceTable()
public GlueMetastoreApiStats getUpdateTable()
{
return replaceTable;
return updateTable;
}

@Managed
Expand Down Expand Up @@ -170,23 +170,23 @@ public GlueMetastoreApiStats getGetPartitionByName()

@Managed
@Nested
public GlueMetastoreApiStats getAddPartitions()
public GlueMetastoreApiStats getCreatePartitions()
{
return addPartitions;
return createPartitions;
}

@Managed
@Nested
public GlueMetastoreApiStats getDropPartition()
public GlueMetastoreApiStats getDeletePartition()
{
return dropPartition;
return deletePartition;
}

@Managed
@Nested
public GlueMetastoreApiStats getAlterPartition()
public GlueMetastoreApiStats getUpdatePartition()
{
return alterPartition;
return updatePartition;
}

@Managed
Expand Down
Expand Up @@ -303,12 +303,12 @@ public void testGetDatabasesLogsStats()
{
GlueHiveMetastore metastore = (GlueHiveMetastore) getMetastoreClient();
GlueMetastoreStats stats = metastore.getStats();
double initialCallCount = stats.getGetAllDatabases().getTime().getAllTime().getCount();
long initialFailureCount = stats.getGetAllDatabases().getTotalFailures().getTotalCount();
double initialCallCount = stats.getGetDatabases().getTime().getAllTime().getCount();
long initialFailureCount = stats.getGetDatabases().getTotalFailures().getTotalCount();
getMetastoreClient().getAllDatabases();
assertEquals(stats.getGetAllDatabases().getTime().getAllTime().getCount(), initialCallCount + 1.0);
assertTrue(stats.getGetAllDatabases().getTime().getAllTime().getAvg() > 0.0);
assertEquals(stats.getGetAllDatabases().getTotalFailures().getTotalCount(), initialFailureCount);
assertEquals(stats.getGetDatabases().getTime().getAllTime().getCount(), initialCallCount + 1.0);
assertTrue(stats.getGetDatabases().getTime().getAllTime().getAvg() > 0.0);
assertEquals(stats.getGetDatabases().getTotalFailures().getTotalCount(), initialFailureCount);
}

@Test
Expand Down

0 comments on commit 707e231

Please sign in to comment.