use of org.ovirt.engine.core.common.businessentities.gluster.ServiceType in project ovirt-engine by oVirt.
the class ClusterServiceModel method filterServices.
private void filterServices() {
VDS selectedVds = hostList.getSelectedItem();
ServiceType serviceType = serviceTypeList.getSelectedItem();
ArrayList<EntityModel<GlusterServerService>> list = new ArrayList<>();
List<GlusterServerService> serviceList = new ArrayList<>(getActualServiceList());
Collections.sort(serviceList, Comparator.comparing(GlusterServerService::getHostName).thenComparing(g -> g.getServiceType().toString()));
for (GlusterServerService service : serviceList) {
if ((selectedVds == null || service.getHostName().equals(selectedVds.getHostName())) && (serviceType == null || service.getServiceType() == serviceType)) {
list.add(new EntityModel<>(service));
}
}
getServiceList().setItems(list);
}
use of org.ovirt.engine.core.common.businessentities.gluster.ServiceType in project ovirt-engine by oVirt.
the class ManageGlusterSwiftPopupView method initEditors.
private void initEditors() {
swiftStatusEditor = new EntityModelLabelEditor<>(new EnumRenderer<GlusterServiceStatus>());
// $NON-NLS-1$
startSwift = new EntityModelRadioButtonEditor("swift_action", Align.RIGHT);
// $NON-NLS-1$
stopSwift = new EntityModelRadioButtonEditor("swift_action", Align.RIGHT);
// $NON-NLS-1$
restartSwift = new EntityModelRadioButtonEditor("swift_action", Align.RIGHT);
manageSwiftServerLevel = new EntityModelCheckBoxEditor(Align.RIGHT);
hostServicesTable = new EntityModelCellTable<>(false, true);
hostServicesTable.addColumn(new AbstractEntityModelTextColumn<GlusterServerService>() {
@Override
public String getText(GlusterServerService entity) {
return entity.getHostName();
}
}, constants.hostGlusterSwift());
hostServicesTable.addColumn(new AbstractEnumColumn<EntityModel, ServiceType>() {
@Override
protected ServiceType getRawValue(EntityModel object) {
return ((GlusterSwiftServiceModel) object).getEntity().getServiceType();
}
}, constants.serviceNameGlusterSwift());
hostServicesTable.addColumn(new AbstractEnumColumn<EntityModel, GlusterServiceStatus>() {
@Override
protected GlusterServiceStatus getRawValue(EntityModel object) {
return ((GlusterSwiftServiceModel) object).getEntity().getStatus();
}
}, constants.serviceStatusGlusterSwift());
Column<EntityModel, Boolean> startSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) {
@Override
public Boolean getValue(EntityModel object) {
GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
return swiftServiceModel.getStartSwift().getEntity();
}
@Override
public void render(Context context, EntityModel object, SafeHtmlBuilder sb) {
GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
if (swiftServiceModel.getStartSwift().getIsChangable()) {
super.render(context, object, sb);
}
}
};
startSwiftColumn.setFieldUpdater((index, object, value) -> {
GlusterSwiftServiceModel swiftModel = (GlusterSwiftServiceModel) object;
swiftModel.getStartSwift().setEntity(value);
if (value) {
swiftModel.getStopSwift().setEntity(false);
swiftModel.getRestartSwift().setEntity(false);
hostServicesTable.redraw();
}
});
hostServicesTable.addColumn(startSwiftColumn, constants.startGlusterSwift());
Column<EntityModel, Boolean> stopSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) {
@Override
public Boolean getValue(EntityModel object) {
GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
return swiftServiceModel.getStopSwift().getEntity();
}
@Override
public void render(Context context, EntityModel object, SafeHtmlBuilder sb) {
GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
if (swiftServiceModel.getStopSwift().getIsChangable()) {
super.render(context, object, sb);
}
}
};
stopSwiftColumn.setFieldUpdater((index, object, value) -> {
GlusterSwiftServiceModel swiftModel = (GlusterSwiftServiceModel) object;
if (swiftModel.getStopSwift().getIsChangable()) {
swiftModel.getStopSwift().setEntity(value);
if (value) {
swiftModel.getStartSwift().setEntity(false);
swiftModel.getRestartSwift().setEntity(false);
hostServicesTable.redraw();
}
}
});
hostServicesTable.addColumn(stopSwiftColumn, constants.stopGlusterSwift());
Column<EntityModel, Boolean> restartSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) {
@Override
public Boolean getValue(EntityModel object) {
GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
return swiftServiceModel.getRestartSwift().getEntity();
}
@Override
public void render(Context context, EntityModel object, SafeHtmlBuilder sb) {
GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
if (swiftServiceModel.getRestartSwift().getIsChangable()) {
super.render(context, object, sb);
}
}
};
restartSwiftColumn.setFieldUpdater((index, object, value) -> {
GlusterSwiftServiceModel swiftModel = (GlusterSwiftServiceModel) object;
swiftModel.getRestartSwift().setEntity(value);
if (value) {
swiftModel.getStartSwift().setEntity(false);
swiftModel.getStopSwift().setEntity(false);
hostServicesTable.redraw();
}
});
hostServicesTable.addColumn(restartSwiftColumn, constants.restartGlusterSwift());
}
use of org.ovirt.engine.core.common.businessentities.gluster.ServiceType in project ovirt-engine by oVirt.
the class GlusterServiceSyncJob method addOrUpdateClusterServices.
private void addOrUpdateClusterServices(Cluster cluster, Map<ServiceType, GlusterServiceStatus> fetchedClusterServiceStatusMap) {
Map<ServiceType, GlusterClusterService> existingClusterServiceMap = getClusterServiceMap(cluster);
for (Entry<ServiceType, GlusterServiceStatus> entry : fetchedClusterServiceStatusMap.entrySet()) {
ServiceType type = entry.getKey();
GlusterServiceStatus status = entry.getValue();
GlusterClusterService existingClusterService = existingClusterServiceMap.get(type);
if (existingClusterService == null) {
existingClusterServiceMap.put(type, addClusterServiceToDb(cluster, type, status));
} else if (existingClusterService.getStatus() != status) {
updateClusterServiceStatus(existingClusterService, status);
}
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.ServiceType in project ovirt-engine by oVirt.
the class GlusterServiceSyncJob method createServiceTypeStatusMap.
private Map<ServiceType, GlusterServiceStatus> createServiceTypeStatusMap(List<Map<String, GlusterServiceStatus>> serviceStatusMaps) {
Map<ServiceType, GlusterServiceStatus> fetchedServiceTypeStatusMap = new HashMap<>();
for (Entry<String, GlusterServiceStatus> entry : mergeServiceStatusMaps(serviceStatusMaps).entrySet()) {
String serviceName = entry.getKey();
GlusterServiceStatus status = entry.getValue();
ServiceType type = getServiceNameMap().get(serviceName).getServiceType();
GlusterServiceStatus foundStatus = fetchedServiceTypeStatusMap.get(type);
if (foundStatus == null) {
fetchedServiceTypeStatusMap.put(type, status);
} else if (foundStatus != status) {
GlusterServiceStatus finalStatus = getFinalStatus(status, foundStatus);
fetchedServiceTypeStatusMap.put(type, finalStatus);
}
}
return fetchedServiceTypeStatusMap;
}
use of org.ovirt.engine.core.common.businessentities.gluster.ServiceType in project ovirt-engine by oVirt.
the class GlusterServiceSyncJob method refreshGlusterServices.
@OnTimerMethodAnnotation("refreshGlusterServices")
public void refreshGlusterServices() {
if (getServiceNameMap().isEmpty()) {
// Lazy loading. Keeping this out of the constructor/getInstance
// helps in writing the JUnit test as well.
populateServiceMap();
}
List<Cluster> clusters = clusterDao.getAll();
for (Cluster cluster : clusters) {
if (supportsGlusterServicesFeature(cluster)) {
try {
List<VDS> serversList = glusterUtil.getAllUpServers(cluster.getId());
// If there are no servers in the cluster, set the status as unknown
if (serversList.isEmpty()) {
Map<ServiceType, GlusterServiceStatus> statusMap = new HashMap<>();
for (ServiceType type : getClusterServiceMap(cluster).keySet()) {
statusMap.put(type, GlusterServiceStatus.UNKNOWN);
}
addOrUpdateClusterServices(cluster, statusMap);
} else {
List<Callable<Map<String, GlusterServiceStatus>>> taskList = createTaskList(serversList);
if (taskList != null && taskList.size() > 0) {
refreshClusterServices(cluster, ThreadPoolUtil.invokeAll(taskList));
}
}
} catch (Exception e) {
log.error("Error while refreshing service statuses of cluster '{}': {}", cluster.getName(), e.getMessage());
log.debug("Exception", e);
}
}
}
}
Aggregations