private void startReportingTimer(final Long statLinkId, final Duration interval, boolean immediateReport) { updateTimerList.get(statLinkId).scheduleAtFixedRate(new TimerTask() { @Override public void run() { //requirement: 3.6.2.h, 3.6.3.b if (active) { reportStatistic(statLinkId); } } }, immediateReport ? 0 : (int) (interval.getValue() * 1000), (int) (interval.getValue() * 1000)); //requirement: 3.6.2.h, 3.6.3.b }
private void startTimer(final Long identityId, final Duration interval, final boolean useConverted) { // requirement: 3.6.2.g sampleTimerList.get(identityId).scheduleAtFixedRate(new TimerTask() { @Override public void run() { // Periodic sampling if (active) { sampleParamValue(identityId, useConverted); } } // the time has to be converted to milliseconds by multiplying by 1000 }, 0, (int) (interval.getValue() * 1000)); // requirement: 3.6.2.g }
private void startUpdatesTimer(final Long checkLinkId, final Duration interval) { updateTimerList.get(checkLinkId).scheduleAtFixedRate(new TimerTask() { @Override public void run() { try { //paramId is null for compound check final ObjectId paramSource = manager.getCheckLinkLinks(checkLinkId).getSource(); //requirement: 3.5.4.m -> Source Object = null manager.executeCheck(checkLinkId, paramSource == null ? null : parameterManager.getParameterValue(paramSource.getKey().getInstId()), false, true, null); } catch (MALInteractionException ex) { Logger.getLogger(CheckProviderServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } } // the time is being converted to milliseconds by multiplying by 1000 (starting delay included) }, (int) (interval.getValue() * 1000), (int) (interval.getValue() * 1000)); // requirement: 3.5.3.ff }
private void startFilterTimeoutTimer(final Long identityId, final Duration interval) { filterTimeoutTimerList.get(identityId).scheduleAtFixedRate(new TimerTask() { @Override public void run() { // requirement: 3.7.2.a.c, 3.7.3.n if (active) { manager.setFilterTriggered(identityId, true); //get the new samples and update the aggregation in the internal list for (int index = 0; index < manager.getAggregationDefinition(identityId).getParameterSets().size(); index++) { manager.sampleParam(identityId, index); } //publish the values in the internal list publishPeriodicAggregationUpdate(identityId, manager.getAggregationValue(identityId, GenerationMode.FILTERED_TIMEOUT)); manager.resetAggregationSampleHelperVariables(identityId); } } // the time is being converted to milliseconds by multiplying by 1000 }, 0, (int) (interval.getValue() * 1000)); }
private void startTimer(final Long checkLinkId, Duration interval) { // requirement: 3.7.2.11 sampleTimerList.get(checkLinkId).scheduleAtFixedRate(new TimerTask() { @Override public void run() { // Periodic Checking if (active) { try { final ObjectId paramId = manager.getCheckLinkLinks(checkLinkId).getSource(); //todo: the source link should be the ObjectId-of the parameterValue manager.executeCheck(checkLinkId, paramId == null ? null : parameterManager.getParameterValue(manager.getCheckLinkLinks(checkLinkId).getSource().getKey().getInstId()), false, false, null); } catch (MALInteractionException ex) { Logger.getLogger(CheckProviderServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } } } // the time has to be converted to milliseconds by multiplying by 1000 }, 0, (int) (interval.getValue() * 1000)); // requirement: 3.6.2.g }
/** * * @param identityId * @param interval */ private void startTimer(final Long identityId, final Duration interval) { // requirement: 3.3.3.c timerList.get(identityId).scheduleAtFixedRate(new TimerTask() { @Override public void run() { if (active) { if (identityId == -1) { return; } if (manager.getParameterDefinition(identityId).getGenerationEnabled()) { publishPeriodicParameterUpdate(identityId); } } } }, 0, (int) (interval.getValue() * 1000)); // the time has to be converted to milliseconds by multiplying by 1000 }
private static Long removeExpiredSamples(Long now, ReferenceValue referenceValue, final HashMap<Long, Attribute> sampleTimes) { //check how many samples checked(= how many param exist in the hashmap) in the duration (now - deltaTime) //samples sampled before the deltaLimit are not important anymore Long deltaLimit = now - Math.round(referenceValue.getDeltaTime().getValue()); for (Long sampleTime : sampleTimes.keySet()) { if (sampleTime < deltaLimit) { sampleTimes.remove(sampleTime); } } return now; }
private void startTimer(final int index, Duration interval) { // requirement: 3.7.2.11 final Long identityId = aggregationObjIdList.get(index); final int indexOfparameterSet = parameterSetIndexList.get(index); sampleTimerList.get(index).scheduleAtFixedRate(new TimerTask() { @Override public void run() { if (active) { // To prevent race conditions with the other timer synchronized (lock) { //create the new paraemtersamples and set them if filter triggered or not enabled manager.sampleAndFilterParam(identityId, indexOfparameterSet); } } } }, 0, (int) (interval.getValue() * 1000)); // the time has to be converted to milliseconds by multiplying by 1000 }
@Override public void encodeDuration(final Duration value) throws MALException { try { checkForNull(value); outputStream.addDouble(value.getValue()); } catch (IOException ex) { throw new MALException(ENCODING_EXCEPTION_STR, ex); } }
@Override public void encodeDuration(final Duration value) throws MALException { try { checkForNull(value); outputStream.addDouble(value.getValue()); } catch (IOException ex) { throw new MALException(ENCODING_EXCEPTION_STR, ex); } }
private void addPeriodicSampling(Long identityId) { final AggregationDefinitionDetails aggrDef = manager.getAggregationDefinition(identityId); if (!aggrDef.getGenerationEnabled()) { return; // Periodic Sampling shall not occur if the generation is not enabled at the definition level } final int parameterSetsTotal = aggrDef.getParameterSets().size(); int index = sampleTimerList.size(); for (int indexOfParameterSet = 0; indexOfParameterSet < parameterSetsTotal; indexOfParameterSet++) { Duration sampleInterval = aggrDef.getParameterSets().get(indexOfParameterSet).getSampleInterval(); //means ad hoc value, dont add to sample timer if (sampleInterval.getValue() > aggrDef.getReportInterval().getValue()) { sampleInterval = new Duration(0); } // Add to the Periodic Sampling Manager only if there's a sampleInterval selected for the parameterSet if (sampleInterval.getValue() != 0) { aggregationObjIdList.add(index, identityId); parameterSetIndexList.add(index, indexOfParameterSet); Timer timer = new Timer(); // Take care of adding a new timer sampleTimerList.add(index, timer); startTimer(index, sampleInterval); index++; } } }
private void addPeriodicCollecting(Long objId) { final StatisticCreationRequest statLink = manager.getStatisticLink(objId); if (!statLink.getLinkDetails().getReportingEnabled()) { return; // Periodic Sampling shall not occur if the generation is not enabled at the definition level } Duration collectionInterval = statLink.getLinkDetails().getCollectionInterval(); // Add to the Periodic Collection Manager if (collectionInterval.getValue() != 0) { Timer timer = new Timer(true); // Take care of adding a new timer collectionTimerList.put(objId, timer); startTimer(objId, collectionInterval); } }
private void addPeriodicSampling(Long identityId) { final StatisticCreationRequest statLink = manager.getStatisticLink(identityId); //requirement 3.6.2.n.b: Periodic Sampling shall not occur if the generation was disabled. So if it was never enabled nothing happens. If is was already enabled it should not even reach this code as the refresh-method will not be called in the enabledGeneration-operation //if (!statLink.getLinkDetails().getReportingEnabled()) { // return; //} // Add to the Periodic Sampling Manager only if there's a sampleInterval selected for the parameterSet // NOTE: The standard says its "perfectly possible" to set a sampleInterval greater than a reporting or collection interval so no other checks of the sampleinterval necessary here Duration sampleInterval = statLink.getLinkDetails().getSamplingInterval(); if (sampleInterval.getValue() != 0) { Timer timer = new Timer(true); // Take care of adding a new timer sampleTimerList.put(identityId, timer); startTimer(identityId, sampleInterval, statLink.getLinkDetails().getUseConverted()); } }
/** * refreshes the interval for periodic updates of the parameter with the * given identityId * * @param objId the identityId of the Parameter * */ public void refresh(Long identityId) { if (timerList.containsKey(identityId)) { // Does it exist in the Periodic Manager? this.removePeriodicReporting(identityId); } // get parameter definition ParameterDefinitionDetails pDef = manager.getParameterDefinition(identityId); if (pDef != null) { // Does it exist in the Parameter Definitions List? //requirement: 3.3.3.d if (pDef.getReportInterval().getValue() != 0 && pDef.getGenerationEnabled()) { // Is the periodic reporting active? this.addPeriodicReporting(identityId); } } }
/** * checks if the sampleInterval is 0 or greater than the updateInterval of * the given definition. if it is, it samples new parameters and check if * the filter was triggered. if it was triggerd, or no filter was enabled, * the values will be set to the internal list * * @param identityId the identity id of the aggregation-definito to be * @param aggrExpired should be set to true, if the aggregation that is * sampling the parameter is periodic and the aggregation period is up. */ private void checkSampleIntervalAndSampleParam(Long identityId, boolean aggrExpired) { final AggregationDefinitionDetails def = manager.getAggregationDefinition(identityId); //check the sampleInterval final AggregationParameterSetList parameterSets = def.getParameterSets(); for (int i = 0; i < parameterSets.size(); i++) { final double sampleInterval = parameterSets.get(i).getSampleInterval().getValue(); //If '0' or if its greater than the updateInterval then just a single sample of the parameters is required per aggregation update if (sampleInterval == 0 || (sampleInterval > def.getReportInterval().getValue())) { checkFilterAndSampleParam(identityId, aggrExpired); } } }
public void refresh(Long identityId) { // get Aggregation Definition AggregationDefinitionDetails aDef = manager.getAggregationDefinition(identityId); if (updateTimerList.containsKey(identityId)) { // Does it exist in the Periodic Reporting Manager? this.removePeriodicReporting(identityId); } if (filterTimeoutTimerList.containsKey(identityId)) { // Does it exist in the filter-timeout timerlist already? this.removeFilteredTimeoutReporting(identityId); } if (aDef != null) { // Does it exist in the Aggregation Definitions List? if (aDef.getGenerationEnabled()) { //requirement 3.7.3.a, 3.7.3.b manager.populateAggregationValues(identityId); // Reset the Sampling Values if (aDef.getReportInterval().getValue() != 0) { // Is the periodic reporting active? (requirement: 3.7.3.i, 3.7.9.2.k) this.addPeriodicReporting(identityId); } //AD-HOC aggregations can also have a filter and must be added to the filtered-timeout-list in this case if (aDef.getFilterEnabled() && aDef.getFilteredTimeout().getValue() != 0) { // requirement 3.7.3.j this.addFilteredTimeoutReporting(identityId); } } } else { //aggregation was removed manager.removeAggregationValues(identityId); } }
private void refresh(Long objId, boolean immediateReport) { if (updateTimerList.containsKey(objId)) { // Does it exist in the Periodic Reporting Manager? this.removePeriodicReporting(objId); } // getStatisticLink aggregation definition StatisticCreationRequest statLink = manager.getStatisticLink(objId); if (statLink != null) { // Does it exist in the Statistic Links List? if (statLink.getLinkDetails().getReportingInterval().getValue() != 0 //requirement: 3.6.3.c && statLink.getLinkDetails().getReportingEnabled()) { // Is the periodic reporting active? this.addPeriodicReporting(objId, immediateReport); } } //TODO: needed here? // manager.getDataSets().resetEvaluation(objId); // Reset the Evaluation }
public void refresh(Long checkLinkId) { if (sampleTimerList.containsKey(checkLinkId)) { // Does it exist in the PeriodicCheckingManager? this.removePeriodicChecking(checkLinkId); } final CheckLinkDetails checkLink = manager.getCheckLinkDetails(manager.getCheckLinkDefId(checkLinkId)); if (checkLink != null // Does it exist? && manager.getCheckServiceEnabled() //checkService globally enabled //TODO: should newly added checkLinks, that were added while the service is disabled, be added or not? -> issue #24 && checkLink.getCheckEnabled() //checkservice enabled on checkDefinition-layer && checkLink.getCheckInterval().getValue() != 0 //3.5.3.l && !checkLink.getCheckOnChange() //3.5.3.k: checkOnChange must be false for periodic checks //TODO: INVALID error if CHECKONCHANGE and CHECKINTERVAL? -> issue #162 ) { this.addPeriodicChecking(checkLinkId, checkLink.getCheckInterval()); } }
public void refresh(Long checkLinkId) { if (updateTimerList.containsKey(checkLinkId)) { // Does it exist in the Periodic Reporting Manager? this.removePeriodicReportingMax(checkLinkId); } CheckLinkDetails checkLink = manager.getCheckLinkDetails(manager.getCheckLinkDefId(checkLinkId)); if (checkLink != null) { // Does it exist in the CheckLinks List? CheckDefinitionDetails checkDef = manager.getActualCheckDefinitionFromCheckLinks(checkLinkId); if (checkDef.getMaxReportingInterval().getValue() != 0 // Is the periodic reporting active? && manager.getCheckServiceEnabled() //checkService globally enabled //TODO: should newly added checkLinks, that were added while the service is disabled, be added or not? -> issue #24 && checkLink.getCheckEnabled() //enabled on the definition layer ) { this.addPeriodicReportingMax(checkLinkId, checkDef.getMaxReportingInterval()); } } }
@Override public void run() { // Periodic sampling if (active) { manager.getDataSets().lock(); // Lock the Sets StatisticCreationRequest link = manager.getStatisticLink(statLinkId); //publish if the intervals dont align if (link.getLinkDetails().getCollectionInterval().getValue() % link.getLinkDetails().getReportingInterval().getValue() != 0) //requirement: 3.6.3.e { // Retrieve the Statistic Link generateAndAddStatisticEvaluationReport(link); Long statLinkDefId = manager.getStatisticLinkDefinitionId(statLinkId); publishStatisticsUpdate(statLinkId, statLinkDefId, manager.getStatisticEvaluationReport(statLinkId).getValue(), null); } // Reset the evaluations if (link.getLinkDetails().getResetEveryCollection()) { manager.getDataSets().resetDataSet(statLinkId); // requirement: 3.6.2.f } manager.getDataSets().unlock(); // Unlock the Sets } }