@Override public String toString() { StringBuilder str = new StringBuilder(); return str.append(getClass().getSimpleName()).append(":[id='").append(getId()).append("', name='").append(name) .append("', description='").append(getDescription()).append("', delay='").append(getDelay()) .append("', recurrence='").append(getRecurrence()).append("', enabled='").append(isEnabled()) .append("', script='").append(getScript()).append("']").toString(); }
private static Service createService(Map<String, String> beanAttr) { if(beanAttr==null) return null; Service service = new Service(); service.setId(Integer.valueOf(beanAttr.get("id"))); service.setName(BeansUtils.eraseEscaping(beanAttr.get("name"))); service.setDescription(BeansUtils.eraseEscaping(beanAttr.get("description"))); service.setDelay(Integer.valueOf(beanAttr.get("delay")).intValue()); service.setRecurrence(Integer.valueOf(beanAttr.get("recurrence")).intValue()); service.setEnabled(Boolean.valueOf(beanAttr.get("enabled")).booleanValue()); service.setScript(BeansUtils.eraseEscaping(beanAttr.get("script"))); return service; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; ServiceForGUI other = (ServiceForGUI) obj; if (allowedOnFacility != other.allowedOnFacility) return false; return true; }
@Override public int compareTo(PerunBean perunBean) { if(perunBean == null) throw new NullPointerException("PerunBean to compare with is null."); if(perunBean instanceof Service) { Service service = (Service) perunBean; if (this.getName() == null && service.getName() != null) return -1; if (service.getName() == null && this.getName() != null) return 1; if (this.getName() == null && service.getName() == null) return 0; return this.getName().compareToIgnoreCase(service.getName()); } else { return (this.getId() - perunBean.getId()); } } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + getId(); return result; }
Facility facility = map.getKey(); for (Service service : map.getValue()) { if (!service.isEnabled()) { log.debug("Service not enabled: {}.", service); continue; if (serviceDenialDao.isServiceBlockedOnFacility(service.getId(), facility.getId())) { log.debug("Service blocked on Facility: {} , {}.", service, facility); continue; while (iter.hasNext()) { Destination dest = iter.next(); if (serviceDenialDao.isServiceBlockedOnDestination(service.getId(), dest.getId())) { iter.remove(); task.setStatus(TaskStatus.WAITING); task.setRecurrence(0); task.setDelay(service.getDelay()); task.setSchedule(new Date(System.currentTimeMillis())); task.setSourceUpdated(false);
service = perun.getServicesManager().getServiceById(perunSession, service.getId()); facility = perun.getFacilitiesManager().getFacilityById(perunSession, facility.getId()); task.setService(service); if (service.isEnabled()) { log.debug("[{}] Service {} is enabled globally.", task.getId(), service.getId()); } else { log.debug("[{}] Service {} is disabled globally.", task.getId(), service.getId()); return DENIED; if (!serviceDenialDao.isServiceBlockedOnFacility(service.getId(), facility.getId())) { log.debug("[{}] Service {} is allowed on Facility {}.", task.getId(), service.getId(), facility.getId()); } else { log.debug("[{}] Service {} is blocked on Facility {}.", task.getId(), service.getId(), facility.getId()); return DENIED; while (iter.hasNext()) { Destination dest = iter.next(); if (serviceDenialDao.isServiceBlockedOnDestination(service.getId(), dest.getId())) { iter.remove(); log.debug("[{}] Removed blocked destination: {}", task.getId(), dest.toString()); + fixStringSeparators(task.getService().serializeToString()) + "]|[" + fixStringSeparators(task.getFacility().serializeToString()) + "]|[" + fixStringSeparators(destinations_s.toString()) + "]");
task.setService(service); task.setDestinations(destinationList); task.setDelay(service.getDelay()); task.setRecurrence(service.getRecurrence()); task.setPropagationForced(Boolean.parseBoolean(eventIsForced));
schedulingPool.scheduleTask(task, -1); } else if (howManyMinutesAgo >= recurrence * task.getDelay() && recurrence <= task.getService().getRecurrence()) {
@Override public String serializeToString() { StringBuilder str = new StringBuilder(); String dateString; if(timestamp != null) dateString = BeansUtils.getDateFormatter().format(timestamp); else dateString = "\\0"; return str.append(this.getClass().getSimpleName()).append(":[").append( "id=<").append(getId()).append(">").append( ", taskId=<").append(taskId).append(">").append( ", destinationId=<").append(destinationId).append(">").append( ", errorMessage=<").append(errorMessage== null ? "\\0" : BeansUtils.createEscaping(errorMessage.toString())).append(">").append( ", standardMessage=<").append(standardMessage== null ? "\\0" : BeansUtils.createEscaping(standardMessage.toString())).append(">").append( ", returnCode=<").append(returnCode).append(">").append( ", timestamp=<").append(dateString).append(">").append( ", status=<").append(status == null ? "\\0" : BeansUtils.createEscaping(status.toString())).append(">").append( ", service=<").append(service == null ? "\\0" : service.serializeToString()).append(">").append( ']').toString(); }
public boolean isBlockedGlobally() { return (service != null) && !service.isEnabled(); }
@Override public Task call() throws TaskExecutionException { getTask().setGenStartTime(new Date(System.currentTimeMillis())); Service service = getTask().getService(); log.info("[{}] Executing GEN worker for Task with Service ID: {} and Facility ID: {}.", getTask().getId(), getTask().getServiceId(), getTask().getFacilityId()); ProcessBuilder pb = new ProcessBuilder(service.getScript(), "-f", String.valueOf(getTask().getFacilityId())); try { // start the script and wait for results super.execute(pb); // set gen end time getTask().setGenEndTime(new Date(System.currentTimeMillis())); if (getReturnCode() != 0) { log.error("[{}] GEN worker failed for Task. Ret code {}, STDOUT: {}, STDERR: {}", getTask().getId(), getReturnCode(), getStdout(), getStderr()); throw new TaskExecutionException(task, getReturnCode(), getStdout(), getStderr()); } else { log.info("[{}] GEN worker finished for Task. Ret code {}, STDOUT: {}, STDERR: {}", getTask().getId(), getReturnCode(), getStdout(), getStderr()); return getTask(); } } catch (IOException e) { log.error("[{}] GEN worker failed for Task. IOException: {}.", task.getId(), e); throw new TaskExecutionException(task, e); } catch (InterruptedException e) { log.warn("[{}] GEN worker failed for Task. Execution was interrupted {}.", task.getId(), e); throw new TaskExecutionException(task, e); } }
public int getServiceId() { if (service != null) { return service.getId(); } else { return -1; } }
@Override public String serializeToString() { StringBuilder str = new StringBuilder(); return str.append(this.getClass().getSimpleName()).append(":[").append( "id=<").append(getId()).append(">").append( ", destination=<").append(super.getDestination() == null ? "\\0" : BeansUtils.createEscaping(super.getDestination())).append(">").append( ", type=<").append(super.getType() == null ? "\\0" : BeansUtils.createEscaping(super.getType())).append(">").append( ", facility=<").append(getFacility() == null ? "\\0" : getFacility().serializeToString()).append(">").append( ", service=<").append(getService() == null ? "\\0" : getService().serializeToString()).append(">").append( ']').toString(); }
if (!task.getService().isEnabled() || generalServiceManager.isServiceBlockedOnFacility(task.getService(), task.getFacility())) { log.error("[{}] Task NOT added to waiting queue, service is blocked: {}.", task.getId(), task);
service.getScript(), task.getFacility().getName(), sendTask.getDestination().getDestination(),
@Override public String serializeToString() { StringBuilder str = new StringBuilder(); return str.append(this.getClass().getSimpleName()).append(":[").append( "id=<").append(getId()).append(">").append( ", name=<").append(getName() == null ? "\\0" : BeansUtils.createEscaping(getName())).append(">").append( ", description=<").append(getDescription() == null ? "\\0" : BeansUtils.createEscaping(getDescription())).append(">").append( ", delay=<").append(this.getDelay()).append(">").append( ", recurrence=<").append(this.getRecurrence()).append(">").append( ", enabled=<").append(this.isEnabled()).append(">").append( ", script=<").append(getScript() == null ? "\\0" : BeansUtils.createEscaping(getScript())).append(">").append( ']').toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Task other = (Task) obj; if (!service.equals(other.service)) return false; if (!facility.equals(other.facility)) return false; if (id != other.id) return false; return true; }
public ServiceForGUI(Service service){ setId(service.getId()); setName(service.getName()); setDescription(service.getDescription()); setDelay(service.getDelay()); setRecurrence(service.getRecurrence()); setScript(service.getScript()); setEnabled(service.isEnabled()); }