Source:
<code>private void onReplaceBrick() { GlusterVolumeEntity volumeEntity = getEntity(); if (volumeEntity == null) { return; } ReplaceBrickModel replaceBrickModel = (ReplaceBrickModel) getWindow(); if (replaceBrickModel == null) { return; } GlusterBrickEntity existingBrick = getSelectedItem(); if (existingBrick == null) { return; } boolean isMultipleBricks = false; String selectedHost = replaceBrickModel.getServers().getSelectedItem().getHostName(); for (String brick : volumeEntity.getBrickDirectories()) { <START> if (brick.contains(selectedHost) && selectedHost != existingBrick.getServerName()) { END> isMultipleBricks = true; } } if (volumeEntity.getVolumeType().isReplicatedType() && isMultipleBricks) { ConfirmationModel model = new ConfirmationModel(); setConfirmWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().replaceBrickTitle()); model.setMessage(ConstantsManager.getInstance().getConstants().replaceBrickWarning()); model.setHelpTag(HelpTag.replace_brick); model.setHashName("replace brick"); UICommand yesCommand = new UICommand("OnReplaceConfirmation", VolumeBrickListModel.this); yesCommand.setTitle(ConstantsManager.getInstance().getConstants().yes()); model.getCommands().add(yesCommand); UICommand cancelCommand = new UICommand("CancelConfirmation", this); cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().no()); cancelCommand.setIsCancel(true); getConfirmWindow().getCommands().add(cancelCommand); } else { onReplaceConfirmation(); } }</code><technical_language>Warning needs shown if server is repeated in replica set. Here, if volume 6 bricks, replica count =3 - warning is shown if a brick in replicaset selectedHost. is, is acceptable throw warning. server1:/brick1 server2:/brick2 server3:/brick3 --> change server4:/brick3 server4:/brick4 server5:/brick5 server6:/brick6</technical_language>

Target:
private void onReplaceBrick() { GlusterVolumeEntity volumeEntity = getEntity(); if (volumeEntity == null) { return; } ReplaceBrickModel replaceBrickModel = (ReplaceBrickModel) getWindow(); if (replaceBrickModel == null) { return; } GlusterBrickEntity existingBrick = getSelectedItem(); if (existingBrick == null) { return; } String selectedHost = replaceBrickModel.getServers().getSelectedItem().getHostName(); AsyncDataProvider.getInstance().getGlusterBricksForServer(new AsyncQuery<>(bricks -> { List<GlusterBrickEntity> brickDirectories = new ArrayList<>(); for (GlusterBrickEntity brick : bricks) { brickDirectories.add(brick); } boolean isMultipleBricks = false; for (String brick : volumeEntity.getBrickDirectories()) { if (brick.contains(selectedHost) && selectedHost != existingBrick.getServerName() && brickDirectories.size() > 1) { isMultipleBricks = true; } } if (volumeEntity.getVolumeType().isReplicatedType() && isMultipleBricks) { ConfirmationModel model = new ConfirmationModel(); setConfirmWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().replaceBrickTitle()); model.setMessage(ConstantsManager.getInstance().getConstants().replaceBrickWarning()); model.setHelpTag(HelpTag.replace_brick); model.setHashName("replace brick"); UICommand yesCommand = new UICommand("OnReplaceConfirmation", VolumeBrickListModel.this); yesCommand.setTitle(ConstantsManager.getInstance().getConstants().yes()); model.getCommands().add(yesCommand); UICommand cancelCommand = new UICommand("CancelConfirmation", this); cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().no()); cancelCommand.setIsCancel(true); getConfirmWindow().getCommands().add(cancelCommand); } else { onReplaceConfirmation(); } }), replaceBrickModel.getServers().getSelectedItem().getId()); }