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 }
public void loadPreviousConfigurations() throws IOException { // Activate the previous configuration this.reloadServiceConfigurations(reconfigurableServices, objIds); Logger.getLogger(PersistProviderConfiguration.class.getName()).log(Level.FINER, "The size of the objIds list is: " + objIds.size() + " and the size of the reconfigurableServices is: " + reconfigurableServices.size()); for (int i = 0; i < objIds.size(); i++) { final ReconfigurableService providerService = reconfigurableServices.get(i); final PersistLatestServiceConfigurationAdapter persistLatestConfig = new PersistLatestServiceConfigurationAdapter(providerService, objIds.get(i), this.archiveService, this.executor); providerService.setOnConfigurationChangeListener(persistLatestConfig); } }
public Boolean reconfigureLinks(LongList objIds, StatisticCreationRequestList statisticParameterDetailsList) { if (objIds.size() != statisticParameterDetailsList.size()) { return false; } statLinks.clear(); for (int i = 0; i < objIds.size(); i++) { statLinks.put(objIds.get(i), statisticParameterDetailsList.get(i)); } return true; }
@Override public void run() { dbBackend.createEntityManager(); // 0.166 ms // Generate the object Ids if needed and the persistence objects to be removed for (int i = 0; i < objIds.size(); i++) { final COMObjectEntityPK id = COMObjectEntity.generatePK(objTypeId, domainId, objIds.get(i)); COMObjectEntity perObj = dbBackend.getEM().find(CLASS_ENTITY, id); dbBackend.getEM().getTransaction().begin(); dbBackend.getEM().remove(perObj); dbBackend.getEM().getTransaction().commit(); } dbBackend.closeEntityManager(); // 0.410 ms generalExecutor.submit(publishEvents); } });
/** * Changes the current set of definitions available by the provided set. * * @param identityIds the identityIds of the parameters to be set * @param names the names of the parameters to be set * @param defIds the definitionsIds of the parameters to be set * @param definitions The object body of the definitions to be set * @return True if the configuration was successfully changed. False * otherwise. */ public synchronized Boolean reconfigureDefinitions(final LongList identityIds, final IdentifierList names, final LongList defIds, final ElementList definitions) { if (identityIds == null || names == null || defIds == null || definitions == null) { return false; } if (identityIds.size() != names.size() && defIds.size() != definitions.size() && identityIds.size() != defIds.size()) { return false; } this.identitiesToNamesMap.clear(); this.namesToPairsMap.clear(); this.objIdToDefMap.clear(); for (int i = 0; i < identityIds.size(); i++) { this.identitiesToNamesMap.put(identityIds.get(i), names.get(i)); this.namesToPairsMap.put(names.get(i), new ObjectInstancePair(identityIds.get(i), defIds.get(i))); this.objIdToDefMap.put(defIds.get(i), (Element) definitions.get(i)); } return true; }
/** * Changes the current set of definitions available by the provided set. * * @param objIds Object instance identifiers * @param definitions The object body of the definitions * @return True if the configuration was successfully changed. False * otherwise. */ public synchronized Boolean reconfigureDefinitions(LongList objIds, ElementList definitions) { if (objIds == null || definitions == null) { return false; } if (objIds.size() != definitions.size()) { return false; } defs.clear(); for (int i = 0; i < objIds.size(); i++) { defs.put(objIds.get(i), (Element) definitions.get(i)); } return true; }
public Long update(Long statLinkId, StatisticCreationRequest statLink, SingleConnectionDetails connectionDetails) { // requirement: 3.3.2.5 Long newLinkDefId; if (comServices.getArchiveService() == null) { newLinkDefId = ++uniqueObjIdLinkDef; // This line as to go before any writing (because it's initialized as zero and that's the wildcard) } else { try { StatisticLinkDetailsList links = new StatisticLinkDetailsList(); links.add(statLink.getLinkDetails()); LongList linkDefIds = comServices.getArchiveService().store( //requirement: 3.6.15.2.i true, StatisticHelper.STATISTICLINKDEFINITION_OBJECT_TYPE, ConfigurationProviderSingleton.getDomain(), HelperArchive.generateArchiveDetailsList(statLinkId, null, connectionDetails), links, null); newLinkDefId = linkDefIds.get(0); } catch (MALException ex) { Logger.getLogger(StatisticManager.class.getName()).log(Level.SEVERE, null, ex); return null; } catch (MALInteractionException ex) { Logger.getLogger(StatisticManager.class.getName()).log(Level.SEVERE, null, ex); return null; } } // requirement: 3.7.2.13 this.statLinks.put(statLinkId, statLink); this.statLinkDefIdsByStatLinkIds.put(statLinkId, newLinkDefId); return newLinkDefId; }
public Long storeAndGenerateAValobjId(AggregationValue aVal, Long related, ObjectId source, URI uri) { if (super.getArchiveService() == null) { uniqueObjIdAVal++; return this.uniqueObjIdAVal; } else { AggregationValueList aValList = new AggregationValueList(); aValList.add(aVal); try { //requirement: 3.7.4.d, 3.7.6.b LongList objIds = super.getArchiveService().store( true, AggregationHelper.AGGREGATIONVALUEINSTANCE_OBJECT_TYPE, ConfigurationProviderSingleton.getDomain(), HelperArchive.generateArchiveDetailsList(related, source, uri), //requirement: 3.7.4.e aValList, null); if (objIds.size() == 1) { return objIds.get(0); } } catch (MALException ex) { Logger.getLogger(ParameterManager.class.getName()).log(Level.SEVERE, null, ex); } catch (MALInteractionException ex) { Logger.getLogger(ParameterManager.class.getName()).log(Level.SEVERE, null, ex); } return null; } }
return objIds.get(0);
public Long update(Long identityId, ActionDefinitionDetails definition, ObjectId source, URI uri) { // requirement: 3.3.2.5 Long newDefId = null; if (super.getArchiveService() == null) { //only update locally //add to providers local list uniqueObjIdDef++; // This line as to go before any writing (because it's initialized as zero and that's the wildcard) newDefId = uniqueObjIdDef; } else { // update in the COM Archive try { ActionDefinitionDetailsList defs = new ActionDefinitionDetailsList(); defs.add(definition); //create a new ActionDefinition LongList defIds = super.getArchiveService().store(true, ActionHelper.ACTIONDEFINITION_OBJECT_TYPE, ConfigurationProviderSingleton.getDomain(), HelperArchive.generateArchiveDetailsList(identityId, source, uri), defs, null); newDefId = defIds.get(0); } catch (MALException ex) { Logger.getLogger(ParameterManager.class.getName()).log(Level.SEVERE, null, ex); } catch (MALInteractionException ex) { Logger.getLogger(ParameterManager.class.getName()).log(Level.SEVERE, null, ex); } } //update internal list this.updateDef(identityId, newDefId, definition); return newDefId; }
public Long update(final Long identityId, final AlertDefinitionDetails definition, final ObjectId source, final SingleConnectionDetails connectionDetails) { // requirement: 3.3.2.5 Long newDefId = null; if (super.getArchiveService() == null) { //only update locally //add to providers local list uniqueObjIdDef++; // This line as to go before any writing (because it's initialized as zero and that's the wildcard) newDefId = uniqueObjIdDef; } else { // update in the COM Archive try { AlertDefinitionDetailsList defs = new AlertDefinitionDetailsList(); defs.add(definition); //create a new AlertDefinition and add to the archive; requirement: 3.4.7.a LongList defIds = super.getArchiveService().store(true, AlertHelper.ALERTDEFINITION_OBJECT_TYPE, //requirement: 3.4.4.c ConfigurationProviderSingleton.getDomain(), HelperArchive.generateArchiveDetailsList(identityId, source, connectionDetails), //requirement: 3.4.4.d, 3.4.4.h defs, null); newDefId = defIds.get(0); } catch (MALException ex) { Logger.getLogger(ParameterManager.class.getName()).log(Level.SEVERE, null, ex); } catch (MALInteractionException ex) { Logger.getLogger(ParameterManager.class.getName()).log(Level.SEVERE, null, ex); } } this.updateDef(identityId, newDefId, definition); return newDefId; }
public synchronized void init() { // Retrieve all the ids and objectTypes from the Database dbBackend.createEntityManager(); // Get All the objectTypes available Query query = dbBackend.getEM().createQuery(QUERY_SELECT_OBJECTTYPE); List resultList = query.getResultList(); ArrayList<ObjectTypeHolderEntity> objectTypeHolderEntities = new ArrayList<ObjectTypeHolderEntity>(); objectTypeHolderEntities.addAll(resultList); dbBackend.closeEntityManager(); final IntegerList ids = new IntegerList(); final LongList objectTypes = new LongList(); // From the list of entities to separate lists of ids and objectTypeIds for (int i = 0; i < objectTypeHolderEntities.size(); i++) { ids.add(objectTypeHolderEntities.get(i).getId()); objectTypes.add(objectTypeHolderEntities.get(i).getObjectType()); } int max = 0; // Populate the variables on this class for (int i = 0; i < ids.size(); i++) { this.fastID.put(objectTypes.get(i), ids.get(i)); this.fastIDreverse.put(ids.get(i), objectTypes.get(i)); if (ids.get(i) > max) { // Get the maximum value max = ids.get(i); } } uniqueId = new AtomicInteger(max); }
return objIds.get(0);
private Long updateCheckLinkObject(Long checkLinkId, CheckLinkDetails checkLinkDetails, SingleConnectionDetails connectionDetails) { final Long oldCheckLinkDefId = this.getCheckLinkDefId(checkLinkId); super.updateCheckLinkDetails(oldCheckLinkDefId, checkLinkDetails); Long newCheckLinkDefId = 0L; if (super.getArchiveService() == null) { // It should also update in the COM Archive newCheckLinkDefId = ++uniqueObjIdLinkDef; } try { //Store the new CheckLinkDefinition-Object CheckLinkDetailsList linkDetails = new CheckLinkDetailsList(); linkDetails.add(checkLinkDetails); LongList checkLinkDefIds = super.getArchiveService().store( //requirement: 3.5.7.d true, CheckHelper.CHECKLINKDEFINITION_OBJECT_TYPE, //requirement: 3.5.4.h ConfigurationProviderSingleton.getDomain(), HelperArchive.generateArchiveDetailsList(checkLinkId, null, connectionDetails), //requirement: 3.5.18.2.b, 3.5.4.i linkDetails, //requirement: 3.5.18.2.a null); newCheckLinkDefId = checkLinkDefIds.get(0); } catch (MALException ex) { Logger.getLogger(CheckManager.class.getName()).log(Level.SEVERE, null, ex); } catch (MALInteractionException ex) { Logger.getLogger(CheckManager.class.getName()).log(Level.SEVERE, null, ex); } return newCheckLinkDefId; }
ConfigurationHelper.SERVICECONFIGURATION_OBJECT_TYPE, ConfigurationProviderSingleton.getDomain(), HelperArchive.generateArchiveDetailsList(objIds1.get(0), null, ConfigurationProviderSingleton.getNetwork(), new URI(""), defaultObjId), serviceKeyList,
/** * if the aggregation periodic expired, the parameters is periodic and the * value didnt change then the parameter that will be saved must be of the * validity-state: EXPIRED * * @param identityId The identity Id. * @param indexOfparameterSet * @param aggrParamSet * @param newParameterValueSamples * @return */ private AggregationParameterValueList checkForExpiredValues(Long identityId, int indexOfparameterSet, AggregationParameterSet aggrParamSet, AggregationParameterValueList newParameterValueSamples) { final AggregationParameterValueList currentParamValues = this.periodicAggregationValuesCurrent.get(identityId).getParameterSetValues().get(indexOfparameterSet).getValues(); //requirement: 3.3.3.i (ParameterService-requirement) //if sendUnchanged is true: replace validity-state with an EXPIRED state //todo: try to let the ParameterService set the EXPIRED state and not the AggregationService if (currentParamValues != null) { for (int k = 0; k < currentParamValues.size(); k++) { final ParameterDefinitionDetails paramDef = parameterManager.getParameterDefinition(aggrParamSet.getParameters().get(k)); if (paramDef.getGenerationEnabled() && paramDef.getReportInterval().getValue() != 0) { if (currentParamValues.get(k).getValue().getRawValue().equals(newParameterValueSamples.get(k).getValue().getRawValue())) { newParameterValueSamples.get(k).getValue().setValidityState(new UOctet(new Short("" + ValidityState.EXPIRED_NUM_VALUE))); } } } } return newParameterValueSamples; }
private static ObjectIdList generateSources(final ObjectType objType, final IdentifierList domain, final LongList objIds) { final ObjectIdList sourceList = new ObjectIdList(objIds.size()); for (int i = 0; i < objIds.size(); i++) { final ObjectId source = new ObjectId(objType, new ObjectKey(domain, objIds.get(i))); // Is the COM Object an Event coming from the archive? if (source.getType().equals(HelperCOM.generateCOMObjectType(ArchiveHelper.ARCHIVE_SERVICE, source.getType().getNumber()))) { continue; // requirement: 3.4.2.5 } sourceList.add(source); } return sourceList; }
Long identityId = alertIdentityIds.get(index); if (identityId == 0) { // Is it the wildcard '0'? requirement: 3.4.12.2.b
tempLong = objInstIds.get(index);
private IdObjectTypeList getGroupObjectIdsFromGroupRecursive(GroupDetails group, LongList previousGroupInstances) { if (archiveService == null || group == null) { // If there's no archive... return null; } //easiest case: group contains non-group-instances //requirement: 3.9.4.h if (!group.getObjectType().equals(GroupHelper.GROUPIDENTITY_OBJECT_TYPE)) { // It is no group of groups? return new IdObjectTypeList(group.getInstanceIds(), group.getObjectType()); } else { //solve a case with less complexity: get the instances of the groups groups final LongList groupsGroupIdentityIds = group.getInstanceIds(); //the recursive method-calls should not check the instances that will be checked during the iterations in this method call LongList newPreviousGroupInstances = new LongList(); newPreviousGroupInstances.addAll(previousGroupInstances); newPreviousGroupInstances.addAll(groupsGroupIdentityIds); //iterate through all new Groups and add all their instances to the final list IdObjectTypeList idObjectTypeList = new IdObjectTypeList(); for (int i = 0; i < groupsGroupIdentityIds.size(); i++) { final Long groupInstance = groupsGroupIdentityIds.get(i); //this group wasnt checked yet? if (!previousGroupInstances.contains(groupInstance)) { previousGroupInstances.add(groupInstance); // Retrieve the groups group-ids from the archive // requirement: 3.9.4.h GroupDetails nextGroupInstance = retrieveGroupDetailsFromArchive(group.getDomain(), groupInstance); idObjectTypeList.addAll(this.getGroupObjectIdsFromGroupRecursive(nextGroupInstance, newPreviousGroupInstances)); } } return idObjectTypeList; } }