本文整理汇总了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);
}