Skip to content

Commit

Permalink
[Feature] support for flink cluster configuration (#2905)
Browse files Browse the repository at this point in the history
  • Loading branch information
xujiangfeng001 authored Jul 29, 2023
1 parent ac1bc0b commit 99fcf29
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public class FlinkCluster implements Serializable {

private Date endTime;

@TableField(updateStrategy = FieldStrategy.IGNORED)
private Integer alertId;

private transient Integer jobs = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public void update(FlinkCluster paramOfCluster) {
success, String.format(ERROR_CLUSTER_QUEUE_HINT, paramOfCluster.getYarnQueue()));

flinkCluster.setClusterName(paramOfCluster.getClusterName());
flinkCluster.setAlertId(paramOfCluster.getAlertId());
flinkCluster.setDescription(paramOfCluster.getDescription());
if (ExecutionMode.isRemoteMode(flinkCluster.getExecutionModeEnum())) {
flinkCluster.setAddress(paramOfCluster.getAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
limitations under the License.
-->
<script lang="ts">
import { defineComponent } from 'vue';
import { defineComponent, unref, ref } from 'vue';
import { useGo } from '/@/hooks/web/usePage';
export default defineComponent({
name: 'EditCluster',
Expand All @@ -36,13 +36,16 @@
import { useRoute } from 'vue-router';
import { useEdit } from '../../flink/app/hooks/useEdit';
import { useI18n } from '/@/hooks/web/useI18n';
import { fetchAlertSetting } from '/@/api/flink/setting/alert';
import { AlertSetting } from '/@/api/flink/setting/types/alert.type';
const go = useGo();
const route = useRoute();
const { t } = useI18n();
const { Swal } = useMessage();
const { handleResetApplication, defaultOptions } = useEdit();
const cluster = reactive<Recordable>({});
const alerts = ref<AlertSetting[]>([]);
const { getLoading, changeLoading, getClusterSchema, handleSubmitParams } = useClusterSetting();
const [registerForm, { submit, setFieldsValue }] = useForm({
Expand Down Expand Up @@ -97,6 +100,10 @@
function handleReset() {
const resetParams = handleResetApplication();
nextTick(() => {
let selectAlertId: string | undefined;
if (cluster.alertId) {
selectAlertId = unref(alerts)?.filter((t) => t.id == cluster.alertId)[0]?.id;
}
setFieldsValue({
clusterName: cluster.clusterName,
clusterId: cluster.clusterId,
Expand All @@ -106,6 +113,7 @@
dynamicProperties: cluster.dynamicProperties,
resolveOrder: cluster.resolveOrder,
yarnQueue: cluster.yarnQueue,
alertId: selectAlertId,
versionId: cluster.versionId || null,
k8sRestExposedType: cluster.k8sRestExposedType,
flinkImage: cluster.flinkImage,
Expand All @@ -117,6 +125,9 @@
});
}
onMounted(() => {
fetchAlertSetting().then((res) => {
alerts.value = res;
});
getClusterInfo();
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ import {
import { handleFormValue } from '../../flink/app/utils';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { AlertSetting } from '/@/api/flink/setting/types/alert.type';
import { fetchAlertSetting } from '/@/api/flink/setting/alert';

export const useClusterSetting = () => {
const { createMessage } = useMessage();
const { t } = useI18n();

const submitLoading = ref(false);
const flinkEnvs = ref<any[]>([]);
const alerts = ref<AlertSetting[]>([]);
const historyRecord = reactive<{
k8sNamespace: string[];
k8sSessionClusterId: string[];
Expand Down Expand Up @@ -156,6 +159,19 @@ export const useClusterSetting = () => {
ifShow: ({ values }) => values.executionMode == ExecModeEnum.YARN_SESSION,
render: (renderCallbackParams) => renderYarnQueue(renderCallbackParams),
},
{
field: 'alertId',
label: t('flink.app.faultAlertTemplate'),
component: 'Select',
componentProps: {
placeholder: t('flink.app.addAppTips.alertTemplatePlaceholder'),
options: unref(alerts),
fieldNames: { label: 'alertName', value: 'id', options: 'options' },
},
ifShow: ({ values }) =>
values.executionMode == ExecModeEnum.YARN_SESSION ||
values.executionMode == ExecModeEnum.REMOTE,
},
{
field: 'clusterId',
label: t('setting.flinkCluster.form.k8sClusterId'),
Expand Down Expand Up @@ -332,6 +348,7 @@ export const useClusterSetting = () => {
executionMode: values.executionMode,
versionId: values.versionId,
description: values.description,
alertId: values.alertId,
};

switch (values.executionMode) {
Expand Down Expand Up @@ -370,6 +387,9 @@ export const useClusterSetting = () => {
fetchFlinkEnv().then((res) => {
flinkEnvs.value = res;
});
fetchAlertSetting().then((res) => {
alerts.value = res;
});
fetchK8sNamespaces().then((res) => {
historyRecord.k8sNamespace = res;
});
Expand Down

0 comments on commit 99fcf29

Please sign in to comment.