public void loadResource() throws Exception { CURI c = this.registerResource(FirstAidResource.class); Description desc = (Description) this.registry.getDescription(c); this.myinfo = new ServiceInfo(); this.myinfo.setCityName("Milano"); this.myinfo.setCountryName("Italy"); this.myinfo.setLatitude(desc.getContext().get("latitude")); this.myinfo.setLongitude(desc.getContext().get("longitude")); this.myinfo.setAvailability(desc.getQoS().getAvailability()); this.myinfo.setResponseTime(desc.getQoS().getResponseTime()); LocalUtilityMonitor qos = new LocalUtilityMonitor(desc); qos.setUtility(Metrics.RESPONSE_TIME, this.myinfo.getResponseTime()); this.startGossipManagerQoS(qos, desc.getDependences(), 10000); }
public synchronized boolean release(CURI curi) { if (this.myServiceInfo.getAvailability() < this.myServiceInfo.getMaxAvailability()) { this.myServiceInfo.setAvailability(this.myServiceInfo.getAvailability() + 1); updateLocalQoS( curi, Metrics.AVAILABILITY, this.myServiceInfo.getAvailability() / this.myServiceInfo.getMaxAvailability()); // Monitoring stuff LocalUtilityMonitor utility = this.getAssemblyManager().getGossipManager(this.truckuri).getUtility(); MonitoringInfo mi = new MonitoringInfo( new AURI("http://www.erc-smscom.org/ontologies/2013/4/eHealth#Ambulance"), this.getApplicationID()); mi.put("compaundAvailability", utility.getUtility(Metrics.AVAILABILITY).toString()); notify(this.getApplicationID(), new AURI("Monitoring"), mi); return true; } else { return false; } }