private boolean isHAEnabledForCluster(final HAResource resource) { if (resource == null || resource.getClusterId() == null) { return true; } final ClusterDetailsVO clusterDetails = clusterDetailsDao.findDetail(resource.getClusterId(), HA_ENABLED_DETAIL); return clusterDetails == null || Strings.isNullOrEmpty(clusterDetails.getValue()) || Boolean.valueOf(clusterDetails.getValue()); }
public boolean isHAEnabledForZone(final HAResource resource) { if (resource == null || resource.getDataCenterId() < 1L) { return true; } final DataCenterDetailVO zoneDetails = dataCenterDetailsDao.findDetail(resource.getDataCenterId(), HA_ENABLED_DETAIL); return zoneDetails == null || Strings.isNullOrEmpty(zoneDetails.getValue()) || Boolean.valueOf(zoneDetails.getValue()); }
private boolean transitionResourceStateToDisabled(final Partition partition) { List<? extends HAResource> resources; if (partition.partitionType() == Partition.PartitionType.Cluster) { resources = hostDao.findByClusterId(partition.getId()); } else if (partition.partitionType() == Partition.PartitionType.Zone) { resources = hostDao.findByDataCenterId(partition.getId()); } else { return true; } boolean result = true; for (final HAResource resource: resources) { result = result && transitionHAState(HAConfig.Event.Disabled, haConfigDao.findHAResource(resource.getId(), resource.resourceType())); } return result; }
private boolean isHAEligibleForResource(final HAResource resource) { if (resource == null || resource.getId() < 1L) { return false; } HAResource.ResourceType resourceType = null; if (resource instanceof Host) { resourceType = HAResource.ResourceType.Host; } if (resourceType == null) { return false; } final HAConfig haConfig = haConfigDao.findHAResource(resource.getId(), resourceType); return haConfig != null && haConfig.isEnabled() && haConfig.getState() != HAConfig.HAState.Disabled && haConfig.getState() != HAConfig.HAState.Ineligible; }
@Override public Boolean call() { if (new DateTime().minusHours(1).isAfter(getCreated())) { return false; } final Future<Boolean> future = executor.submit(new Callable<Boolean>() { @Override public Boolean call() throws HACheckerException, HAFenceException, HARecoveryException { return performAction(); } }); boolean result = false; Throwable throwable = null; try { if (timeout == null) { result = future.get(); } else { result = future.get(timeout, TimeUnit.SECONDS); } } catch (InterruptedException | ExecutionException e) { LOG.warn("Exception occurred while running " + getTaskType() + " on a resource: " + e.getMessage(), e.getCause()); throwable = e.getCause(); } catch (TimeoutException e) { LOG.trace(getTaskType() + " operation timed out for resource id:" + resource.getId()); } processResult(result, throwable); return result; }