The best way how to start consume lighty.io services is to check example applications in this project, usage of lighty core components as well as RESTCONF and NETCONF plugins.
- Simple RESTCONF-NETCONF SDN controller.
- Simple Spring Boot NETCONF SDN controller.
Typical controller project requires initialization of ODL core services, south-bound plugins and optionally RESTCONF north-bound plugin. ODL core services represent MD-SAL layer, controller, DataStore, global schema context and all related services.
- Add dependency on lighty.io core services
<dependencies>
<dependency>
<groupId>io.lighty.core.parents</groupId>
<artifactId>lighty-dependency-artifacts</artifactId>
<version>21.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
- Optionally add dependencies on south-bound or north-bound plugins.
- Initialize and start LightyController
LightyControllerBuilder lightyControllerBuilder = new LightyControllerBuilder();
LightyController lightyController = lightyControllerBuilder.from(controllerConfiguration).build();
lightyController.start().get();
Controller startup sequence consists of 5 easy steps. Step #4 is optional.
lighty.io supports development of two basic controller types:
- Standalone controller - runs in own JVM as micro service
- Embedded controller - runs with other application components in single JVM
Java Management Extensions is a tool enabled by default which makes it easy to change runtime configuration of the application. Among other options, we use log4j2 which has built in option to change logging behaviour during runtime via JMX client which can be connected to the running lighty instance.
- Start the lighty example application
- Connect the JXM client
We recommend using
jconsole
because it is part of the standard Java JRE. The command for connecting jconsole to JMX server is:jconsole <ip-of-running-lighty>:<JMX-port>
, the default JMX-port is 1099.
This approach works only if the application is running locally.
If you want to connect the JMX client to the application running remotely or containerized (k8s deployment or/and docker), you need to start the application using the following JAVA_OPTS:
JAVA_OPTS = -Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.port=<JMX_PORT>
-Dcom.sun.management.jmxremote.rmi.port=<JMX_PORT>
-Djava.rmi.server.hostname=127.0.0.1
Then run java $JAVA_OPTS -jar lighty-rnc-app-<version> ...
If you want to completely disable logger JMX option, run application with following JAVA_OPTS
java -Dlog4j2.disable.jmx=true -jar lighty-rnc-app-<version> ...
After successful start of lighty example application is able to update logger information in runtime. Log4j2 JMX provides more configuration but, for this example, we show how to change logger level.
- Start
jconsole
(part of the standard Java JRE) - Chose lighty example application in local process application
- Open
MBeans
window and choseorg.apache.logging.log4j2
- Chose from dropdown
loggers
thanStatusLogger
andlevel
- By double-clicking on level value, can be updated to desire state.