diff --git a/app/cdap/components/PipelineTriggers/EnabledTriggersTab/EnabledCompositeTriggerRow.tsx b/app/cdap/components/PipelineTriggers/EnabledTriggersTab/EnabledCompositeTriggerRow.tsx index 30b91ec76af..7fae984e163 100644 --- a/app/cdap/components/PipelineTriggers/EnabledTriggersTab/EnabledCompositeTriggerRow.tsx +++ b/app/cdap/components/PipelineTriggers/EnabledTriggersTab/EnabledCompositeTriggerRow.tsx @@ -75,6 +75,11 @@ const EnabledCompositeTriggerRowView = ({ ? (compositeTrigger.trigger as ICompositeTrigger).triggers[0].programId.application : compositeTrigger.name; + const concurrencyConstraint = compositeTrigger.constraints.find( + (constraint) => constraint.type === 'CONCURRENCY' + ); + const maxConcurrentRuns = concurrencyConstraint ? concurrencyConstraint.maxConcurrency : '_'; + const handleConfirmModalOpen = (e) => { e.stopPropagation(); setShowDeleteModal(true); @@ -139,6 +144,10 @@ const EnabledCompositeTriggerRowView = ({ isLoading={loading} closeable={true} /> + + {T.translate(`${TRIGGER_PREFIX}.pipelineTriggerConcurrencyHeader`, { maxConcurrentRuns })} + +
{(compositeTrigger.trigger as ICompositeTrigger).triggers.map((trigger) => { return ( diff --git a/app/cdap/components/PipelineTriggers/EnabledTriggersTab/EnabledTriggerRow.tsx b/app/cdap/components/PipelineTriggers/EnabledTriggersTab/EnabledTriggerRow.tsx index 03a6bf89b31..e453b457a37 100644 --- a/app/cdap/components/PipelineTriggers/EnabledTriggersTab/EnabledTriggerRow.tsx +++ b/app/cdap/components/PipelineTriggers/EnabledTriggersTab/EnabledTriggerRow.tsx @@ -78,6 +78,10 @@ const EnabledTriggerRowView = ({ workflowName, }: IEnabledTriggerRowViewProps) => { const currentTrigger = schedule.trigger as IProgramStatusTrigger; + const concurrencyConstraint = schedule.constraints.find( + (constraint) => constraint.type === 'CONCURRENCY' + ); + const maxConcurrentRuns = concurrencyConstraint ? concurrencyConstraint.maxConcurrency : '_'; const [showDeleteModal, setShowDeleteModal] = useState(false); const [selectedNamespace, setSelectedNamesapce] = useState(null); const [payloadModalOpen, setPayloadModalOpen] = useState(false); @@ -138,6 +142,10 @@ const EnabledTriggerRowView = ({ return (
+ + {T.translate(`${TRIGGER_PREFIX}.pipelineTriggerConcurrencyHeader`, { maxConcurrentRuns })} + +
{T.translate(`${TRIGGER_PREFIX}.description`)}: {info ? {info && info.description} : renderLoading()} diff --git a/app/cdap/components/PipelineTriggers/PipelineListCompositeTab/index.tsx b/app/cdap/components/PipelineTriggers/PipelineListCompositeTab/index.tsx index 8f65f3d6f2f..5e689470d62 100644 --- a/app/cdap/components/PipelineTriggers/PipelineListCompositeTab/index.tsx +++ b/app/cdap/components/PipelineTriggers/PipelineListCompositeTab/index.tsx @@ -17,6 +17,7 @@ import React, { useEffect, useReducer } from 'react'; import styled from 'styled-components'; import { + changeMaxConcurrentRuns, changeNamespace, changeTriggersType, enableGroupTrigger, @@ -54,6 +55,7 @@ import { } from 'components/PipelineTriggers/reducer'; import PayloadConfigModal from 'components/PipelineTriggers/PayloadConfigModal'; import PipelineCompositeTriggerRow from './PipelineCompositeTriggerRow'; +import { DEFAULT_TRIGGER_MAX_CONCURRENT_RUNS } from '../store/PipelineTriggersStore'; const TRIGGER_PREFIX = 'features.PipelineTriggers'; const PREFIX = `${TRIGGER_PREFIX}.SetTriggers`; @@ -146,6 +148,7 @@ interface IPipelineListCompositeTabViewProps { configureError: string; onPayloadToggle: (isOpen: boolean) => void; setTab: (tab: number) => void; + maxConcurrentRuns?: number; } const PipelineListCompositeTabView = ({ @@ -160,6 +163,7 @@ const PipelineListCompositeTabView = ({ toggleExpandPipeline, configureError, setTab, + maxConcurrentRuns = DEFAULT_TRIGGER_MAX_CONCURRENT_RUNS, }: IPipelineListCompositeTabViewProps) => { const [state, dispatch] = useReducer(triggerNameReducer, initialAvailablePipelineListState); const emptyTriggerErrorMsg = @@ -220,6 +224,10 @@ const PipelineListCompositeTabView = ({ changeTriggersType(e.target.value); }; + const handleChangeMaxConcurrentRuns = (e) => { + changeMaxConcurrentRuns(e.target.value); + }; + const addGroupTriggerClick = () => { enableGroupTrigger(state.triggerName, setTab, state.computeProfile); }; @@ -277,6 +285,24 @@ const PipelineListCompositeTabView = ({
+
+ {T.translate(`${PREFIX}.maxConcurrentRuns`)} + + + +
{T.translate(`${PREFIX}.triggerName`)} { pipelineName: state.triggers.pipelineName, expandedPipeline: state.triggers.expandedPipeline, configureError: state.triggers.configureError, + maxConcurrentRuns: state.triggers.maxConcurrentRuns, }; }; diff --git a/app/cdap/components/PipelineTriggers/store/PipelineTriggersActionCreator.ts b/app/cdap/components/PipelineTriggers/store/PipelineTriggersActionCreator.ts index c6c5c0a74fa..f2362883560 100644 --- a/app/cdap/components/PipelineTriggers/store/PipelineTriggersActionCreator.ts +++ b/app/cdap/components/PipelineTriggers/store/PipelineTriggersActionCreator.ts @@ -72,6 +72,15 @@ export function changeTriggersType(selectedTriggersType: string) { }); } +export function changeMaxConcurrentRuns(maxConcurrentRuns: number) { + PipelineTriggersStore.dispatch({ + type: PipelineTriggersActions.setMaxConcurrentRuns, + payload: { + maxConcurrentRuns, + }, + }); +} + /** * Method to remove the selected trigger from the composite AND or OR trigger group. */ @@ -174,7 +183,7 @@ export function enableGroupTrigger( }, constraints: [ { - maxConcurrency: 3, + maxConcurrency: pipelineTriggers.maxConcurrentRuns, type: 'CONCURRENCY', waitUntilMet: false, }, diff --git a/app/cdap/components/PipelineTriggers/store/PipelineTriggersActions.ts b/app/cdap/components/PipelineTriggers/store/PipelineTriggersActions.ts index 6818fff0576..64222e88647 100644 --- a/app/cdap/components/PipelineTriggers/store/PipelineTriggersActions.ts +++ b/app/cdap/components/PipelineTriggers/store/PipelineTriggersActions.ts @@ -31,6 +31,7 @@ const PipelineTriggersActions = { setPayloadModalState: 'TRIGGERS_SET_PAYLOAD_MODAL_STATE', setTriggerType: 'TRIGGERS_SET_TYPE', reset: 'TRIGGERS_RESET', + setMaxConcurrentRuns: 'TRIGGERS_SET_MAX_CONCURRENT_RUNS', }; export default PipelineTriggersActions; diff --git a/app/cdap/components/PipelineTriggers/store/PipelineTriggersStore.ts b/app/cdap/components/PipelineTriggers/store/PipelineTriggersStore.ts index c7d3961a365..c0eb7999231 100644 --- a/app/cdap/components/PipelineTriggers/store/PipelineTriggersStore.ts +++ b/app/cdap/components/PipelineTriggers/store/PipelineTriggersStore.ts @@ -25,6 +25,8 @@ import { } from 'components/PipelineTriggers/store/ScheduleTypes'; import PipelineTriggersTypes from 'components/PipelineTriggers/store/PipelineTriggersTypes'; +export const DEFAULT_TRIGGER_MAX_CONCURRENT_RUNS = 3; + interface IPayLoad { pipelineName?: string; workflowName?: string; @@ -41,6 +43,7 @@ interface IPayLoad { isOpen?: boolean; expandedSchedule?: string; pipelineInfo?: IPipelineInfo; + maxConcurrentRuns?: number; } interface IAction { @@ -71,6 +74,7 @@ const defaultInitialState = { configureError: null, pipelineCompositeTriggersEnabled: false, lifecycleManagementEditEnabled: false, + maxConcurrentRuns: DEFAULT_TRIGGER_MAX_CONCURRENT_RUNS, }; const defaultInitialEnabledTriggersState = { @@ -159,6 +163,12 @@ const triggers = (state = defaultInitialState, action = defaultAction) => { configureError: action.payload.error, }; break; + case PipelineTriggersActions.setMaxConcurrentRuns: + stateCopy = { + ...state, + maxConcurrentRuns: action.payload.maxConcurrentRuns, + }; + break; case PipelineTriggersActions.reset: return defaultInitialState; default: diff --git a/app/cdap/text/text-en.yaml b/app/cdap/text/text-en.yaml index ca74136945e..07c0ba3a3f4 100644 --- a/app/cdap/text/text-en.yaml +++ b/app/cdap/text/text-en.yaml @@ -2808,6 +2808,7 @@ features: groupTriggers: Composite Triggers pipelineTriggerType: "Trigger Type: {type}" pipelineTriggerTypeHeader: "Type" + pipelineTriggerConcurrencyHeader: "Max concurrent runs: {maxConcurrentRuns}" ScheduleRuntimeArgs: configure_enable_btn: Configure and Enable Trigger configure_select_btn: Select @@ -2849,6 +2850,7 @@ features: SetTriggers: addNewTrigger: Enable the trigger configComputeProfie: Compute Profile + maxConcurrentRuns: Max concurrent runs compositeTriggersTitle: "Add a new trigger for \"{pipelineName}\"" buttonLabel: Enable Trigger pipelineCount: "{count} pipelines available"