当前位置: 首页>>代码示例>>Java>>正文


Java IShutdownListener.floodlightIsShuttingDown方法代码示例

本文整理汇总了Java中net.floodlightcontroller.core.IShutdownListener.floodlightIsShuttingDown方法的典型用法代码示例。如果您正苦于以下问题:Java IShutdownListener.floodlightIsShuttingDown方法的具体用法?Java IShutdownListener.floodlightIsShuttingDown怎么用?Java IShutdownListener.floodlightIsShuttingDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.floodlightcontroller.core.IShutdownListener的用法示例。


在下文中一共展示了IShutdownListener.floodlightIsShuttingDown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: terminate

import net.floodlightcontroller.core.IShutdownListener; //导入方法依赖的package包/类
@SuppressFBWarnings(value="DM_EXIT", justification="exit by design")
@Override
public void terminate(@Nullable final String reason, final int exitCode) {
    final String paddedReason;
    if (reason == null) {
        paddedReason = "";
    } else {
        paddedReason = " due to " + reason;
    }
    // A safety valve to make sure we really do indeed terminate floodlight
    // We are using a Thread rather than a task to make sure nothing can
    // cancel the shutdown (e.g., if an ExecutorService was already
    // shutdown
    Thread shutdownForHungListeners =  new Thread(new Runnable() {
        // Suppress findbugs warning that we call system.exit
        @SuppressFBWarnings(value="DM_EXIT", justification="exit by design")
        @Override
        public void run() {
            try {
                Thread.sleep(MAX_SHUTDOWN_WAIT_MS);
            } catch (InterruptedException e) {
                // do nothing, we are about to exit anyways
            }
            logger.error("**************************************************");
            logger.error("* Floodlight is terminating {}", paddedReason);
            logger.error("* ShutdownListeners failed to complete in time");
            logger.error("**************************************************");
            System.exit(exitCode);
        }
    }, "ShutdownSafetyValve");
    shutdownForHungListeners.start();
    logger.info("Floodlight about to terminate. Calling shutdown listeners");
    for (IShutdownListener listener: shutdownListeners) {
        listener.floodlightIsShuttingDown();
    }
    if (exitCode == 0) {
        logger.info("**************************************************");
        logger.info("* Floodlight is terminating normally{}", paddedReason);
        logger.info("**************************************************");
    } else {
        logger.error("**************************************************");
        logger.error("* Floodlight is terminating abnormally{}", paddedReason);
        logger.error("**************************************************");
    }
    // Game Over.
    System.exit(exitCode);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:48,代码来源:ShutdownServiceImpl.java


注:本文中的net.floodlightcontroller.core.IShutdownListener.floodlightIsShuttingDown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。