From 556a0f59abc9b09005d40945bc20948d69e4f98e Mon Sep 17 00:00:00 2001 From: Michal Cmarada Date: Tue, 25 Sep 2018 11:15:35 +0200 Subject: Bump ODL dependencies to Fluorine (HONEYCOMB-433) Change-Id: I142ebd2899272feff00abe7d4bae708f093ee3ec Signed-off-by: Michal Cmarada --- .../northbound/restconf/BrokerFacadeProvider.java | 47 ++++++++++++++++++++++ .../restconf/ControllerContextProvider.java | 38 +++++++++++++++++ .../northbound/restconf/JettyServerProvider.java | 40 ++++++++++++++++++ .../restconf/RestconfApplicationProvider.java | 37 +++++++++++++++++ .../northbound/restconf/RestconfModule.java | 12 ++++++ .../northbound/restconf/RestconfProvider.java | 28 +++---------- .../restconf/RestconfServiceProvider.java | 37 +++++++++++++++++ .../StatisticsRestconfServiceWrapperProvider.java | 34 ++++++++++++++++ 8 files changed, 250 insertions(+), 23 deletions(-) create mode 100644 infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/BrokerFacadeProvider.java create mode 100644 infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/ControllerContextProvider.java create mode 100644 infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfApplicationProvider.java create mode 100644 infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfServiceProvider.java create mode 100644 infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/StatisticsRestconfServiceWrapperProvider.java (limited to 'infra/northbound/restconf/src') diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/BrokerFacadeProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/BrokerFacadeProvider.java new file mode 100644 index 000000000..f6a7e5e81 --- /dev/null +++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/BrokerFacadeProvider.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.northbound.restconf; + +import com.google.inject.Inject; +import com.google.inject.name.Named; +import io.fd.honeycomb.binding.init.ProviderTrait; +import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; +import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter; +import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade; +import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; + +final class BrokerFacadeProvider extends ProviderTrait { + + @Inject + @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG) + private DOMDataBroker domDataBroker; + @Inject + private DOMRpcService rpcService; + @Inject + private DOMNotificationRouter notificationService; + @Inject + private ControllerContext controllerContext; + + @Override + protected BrokerFacade create() { + BrokerFacade brokerFacade = + BrokerFacade.newInstance(rpcService, domDataBroker, notificationService, controllerContext); + return brokerFacade; + } +} diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/ControllerContextProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/ControllerContextProvider.java new file mode 100644 index 000000000..909f063d1 --- /dev/null +++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/ControllerContextProvider.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.northbound.restconf; + +import com.google.inject.Inject; +import io.fd.honeycomb.binding.init.ProviderTrait; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; + +final class ControllerContextProvider extends ProviderTrait { + + @Inject + private DOMSchemaService schemaService; + @Inject + private DOMMountPointService mountPointService; + + @Override + protected ControllerContext create() { + ControllerContext controllerCtx = + ControllerContext.newInstance(schemaService, mountPointService, schemaService); + return controllerCtx; + } +} diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/JettyServerProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/JettyServerProvider.java index a87459560..8a3ee62f6 100644 --- a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/JettyServerProvider.java +++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/JettyServerProvider.java @@ -27,10 +27,21 @@ import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.security.authentication.BasicAuthenticator; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.gzip.GzipHandler; +import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.util.security.Constraint; import org.eclipse.jetty.util.security.Password; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.webapp.WebAppContext; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.servlet.ServletContainer; +import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader; +import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter; +import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter; +import org.opendaylight.netconf.sal.rest.impl.RestconfApplication; +import org.opendaylight.netconf.sal.rest.impl.RestconfDocumentedExceptionMapper; +import org.opendaylight.netconf.sal.rest.impl.XmlNormalizedNodeBodyReader; +import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; +import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl; final class JettyServerProvider extends ProviderTrait { @@ -41,6 +52,7 @@ final class JettyServerProvider extends ProviderTrait { "application/yang.data+xml", "application/json", "application/yang.data+json"}; + public static final String RESTCONF_APP_NAME = "JAXRSRestconf"; @Inject private RestconfConfiguration cfg; @@ -48,6 +60,15 @@ final class JettyServerProvider extends ProviderTrait { @Inject private CredentialsConfiguration credentialsCfg; + @Inject + private RestconfApplication restconfApplication; + + @Inject + private RestconfImpl restconf; + + @Inject + private ControllerContext controllerContext; + @Override protected Server create() { Server server = new Server(new QueuedThreadPool(cfg.restPoolMaxSize.get(), cfg.restPoolMinSize.get())); @@ -62,7 +83,26 @@ final class JettyServerProvider extends ProviderTrait { final URL resource = getClass().getResource("/"); WebAppContext webapp = new WebAppContext(resource.getPath(), cfg.restconfRootPath.get()); + // Create Restconf application implementation for server + ResourceConfig resourceConfig = new ResourceConfig(); + resourceConfig.setApplicationName(RESTCONF_APP_NAME); + resourceConfig = resourceConfig.registerInstances(restconf, new NormalizedNodeJsonBodyWriter(), + new NormalizedNodeXmlBodyWriter(), new XmlNormalizedNodeBodyReader(controllerContext), + new JsonNormalizedNodeBodyReader(controllerContext), + new RestconfDocumentedExceptionMapper(controllerContext)); + // register Restconf Application classes + resourceConfig.registerClasses(restconfApplication.getClasses()); + + // Create Servlet container which holds configured application + ServletContainer servlet = new ServletContainer(resourceConfig); + ServletHolder servletHolder = new ServletHolder(RESTCONF_APP_NAME, servlet); + // init on startup + servletHolder.setInitOrder(1); + // set service handler server.setHandler(getGzip(service, webapp)); + + //add servlet with "/*" mapping + webapp.addServlet(servletHolder, "/*"); return server; } diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfApplicationProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfApplicationProvider.java new file mode 100644 index 000000000..0f55b4947 --- /dev/null +++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfApplicationProvider.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.fd.honeycomb.northbound.restconf; + +import com.google.inject.Inject; +import io.fd.honeycomb.binding.init.ProviderTrait; +import org.opendaylight.netconf.sal.rest.impl.RestconfApplication; +import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; +import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper; + +public class RestconfApplicationProvider extends ProviderTrait { + + @Inject + private ControllerContext controllerContext; + @Inject + private StatisticsRestconfServiceWrapper statisticsRestconfServiceWrapper; + + @Override + protected RestconfApplication create() { + return new RestconfApplication(controllerContext, statisticsRestconfServiceWrapper); + } +} diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfModule.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfModule.java index 1a59b7298..d2841baef 100644 --- a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfModule.java +++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfModule.java @@ -23,6 +23,11 @@ import io.fd.honeycomb.northbound.restconf.JettyServerStarter.RestconfJettyServe import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.opendaylight.netconf.sal.rest.api.RestConnector; +import org.opendaylight.netconf.sal.rest.impl.RestconfApplication; +import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade; +import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; +import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl; +import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,6 +35,7 @@ public class RestconfModule extends NorthboundAbstractModule { @Inject private RestconfConfiguration cfg; @Inject - @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG) - private DOMDataBroker domDataBroker; - @Inject - private SchemaService schemaService; - @Inject - private DOMRpcService rpcService; - @Inject - private DOMNotificationRouter notificationService; - @Inject private ShutdownHandler shutdownHandler; @Inject - private DOMMountPointService mountPointService; + private StatisticsRestconfServiceWrapper statsServiceWrapper; @Override protected RestconfProviderImpl create() { - final RestconfProviderImpl instance = new RestconfProviderImpl(domDataBroker, schemaService, rpcService, - notificationService, mountPointService, - schemaService, - IpAddressBuilder.getDefaultInstance(cfg.restconfWebsocketAddress.get()), - new PortNumber(cfg.restconfWebsocketPort.get())); - + final RestconfProviderImpl instance = new RestconfProviderImpl(statsServiceWrapper, + IpAddressBuilder.getDefaultInstance(cfg.restconfWebsocketAddress.get()), + new PortNumber(cfg.restconfWebsocketPort.get())); // Required to properly initialize restconf (broker, schema ctx, etc.). // Without that restconf would fail with 503 (service not available). instance.start(); diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfServiceProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfServiceProvider.java new file mode 100644 index 000000000..20dcc28ad --- /dev/null +++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfServiceProvider.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.fd.honeycomb.northbound.restconf; + +import com.google.inject.Inject; +import io.fd.honeycomb.binding.init.ProviderTrait; +import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade; +import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; +import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl; + +public class RestconfServiceProvider extends ProviderTrait { + + @Inject + private ControllerContext controllerContext; + @Inject + private BrokerFacade brokerFacade; + + @Override + protected RestconfImpl create() { + return RestconfImpl.newInstance(brokerFacade, controllerContext); + } +} diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/StatisticsRestconfServiceWrapperProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/StatisticsRestconfServiceWrapperProvider.java new file mode 100644 index 000000000..f3a4c3b73 --- /dev/null +++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/StatisticsRestconfServiceWrapperProvider.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.fd.honeycomb.northbound.restconf; + +import com.google.inject.Inject; +import io.fd.honeycomb.binding.init.ProviderTrait; +import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl; +import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper; + +public class StatisticsRestconfServiceWrapperProvider extends ProviderTrait { + + @Inject + RestconfImpl restconfService; + + @Override + protected StatisticsRestconfServiceWrapper create() { + return StatisticsRestconfServiceWrapper.newInstance(restconfService); + } +} -- cgit 1.2.3-korg