use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService in project ovirt-engine by oVirt.
the class GlusterServerServiceDaoTest method testGetByClusterId.
@Test
public void testGetByClusterId() {
List<GlusterServerService> services = dao.getByClusterId(CLUSTER_ID);
assertNotNull(services);
assertEquals(2, services.size());
for (GlusterServerService service : services) {
Guid serverId = service.getServerId();
if (FixturesTool.GLUSTER_BRICK_SERVER1.equals(serverId)) {
verifyServiceOnServer1(service);
} else if (FixturesTool.VDS_GLUSTER_SERVER2.equals(serverId)) {
verifyServiceOnServer2(service);
} else {
fail("Unexpected server id: " + service.getServerId());
}
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService 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;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService in project ovirt-engine by oVirt.
the class GlusterServiceSyncJob method updateGlusterServicesStatusForStoppedServer.
private Map<String, GlusterServiceStatus> updateGlusterServicesStatusForStoppedServer(VDS server) {
Map<String, GlusterServiceStatus> retMap = new HashMap<>();
List<GlusterServerService> serviceList = serverServiceDao.getByServerId(server.getId());
for (GlusterServerService service : serviceList) {
retMap.put(service.getServiceName(), GlusterServiceStatus.UNKNOWN);
service.setStatus(GlusterServiceStatus.UNKNOWN);
serverServiceDao.update(service);
}
return retMap;
}
Aggregations