Skip to content

Commit

Permalink
Remove duplicate type and refactor NodeRole to NodeDataRole
Browse files Browse the repository at this point in the history
Also deleted unused component "AdvancedSection" for now
  • Loading branch information
jloleysens committed Sep 16, 2020
1 parent 8d0d46b commit d695e95
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 53 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/index_lifecycle_management/common/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

export type NodeRole = 'data' | 'data_hot' | 'data_warm' | 'data_cold' | 'data_frozen';
export type NodeDataRole = 'data' | 'data_hot' | 'data_warm' | 'data_cold' | 'data_frozen';

export interface ListNodesRouteResponse {
nodesByAttributes: { [attributePair: string]: string[] };
nodesByRoles: { [role in NodeRole]?: string[] };
nodesByRoles: { [role in NodeDataRole]?: string[] };
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@

export * from './api';

export type DataTierNodeRole = 'data' | 'data_hot' | 'data_warm' | 'data_cold' | 'data_frozen';

export type PhaseWithAllocation = 'warm' | 'cold' | 'frozen';

export * from './policies';
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import { Index as IndexInterface } from '../../../index_management/common/types';

export type PhaseWithAllocation = 'warm' | 'cold' | 'frozen';

export interface SerializedPolicy {
name: string;
phases: Phases;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { NodeRole, ListNodesRouteResponse, PhaseWithAllocation } from '../../../../common/types';
import {
NodeDataRole,
ListNodesRouteResponse,
PhaseWithAllocation,
} from '../../../../common/types';

/**
* Given a phase and current node roles, determine whether the phase
Expand All @@ -23,7 +27,7 @@ export const isPhaseDefaultDataAllocationCompatible = (
}

// Otherwise we need to check whether a node role for the specific phase exists
if (nodesByRoles[`data_${phase}` as NodeRole]?.length) {
if (nodesByRoles[`data_${phase}` as NodeDataRole]?.length) {
return true;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { LegacyAPICaller } from 'src/core/server';

import { ListNodesRouteResponse, NodeRole } from '../../../../common/types';
import { ListNodesRouteResponse, NodeDataRole } from '../../../../common/types';

import { RouteDependencies } from '../../../types';
import { addBasePath } from '../../../services';
Expand Down Expand Up @@ -36,10 +36,10 @@ function convertStatsIntoList(
}
}

const dataRoles = nodeStats.roles.filter((r) => r.startsWith('data')) as NodeRole[];
const dataRoles = nodeStats.roles.filter((r) => r.startsWith('data')) as NodeDataRole[];
for (const role of dataRoles) {
accum.nodesByRoles[role as NodeRole] = accum.nodesByRoles[role] ?? [];
accum.nodesByRoles[role as NodeRole]!.push(nodeId);
accum.nodesByRoles[role as NodeDataRole] = accum.nodesByRoles[role] ?? [];
accum.nodesByRoles[role as NodeDataRole]!.push(nodeId);
}
return accum;
},
Expand Down

0 comments on commit d695e95

Please sign in to comment.