@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((hostname == null) ? 0 : hostname.hashCode()); result = prime * result + getId(); return result; }
private static Host createHost(Map<String, String> beanAttr) throws InternalErrorException { if(beanAttr==null) return null; Host host = new Host(); host.setId(Integer.valueOf(beanAttr.get("id"))); host.setHostname(BeansUtils.eraseEscaping(beanAttr.get("hostname"))); return host; }
@Override public int compareTo(PerunBean perunBean) { if(perunBean == null) throw new NullPointerException("PerunBean to compare with is null."); if(perunBean instanceof Host) { Host host = (Host) perunBean; if (this.getHostname() == null && host.getHostname() != null) return -1; if (host.getHostname() == null && this.getHostname() != null) return 1; if (this.getHostname() == null && host.getHostname() == null) return 0; return this.getHostname().compareToIgnoreCase(host.getHostname()); } else { return (this.getId() - perunBean.getId()); } } }
public HostExistsException(Host host) { super(host.toString()); this.host = host; }
public HostNotExistsException(Host host) { super(host.toString()); this.host = host; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Host other = (Host) obj; if (hostname == null) { if (other.hostname != null) return false; } else if (!hostname.equals(other.hostname)) return false; if (getId() != other.getId()) return false; return true; }
@Override public String serializeToString() { StringBuilder str = new StringBuilder(); return str.append(this.getClass().getSimpleName()).append(":[").append( "id=<").append(getId()).append(">").append( ", hostname=<").append(getHostname() == null ? "\\0" : BeansUtils.createEscaping(getHostname())).append(">").append( ']').toString(); }
@Override public String toString() { StringBuilder str = new StringBuilder(); return str.append(getClass().getSimpleName()).append(":[id='").append(getId()).append("', hostname='").append(hostname).append("']").toString(); }
public static Facility getFacilityForHost(RpcCaller rpcCaller, Host host) throws InternalErrorException, PrivilegeException, HostNotExistsException { Map<String, Object> params = new HashMap<String, Object>(); params.put("host", host.getId()); try { return rpcCaller.call("facilitiesManager", "getFacilityForHost", params).read(Facility.class); } catch (HostNotExistsException e) { throw e; } catch (PrivilegeException e) { throw e; } catch (InternalErrorException e) { throw e; } catch (PerunException e) { throw new ConsistencyErrorException(e); } } }
log.debug("Host found in event.id= {}.", host.getId()); facility = perun.getFacilitiesManager().getFacilityForHost(perunSession, host); facilitiesResolvedFromEvent.add(facility); log.warn( "Host on non-existing facility found while resolving event. Host id={}", host.getId()); } catch (HostNotExistsException ex) { log.warn("Non-existing host found while resolving event. id={}", host.getId());