use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus 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.GlusterServiceStatus in project ovirt-engine by oVirt.
the class GlusterServiceSyncJob method updateStatusToUnknown.
private Map<String, GlusterServiceStatus> updateStatusToUnknown(Collection<GlusterServerService> existingServices) {
Map<String, GlusterServiceStatus> serviceStatusMap = new HashMap<>();
for (GlusterServerService existingService : existingServices) {
existingService.setStatus(GlusterServiceStatus.UNKNOWN);
serviceStatusMap.put(existingService.getServiceName(), existingService.getStatus());
}
serverServiceDao.updateAll(existingServices);
return serviceStatusMap;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus 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.GlusterServiceStatus 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.GlusterServiceStatus in project ovirt-engine by oVirt.
the class GlusterServiceSyncJob method refreshServerServices.
/**
* Refreshes statuses of services on given server, and returns a map of service name to it's status
*
* @param server
* The server whose services statuses are to be refreshed
* @return map of service name to it's status
*/
@SuppressWarnings({ "unchecked", "serial" })
private Map<String, GlusterServiceStatus> refreshServerServices(final VDS server) {
Map<String, GlusterServiceStatus> serviceStatusMap = new HashMap<>();
if (server.getStatus() != VDSStatus.Up) {
// Update the status of all the services of stopped server in single transaction
TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> updateGlusterServicesStatusForStoppedServer(server));
} else {
acquireLock(server.getId());
try {
Map<Guid, GlusterServerService> existingServicesMap = getExistingServicesMap(server);
List<GlusterServerService> servicesToUpdate = new ArrayList<>();
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GlusterServicesList, new GlusterServicesListVDSParameters(server.getId(), getServiceNameMap().keySet()));
if (!returnValue.getSucceeded()) {
log.error("Couldn't fetch services statuses from server '{}', error: {}! " + "Updating statuses of all services on this server to UNKNOWN.", server.getHostName(), returnValue.getVdsError().getMessage());
logUtil.logServerMessage(server, AuditLogType.GLUSTER_SERVICES_LIST_FAILED);
return updateStatusToUnknown(existingServicesMap.values());
}
for (final GlusterServerService fetchedService : (List<GlusterServerService>) returnValue.getReturnValue()) {
serviceStatusMap.put(fetchedService.getServiceName(), fetchedService.getStatus());
GlusterServerService existingService = existingServicesMap.get(fetchedService.getServiceId());
if (existingService == null) {
insertServerService(server, fetchedService);
} else {
final GlusterServiceStatus oldStatus = existingService.getStatus();
final GlusterServiceStatus newStatus = fetchedService.getStatus();
if (oldStatus != newStatus) {
log.info("Status of service '{}' on server '{}' changed from '{}' to '{}'. Updating in engine now.", fetchedService.getServiceName(), server.getHostName(), oldStatus.name(), newStatus.name());
Map<String, String> customValues = new HashMap<>();
customValues.put(GlusterConstants.SERVICE_NAME, fetchedService.getServiceName());
customValues.put(GlusterConstants.OLD_STATUS, oldStatus.getStatusMsg());
customValues.put(GlusterConstants.NEW_STATUS, newStatus.getStatusMsg());
logUtil.logAuditMessage(server.getClusterId(), server.getClusterName(), null, server, AuditLogType.GLUSTER_SERVER_SERVICE_STATUS_CHANGED, customValues);
existingService.setStatus(fetchedService.getStatus());
servicesToUpdate.add(existingService);
}
}
}
if (servicesToUpdate.size() > 0) {
serverServiceDao.updateAll(servicesToUpdate);
}
} finally {
releaseLock(server.getId());
}
}
return serviceStatusMap;
}
Aggregations