use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GlusterVolumeUtils method countDownBricks.
public static int countDownBricks(GlusterVolumeEntity volume) {
int downCount = 0;
int upCount = 0;
for (GlusterBrickEntity brick : volume.getBricks()) {
if (brick.getStatus() == GlusterStatus.UP) {
upCount++;
} else {
downCount++;
}
if (upCount > 0 && downCount > 0) {
return downCount;
}
}
return downCount;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GlusterStorageModel method volumeSelectedItemChanged.
private void volumeSelectedItemChanged() {
GlusterVolumeEntity volume = getGlusterVolumes().getSelectedItem();
Boolean useLinkGlusterVolume = getLinkGlusterVolume().getEntity();
// $NON-NLS-1$
String mountOptions = "";
if (volume == null || !useLinkGlusterVolume) {
return;
}
Set<String> addressSet = new LinkedHashSet<>();
for (GlusterBrickEntity brick : volume.getBricks()) {
addressSet.add(brick.getNetworkId() != null && !brick.getNetworkAddress().isEmpty() ? brick.getNetworkAddress() : brick.getServerName());
}
List<String> addressList = new ArrayList<>();
addressList.addAll(addressSet);
if (addressList.size() >= 1) {
// the first server is already used to mount volume
addressList.remove(0);
}
if (addressList.size() > 0) {
mountOptions = StorageConstants.GLUSTER_BACKUP_SERVERS_MNT_OPTION + "=" + // $NON-NLS-1$ //$NON-NLS-2$
String.join(":", addressList);
}
getMountOptions().setEntity(mountOptions);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class VolumeBrickStatusColumn method getTooltip.
@Override
public SafeHtml getTooltip(GlusterVolumeEntity object) {
// $NON-NLS-1$
String SPACE = " ";
// Nothing to render if no volume is provided:
if (object == null) {
return null;
}
int upBricks = 0;
int downBricks = 0;
for (GlusterBrickEntity brick : object.getBricks()) {
if (brick.isOnline()) {
upBricks++;
} else {
downBricks++;
}
}
StringBuilder sb = new StringBuilder();
sb.append(upBricks).append(SPACE).append(constants.up()).append(SPACE).append(downBricks).append(SPACE).append(constants.down());
return SafeHtmlUtils.fromString(sb.toString());
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GlusterCommandBase method validateDuplicateBricks.
protected boolean validateDuplicateBricks(List<GlusterBrickEntity> newBricks) {
Set<String> bricks = new HashSet<>();
for (GlusterBrickEntity brick : newBricks) {
if (bricks.contains(brick.getQualifiedName())) {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_DUPLICATE_BRICKS);
addValidationMessageVariable("brick", brick.getQualifiedName());
return false;
}
bricks.add(brick.getQualifiedName());
GlusterBrickEntity existingBrick = glusterBrickDao.getBrickByServerIdAndDirectory(brick.getServerId(), brick.getBrickDirectory());
if (existingBrick != null) {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_BRICK_ALREADY_EXISTS_IN_VOLUME);
addValidationMessageVariable("brick", brick.getQualifiedName());
addValidationMessageVariable("volumeName", glusterVolumeDao.getById(existingBrick.getVolumeId()).getName());
return false;
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.
the class GlusterHostValidator method checkUnsyncedEntries.
public Map<Guid, List<String>> checkUnsyncedEntries(Iterable<Guid> hostIds) {
Map<Guid, List<String>> result = new HashMap<>();
for (Guid serverId : hostIds) {
List<GlusterBrickEntity> bricks = brickDao.getGlusterVolumeBricksByServerId(serverId);
List<String> bricksWithUnsyncedEntries = bricks.stream().filter(brick -> brick.getStatus() == GlusterStatus.UP && brick.getUnSyncedEntries() != null && brick.getUnSyncedEntries() > 0).map(brick -> brick.getQualifiedName()).collect(Collectors.toList());
if (!bricksWithUnsyncedEntries.isEmpty()) {
result.put(serverId, bricksWithUnsyncedEntries);
}
}
return result;
}
Aggregations