public Vdc(String... hostNames) { this.name = hostNames[0]; hosts = new ArrayList<VdcHost>(); for (String hostName : hostNames) { hosts.add(new VdcHost(this, hostName)); } }
@Override public boolean isHealthy() { return !isMaintenanceMode() && super.isHealthy(); }
vdcNodeList.add(new VdcHost(vdc, host.getName())); if (vdcHost.equals(node)) { hostPresent = true; nodeI.remove(); log.info("host " + vdcHost.getName() + " was not in the updated node list; removing from VDC " + vdc.getName()); vdcI.remove(); log.info("adding host " + node.getName() + " to VDC " + vdc.getName()); vdc.getHosts().add(new VdcHost(vdc, node.getName()));
@ConfigUriProperty(type = ConfigUriProperty.Type.Host) public String getHost() { if (getVdcs() == null || getVdcs().isEmpty()) return null; return getVdcs().get(0).getHosts().get(0).getName(); }
@Override public void runHealthCheck(Host host) { // header is workaround for STORAGE-1833 PingResponse response = client.resource(getRequestUri(host, "/?ping")).header("x-emc-namespace", "x") .get(PingResponse.class); if (host instanceof VdcHost) { PingItem.Status status = PingItem.Status.OFF; if (response != null && response.getPingItemMap() != null) { PingItem pingItem = response.getPingItemMap().get(PingItem.MAINTENANCE_MODE); if (pingItem != null) status = pingItem.getStatus(); } if (status == PingItem.Status.ON) ((VdcHost) host).setMaintenanceMode(true); else ((VdcHost) host).setMaintenanceMode(false); } }
@Override public String getAsText() { Vdc vdc = (Vdc) getValue(); if (vdc.getHosts().isEmpty()) return ""; List<String> names = new ArrayList<>(); for (Host host : vdc.getHosts()) { names.add(host.getName()); } if (vdc.getName() == null || vdc.getName().equals(vdc.getHosts().get(0).getName())) { return SyncUtil.join(names, ","); } else { return String.format("%s(%s)", vdc.getName(), SyncUtil.join(names, ",")); } }
@Override public boolean shouldVeto(Host host, Map<String, Object> requestProperties) { Vdc vdc = (Vdc) requestProperties.get(PROP_GEO_PINNED_VDC); return (vdc != null && host instanceof VdcHost && !vdc.equals(((VdcHost) host).getVdc())); } }
protected List<VdcHost> createVdcHosts(List<? extends Host> hosts) { List<VdcHost> vdcHosts = new ArrayList<VdcHost>(); for (Host host : hosts) { vdcHosts.add(new VdcHost(this, host.getName())); } return vdcHosts; }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + getVdc().hashCode(); return result; }