@Override public EventResult action() throws EventExecutionException { int asId = isSetASID() ? getASID() : InterDomainManager.getInstance().getDefaultDomain().getASID(); int tmId; try { tmId = isSetTMID() ? getTMID() : TrafficMatrixManager.getInstance().getDefaultTrafficMatrixID(asId); } catch (InvalidTrafficMatrixException ex) { throw new EventExecutionException(ex); } ExternalRouting output; try { output = RoutingTools.execExternalCommand(getCmd(), asId, tmId); RoutingTools.applyExternalRouting(getLlcId(), asId, tmId, output); } catch (ExternalRoutingException ex) { logger.warn(ex); } return new EventResult(); }
/** @see be.ac.ulg.montefiore.run.totem.scenario.model.Event#action() */ public EventResult action() throws EventExecutionException { logger.debug("Processing an bgpAwareIGPWO event - ASID: " + _ASID); try { int asId = isSetASID() ? _ASID : InterDomainManager.getInstance().getDefaultDomain().getASID(); int[] tmIds; if (this.getTrafficMatrix().size() == 0) { tmIds = new int[] {TrafficMatrixManager.getInstance().getDefaultTrafficMatrixID(asId)}; } else { List list = this.getTrafficMatrix(); tmIds = new int[list.size()]; int i = 0; for (Iterator iter = list.iterator(); iter.hasNext(); ++i) { IGPWOCalculateWeightsType.TrafficMatrixType tm = (IGPWOCalculateWeightsType.TrafficMatrixType) iter.next(); tmIds[i] = tm.getTMID(); } } bgpAwareIGPWO bgpAwareIgpwo = (bgpAwareIGPWO) RepositoryManager.getInstance().getAlgo("bgpAwareIGPWO", asId); int nbIter = isSetNbIter() ? _NbIter : 150; int maxPossibleWeight = isSetMaxPossibleWeight() ? _MaxPossibleWeight : 50; int seed = isSetSeed() ? _Seed : 0; boolean interDomainTE = isSetInterdomainTE() ? _InterdomainTE : true; boolean randomInitialArray = true; if (isSetInitialWeightArray() && (getInitialWeightArray() == IgpwoInitialWeightArrayType.CURRENT)) { randomInitialArray = false; } SamplingRateType samplingRate = getSamplingRate(); float maxSamplingRate, minSamplingRate, initialSamplingRate; if (samplingRate == null) { maxSamplingRate = 0.4f; minSamplingRate = 0.01f; initialSamplingRate = 0.2f; } else { maxSamplingRate = samplingRate.isSetMax() ? samplingRate.getMax() : 0.4f; minSamplingRate = samplingRate.isSetMin() ? samplingRate.getMin() : 0.01f; initialSamplingRate = samplingRate.isSetInitial() ? samplingRate.getInitial() : 0.2f; } long time = System.currentTimeMillis(); TotemActionList actionList = bgpAwareIgpwo.calculateWeightsParameters( asId, tmIds, nbIter, maxPossibleWeight, randomInitialArray, seed, minSamplingRate, maxSamplingRate, initialSamplingRate, interDomainTE); time = System.currentTimeMillis() - time; System.out.println( "bgpAwareIGPWO takes " + time + " ms to compute weights on domain ASID" + _ASID); logger.info("bgpAwareIGPWO takes " + time + " ms to compute weights on domain ASID" + _ASID); double[] newLinkWeights = null; for (Iterator iter = actionList.iterator(); iter.hasNext(); ) { TotemAction action = (TotemAction) iter.next(); if (action instanceof UpdateIGPWeightsAction) { newLinkWeights = ((UpdateIGPWeightsAction) action).getWeights(); } action.execute(); } return new EventResult(newLinkWeights); } catch (Exception e) { logger.error("An exception occurred. Message: " + e.getMessage()); throw new EventExecutionException(e); } }