From bda10b43e7f94562a61223fc46a9f0ef59719311 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 2 Feb 2017 09:36:02 +0100 Subject: Catch ZKOperationTimeoutException and exit controlled --- .../src/apps/filedistributor/filedistributor.cpp | 35 ++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/filedistribution/src/apps/filedistributor/filedistributor.cpp b/filedistribution/src/apps/filedistributor/filedistributor.cpp index ee6663e05f4..c51182134a0 100644 --- a/filedistribution/src/apps/filedistributor/filedistributor.cpp +++ b/filedistribution/src/apps/filedistributor/filedistributor.cpp @@ -1,8 +1,4 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include -#include -#include +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root #include @@ -23,6 +19,7 @@ #include #include #include +#include namespace { const char* programName = "filedistributor"; @@ -286,31 +283,34 @@ FileDistributorApplication::Main() { EV_STOPPING(programName, "Clean exit"); return 0; - } catch(const FileDoesNotExistException & e) { + } catch (const FileDoesNotExistException & e) { EV_STOPPING(programName, e.what()); return 1; - } catch(const ZKNodeDoesNotExistsException & e) { + } catch (const ZKNodeDoesNotExistsException & e) { EV_STOPPING(programName, e.what()); return 2; - } catch(const ZKSessionExpired & e) { + } catch (const ZKSessionExpired & e) { EV_STOPPING(programName, e.what()); return 3; - } catch(const config::ConfigTimeoutException & e) { + } catch (const config::ConfigTimeoutException & e) { EV_STOPPING(programName, e.what()); return 4; - } catch(const vespalib::PortListenException & e) { + } catch (const vespalib::PortListenException & e) { EV_STOPPING(programName, e.what()); return 5; - } catch(const ZKConnectionLossException & e) { + } catch (const ZKConnectionLossException & e) { EV_STOPPING(programName, e.what()); return 6; - } catch(const ZKFailedConnecting & e) { + } catch (const ZKFailedConnecting & e) { EV_STOPPING(programName, e.what()); return 7; - } catch(const config::InvalidConfigException & e) { + } catch (const config::InvalidConfigException & e) { EV_STOPPING(programName, e.what()); return 8; - } catch(const ZKGenericException & e) { + } catch (const ZKOperationTimeoutException & e) { + EV_STOPPING(programName, e.what()); + return 9; + } catch (const ZKGenericException & e) { EV_STOPPING(programName, e.what()); return 99; } @@ -330,9 +330,7 @@ executeApplication(int argc, char** argv) { try { po::variables_map values; - po::store( - po::parse_command_line(argc, argv, description), - values); + po::store(po::parse_command_line(argc, argv, description), values); if (exists(help, values)) { std::cout < ()); + FileDistributorApplication application(values[configId].as ()); return application.Entry(argc, argv); } catch(ProgramOptionException& e) { -- cgit v1.2.3