AvailabilityReport report = reports.get(agent); if (null == report) { report = new AvailabilityReport(agent.getName()); report.setEnablementReport(true); reports.put(agent, report);
AvailabilityReport report = reports.get(agent); if (null == report) { report = new AvailabilityReport(agent.getName()); report.setEnablementReport(true); reports.put(agent, report);
@Override @NotNull public AvailabilityReport getCurrentAvailability(Resource resource, boolean changesOnly) { try { //make sure we have the full version of the resource ResourceContainer container = getResourceContainer(resource.getId()); if (container == null) { //don't bother doing anything return new AvailabilityReport(changesOnly, getAgent().getName()); } resource = container.getResource(); MeasurementScheduleRequest availSchedule = container.getAvailabilitySchedule(); boolean forceScanForRoot = availSchedule == null || availSchedule.isEnabled(); // force scan for root resource only if availability schedule is enabled AvailabilityExecutor availExec = new CustomScanRootAvailabilityExecutor(this, resource, forceScanForRoot); if (changesOnly) { availExec.sendChangesOnlyReportNextTime(); } else { availExec.sendFullReportNextTime(); } return availabilityThreadPoolExecutor.submit((Callable<AvailabilityReport>) availExec).get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException("Availability scan execution was interrupted", e); } catch (ExecutionException e) { // Should never happen, reports are always generated, even if they're just to report the error throw new RuntimeException("Unexpected exception", e); } }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setResourceAvailabilities(Map<Agent, int[]> map, AvailabilityType avail) { long now = System.currentTimeMillis(); for (Agent agent : map.keySet()) { AvailabilityReport report = new AvailabilityReport(true, null); report.setServerSideReport(true); for (int resourceId : map.get(agent)) { report.addAvailability(new Datum(resourceId, avail, now)); } AvailabilityReportSerializer.getSingleton().lock(agent.getName()); try { this.availabilityManager.mergeAvailabilityReport(report); } finally { AvailabilityReportSerializer.getSingleton().unlock(agent.getName()); } } return; }
availabilityReport = new AvailabilityReport(changesOnly, inventoryManager.getAgent().getName());
@PUT @Path("/{id}/availability") @ApiOperation("Set the current availability of the passed resource") @TransactionAttribute(TransactionAttributeType.NEVER) public void reportAvailability(@ApiParam("Id of the resource to update") @PathParam("id") int resourceId, @ApiParam(value= "New Availability setting", required = true) AvailabilityRest avail) { if (avail.getResourceId() != resourceId) throw new IllegalArgumentException("Resource Ids do not match"); Resource resource = fetchResource(resourceId); AvailabilityType at; at = AvailabilityType.valueOf(avail.getType()); // According to jshaughn, plaforms must not be set to DISABLED, so catch this case here. if (resource.getResourceType().getCategory()==ResourceCategory.PLATFORM && at==AvailabilityType.DISABLED) { throw new BadArgumentException("Availability","Platforms must not be set to DISABLED"); } Agent agent = agentMgr.getAgentByResourceId(caller,resourceId); AvailabilityReport report = new AvailabilityReport(true, agent.getName()); Availability availability = new Availability(resource, avail.getSince(), at); report.addAvailability(availability); availMgr.mergeAvailabilityReport(report); }