Skip to content

Commit

Permalink
Merge branch 'master' into amoro-2875
Browse files Browse the repository at this point in the history
  • Loading branch information
huyuanfeng2018 authored Jul 4, 2024
2 parents 061e1f1 + 69445d7 commit 5e71bf5
Show file tree
Hide file tree
Showing 20 changed files with 160 additions and 236 deletions.
2 changes: 1 addition & 1 deletion amoro-ams/amoro-ams-dashboard/src/language/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,5 @@ export default {
fileSearchPlaceholder: 'Filter partitions',
noResourceGroupsTitle: 'No resource groups available.',
noResourceGroupsContent: 'Please create an optimizer group first.',
goToButtonText: 'Go'
goToButtonText: 'Go',
}
7 changes: 3 additions & 4 deletions amoro-ams/amoro-ams-dashboard/src/language/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default {
remove: '移除',
edit: '编辑',
deleteCatalogModalTitle: '移除此目录?',
cannotDeleteModalTitle: "不能移除这个目录",
cannotDeleteModalTitle: '不能移除这个目录',
cannotDeleteModalContent: '这个目录已被使用',
success: '成功',
optimzeGroup: '优化组',
Expand All @@ -183,7 +183,7 @@ export default {
invalidInput: '非法输入',
addgroup: '添加组',
editgroup: '编辑组',
cannotDeleteGroupModalTitle: "不能移除这个组",
cannotDeleteGroupModalTitle: '不能移除这个组',
cannotDeleteGroupModalContent: '这个组已被使用',
deleteGroupModalTitle: '移除这个组',
processId: '进程 ID',
Expand All @@ -204,6 +204,5 @@ export default {
fileSearchPlaceholder: '过滤分区',
noResourceGroupsTitle: '没有任何优化组',
noResourceGroupsContent: '需要首先创建一个默认优化组',
goToButtonText: '前往'
goToButtonText: '前往',
}

22 changes: 15 additions & 7 deletions amoro-ams/amoro-ams-dashboard/src/views/catalogs/Detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,14 @@ async function getOptimizerGroupList() {
onOk: async () => {
try {
router.push({ path: '/optimizing', query: { tab: 'optimizergroup' } })
} catch (error) {
}
catch (error) {
console.error('Navigation error:', error)
}
},
})
} else {
}
else {
optimizerGroupList.value = list
}
}
Expand Down Expand Up @@ -524,7 +526,7 @@ function handleSave() {
.catch(() => {
})
}
function handleCancle() {
function handleCancel() {
formRef.value.resetFields()
emit('updateEdit', false)
getConfigInfo()
Expand All @@ -533,9 +535,15 @@ async function deleteCatalogModal() {
Modal.confirm({
title: t('deleteCatalogModalTitle'),
onOk: async () => {
await delCatalog(formState.catalog.name || '')
message.success(`${t('remove')} ${t('success')}`)
emit('updateEdit', false)
try {
await delCatalog(formState.catalog.name || '')
message.success(`${t('remove')} ${t('success')}`, 1, () => {
router.replace({ path: '/catalogs', query: {} }).then(() => router.go(0))
})
}
catch (error) {
message.error(`${t('remove')} ${t('failed')}`)
}
},
})
}
Expand Down Expand Up @@ -770,7 +778,7 @@ onMounted(() => {
<a-button type="primary" class="save-btn g-mr-12" @click="handleSave">
{{ $t('save') }}
</a-button>
<a-button @click="handleCancle">
<a-button @click="handleCancel">
{{ $t('cancel') }}
</a-button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { ref } from 'vue'

const props = defineProps<{ msg: string }>()
const emit = defineEmits<{
(e: 'cancle'): void
(e: 'cancel'): void
}>()
const open = ref(true)
</script>
Expand All @@ -34,7 +34,7 @@ const open = ref(true)
:title="`${$t('errorMessage')}`"
:footer="null"
class="upgrade-error"
@cancel="emit('cancle')"
@cancel="emit('cancel')"
>
<p class="msg">
{{ props.msg }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default defineComponent({
<u-loading v-if="loading" />
<!-- upgrade table secondary page -->
<router-view v-if="isSecondaryNav" @go-back="goBack" @refresh="refresh" />
<ErrorMsg v-if="showErrorMsg" :msg="errorMessage" @cancle="showErrorMsg = false" />
<ErrorMsg v-if="showErrorMsg" :msg="errorMessage" @cancel="showErrorMsg = false" />
</div>
</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ function viewDetail(record: OperationItem) {
activeCopyText.value = record.operation
}

function cancle() {
function cancel() {
visible.value = false
}

async function onCopy() {
try {
await toClipboard(activeCopyText.value)
message.success(t('copySuccess'))
cancle()
cancel()
}
catch (error) {}
}
Expand Down Expand Up @@ -128,7 +128,7 @@ onMounted(() => {
:width="560"
:title="`${$t('operationDetails')}`"
class="operation-wrap"
@cancel="cancle"
@cancel="cancel"
>
{{ activeCopyText }}
<template #footer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.apache.amoro.api.TableCommitMeta;
import org.apache.amoro.api.TableIdentifier;
import org.apache.amoro.api.TableMeta;
import org.apache.amoro.server.catalog.InternalCatalog;
import org.apache.amoro.server.catalog.ServerCatalog;
import org.apache.amoro.server.table.TableMetadata;
import org.apache.amoro.server.table.TableService;
import org.apache.amoro.server.utils.InternalTableUtil;
Expand Down Expand Up @@ -61,17 +63,20 @@ public CatalogMeta getCatalog(String name) {

@Override
public List<String> getDatabases(String catalogName) {
return tableService.listDatabases(catalogName);
ServerCatalog serverCatalog = tableService.getServerCatalog(catalogName);
return serverCatalog.listDatabases();
}

@Override
public void createDatabase(String catalogName, String database) {
tableService.createDatabase(catalogName, database);
InternalCatalog serverCatalog = tableService.getInternalCatalog(catalogName);
serverCatalog.createDatabase(database);
}

@Override
public void dropDatabase(String catalogName, String database) {
tableService.dropDatabase(catalogName, database);
InternalCatalog serverCatalog = tableService.getInternalCatalog(catalogName);
serverCatalog.dropDatabase(database);
}

@Override
Expand All @@ -82,22 +87,27 @@ public void createTableMeta(TableMeta tableMeta) {
ServerTableIdentifier identifier =
ServerTableIdentifier.of(
tableMeta.getTableIdentifier(), TableFormat.valueOf(tableMeta.getFormat()));
CatalogMeta catalogMeta = getCatalog(identifier.getCatalog());
InternalCatalog catalog = tableService.getInternalCatalog(identifier.getCatalog());
CatalogMeta catalogMeta = catalog.getMetadata();
TableMetadata tableMetadata = new TableMetadata(identifier, tableMeta, catalogMeta);
tableService.createTable(tableMeta.tableIdentifier.getCatalog(), tableMetadata);
tableService.createTable(catalog.name(), tableMetadata);
}

@Override
public List<TableMeta> listTables(String catalogName, String database) {
List<TableMetadata> tableMetadataList = tableService.listTableMetas(catalogName, database);
InternalCatalog serverCatalog = tableService.getInternalCatalog(catalogName);
List<TableMetadata> tableMetadataList = serverCatalog.listTableMetadataInDatabase(database);
return tableMetadataList.stream()
.map(TableMetadata::buildTableMeta)
.collect(Collectors.toList());
}

@Override
public TableMeta getTable(TableIdentifier tableIdentifier) {
TableMetadata tableMetadata = tableService.loadTableMetadata(tableIdentifier);
InternalCatalog serverCatalog = tableService.getInternalCatalog(tableIdentifier.getCatalog());
TableMetadata tableMetadata =
serverCatalog.loadTableMetadata(
tableIdentifier.getDatabase(), tableIdentifier.getTableName());
if (tableMetadata.getFormat() == TableFormat.MIXED_ICEBERG
&& !InternalTableUtil.isLegacyMixedIceberg(tableMetadata)) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public interface CatalogService {
*/
ServerCatalog getServerCatalog(String catalogName);

/**
* Retrieves the InternalCatalog with the given catalog name.
*
* @param catalogName the name of the ServerCatalog to retrieve
* @return the InternalCatalog object matching the catalogName, or null if no catalog exists
*/
InternalCatalog getInternalCatalog(String catalogName);

/**
* Creates a catalog based on the provided catalog meta information. The catalog name is obtained
* from the catalog meta.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ public TableMetadata loadTableMetadata(String database, String table) {
org.apache.amoro.table.TableIdentifier.of(name(), database, table).toString()));
}

public List<TableMetadata> listTableMetadataInDatabase(String database) {
return getAs(TableMetaMapper.class, mapper -> mapper.selectTableMetasByDb(name(), database));
}

private String getDatabaseDesc(String database) {
return name() + '.' + database;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.apache.amoro.api.CatalogMeta;
import org.apache.amoro.properties.CatalogMetaProperties;
import org.apache.amoro.server.AmoroManagementConf;
import org.apache.amoro.server.catalog.CatalogService;
import org.apache.amoro.server.catalog.InternalCatalog;
import org.apache.amoro.server.catalog.ServerCatalog;
import org.apache.amoro.server.dashboard.PlatformFileManager;
Expand Down Expand Up @@ -147,7 +148,7 @@ public class CatalogController {
}

private final PlatformFileManager platformFileInfoService;
private final TableService tableService;
private final CatalogService tableService;

public CatalogController(TableService tableService, PlatformFileManager platformFileInfoService) {
this.tableService = tableService;
Expand Down Expand Up @@ -588,7 +589,7 @@ public void catalogDeleteCheck(Context ctx) {
StringUtils.isNotEmpty(ctx.pathParam("catalogName")), "Catalog name is empty!");
ServerCatalog serverCatalog = tableService.getServerCatalog(catalogName);
if (serverCatalog instanceof InternalCatalog) {
ctx.json(OkResponse.of(tableService.listManagedTables(catalogName).size() == 0));
ctx.json(OkResponse.of(serverCatalog.listTables().size() == 0));
} else {
ctx.json(OkResponse.of(true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public void getTableList(Context ctx) {
};

List<TableMeta> tables =
tableService.listTables(catalog, db).stream()
serverCatalog.listTables(db).stream()
.map(
idWithFormat ->
new TableMeta(
Expand Down Expand Up @@ -542,7 +542,7 @@ public void getDatabaseList(Context ctx) {
String keywords = ctx.queryParam("keywords");

List<String> dbList =
tableService.listDatabases(catalog).stream()
tableService.getServerCatalog(catalog).listDatabases().stream()
.filter(item -> StringUtils.isBlank(keywords) || item.contains(keywords))
.collect(Collectors.toList());
ctx.json(OkResponse.of(dbList));
Expand Down
Loading

0 comments on commit 5e71bf5

Please sign in to comment.