Skip to content

Commit

Permalink
continue
Browse files Browse the repository at this point in the history
  • Loading branch information
karesti committed Sep 9, 2024
1 parent 87dee12 commit 6f9962f
Show file tree
Hide file tree
Showing 10 changed files with 287 additions and 266 deletions.
29 changes: 15 additions & 14 deletions src/app/Caches/Create/AdvancedTuning/BackupsCofigurationTuning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useTranslation } from 'react-i18next';
import { useCreateCache } from '@app/services/createCacheHook';
import { PopoverHelp } from '@app/Common/PopoverHelp';
import BackupSiteConfigurator from '@app/Caches/Create/AdvancedTuning/BackupsSiteConfigurator';
import TimeQuantityInputGroup from '@app/Caches/Create/TimeQuantityInputGroup';

const BackupsConfigurationTuning = () => {
const { configuration, setConfiguration } = useCreateCache();
Expand All @@ -25,6 +26,7 @@ const BackupsConfigurationTuning = () => {
);
const [mergePolicy, setMergePolicy] = useState(configuration.advanced.backupSetting?.mergePolicy);
const [maxCleanupDelay, setMaxCleanupDelay] = useState(configuration.advanced.backupSetting?.maxCleanupDelay);
const [maxCleanupDelayUnit, setMaxCleanupDelayUnit] = useState(configuration.advanced.backupSetting?.maxCleanupDelayUnit);
const [tombstoneMapSize, setTombstoneMapSize] = useState(configuration.advanced.backupSetting?.tombstoneMapSize);

useEffect(() => {
Expand All @@ -36,14 +38,15 @@ const BackupsConfigurationTuning = () => {
backupSetting: {
mergePolicy: mergePolicy,
maxCleanupDelay: maxCleanupDelay,
maxCleanupDelayUnit: maxCleanupDelayUnit,
tombstoneMapSize: tombstoneMapSize
},
backupSiteData: backupSiteData,
valid: true
}
};
});
}, [backupSiteData, mergePolicy, maxCleanupDelay, tombstoneMapSize]);
}, [backupSiteData, mergePolicy, maxCleanupDelay, maxCleanupDelayUnit, tombstoneMapSize]);

if (!configuration.feature.cacheFeatureSelected.includes(CacheFeature.BACKUPS)) {
return <div />;
Expand All @@ -66,9 +69,9 @@ const BackupsConfigurationTuning = () => {
<TextInput
placeholder="DEFAULT"
value={mergePolicy}
onChange={(_event, val) => {
val === '' ? setMergePolicy(undefined!) : setMergePolicy(val);
}}
onChange={(_event, val) =>
setMergePolicy(val === ''? undefined! : val)
}
aria-label="merge-policy-input"
/>
</FormGroup>
Expand All @@ -84,15 +87,12 @@ const BackupsConfigurationTuning = () => {
/>
}
>
<TextInput
placeholder="30000"
type="number"
value={maxCleanupDelay}
onChange={(_event, val) => {
isNaN(parseInt(val)) ? setMaxCleanupDelay(undefined!) : setMaxCleanupDelay(parseInt(val));
}}
aria-label="max-cleanup-delay-input"
/>
<TimeQuantityInputGroup name={'maxCleanupDelay'}
defaultValue={'30000'}
value={maxCleanupDelay}
valueModifier={setMaxCleanupDelay}
unit={maxCleanupDelayUnit}
unitModifier={setMaxCleanupDelayUnit}/>
</FormGroup>

<FormGroup
Expand All @@ -111,7 +111,8 @@ const BackupsConfigurationTuning = () => {
type="number"
value={tombstoneMapSize}
onChange={(_event, val) => {
isNaN(parseInt(val)) ? setTombstoneMapSize(undefined!) : setTombstoneMapSize(parseInt(val));
const parsedVal = parseInt(val);
setTombstoneMapSize(isNaN(parsedVal) ? undefined! : parsedVal)
}}
aria-label="tombstone-map-size-input"
/>
Expand Down
129 changes: 66 additions & 63 deletions src/app/Caches/Create/AdvancedTuning/BackupsSiteConfigurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Grid,
GridItem,
Radio,
SelectOptionProps,
Switch,
Text,
TextContent,
Expand All @@ -16,6 +15,7 @@ import { useTranslation } from 'react-i18next';
import { BackupSiteFailurePolicy, BackupSiteStateTransferMode, BackupSiteStrategy } from '@services/infinispanRefData';
import { PopoverHelp } from '@app/Common/PopoverHelp';
import { selectOptionProps } from '@utils/selectOptionPropsCreator';
import TimeQuantityInputGroup from '@app/Caches/Create/TimeQuantityInputGroup';

const BackupSiteConfigurator = (props: {
backupSiteOptions: BackupSite[];
Expand All @@ -26,43 +26,51 @@ const BackupSiteConfigurator = (props: {
const { t } = useTranslation();
const brandname = t('brandname.brandname');

const [failurePolicy, setFailurePolicy] = useState(props.backupSiteOptions[props.index]?.failurePolicy!);
const [timeout, setTimeout] = useState(props.backupSiteOptions[props.index]?.timeout!);
const [twoPhaseCommit, setTwoPhaseCommit] = useState(props.backupSiteOptions[props.index]?.twoPhaseCommit!);
const [failurePolicy, setFailurePolicy] = useState(props.backupSiteOptions[props.index]?.failurePolicy);
const [timeout, setTimeout] = useState(props.backupSiteOptions[props.index]?.timeout);
const [timeoutUnit, setTimeoutUnit] = useState(props.backupSiteOptions[props.index]?.timeoutUnit);
const [twoPhaseCommit, setTwoPhaseCommit] = useState(props.backupSiteOptions[props.index]?.twoPhaseCommit);
const [failurePolicyClass, setFailurePolicyClass] = useState(
props.backupSiteOptions[props.index]?.failurePolicyClass!
props.backupSiteOptions[props.index]?.failurePolicyClass
);

const [afterFailures, setAfterFailures] = useState(
props.backupSiteOptions![props.index]?.takeOffline?.afterFailures!
props.backupSiteOptions![props.index]?.takeOffline?.afterFailures
);
const [minWait, setMinWait] = useState(props.backupSiteOptions[props.index]?.takeOffline?.minWait!);
const [minWait, setMinWait] = useState(props.backupSiteOptions[props.index]?.takeOffline?.minWait);
const [minWaitUnit, setMinWaitUnit] = useState(props.backupSiteOptions[props.index]?.takeOffline?.minWaitUnit);

const [chunckSize, setChunckSize] = useState(props.backupSiteOptions[props.index]?.stateTransfer?.chunckSize!);
const [chunckSize, setChunckSize] = useState(props.backupSiteOptions[props.index]?.stateTransfer?.chunckSize);
const [timeoutStateTransfer, setTimeoutStateTransfer] = useState(
props.backupSiteOptions[props.index]?.stateTransfer?.timeout!
props.backupSiteOptions[props.index]?.stateTransfer?.timeout
);
const [maxRetries, setMaxRetries] = useState(props.backupSiteOptions[props.index]?.stateTransfer?.maxRetries!);
const [waitTime, setWaitTime] = useState(props.backupSiteOptions[props.index]?.stateTransfer?.waitTime!);
const [mode, setMode] = useState(props.backupSiteOptions[props.index]?.stateTransfer?.mode!);

const [isOpenFailurePolicy, setIsOpenFailurePolicy] = useState(false);
const [timeoutStateTransferUnit, setTimeoutStateTransferUnit] = useState(
props.backupSiteOptions[props.index]?.stateTransfer?.timeoutUnit
);
const [maxRetries, setMaxRetries] = useState(props.backupSiteOptions[props.index]?.stateTransfer?.maxRetries);
const [waitTime, setWaitTime] = useState(props.backupSiteOptions[props.index]?.stateTransfer?.waitTime);
const [waitTimeUnit, setWaitTimeUnit] = useState(props.backupSiteOptions[props.index]?.stateTransfer?.waitTimeUnit);
const [mode, setMode] = useState(props.backupSiteOptions[props.index]?.stateTransfer?.mode);

useEffect(() => {
const data = {
failurePolicy: failurePolicy,
timeout: timeout,
timeoutUnit: timeoutUnit,
twoPhaseCommit: twoPhaseCommit,
failurePolicyClass: failurePolicyClass,
takeOffline: {
afterFailures: afterFailures,
minWait: minWait
minWait: minWait,
minWaitUnit: minWaitUnit
},
stateTransfer: {
chunckSize: chunckSize,
timeout: timeoutStateTransfer,
timeoutUnit: timeoutStateTransferUnit,
maxRetries: maxRetries,
waitTime: waitTime,
waitTimeUnit: waitTimeUnit,
mode: mode
}
};
Expand All @@ -74,14 +82,18 @@ const BackupSiteConfigurator = (props: {
}, [
failurePolicy,
timeout,
timeoutUnit,
twoPhaseCommit,
failurePolicyClass,
afterFailures,
minWait,
minWaitUnit,
chunckSize,
timeoutStateTransfer,
timeoutStateTransferUnit,
maxRetries,
waitTime,
waitTimeUnit,
mode
]);

Expand Down Expand Up @@ -110,10 +122,11 @@ const BackupSiteConfigurator = (props: {
<TextInput
placeholder="0"
type="number"
id="timeout"
id="afterFailures"
value={afterFailures}
onChange={(e, val) => {
isNaN(parseInt(val)) ? setAfterFailures(undefined!) : setAfterFailures(parseInt(val));
const value = parseInt(val);
setAfterFailures(isNaN(value)? undefined!: value)
}}
/>
</FormGroup>
Expand All @@ -128,15 +141,12 @@ const BackupSiteConfigurator = (props: {
/>
}
>
<TextInput
placeholder="0"
type="number"
id="minwait"
value={minWait}
onChange={(e, val) => {
isNaN(parseInt(val)) ? setMinWait(undefined!) : setMinWait(parseInt(val));
}}
/>
<TimeQuantityInputGroup name={'minwait'}
defaultValue={'0'}
value={minWait}
valueModifier={setMinWait}
unit={minWaitUnit}
unitModifier={setMinWaitUnit}/>
</FormGroup>
</React.Fragment>
);
Expand Down Expand Up @@ -182,7 +192,7 @@ const BackupSiteConfigurator = (props: {
/>
</FormGroup>
</GridItem>
<GridItem span={3}>
<GridItem span={6}>
<FormGroup
fieldId="chuncksize"
label={t('caches.create.configurations.feature.chunk-size')}
Expand All @@ -200,12 +210,13 @@ const BackupSiteConfigurator = (props: {
id="chuncksize"
value={chunckSize}
onChange={(e, val) => {
isNaN(parseInt(val)) ? setChunckSize(undefined!) : setChunckSize(parseInt(val));
const value = parseInt(val);
setChunckSize(isNaN(value)? undefined!: value)
}}
/>
</FormGroup>
</GridItem>
<GridItem span={3}>
<GridItem span={6}>
<FormGroup
fieldId="timeout-state-transfer"
label={t('caches.create.configurations.feature.timeout-state-transfer')}
Expand All @@ -217,18 +228,15 @@ const BackupSiteConfigurator = (props: {
/>
}
>
<TextInput
placeholder="1200000"
type="number"
id="timeout"
value={timeoutStateTransfer}
onChange={(e, val) => {
isNaN(parseInt(val)) ? setTimeoutStateTransfer(undefined!) : setTimeoutStateTransfer(parseInt(val));
}}
/>
<TimeQuantityInputGroup name={'timeoutStateTransfer'}
defaultValue={'1200000'}
value={timeoutStateTransfer}
valueModifier={setTimeoutStateTransfer}
unit={timeoutStateTransferUnit}
unitModifier={setTimeoutStateTransferUnit}/>
</FormGroup>
</GridItem>
<GridItem span={3}>
<GridItem span={6}>
<FormGroup
fieldId="maxretries"
label={t('caches.create.configurations.feature.max-retries')}
Expand All @@ -246,12 +254,13 @@ const BackupSiteConfigurator = (props: {
id="maxretries"
value={maxRetries}
onChange={(e, val) => {
isNaN(parseInt(val)) ? setMaxRetries(undefined!) : setMaxRetries(parseInt(val));
const value = parseInt(val);
setMaxRetries(isNaN(value)? undefined!: value)
}}
/>
</FormGroup>
</GridItem>
<GridItem span={3}>
<GridItem span={6}>
<FormGroup
fieldId="wait-time"
label={t('caches.create.configurations.feature.wait-time')}
Expand All @@ -263,15 +272,12 @@ const BackupSiteConfigurator = (props: {
/>
}
>
<TextInput
placeholder="2000"
type="number"
id="waittime"
value={waitTime}
onChange={(e, val) => {
isNaN(parseInt(val)) ? setWaitTime(undefined!) : setWaitTime(parseInt(val));
}}
/>
<TimeQuantityInputGroup name={'waitTime'}
defaultValue={'2000'}
value={waitTime}
valueModifier={setWaitTime}
unit={waitTimeUnit}
unitModifier={setWaitTimeUnit}/>
</FormGroup>
</GridItem>
</React.Fragment>
Expand Down Expand Up @@ -320,7 +326,7 @@ const BackupSiteConfigurator = (props: {
<SelectSingle
id={'failurePolicy'}
placeholder={BackupSiteFailurePolicy.IGNORE}
selected={failurePolicy}
selected={failurePolicy!}
options={selectOptionProps(BackupSiteFailurePolicy)}
onSelect={(value) => setFailurePolicy(value)}
/>
Expand All @@ -336,15 +342,12 @@ const BackupSiteConfigurator = (props: {
/>
}
>
<TextInput
placeholder="15000"
type="number"
id="timeout"
value={timeout}
onChange={(e, val) => {
isNaN(parseInt(val)) ? setTimeout(undefined!) : setTimeout(parseInt(val));
}}
/>
<TimeQuantityInputGroup name={'timeout'}
defaultValue={'15000'}
value={timeout}
valueModifier={setTimeout}
unit={timeoutUnit}
unitModifier={setTimeoutUnit}/>
</FormGroup>
<FormGroup
fieldId="failurePolicyClass"
Expand All @@ -361,9 +364,9 @@ const BackupSiteConfigurator = (props: {
type="text"
id="failurePolicyClass"
value={failurePolicyClass}
onChange={(e, val) => {
val === '' ? setFailurePolicyClass(undefined!) : setFailurePolicyClass(val);
}}
onChange={(e, val) =>
setFailurePolicyClass(val === ''? undefined!: val)
}
/>
</FormGroup>
{formTakeOffline()}
Expand Down
Loading

0 comments on commit 6f9962f

Please sign in to comment.