diff options
author | Sagar Srivastav <sagsriva@cisco.com> | 2016-12-19 01:42:11 -0800 |
---|---|---|
committer | Sagar Srivastav <sagsriva@cisco.com> | 2017-02-06 22:45:26 -0800 |
commit | fd88a38ef0c95452953deb2c52a07eb1232a82a5 (patch) | |
tree | 6e52e8ee92669a1924e1a6ff9fa25095f3cf219f /ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java | |
parent | ffc4005f85536f9d19379cab26a1d8dd9b3c4b10 (diff) |
ioam: export plugin - support for ioam-export plugin in hc2vpp
Change-Id: I2314a2de3b9c2a1d9c2e5950659e44cb9bdda985
Signed-off-by: Sagar Srivastav <sagsriva@cisco.com>
Diffstat (limited to 'ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java')
-rw-r--r-- | ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java new file mode 100644 index 000000000..fa4d20004 --- /dev/null +++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016 Cisco and 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.hc2vpp.vppioam.impl.util; + +import com.google.inject.Inject; +import io.fd.honeycomb.infra.distro.ProviderTrait; +import io.fd.vpp.jvpp.JVppRegistry; +import io.fd.vpp.jvpp.ioamexport.JVppIoamexportImpl; +import io.fd.vpp.jvpp.ioamexport.future.FutureJVppIoamexportFacade; +import java.io.IOException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class JVppIoamExportProvider extends ProviderTrait<FutureJVppIoamexportFacade> { + + private static final Logger LOG = LoggerFactory.getLogger(JVppIoamExportProvider.class); + + @Inject + private JVppRegistry registry; + + @Override + protected FutureJVppIoamexportFacade create() { + try { + final JVppIoamexportImpl jVppIoamexport = new JVppIoamexportImpl(); + // Free jvpp-ioam-export plugin's resources on shutdown + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + LOG.info("Unloading jvpp-ioam-export plugin"); + jVppIoamexport.close(); + LOG.info("Successfully unloaded jvpp-ioam-export plugin"); + } + }); + + LOG.info("Successfully loaded jvpp-ioam-export plugin"); + return new FutureJVppIoamexportFacade(registry, jVppIoamexport); + } catch (IOException e) { + throw new IllegalStateException("Unable to open VPP management connection", e); + } + } +} |