Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class NettyRestConf extends AbstractLightyModule {
private final InetAddress inetAddress;
private final int httpPort;
private final String restconfServletContextPath;
private final String groupName;
private final int workThreads;

private MdsalRestconfStreamRegistry mdsalRestconfStreamRegistry;
private SimpleNettyEndpoint nettyEndpoint;
Expand All @@ -62,7 +64,7 @@ public NettyRestConf(final DOMDataBroker domDataBroker, final DOMRpcService domR
final DOMNotificationService domNotificationService, final DOMActionService domActionService,
final DOMMountPointService domMountPointService, final DOMSchemaService domSchemaService,
final InetAddress inetAddress, final int httpPort, final String restconfServletContextPath,
final WebEnvironment webEnvironment) {
final String groupName, final int workThreads, final WebEnvironment webEnvironment) {
this.domDataBroker = domDataBroker;
this.domRpcService = domRpcService;
this.domNotificationService = domNotificationService;
Expand All @@ -72,6 +74,8 @@ public NettyRestConf(final DOMDataBroker domDataBroker, final DOMRpcService domR
this.inetAddress = inetAddress;
this.httpPort = httpPort;
this.restconfServletContextPath = restconfServletContextPath;
this.groupName = groupName;
this.workThreads = workThreads;
this.webEnvironment = webEnvironment;
}

Expand All @@ -94,8 +98,9 @@ protected boolean initProcedure() {
};
this.mdsalRestconfStreamRegistry = new MdsalRestconfStreamRegistry(domDataBroker, domNotificationService,
domSchemaService, new JaxRsLocationProvider(), databindProvider, cssProvider);
final var bootstrapFactory = new BootstrapFactory(groupName ,workThreads);
nettyEndpoint = new SimpleNettyEndpoint(server, service, mdsalRestconfStreamRegistry,
new BootstrapFactory("lighty-restconf-nb-worker", 0), configuration);
bootstrapFactory, configuration);

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public NettyRestConf build() {
restconfConfiguration.getInetAddress(),
restconfConfiguration.getHttpPort(),
restconfConfiguration.getRestconfServletContextPath(),
restconfConfiguration.getGroupName(),
restconfConfiguration.getWorkThreads(),
webEnvironment
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class NettyRestConfConfiguration {
private InetAddress inetAddress = InetAddress.getLoopbackAddress();
private int httpPort = 8888;
private String restconfServletContextPath = "restconf";
private String groupName = "lighty-netty-worker"; //use as default
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not Java style comment, and comments have no meaning IMO

private int workThreads = 0; //default 0 which is ODL netconf default allowing to use Netty default

public NettyRestConfConfiguration() {
}
Expand All @@ -49,6 +51,7 @@ public NettyRestConfConfiguration(final NettyRestConfConfiguration restConfConfi
this.domActionService = restConfConfiguration.getDomActionService();
this.domNotificationService = restConfConfiguration.getDomNotificationService();
this.domMountPointService = restConfConfiguration.getDomMountPointService();
this.workThreads = restConfConfiguration.getWorkThreads();
}

public NettyRestConfConfiguration(final DOMDataBroker domDataBroker, final DOMSchemaService schemaService,
Expand All @@ -62,6 +65,26 @@ public NettyRestConfConfiguration(final DOMDataBroker domDataBroker, final DOMSc
this.domMountPointService = domMountPointService;
}


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why empty line?

public int getWorkThreads() {
return workThreads;
}

public void setWorkThreads(int workThreads) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

if (workThreads < 0) {
throw new IllegalArgumentException("workThreads cannot be negative");
}
this.workThreads = workThreads;
}

public String getGroupName() {
return groupName;
}

public void setGroupName(String groupName) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

this.groupName = groupName;
}

public InetAddress getInetAddress() {
return this.inetAddress;
}
Expand Down Expand Up @@ -147,13 +170,15 @@ public boolean equals(final Object obj) {
&& Objects.equals(domNotificationService, that.domNotificationService)
&& Objects.equals(domMountPointService, that.domMountPointService)
&& Objects.equals(inetAddress, that.inetAddress)
&& Objects.equals(restconfServletContextPath, that.restconfServletContextPath);
&& Objects.equals(restconfServletContextPath, that.restconfServletContextPath)
&& Objects.equals(groupName, that.groupName)
&& Objects.equals(workThreads, that.workThreads);
}

@Override
public int hashCode() {
return Objects.hash(domDataBroker, schemaService, domRpcService, domActionService, domNotificationService,
domMountPointService, inetAddress, httpPort, restconfServletContextPath);
domMountPointService, inetAddress, httpPort, restconfServletContextPath, groupName, workThreads);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public void testNettyRestConfConfiguration() {
final var defaultRestConfConfiguration = NettyRestConfUtils.getDefaultNettyRestConfConfiguration();
final var restConfConfiguration = new NettyRestConfConfiguration(defaultRestConfConfiguration);

Assert.assertEquals(defaultRestConfConfiguration.getWorkThreads(), 0);
Assert.assertEquals(defaultRestConfConfiguration.getGroupName(), "lighty-netty-worker");

Assert.assertEquals(defaultRestConfConfiguration, restConfConfiguration);
Assert.assertEquals(restConfConfiguration.hashCode(), defaultRestConfConfiguration.hashCode());

Expand All @@ -38,6 +41,8 @@ public void testNettyRestConfConfigurationUtilsLoadFromStream() throws Configura
Assert.assertNotNull(restConfConfiguration);
Assert.assertEquals(restConfConfiguration.getHttpPort(), 5555);
Assert.assertEquals(restConfConfiguration.getInetAddress().getHostAddress(), "127.0.0.3");
Assert.assertEquals(restConfConfiguration.getGroupName(), "netty-group-name");
Assert.assertEquals(restConfConfiguration.getWorkThreads(), 2);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"restconf": {
"inetAddress": "127.0.0.3",
"httpPort": 5555,
"restconfServletContextPath": "/restconf-path"
"restconfServletContextPath": "/restconf-path",
"workThreads": 2,
"groupName": "netty-group-name"
}
}
Loading