OLM timer values are defined by OpenROADM whitepaper specifications.
For this reason, they are hardcoded with constants in the current code.
Though, there are at least 2 reasons to make them configurable:
1- At least one vendor product needs more than the OpenROADM whitepaper
recommandation because it is not supporting GainLoss with
target-output-power.
2- The OlmUtils constants are patched in functional tests to speed-up
tests because the simulators needs less time to set the OLM up than
real devices.
As a consequence,
- remove OlmUtils timers constants
- remove related command to patch them in tests scripts
- create a new constructor PowerMgmtImpl to allow any timers values
- modify OLM OSGi blueprint to set default values for these timers
(Default values are the ones recommended in the OpenROADM whitepaper)
- modify lighty build to retrieve these timers from new CLI options
- adapt tests scripts and assembly ressources accordingly
JIRA: TRNSPRTPCE-496
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I71f9bdfd38c11ea3427ca2e661cd3590bc2863bf
sed -e 's/1099/ODL_RMI_REGISTRY_PORT/' -e 's/44444/ODL_RMI_SERVER_PORT/' ../etc/org.apache.karaf.management.cfg > org.apache.karaf.management._template.cfg
sed 's/^[#|]websocket-port=8185/websocket-port=ODL_WEBSOCKET_PORT/' ../system/org/opendaylight/netconf/sal-rest-connector-config/[0-9.]*/sal-rest-connector-config-[0-9.]*-restconf.cfg >org.opendaylight.restconf._template.cfg
+echo 'timer1=3000' >../etc/org.opendaylight.transportpce.olm.cfg
+echo 'timer2=2000' >>../etc/org.opendaylight.transportpce.olm.cfg
+
sed -i'_' -e '1 a\
\
. \$(dirname \$0)/\.\./\.\./\.\./\.\./tests/reflectwarn.sh\
cat akka-default_template.conf | sed -e "s/ODL_AKKA_PORT/$AKKA_PORT/" -e "s/ODL_AKKA_MGT_PORT/$AKKA_MGT_PORT/" >singlenode/akka-default.conf
#start controller
-java -ms128m -mx512m -XX:MaxMetaspaceSize=128m -jar tpce.jar -restconf config.json
+java -ms128m -mx512m -XX:MaxMetaspaceSize=128m -jar tpce.jar -restconf config.json -olmtimer1 3000 -olmtimer2 2000
public class Main {
private static final String RESTCONF_OPTION_NAME = "restconf";
-
private static final String NBINOTIFICATION_OPTION_NAME = "nbinotification";
+ private static final String OLMTIMER1_OPTION_NAME = "olmtimer1";
+ private static final String OLMTIMER2_OPTION_NAME = "olmtimer2";
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
private ShutdownHook shutdownHook;
public void start() {
- start(null, false, false);
+ start(null, false, null, null, false);
}
@SuppressWarnings("checkstyle:Illegalcatch")
- public void start(String restConfConfigurationFile, boolean activateNbiNotification, boolean registerShutdownHook) {
+ public void start(String restConfConfigurationFile, boolean activateNbiNotification,
+ String olmtimer1, String olmtimer2, boolean registerShutdownHook) {
long startTime = System.nanoTime();
TpceBanner.print();
RestConfConfiguration restConfConfig = null;
// 3. NETCONF SBP configuration
NetconfConfiguration netconfSBPConfig = NetconfConfigUtils.createDefaultNetconfConfiguration();
startLighty(singleNodeConfiguration, restConfConfig, netconfSBPConfig, registerShutdownHook,
- activateNbiNotification);
+ activateNbiNotification, olmtimer1, olmtimer2);
float duration = (System.nanoTime() - startTime) / 1_000_000f;
LOG.info("lighty.io and RESTCONF-NETCONF started in {}ms", duration);
} catch (ConfigurationException | ExecutionException | IOException e) {
.hasArg(false)
.required(false)
.build();
+ Option olmTimer1Option = Option.builder(OLMTIMER1_OPTION_NAME)
+ .desc("OLM timer 1 value")
+ .argName(OLMTIMER1_OPTION_NAME)
+ .hasArg(true)
+ .required(false)
+ .build();
+ Option olmTimer2Option = Option.builder(OLMTIMER2_OPTION_NAME)
+ .desc("OLM timer 2 value")
+ .argName(OLMTIMER1_OPTION_NAME)
+ .hasArg(true)
+ .required(false)
+ .build();
Options options = new Options();
options.addOption(restconfFileOption);
options.addOption(useNbiNotificationsOption);
+ options.addOption(olmTimer1Option);
+ options.addOption(olmTimer2Option);
return options;
}
private void startLighty(ControllerConfiguration controllerConfiguration,
RestConfConfiguration restConfConfiguration, NetconfConfiguration netconfSBPConfiguration,
- boolean registerShutdownHook, boolean activateNbiNotification)
+ boolean registerShutdownHook, boolean activateNbiNotification, String olmtimer1, String olmtimer2)
throws ConfigurationException, ExecutionException, InterruptedException {
// 1. initialize and start Lighty controller (MD-SAL, Controller, YangTools,
netconfSouthboundPlugin.start().get();
// 4. start TransportPCE beans
- TransportPCE transportPCE = new TransportPCEImpl(lightyController.getServices(), activateNbiNotification);
+ TransportPCE transportPCE = new TransportPCEImpl(lightyController.getServices(), activateNbiNotification,
+ olmtimer1, olmtimer2);
transportPCE.start().get();
// 5. Register shutdown hook for graceful shutdown.
CommandLine commandLine = new DefaultParser().parse(options, args);
String restConfConfigurationFile = commandLine.getOptionValue(RESTCONF_OPTION_NAME, null);
boolean useNbiNotifications = commandLine.hasOption(NBINOTIFICATION_OPTION_NAME);
+ String olmtimer1 = commandLine.getOptionValue(OLMTIMER1_OPTION_NAME, null);
+ String olmtimer2 = commandLine.getOptionValue(OLMTIMER2_OPTION_NAME, null);
Main app = new Main();
- app.start(restConfConfigurationFile, useNbiNotifications, true);
+ app.start(restConfConfigurationFile, useNbiNotifications, olmtimer1, olmtimer2, true);
} catch (ParseException e) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(
"java -ms<size> -mx<size> -XX:MaxMetaspaceSize=<size> -jar tpce.jar "
+ "[-restconf <restconfConfigurationFile>] [-nbinotification]"
+ " e.g. java -ms128m -mx512m -XX:MaxMetaspaceSize=128m -jar tpce.jar"
- + "-restconf ../src/test/resources/config.json -nbinotification",
+ + "-restconf ../src/test/resources/config.json -nbinotification"
+ + "-olmtimer1 120000 -olmtimer2 20000",
options);
System.exit(1);
}
"ServiceHandler", "RendererListener");
private final List<String> publisherTopicAlarmList = Arrays.asList("ServiceListener");
- public TransportPCEImpl(LightyServices lightyServices, boolean activateNbiNotification) {
+ public TransportPCEImpl(LightyServices lightyServices, boolean activateNbiNotification,
+ String olmtimer1, String olmtimer2) {
LOG.info("Initializing transaction providers ...");
deviceTransactionManager = new DeviceTransactionManagerImpl(lightyServices.getBindingMountPointService(),
MAX_DURATION_TO_SUBMIT_TRANSACTION);
LOG.info("Creating OLM beans ...");
CrossConnect crossConnect = initCrossConnect(mappingUtils);
PowerMgmt powerMgmt = new PowerMgmtImpl(lightyServices.getBindingDataBroker(), openRoadmInterfaces,
- crossConnect, deviceTransactionManager);
+ crossConnect, deviceTransactionManager, olmtimer1, olmtimer2);
OlmPowerService olmPowerService = new OlmPowerServiceImpl(lightyServices.getBindingDataBroker(), powerMgmt,
deviceTransactionManager, portMapping, mappingUtils, openRoadmInterfaces);
olmProvider = new OlmProvider(lightyServices.getRpcProviderService(), olmPowerService);
@Test
public void startNoConfigFileTest() throws Exception {
- main.start(null, false, true);
+ main.start(null, false, "3000", "2000", true);
ContentResponse response = client.GET("http://localhost:8181/restconf/config/ietf-network:networks/network/openroadm-topology");
assertEquals("Response code should be 200", 200, response.getStatus());
}
@Test
public void startConfigFileTest() throws Exception {
File configFile = new File("src/test/resources/config.json");
- main.start(configFile.getAbsolutePath(), false, true);
+ main.start(configFile.getAbsolutePath(), false, "3000", "2000", true);
ContentResponse response = client.GET("http://localhost:8888/restconfCustom/config/ietf-network:networks/network/openroadm-topology");
assertEquals("Response code should be 200", 200, response.getStatus());
}
private static final BigDecimal DEFAULT_TPDR_PWR_400G = new BigDecimal(0);
private static final String INTERFACE_NOT_PRESENT = "Interface {} on node {} is not present!";
+ private long timer1 = 120000;
+ // openroadm spec value is 120000, functest value is 3000
+ private long timer2 = 20000;
+ // openroadm spec value is 20000, functest value is 2000
+
public PowerMgmtImpl(DataBroker db, OpenRoadmInterfaces openRoadmInterfaces,
CrossConnect crossConnect, DeviceTransactionManager deviceTransactionManager) {
this.db = db;
this.deviceTransactionManager = deviceTransactionManager;
}
+ public PowerMgmtImpl(DataBroker db, OpenRoadmInterfaces openRoadmInterfaces,
+ CrossConnect crossConnect, DeviceTransactionManager deviceTransactionManager,
+ String timer1, String timer2) {
+ this.db = db;
+ this.openRoadmInterfaces = openRoadmInterfaces;
+ this.crossConnect = crossConnect;
+ this.deviceTransactionManager = deviceTransactionManager;
+ try {
+ this.timer1 = Long.parseLong(timer1);
+ } catch (NumberFormatException e) {
+ this.timer1 = 120000;
+ LOG.warn("Failed to retrieve Olm timer1 value from configuration - using default value {}",
+ this.timer1, e);
+ }
+ try {
+ this.timer2 = Long.parseLong(timer2);
+ } catch (NumberFormatException e) {
+ this.timer2 = 20000;
+ LOG.warn("Failed to retrieve Olm timer2 value from configuration - using default value {}",
+ this.timer2, e);
+ }
+ }
+
/**
* This methods measures power requirement for turning up a WL
* from the Spanloss at OTS transmit direction and update
LOG.info("Transponder OCH connection: {} power updated ", interfaceName);
try {
LOG.info("Now going in sleep mode");
- Thread.sleep(OlmUtils.OLM_TIMER_1);
+ Thread.sleep(timer1);
} catch (InterruptedException e) {
LOG.info("Transponder warmup failed for OCH connection: {}", interfaceName, e);
// FIXME shouldn't it be LOG.warn or LOG.error?
return false;
}
LOG.info("Roadm-connection: {} updated ", connectionNumber);
- Thread.sleep(OlmUtils.OLM_TIMER_2);
+ Thread.sleep(timer2);
// TODO make this timer value configurable via OSGi blueprint
// although the value recommended by the white paper is 20 seconds.
// At least one vendor product needs 60 seconds
LOG.warn("Power down failed for Roadm-connection: {}", connectionNumber);
return false;
}
- Thread.sleep(OlmUtils.OLM_TIMER_2);
+ Thread.sleep(timer2);
if (!crossConnect.setPowerLevel(nodeId, OpticalControlMode.Off.getName(), null, connectionNumber)) {
LOG.warn("Setting power-control mode off failed for Roadm-connection: {}", connectionNumber);
return false;
private static final Logger LOG = LoggerFactory.getLogger(OlmUtils.class);
private static long DATABROKER_READ_TIMEOUT_SECONDS = 120;
- public static final long OLM_TIMER_1 = 120000; //#FUNCTESTVAL= 3000;
- public static final long OLM_TIMER_2 = 20000; //#FUNCTESTVAL= 2000;
/**
* This static method returns the port mapping {@link Nodes} for node.
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
odl:use-default-for-reference-types="true">
+ <cm:property-placeholder persistent-id="org.opendaylight.transportpce.olm" update-strategy="reload">
+ <cm:default-properties>
+ <cm:property name="timer1" value="120000" />
+ <cm:property name="timer2" value="20000" />
+ <!--The following values are used to speed-up tests with simulators without convergence times-->
+ <!--cm:property name="timer1" value="3000" /-->
+ <!--cm:property name="timer2" value="2000" /-->
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+
<reference id="dataBroker"
interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
<reference id="rpcProviderService"
<argument ref="openRoadmInterfaces" />
<argument ref="crossConnect" />
<argument ref="deviceTransactionManager" />
+ <argument value="${timer1}"/>
+ <argument value="${timer2}"/>
</bean>
<bean id="provider"
<service ref="olmPowerServiceImpl"
interface="org.opendaylight.transportpce.olm.service.OlmPowerService"/>
-
</blueprint>
which mvn >/dev/null || ./installMavenCentOS.sh
cd ../
-#patch OLM constant to speed up tests, unnecessary for PCE tests
-sed -i'_' 's@=.*//#FUNCTESTVAL=@=@g' olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java
if [ "$USE_LIGHTY" != "True" ]; then
for suffix in 121 221 71; do
rm -rf "karaf$suffix"
. "$current_dir"/reflectwarn.sh
mvn clean install -B -q -s tests/odl_settings.xml -DskipTests -Dmaven.javadoc.skip=true -Dodlparent.spotbugs.skip -Dodlparent.checkstyle.skip
-mv olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java_ olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java
-
#patch Karaf exec for the same reason at runtime and also to have the possibility to use alternative ports
./karaf/target/assembly/ressources/post_install_for_tests.sh