mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-04 13:29:13 -04:00
implementation of raid calculator with levels 0, 1, 5, 6, and 10
need to add descriptions yet
This commit is contained in:
parent
76a19d218d
commit
37cfd0a105
7 changed files with 247 additions and 7 deletions
17
components.d.ts
vendored
17
components.d.ts
vendored
|
@ -89,7 +89,9 @@ declare module '@vue/runtime-core' {
|
||||||
HttpStatusCodes: typeof import('./src/tools/http-status-codes/http-status-codes.vue')['default']
|
HttpStatusCodes: typeof import('./src/tools/http-status-codes/http-status-codes.vue')['default']
|
||||||
IbanValidatorAndParser: typeof import('./src/tools/iban-validator-and-parser/iban-validator-and-parser.vue')['default']
|
IbanValidatorAndParser: typeof import('./src/tools/iban-validator-and-parser/iban-validator-and-parser.vue')['default']
|
||||||
'IconMdi:brushVariant': typeof import('~icons/mdi/brush-variant')['default']
|
'IconMdi:brushVariant': typeof import('~icons/mdi/brush-variant')['default']
|
||||||
|
'IconMdi:contentCopy': typeof import('~icons/mdi/content-copy')['default']
|
||||||
'IconMdi:kettleSteamOutline': typeof import('~icons/mdi/kettle-steam-outline')['default']
|
'IconMdi:kettleSteamOutline': typeof import('~icons/mdi/kettle-steam-outline')['default']
|
||||||
|
IconMdiArrowRightBottom: typeof import('~icons/mdi/arrow-right-bottom')['default']
|
||||||
IconMdiChevronDown: typeof import('~icons/mdi/chevron-down')['default']
|
IconMdiChevronDown: typeof import('~icons/mdi/chevron-down')['default']
|
||||||
IconMdiChevronRight: typeof import('~icons/mdi/chevron-right')['default']
|
IconMdiChevronRight: typeof import('~icons/mdi/chevron-right')['default']
|
||||||
IconMdiClose: typeof import('~icons/mdi/close')['default']
|
IconMdiClose: typeof import('~icons/mdi/close')['default']
|
||||||
|
@ -126,25 +128,27 @@ declare module '@vue/runtime-core' {
|
||||||
MenuLayout: typeof import('./src/components/MenuLayout.vue')['default']
|
MenuLayout: typeof import('./src/components/MenuLayout.vue')['default']
|
||||||
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
|
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
|
||||||
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
||||||
|
NAlert: typeof import('naive-ui')['NAlert']
|
||||||
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
||||||
NCode: typeof import('naive-ui')['NCode']
|
|
||||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||||
|
NDatePicker: typeof import('naive-ui')['NDatePicker']
|
||||||
NDivider: typeof import('naive-ui')['NDivider']
|
NDivider: typeof import('naive-ui')['NDivider']
|
||||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||||
|
NForm: typeof import('naive-ui')['NForm']
|
||||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||||
NGi: typeof import('naive-ui')['NGi']
|
|
||||||
NGrid: typeof import('naive-ui')['NGrid']
|
|
||||||
NH1: typeof import('naive-ui')['NH1']
|
NH1: typeof import('naive-ui')['NH1']
|
||||||
NH3: typeof import('naive-ui')['NH3']
|
NH3: typeof import('naive-ui')['NH3']
|
||||||
NIcon: typeof import('naive-ui')['NIcon']
|
NIcon: typeof import('naive-ui')['NIcon']
|
||||||
|
NInputGroup: typeof import('naive-ui')['NInputGroup']
|
||||||
|
NInputGroupLabel: typeof import('naive-ui')['NInputGroupLabel']
|
||||||
NInputNumber: typeof import('naive-ui')['NInputNumber']
|
NInputNumber: typeof import('naive-ui')['NInputNumber']
|
||||||
NLabel: typeof import('naive-ui')['NLabel']
|
|
||||||
NLayout: typeof import('naive-ui')['NLayout']
|
NLayout: typeof import('naive-ui')['NLayout']
|
||||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||||
NMenu: typeof import('naive-ui')['NMenu']
|
NMenu: typeof import('naive-ui')['NMenu']
|
||||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
NStatistic: typeof import('naive-ui')['NStatistic']
|
||||||
NSpin: typeof import('naive-ui')['NSpin']
|
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||||
|
NTable: typeof import('naive-ui')['NTable']
|
||||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
||||||
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
|
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
|
||||||
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
|
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
|
||||||
|
@ -153,6 +157,7 @@ declare module '@vue/runtime-core' {
|
||||||
PercentageCalculator: typeof import('./src/tools/percentage-calculator/percentage-calculator.vue')['default']
|
PercentageCalculator: typeof import('./src/tools/percentage-calculator/percentage-calculator.vue')['default']
|
||||||
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
|
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
|
||||||
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
|
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
|
||||||
|
RaidCalculator: typeof import('./src/tools/raid-calculator/raid-calculator.vue')['default']
|
||||||
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
|
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
|
||||||
ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default']
|
ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default']
|
||||||
RomanNumeralConverter: typeof import('./src/tools/roman-numeral-converter/roman-numeral-converter.vue')['default']
|
RomanNumeralConverter: typeof import('./src/tools/roman-numeral-converter/roman-numeral-converter.vue')['default']
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { tool as base64FileConverter } from './base64-file-converter';
|
import { tool as base64FileConverter } from './base64-file-converter';
|
||||||
import { tool as base64StringConverter } from './base64-string-converter';
|
import { tool as base64StringConverter } from './base64-string-converter';
|
||||||
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||||
|
import { tool as raidCalculator } from './raid-calculator';
|
||||||
|
|
||||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||||
|
|
||||||
|
@ -156,7 +157,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Math',
|
name: 'Math',
|
||||||
components: [mathEvaluator, etaCalculator, percentageCalculator],
|
components: [mathEvaluator, etaCalculator, percentageCalculator, raidCalculator],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Measurement',
|
name: 'Measurement',
|
||||||
|
|
12
src/tools/raid-calculator/index.ts
Normal file
12
src/tools/raid-calculator/index.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { Database } from '@vicons/tabler';
|
||||||
|
import { defineTool } from '../tool';
|
||||||
|
|
||||||
|
export const tool = defineTool({
|
||||||
|
name: 'RAID Calculator',
|
||||||
|
path: '/raid-calculator',
|
||||||
|
description: 'Calculate storage capacity and fault tolerance of an array based on the number of disks, size, and RAID type',
|
||||||
|
keywords: ['raid', 'calculator'],
|
||||||
|
component: () => import('./raid-calculator.vue'),
|
||||||
|
icon: Database,
|
||||||
|
createdAt: new Date('2024-07-27'),
|
||||||
|
});
|
15
src/tools/raid-calculator/raid-calculator.e2e.spec.ts
Normal file
15
src/tools/raid-calculator/raid-calculator.e2e.spec.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test.describe('Tool - RAID Calculator', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('/raid-calculator');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Has correct title', async ({ page }) => {
|
||||||
|
await expect(page).toHaveTitle('RAID Calculator - IT Tools');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('', async ({ page }) => {
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,6 @@
|
||||||
|
import { expect, describe, it } from 'vitest';
|
||||||
|
// import { } from './raid-calculator.service';
|
||||||
|
//
|
||||||
|
// describe('raid-calculator', () => {
|
||||||
|
//
|
||||||
|
// })
|
94
src/tools/raid-calculator/raid-calculator.service.ts
Normal file
94
src/tools/raid-calculator/raid-calculator.service.ts
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
export { raidCalculations };
|
||||||
|
|
||||||
|
const raidCalculations = {
|
||||||
|
raid_0: {
|
||||||
|
about: 'RAID 0 splits data evenly across 2 or more disks with redunancy or fault tolerance. More info: <a href="https://en.wikipedia.org/wiki/Standard_RAID_levels#RAID_0">Wikipedia</a>',
|
||||||
|
requirements: 'RAID 0 requires at least 1 disk',
|
||||||
|
validate: function(num, size){
|
||||||
|
return num > 1
|
||||||
|
},
|
||||||
|
capacity: function(num, size, unit){
|
||||||
|
// total disks * size
|
||||||
|
return (num * size) * unit;
|
||||||
|
},
|
||||||
|
speed: function(num, size, unit){
|
||||||
|
return `${num}x read and ${num}x write speed gain`;
|
||||||
|
},
|
||||||
|
fault: function(num, size, unit){
|
||||||
|
return "None";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
raid_1: {
|
||||||
|
about: 'RAID 1 consists of an exact copy of the data across two or moe disks. The array will operate as long as at least one drive is operational. More info: <a href="https://en.wikipedia.org/wiki/Standard_RAID_levels#RAID_1">Wikipedia</a>',
|
||||||
|
requirements: 'RAID 1 requires at least 1 disk',
|
||||||
|
validate: function(num, size){
|
||||||
|
return num > 1
|
||||||
|
},
|
||||||
|
capacity: function(num, size, unit){
|
||||||
|
// total size is size of a single drive
|
||||||
|
return size * unit;
|
||||||
|
},
|
||||||
|
speed: function(num, size, unit){
|
||||||
|
// potential for all drives read at once
|
||||||
|
return `Potential ${num}x read and no write speed gain`;
|
||||||
|
},
|
||||||
|
fault: function(num, size, unit){
|
||||||
|
// FT = total - 1
|
||||||
|
return `${num -1} drive failures`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
raid_5: {
|
||||||
|
about: 'This is RAID 5',
|
||||||
|
requirements: 'RAID 5 requires at least 3 disks',
|
||||||
|
validate: function(num, size){
|
||||||
|
return num >= 3
|
||||||
|
},
|
||||||
|
capacity: function(num, size, unit){
|
||||||
|
// (N-1) * S (one drive for parity)
|
||||||
|
return ((num - 1) * size) * unit;
|
||||||
|
},
|
||||||
|
speed: function(num, size, unit){
|
||||||
|
return `${num - 1}x read speed gain and write speed penalty (due to parity calculations)`;
|
||||||
|
},
|
||||||
|
fault: function(num, size, unit){
|
||||||
|
// always 1 failure
|
||||||
|
return "1 drive failure";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
raid_6: {
|
||||||
|
about: 'This is RAID 6',
|
||||||
|
requirements: 'RAID 6 requires at least 4 disks',
|
||||||
|
validate: function(num, size){
|
||||||
|
return num >= 4
|
||||||
|
},
|
||||||
|
capacity: function(num, size, unit){
|
||||||
|
// (N-2) * S (2 parity)
|
||||||
|
return ((num - 2) * size) * unit;
|
||||||
|
},
|
||||||
|
speed: function(num, size, unit){
|
||||||
|
return `${num - 2}x read speed gain and write speed penalty (due to parity calculations)`;
|
||||||
|
},
|
||||||
|
fault: function(num, size, unit){
|
||||||
|
// always 2 drive failures
|
||||||
|
return "2 drive failures";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
raid_10: {
|
||||||
|
about: 'RAID 10 is generally recognized as a stripe of mirrors (RAID 1 + RAID 2). Each set of drives is mirrored and striped together so that each drive in the set is fault tolerant within the group. More info: <a href="https://en.wikipedia.org/wiki/Nested_RAID_levels#RAID_10_(RAID_1+0)">Wikipedia</a>',
|
||||||
|
requirements: 'RAID 10 requires an even number of at least 4 disks',
|
||||||
|
validate: function(num, size){
|
||||||
|
return num >= 4 && num % 2 == 0
|
||||||
|
},
|
||||||
|
capacity: function(num, size, unit){
|
||||||
|
// Total disks (stripe)/2 (mirror)
|
||||||
|
return ((num * size) / 2) * unit;
|
||||||
|
},
|
||||||
|
speed: function(num, size, unit){
|
||||||
|
return `${num - 2}x read speed gain and write speed penalty (due to parity calculations)`;
|
||||||
|
},
|
||||||
|
fault: function(num, size, unit){
|
||||||
|
// always 2 drive failures
|
||||||
|
return "At least 1 drive failure per mirrored set";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
107
src/tools/raid-calculator/raid-calculator.vue
Normal file
107
src/tools/raid-calculator/raid-calculator.vue
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { isNotThrowing } from '@/utils/boolean';
|
||||||
|
import { raidCalculations } from './raid-calculator.service';
|
||||||
|
|
||||||
|
const diskTotal = ref(2);
|
||||||
|
const diskSize = ref(100);
|
||||||
|
const diskUnit = ref(Math.pow(10, 9));
|
||||||
|
const raidType = ref('raid_0');
|
||||||
|
const raidInfo = computed(() => raidCalculations[raidType.value].about);
|
||||||
|
const raidRequirements = computed(() => raidCalculations[raidType.value].requirements);
|
||||||
|
const inputsValid = computed(() => validateSetup());
|
||||||
|
|
||||||
|
const calculatedCapacity = computed(() => {
|
||||||
|
// make sure values exist
|
||||||
|
if(diskTotal.value === undefined || diskSize.value === undefined)
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatBytes(raidCalculations[raidType.value].capacity(diskTotal.value, diskSize.value, diskUnit.value));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
const calculatedFaultTolerance = computed(() => {
|
||||||
|
// make sure values exist
|
||||||
|
if(diskTotal.value === undefined || diskSize.value === undefined)
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return raidCalculations[raidType.value].fault(diskTotal.value, diskSize.value, diskUnit.value);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function validateSetup(){
|
||||||
|
// validate the selected RAID type against parameters
|
||||||
|
return raidCalculations[raidType.value].validate(diskTotal.value, diskSize.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// similar to the utility function but uses base 10 instead of base 2
|
||||||
|
function formatBytes(bytes: number, decimals = 2) {
|
||||||
|
if (bytes === 0) {
|
||||||
|
return '0 Bytes';
|
||||||
|
}
|
||||||
|
|
||||||
|
const k = Math.pow(10, 3);
|
||||||
|
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||||
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||||
|
|
||||||
|
return `${Number.parseFloat((bytes / k ** i).toFixed(decimals))} ${sizes[i]}`;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<c-card>
|
||||||
|
<n-form-item label="Number of disks" label-placement="left" label-width="150" mb-2>
|
||||||
|
<n-input-number v-model:value="diskTotal" max="10000" min="2" placeholder="Number of disks (ex: 2)" w-full />
|
||||||
|
</n-form-item>
|
||||||
|
|
||||||
|
<n-form-item label="Disk size" label-placement="left" label-width="150" mb-2>
|
||||||
|
<n-input-number v-model:value="diskSize" max="10000" min="1" placeholder="Disk size (ex: 100)" w-full />
|
||||||
|
<div flex items-baseline gap-2>
|
||||||
|
<c-select
|
||||||
|
v-model:value="diskUnit"
|
||||||
|
min-w-130px
|
||||||
|
:options="[
|
||||||
|
{ label: 'MB', value: Math.pow(10, 6) },
|
||||||
|
{ label: 'GB', value: Math.pow(10, 9) },
|
||||||
|
{ label: 'TB', value: Math.pow(10, 12) },
|
||||||
|
{ label: 'PB', value: Math.pow(10, 15) },
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="RAID Type" label-placement="left" label-width="150" mb-2>
|
||||||
|
<c-select
|
||||||
|
v-model:value="raidType"
|
||||||
|
w-full
|
||||||
|
:options="[
|
||||||
|
{ label: 'RAID 0 (stripe)', value: 'raid_0' },
|
||||||
|
{ label: 'RAID 1 (mirror)', value: 'raid_1' },
|
||||||
|
{ label: 'RAID 5 (parity)', value: 'raid_5' },
|
||||||
|
{ label: 'RAID 6 (double parity)', value: 'raid_6' },
|
||||||
|
{ label: 'RAID 10 (mirror + stripe)', value: 'raid_10' },
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
<p class="raidError" v-if="!inputsValid">{{ raidRequirements }}</p>
|
||||||
|
<p v-else v-html="raidInfo"></p>
|
||||||
|
</c-card>
|
||||||
|
<c-card title="Results">
|
||||||
|
<n-statistic label="Capacity" mb-2 v-if="inputsValid">
|
||||||
|
{{ calculatedCapacity }}
|
||||||
|
</n-statistic>
|
||||||
|
<n-statistic label="Fault Tolerance" mb-2 v-if="inputsValid">
|
||||||
|
{{ calculatedFaultTolerance }}
|
||||||
|
</n-statistic>
|
||||||
|
</c-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.raidError {
|
||||||
|
color: rgb(208, 48, 80)
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Add table
Add a link
Reference in a new issue