@XmlElement public long getValue() { return ((TimeResource) res).getValue(); }
public static long getInterval(final TimeResource itvRes, long defaultItv) { long proposed = 0; if (itvRes.isActive()) proposed = itvRes.getValue(); if (proposed < MIN_SUPERVISION_ITV) { proposed = defaultItv; itvRes.<TimeResource> create().setValue(defaultItv); itvRes.activate(false); } return proposed; }
private static RecordedData getHistoricalData(SingleValueResource resource) { RecordedData rd = null; if (resource instanceof FloatResource) rd = ((FloatResource) resource).getHistoricalData(); else if (resource instanceof IntegerResource) rd = ((IntegerResource) resource).getHistoricalData(); else if (resource instanceof TimeResource) rd = ((TimeResource) resource).getHistoricalData(); else if (resource instanceof BooleanResource) rd = ((BooleanResource) resource).getHistoricalData(); else throw new IllegalArgumentException("Logging not possible for resource of type " + resource.getResourceType().getName()); return rd; }
private int performAttempt() { int code; if((serverUnavailableUntil != null) && (serverUnavailableUntil.getValue() > appMan.getFrameworkTime())) { code = -2; } else { code = FileUploadUtil.sendFile(sourceToUse, dest, user, pw, serverPortAddress, appMan); if(((code == -2)||(code == -3))&&(serverUnavailableUntil != null)) { serverUnavailableUntil.setValue(appMan.getFrameworkTime()+retryInterval/2); } } attemptCount++; setStatus(code); return code; }
private ScheduleReductionAction getResourceFromConfig(TimeSeriesReduction config, long ageThreshold) { ScheduleReductionAction resource = null; if (config instanceof DeletionAction) { resource = this.config.actions().getSubResource(getNextActionName(), ScheduleDeletionAction.class).create(); } else if (config instanceof InterpolationAction) { resource = this.config.actions().getSubResource(getNextActionName(), ScheduleDownsamplingAction.class).create(); ((ScheduleDownsamplingAction) resource).minInterval().<TimeResource> create().setValue(((InterpolationAction) config).getMinInterval()); } else if (config instanceof StepsReductionAction) { resource = this.config.actions().getSubResource(getNextActionName(), ScheduleStepsReductionAction.class).create(); } else throw new IllegalArgumentException("TimeSeriesReduction must be either a deletion action or a interpolation action; got " + config.getClass().getName() ); if (resource != null) { resource.ageThreshold().<TimeResource> create().setValue(ageThreshold); } return resource; }
@Override public void timerElapsed(Timer timer /* may be null */) { if (!ramCheckSemaphore.tryAcquire()) return; try { final Runtime runtime = Runtime.getRuntime(); runtime.gc(); final long used = ( runtime.totalMemory() - runtime.freeMemory()); final long memMax = runtime.maxMemory(); config.results().usedMemorySize().<TimeResource> create().setValue(used); config.results().maxAvailableMemorySize().<TimeResource> create().setValue(memMax); // should not really change config.results().usedMemorySize().activate(false); config.results().maxAvailableMemorySize().activate(false); appMan.getLogger().info("RAM used: {} MB, max. RAM available: {}", (used/mb), (memMax/mb)); } finally { ramCheckSemaphore.release(); } } };
@Override protected void setResourceValue(TimeResource resource, String value, OgemaHttpRequest req) { try { resource.setValue(getTimeValue(value, getData(req).getInterval())); } catch (Exception e) { // ignore: we do not want to write user data to the log } }
switch (dataType.getDataType()) { case 0: ts = tr.getHistoricalData(); break; case 1: ts = tr.forecast(); break; case 2: ts = tr.program(); break;
protected boolean needsPushListener() { if (isRecursivePushTrigger()) return true; return !con.pushInterval().isActive(); }
public void onGET(OgemaHttpRequest req) { TimeResource source = getResource(sva, req, null); if ((source == null)||(!source.isActive())) { myLabel.setText("n.a.", req); return; switch(mode) { case 1: time = StringFormatHelper.getFormattedTimeOfDay(source.getValue()); break; case 2: if(source.getValue() <= 0) time = "not set"; else time = StringFormatHelper.getFormattedAgoValue(appMan, source); break; case 3: if(source.getValue() <= 0) time = "not set"; else time = StringFormatHelper.getFormattedFutureValue(appMan, source); break; case 4: if(source.getValue() <= 0) time = "not set"; else time = TimeUtils.getDateString(source.getValue()); break; default: if(source.getValue() <= 0) time = "not set"; else time = TimeUtils.getDateAndTimeString(source.getValue());
@Override public void timerElapsed(Timer timer /* may be null */) { if (!diskCheckSemaphore.tryAcquire()) return; try { final long dataSize = size(Paths.get("./data")); final long rundirSize = size(Paths.get(".")); long free = Long.MIN_VALUE; try { free = Files.getFileStore(Paths.get("/")).getUsableSpace(); } catch (IOException e) { appMan.getLogger().warn("Error determining free disk space",e); } config.results().rundirFolderSize().<TimeResource> create().setValue(rundirSize); config.results().dataFolderSize().<TimeResource> create().setValue(dataSize); if (free != Long.MIN_VALUE) config.results().freeDiskSpace().<TimeResource> create().setValue(free); config.results().rundirFolderSize().activate(false); config.results().dataFolderSize().activate(false); config.results().freeDiskSpace().activate(false); appMan.getLogger().info("Rundir folder size: {} MB, data folder: {} MB, free disk space: {} MB", (rundirSize/mb), (dataSize/mb), (free != Long.MIN_VALUE ? (free/mb) : "n.a.")); } finally { diskCheckSemaphore.release(); } } };
/** * Set the resource value. The <code>value</code> parameter must be parsable to the primitive (or String) * value type of <code>resource</code>. For instance, if <code>resource</code> is a {@link FloatResource}, * then <code>value</code> must be parsable as float. * @param resource * @param value * @throws NumberFormatException */ public static void setValue(SingleValueResource resource, String value) throws NumberFormatException { if (resource instanceof StringResource) { ((StringResource) resource).setValue(value); } else if (resource instanceof FloatResource) { ((FloatResource) resource).setValue(Float.parseFloat(value)); } else if (resource instanceof IntegerResource) { ((IntegerResource) resource).setValue(Integer.parseInt(value)); } else if (resource instanceof BooleanResource) { ((BooleanResource) resource).setValue(Boolean.parseBoolean(value)); } else if (resource instanceof TimeResource) { ((TimeResource) resource).setValue(Long.parseLong(value)); } }