-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-11491, ISPN-11492, ISPN-11493 Cluster and Cache enable/disable r…
…ebalancing
- Loading branch information
Showing
14 changed files
with
314 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
import {Divider, FlexItem, Spinner, Switch} from '@patternfly/react-core'; | ||
import {useConnectedUser} from "@app/services/userManagementHook"; | ||
import {ConsoleServices} from "@services/ConsoleServices"; | ||
import {ConsoleACL} from "@services/securityService"; | ||
import {useTranslation} from "react-i18next"; | ||
import {useApiAlert} from "@app/utils/useApiAlert"; | ||
import {useDataContainer} from "@app/services/dataContainerHooks"; | ||
|
||
const RebalancingCacheManager = () => { | ||
const { addAlert } = useApiAlert(); | ||
const { t } = useTranslation(); | ||
const { connectedUser } = useConnectedUser(); | ||
const { cm, loading, reload } = useDataContainer(); | ||
|
||
if (loading || !cm) { | ||
return ( | ||
<FlexItem> | ||
<Spinner size={'md'} /> | ||
</FlexItem> | ||
); | ||
} | ||
|
||
if (ConsoleServices.security().hasConsoleACL(ConsoleACL.ADMIN, connectedUser) && cm.rebalancing_enabled != undefined) { | ||
return ( | ||
<React.Fragment> | ||
<Divider isVertical /> | ||
<FlexItem> | ||
<Switch | ||
id="rebalancing-switch" | ||
label={t('cache-managers.rebalancing-enabled')} | ||
labelOff={t('cache-managers.rebalancing-disabled')} | ||
isChecked={cm.rebalancing_enabled} | ||
onChange={() => { | ||
ConsoleServices.dataContainer().rebalancing(cm.name, !cm.rebalancing_enabled) | ||
.then(r => { | ||
addAlert(r); | ||
reload(); | ||
}) | ||
}} | ||
/> | ||
</FlexItem> | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
// Return nothing if the connected user is not ADMIN | ||
return (<FlexItem></FlexItem>); | ||
}; | ||
|
||
export { RebalancingCacheManager }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from 'react'; | ||
import {Label, Spinner, Switch, ToolbarItem} from '@patternfly/react-core'; | ||
import {useCacheDetail} from "@app/services/cachesHook"; | ||
import {useConnectedUser} from "@app/services/userManagementHook"; | ||
import {ConsoleServices} from "@services/ConsoleServices"; | ||
import {ConsoleACL} from "@services/securityService"; | ||
import {useTranslation} from "react-i18next"; | ||
import {useApiAlert} from "@app/utils/useApiAlert"; | ||
import {useDataContainer} from "@app/services/dataContainerHooks"; | ||
|
||
const RebalancingCache = () => { | ||
const { addAlert } = useApiAlert(); | ||
const { t } = useTranslation(); | ||
const { connectedUser } = useConnectedUser(); | ||
const { cache, cacheManager, loading, reload } = useCacheDetail(); | ||
|
||
// If rebalancing is not activated at cluster level, don't display anything | ||
if (!cacheManager.rebalancing_enabled || cache.rebalancing_enabled == undefined) { | ||
return ( <ToolbarItem/>) | ||
} | ||
|
||
if (loading || !cache) { | ||
return ( | ||
<ToolbarItem> | ||
<Spinner size={'md'} /> | ||
</ToolbarItem> | ||
); | ||
} | ||
|
||
/** | ||
* When the rehash is in progress just display the value | ||
*/ | ||
if (cache?.rehash_in_progress) { | ||
return ( | ||
<ToolbarItem> | ||
<Spinner size={'md'} /> {t('caches.info.rebalancing')} | ||
</ToolbarItem> | ||
); | ||
} | ||
|
||
/** | ||
* If the user is ADMIN, can enable and disable rebalancing | ||
*/ | ||
if (ConsoleServices.security().hasConsoleACL(ConsoleACL.ADMIN, connectedUser)) { | ||
return ( | ||
<ToolbarItem> | ||
<Switch | ||
id="rebalancing-switch" | ||
label={t('caches.info.rebalancing-enabled')} | ||
labelOff={t('caches.info.rebalancing-disabled')} | ||
isChecked={cache.rebalancing_enabled} | ||
onChange={() => { | ||
ConsoleServices.caches().rebalancing(cache.name, !cache.rebalancing_enabled) | ||
.then(r => { | ||
addAlert(r); | ||
reload(); | ||
}) | ||
}} | ||
/> | ||
</ToolbarItem> | ||
); | ||
} | ||
|
||
if (cache.rebalancing_enabled) { | ||
return ( | ||
<ToolbarItem> | ||
<Label>{t('caches.info.rebalanced')}</Label> | ||
</ToolbarItem> | ||
); | ||
} | ||
|
||
return ( | ||
<ToolbarItem> | ||
<Label>{t('caches.info.rebalancing-disabled')}</Label> | ||
</ToolbarItem> | ||
); | ||
}; | ||
|
||
export { RebalancingCache }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.