trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [14/50] incubator-trafodion-site git commit: Merge [TRAFODION-1822] PR 316 new incubator logo and more
Date Fri, 12 Feb 2016 22:25:48 GMT
http://git-wip-us.apache.org/repos/asf/incubator-trafodion-site/blob/8843c99f/docs/dcs_reference/xref/org/trafodion/dcs/server/ServerManager.html
----------------------------------------------------------------------
diff --git a/docs/dcs_reference/xref/org/trafodion/dcs/server/ServerManager.html b/docs/dcs_reference/xref/org/trafodion/dcs/server/ServerManager.html
index 8ae478c..82686b1 100644
--- a/docs/dcs_reference/xref/org/trafodion/dcs/server/ServerManager.html
+++ b/docs/dcs_reference/xref/org/trafodion/dcs/server/ServerManager.html
@@ -261,312 +261,325 @@
 <a class="jxr_linenumber" name="251" href="#251">251</a>         }
 <a class="jxr_linenumber" name="252" href="#252">252</a> 
 <a class="jxr_linenumber" name="253" href="#253">253</a>         <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> isTrafodionRunning() {
-<a class="jxr_linenumber" name="254" href="#254">254</a>             <a href="../../../../org/trafodion/dcs/script/ScriptContext.html">ScriptContext</a> scriptContext = <strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/script/ScriptContext.html">ScriptContext</a>();
-<a class="jxr_linenumber" name="255" href="#255">255</a>             scriptContext.setHostName(hostName);
-<a class="jxr_linenumber" name="256" href="#256">256</a>             scriptContext.setScriptName(Constants.SYS_SHELL_SCRIPT_NAME);
-<a class="jxr_linenumber" name="257" href="#257">257</a>             String command = (<span class="jxr_string">"sqcheck"</span>);
-<a class="jxr_linenumber" name="258" href="#258">258</a>             scriptContext.setCommand(command);
-<a class="jxr_linenumber" name="259" href="#259">259</a>             ScriptManager.getInstance().runScript(scriptContext);<em class="jxr_comment">// This will</em>
-<a class="jxr_linenumber" name="260" href="#260">260</a>                                                                  <em class="jxr_comment">// block while</em>
-<a class="jxr_linenumber" name="261" href="#261">261</a>                                                                  <em class="jxr_comment">// script is</em>
-<a class="jxr_linenumber" name="262" href="#262">262</a>                                                                  <em class="jxr_comment">// running</em>
-<a class="jxr_linenumber" name="263" href="#263">263</a>             <strong class="jxr_keyword">return</strong> scriptContext.getExitCode() != 0 ? false : <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="264" href="#264">264</a>         }
-<a class="jxr_linenumber" name="265" href="#265">265</a>     }
-<a class="jxr_linenumber" name="266" href="#266">266</a> 
-<a class="jxr_linenumber" name="267" href="#267">267</a>     <strong class="jxr_keyword">class</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerHandler</a> <strong class="jxr_keyword">implements</strong> Callable&lt;Integer&gt; {
-<a class="jxr_linenumber" name="268" href="#268">268</a>         <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerMonitor</a> serverMonitor;
-<a class="jxr_linenumber" name="269" href="#269">269</a>         <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerRunner</a> serverRunner;
-<a class="jxr_linenumber" name="270" href="#270">270</a>         <strong class="jxr_keyword">int</strong> childInstance;
-<a class="jxr_linenumber" name="271" href="#271">271</a>         String registeredPath;
-<a class="jxr_linenumber" name="272" href="#272">272</a>         CountDownLatch startSignal = <strong class="jxr_keyword">new</strong> CountDownLatch(1);
-<a class="jxr_linenumber" name="273" href="#273">273</a> 
-<a class="jxr_linenumber" name="274" href="#274">274</a>         <strong class="jxr_keyword">public</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerHandler</a>(<strong class="jxr_keyword">int</strong> childInstance) {
-<a class="jxr_linenumber" name="275" href="#275">275</a>             <strong class="jxr_keyword">this</strong>.childInstance = childInstance;
-<a class="jxr_linenumber" name="276" href="#276">276</a>             <strong class="jxr_keyword">this</strong>.registeredPath = parentZnode
-<a class="jxr_linenumber" name="277" href="#277">277</a>                     + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_REGISTERED
-<a class="jxr_linenumber" name="278" href="#278">278</a>                     + <span class="jxr_string">"/"</span> + hostName + <span class="jxr_string">":"</span> + instance + <span class="jxr_string">":"</span> + childInstance;
-<a class="jxr_linenumber" name="279" href="#279">279</a>             serverMonitor = <strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerMonitor</a>(childInstance, registeredPath);
-<a class="jxr_linenumber" name="280" href="#280">280</a>             serverRunner = <strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerRunner</a>(childInstance, registeredPath);
-<a class="jxr_linenumber" name="281" href="#281">281</a>         }
-<a class="jxr_linenumber" name="282" href="#282">282</a> 
-<a class="jxr_linenumber" name="283" href="#283">283</a>         @Override
-<a class="jxr_linenumber" name="284" href="#284">284</a>         <strong class="jxr_keyword">public</strong> Integer call() <strong class="jxr_keyword">throws</strong> Exception {
-<a class="jxr_linenumber" name="285" href="#285">285</a>             Integer result = <strong class="jxr_keyword">new</strong> Integer(childInstance);
+<a class="jxr_linenumber" name="254" href="#254">254</a> 
+<a class="jxr_linenumber" name="255" href="#255">255</a>         <em class="jxr_comment">// Check if Trafodion is up and running</em>
+<a class="jxr_linenumber" name="256" href="#256">256</a>         <em class="jxr_comment">// If Trafodion is fully or partially up and operational </em>
+<a class="jxr_linenumber" name="257" href="#257">257</a>         <em class="jxr_comment">// return true else return false.</em>
+<a class="jxr_linenumber" name="258" href="#258">258</a>         <em class="jxr_comment">// Invoke sqcheck to check Trafodion status. </em>
+<a class="jxr_linenumber" name="259" href="#259">259</a>         <em class="jxr_comment">// </em>
+<a class="jxr_linenumber" name="260" href="#260">260</a>         <em class="jxr_comment">//   sqcheck returns:</em>
+<a class="jxr_linenumber" name="261" href="#261">261</a>         <em class="jxr_comment">//   -1 - Not up ($?=255)</em>
+<a class="jxr_linenumber" name="262" href="#262">262</a>         <em class="jxr_comment">//    0 - Fully up and operational</em>
+<a class="jxr_linenumber" name="263" href="#263">263</a>         <em class="jxr_comment">//    1 - Partially up and operational</em>
+<a class="jxr_linenumber" name="264" href="#264">264</a>         <em class="jxr_comment">//    2 - Partially up and NOT operational</em>
+<a class="jxr_linenumber" name="265" href="#265">265</a> 
+<a class="jxr_linenumber" name="266" href="#266">266</a>             <a href="../../../../org/trafodion/dcs/script/ScriptContext.html">ScriptContext</a> scriptContext = <strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/script/ScriptContext.html">ScriptContext</a>();
+<a class="jxr_linenumber" name="267" href="#267">267</a>             scriptContext.setHostName(hostName);
+<a class="jxr_linenumber" name="268" href="#268">268</a>             scriptContext.setScriptName(Constants.SYS_SHELL_SCRIPT_NAME);
+<a class="jxr_linenumber" name="269" href="#269">269</a>             String command = (<span class="jxr_string">"sqcheck"</span>);
+<a class="jxr_linenumber" name="270" href="#270">270</a>             scriptContext.setCommand(command);
+<a class="jxr_linenumber" name="271" href="#271">271</a>             ScriptManager.getInstance().runScript(scriptContext);<em class="jxr_comment">// This will</em>
+<a class="jxr_linenumber" name="272" href="#272">272</a>                                                                  <em class="jxr_comment">// block while</em>
+<a class="jxr_linenumber" name="273" href="#273">273</a>                                                                  <em class="jxr_comment">// script is</em>
+<a class="jxr_linenumber" name="274" href="#274">274</a>                                                                  <em class="jxr_comment">// running</em>
+<a class="jxr_linenumber" name="275" href="#275">275</a>             <strong class="jxr_keyword">int</strong> exitCode = scriptContext.getExitCode();
+<a class="jxr_linenumber" name="276" href="#276">276</a>             <strong class="jxr_keyword">return</strong> (exitCode == 0 || exitCode == 1) ? <strong class="jxr_keyword">true</strong> : false;
+<a class="jxr_linenumber" name="277" href="#277">277</a>         }
+<a class="jxr_linenumber" name="278" href="#278">278</a>     }
+<a class="jxr_linenumber" name="279" href="#279">279</a> 
+<a class="jxr_linenumber" name="280" href="#280">280</a>     <strong class="jxr_keyword">class</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerHandler</a> <strong class="jxr_keyword">implements</strong> Callable&lt;Integer&gt; {
+<a class="jxr_linenumber" name="281" href="#281">281</a>         <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerMonitor</a> serverMonitor;
+<a class="jxr_linenumber" name="282" href="#282">282</a>         <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerRunner</a> serverRunner;
+<a class="jxr_linenumber" name="283" href="#283">283</a>         <strong class="jxr_keyword">int</strong> childInstance;
+<a class="jxr_linenumber" name="284" href="#284">284</a>         String registeredPath;
+<a class="jxr_linenumber" name="285" href="#285">285</a>         CountDownLatch startSignal = <strong class="jxr_keyword">new</strong> CountDownLatch(1);
 <a class="jxr_linenumber" name="286" href="#286">286</a> 
-<a class="jxr_linenumber" name="287" href="#287">287</a>             <strong class="jxr_keyword">if</strong> (serverMonitor.monitor()) {
-<a class="jxr_linenumber" name="288" href="#288">288</a>                 LOG.info(<span class="jxr_string">"Server handler ["</span> + instance + <span class="jxr_string">":"</span> + childInstance
-<a class="jxr_linenumber" name="289" href="#289">289</a>                         + <span class="jxr_string">"] is running"</span>);
-<a class="jxr_linenumber" name="290" href="#290">290</a>                 zkc.exists(registeredPath, <strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">RegisteredWatcher</a>(startSignal));
-<a class="jxr_linenumber" name="291" href="#291">291</a>                 LOG.debug(<span class="jxr_string">"Waiting for start signal"</span>);
-<a class="jxr_linenumber" name="292" href="#292">292</a>                 startSignal.await();
-<a class="jxr_linenumber" name="293" href="#293">293</a>                 serverRunner.exec();
-<a class="jxr_linenumber" name="294" href="#294">294</a>             } <strong class="jxr_keyword">else</strong> {
-<a class="jxr_linenumber" name="295" href="#295">295</a>                 LOG.info(<span class="jxr_string">"Server handler ["</span> + instance + <span class="jxr_string">":"</span> + childInstance
-<a class="jxr_linenumber" name="296" href="#296">296</a>                         + <span class="jxr_string">"] is not running"</span>);
-<a class="jxr_linenumber" name="297" href="#297">297</a>                 serverRunner.exec();
-<a class="jxr_linenumber" name="298" href="#298">298</a>             }
+<a class="jxr_linenumber" name="287" href="#287">287</a>         <strong class="jxr_keyword">public</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerHandler</a>(<strong class="jxr_keyword">int</strong> childInstance) {
+<a class="jxr_linenumber" name="288" href="#288">288</a>             <strong class="jxr_keyword">this</strong>.childInstance = childInstance;
+<a class="jxr_linenumber" name="289" href="#289">289</a>             <strong class="jxr_keyword">this</strong>.registeredPath = parentZnode
+<a class="jxr_linenumber" name="290" href="#290">290</a>                     + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_REGISTERED
+<a class="jxr_linenumber" name="291" href="#291">291</a>                     + <span class="jxr_string">"/"</span> + hostName + <span class="jxr_string">":"</span> + instance + <span class="jxr_string">":"</span> + childInstance;
+<a class="jxr_linenumber" name="292" href="#292">292</a>             serverMonitor = <strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerMonitor</a>(childInstance, registeredPath);
+<a class="jxr_linenumber" name="293" href="#293">293</a>             serverRunner = <strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerRunner</a>(childInstance, registeredPath);
+<a class="jxr_linenumber" name="294" href="#294">294</a>         }
+<a class="jxr_linenumber" name="295" href="#295">295</a> 
+<a class="jxr_linenumber" name="296" href="#296">296</a>         @Override
+<a class="jxr_linenumber" name="297" href="#297">297</a>         <strong class="jxr_keyword">public</strong> Integer call() <strong class="jxr_keyword">throws</strong> Exception {
+<a class="jxr_linenumber" name="298" href="#298">298</a>             Integer result = <strong class="jxr_keyword">new</strong> Integer(childInstance);
 <a class="jxr_linenumber" name="299" href="#299">299</a> 
-<a class="jxr_linenumber" name="300" href="#300">300</a>             <strong class="jxr_keyword">return</strong> result;
-<a class="jxr_linenumber" name="301" href="#301">301</a>         }
-<a class="jxr_linenumber" name="302" href="#302">302</a>     }
-<a class="jxr_linenumber" name="303" href="#303">303</a> 
-<a class="jxr_linenumber" name="304" href="#304">304</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerManager</a>(Configuration conf, <a href="../../../../org/trafodion/dcs/zookeeper/ZkClient.html">ZkClient</a> zkc,
-<a class="jxr_linenumber" name="305" href="#305">305</a>             <a href="../../../../org/trafodion/dcs/util/DcsNetworkConfiguration.html">DcsNetworkConfiguration</a> netConf, String instance, <strong class="jxr_keyword">int</strong> infoPort,
-<a class="jxr_linenumber" name="306" href="#306">306</a>             <strong class="jxr_keyword">int</strong> childServers) <strong class="jxr_keyword">throws</strong> Exception {
-<a class="jxr_linenumber" name="307" href="#307">307</a>         <strong class="jxr_keyword">this</strong>.conf = conf;
-<a class="jxr_linenumber" name="308" href="#308">308</a>         <strong class="jxr_keyword">this</strong>.zkc = zkc;
-<a class="jxr_linenumber" name="309" href="#309">309</a>         <strong class="jxr_keyword">this</strong>.netConf = netConf;
-<a class="jxr_linenumber" name="310" href="#310">310</a>         <strong class="jxr_keyword">this</strong>.hostName = netConf.getHostName();
-<a class="jxr_linenumber" name="311" href="#311">311</a>         <strong class="jxr_keyword">this</strong>.instance = Integer.parseInt(instance);
-<a class="jxr_linenumber" name="312" href="#312">312</a>         <strong class="jxr_keyword">this</strong>.infoPort = infoPort;
-<a class="jxr_linenumber" name="313" href="#313">313</a>         <strong class="jxr_keyword">this</strong>.childServers = childServers;
-<a class="jxr_linenumber" name="314" href="#314">314</a>         <strong class="jxr_keyword">this</strong>.parentZnode = <strong class="jxr_keyword">this</strong>.conf.get(Constants.ZOOKEEPER_ZNODE_PARENT,
-<a class="jxr_linenumber" name="315" href="#315">315</a>                 Constants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
-<a class="jxr_linenumber" name="316" href="#316">316</a>         <strong class="jxr_keyword">this</strong>.connectingTimeout = <strong class="jxr_keyword">this</strong>.conf.getInt(
-<a class="jxr_linenumber" name="317" href="#317">317</a>                 Constants.DCS_SERVER_USER_PROGRAM_CONNECTING_TIMEOUT,
-<a class="jxr_linenumber" name="318" href="#318">318</a>                 Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_CONNECTING_TIMEOUT);
-<a class="jxr_linenumber" name="319" href="#319">319</a>         <strong class="jxr_keyword">this</strong>.zkSessionTimeout = <strong class="jxr_keyword">this</strong>.conf
-<a class="jxr_linenumber" name="320" href="#320">320</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_ZOOKEEPER_SESSION_TIMEOUT,
-<a class="jxr_linenumber" name="321" href="#321">321</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_ZOOKEEPER_SESSION_TIMEOUT);
-<a class="jxr_linenumber" name="322" href="#322">322</a>         <strong class="jxr_keyword">this</strong>.userProgExitAfterDisconnect = <strong class="jxr_keyword">this</strong>.conf
-<a class="jxr_linenumber" name="323" href="#323">323</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_EXIT_AFTER_DISCONNECT,
-<a class="jxr_linenumber" name="324" href="#324">324</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_EXIT_AFTER_DISCONNECT);
-<a class="jxr_linenumber" name="325" href="#325">325</a>         <strong class="jxr_keyword">this</strong>.maxHeapPctExit = <strong class="jxr_keyword">this</strong>.conf.getInt(
-<a class="jxr_linenumber" name="326" href="#326">326</a>                 Constants.DCS_SERVER_USER_PROGRAM_MAX_HEAP_PCT_EXIT,
-<a class="jxr_linenumber" name="327" href="#327">327</a>                 Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_MAX_HEAP_PCT_EXIT);
-<a class="jxr_linenumber" name="328" href="#328">328</a>         <strong class="jxr_keyword">this</strong>.statisticsIntervalTime = <strong class="jxr_keyword">this</strong>.conf
-<a class="jxr_linenumber" name="329" href="#329">329</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_INTERVAL_TIME,
-<a class="jxr_linenumber" name="330" href="#330">330</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_INTERVAL_TIME);
-<a class="jxr_linenumber" name="331" href="#331">331</a>         <strong class="jxr_keyword">this</strong>.statisticsLimitTime = <strong class="jxr_keyword">this</strong>.conf
-<a class="jxr_linenumber" name="332" href="#332">332</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_LIMIT_TIME,
-<a class="jxr_linenumber" name="333" href="#333">333</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_LIMIT_TIME);
-<a class="jxr_linenumber" name="334" href="#334">334</a>         <strong class="jxr_keyword">this</strong>.statisticsType = <strong class="jxr_keyword">this</strong>.conf.get(
-<a class="jxr_linenumber" name="335" href="#335">335</a>                 Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_TYPE,
-<a class="jxr_linenumber" name="336" href="#336">336</a>                 Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_TYPE);
-<a class="jxr_linenumber" name="337" href="#337">337</a>         <strong class="jxr_keyword">this</strong>.statisticsEnable = <strong class="jxr_keyword">this</strong>.conf.get(
-<a class="jxr_linenumber" name="338" href="#338">338</a>                 Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_ENABLE,
-<a class="jxr_linenumber" name="339" href="#339">339</a>                 Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_ENABLE);
-<a class="jxr_linenumber" name="340" href="#340">340</a>         <strong class="jxr_keyword">this</strong>.sqlplanEnable = <strong class="jxr_keyword">this</strong>.conf
-<a class="jxr_linenumber" name="341" href="#341">341</a>                 .get(Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_SQLPLAN_ENABLE,
-<a class="jxr_linenumber" name="342" href="#342">342</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_SQLPLAN_ENABLE);
-<a class="jxr_linenumber" name="343" href="#343">343</a>         <strong class="jxr_keyword">this</strong>.userProgPortMapToSecs = <strong class="jxr_keyword">this</strong>.conf
-<a class="jxr_linenumber" name="344" href="#344">344</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_PORT_MAP_TIMEOUT_SECONDS,
-<a class="jxr_linenumber" name="345" href="#345">345</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_PORT_MAP_TIMEOUT_SECONDS);
-<a class="jxr_linenumber" name="346" href="#346">346</a>         <strong class="jxr_keyword">this</strong>.userProgPortBindToSecs = <strong class="jxr_keyword">this</strong>.conf
-<a class="jxr_linenumber" name="347" href="#347">347</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_PORT_BIND_TIMEOUT_SECONDS,
-<a class="jxr_linenumber" name="348" href="#348">348</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_PORT_BIND_TIMEOUT_SECONDS);
-<a class="jxr_linenumber" name="349" href="#349">349</a>         <strong class="jxr_keyword">this</strong>.maxRestartAttempts = conf
-<a class="jxr_linenumber" name="350" href="#350">350</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_RESTART_HANDLER_ATTEMPTS,
-<a class="jxr_linenumber" name="351" href="#351">351</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_RESTART_HANDLER_ATTEMPTS);
-<a class="jxr_linenumber" name="352" href="#352">352</a>         <strong class="jxr_keyword">this</strong>.retryIntervalMillis = conf
-<a class="jxr_linenumber" name="353" href="#353">353</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_RESTART_HANDLER_RETRY_INTERVAL_MILLIS,
-<a class="jxr_linenumber" name="354" href="#354">354</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_RESTART_HANDLER_RETRY_INTERVAL_MILLIS);
-<a class="jxr_linenumber" name="355" href="#355">355</a>         <strong class="jxr_keyword">this</strong>.retryCounterFactory = <strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/util/RetryCounterFactory.html">RetryCounterFactory</a>(
-<a class="jxr_linenumber" name="356" href="#356">356</a>                 <strong class="jxr_keyword">this</strong>.maxRestartAttempts, <strong class="jxr_keyword">this</strong>.retryIntervalMillis);
-<a class="jxr_linenumber" name="357" href="#357">357</a>     }
-<a class="jxr_linenumber" name="358" href="#358">358</a> 
-<a class="jxr_linenumber" name="359" href="#359">359</a>     @Override
-<a class="jxr_linenumber" name="360" href="#360">360</a>     <strong class="jxr_keyword">public</strong> Boolean call() <strong class="jxr_keyword">throws</strong> Exception {
-<a class="jxr_linenumber" name="361" href="#361">361</a> 
-<a class="jxr_linenumber" name="362" href="#362">362</a>         ExecutorService executorService = Executors
-<a class="jxr_linenumber" name="363" href="#363">363</a>                 .newFixedThreadPool(childServers);
-<a class="jxr_linenumber" name="364" href="#364">364</a>         CompletionService&lt;Integer&gt; completionService = <strong class="jxr_keyword">new</strong> ExecutorCompletionService&lt;Integer&gt;(
-<a class="jxr_linenumber" name="365" href="#365">365</a>                 executorService);
-<a class="jxr_linenumber" name="366" href="#366">366</a> 
-<a class="jxr_linenumber" name="367" href="#367">367</a>         <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="368" href="#368">368</a>             getMaster();
-<a class="jxr_linenumber" name="369" href="#369">369</a>             featureCheck();
-<a class="jxr_linenumber" name="370" href="#370">370</a>             registerInRunning(instance);
+<a class="jxr_linenumber" name="300" href="#300">300</a>             <strong class="jxr_keyword">if</strong> (serverMonitor.monitor()) {
+<a class="jxr_linenumber" name="301" href="#301">301</a>                 LOG.info(<span class="jxr_string">"Server handler ["</span> + instance + <span class="jxr_string">":"</span> + childInstance
+<a class="jxr_linenumber" name="302" href="#302">302</a>                         + <span class="jxr_string">"] is running"</span>);
+<a class="jxr_linenumber" name="303" href="#303">303</a>                 zkc.exists(registeredPath, <strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">RegisteredWatcher</a>(startSignal));
+<a class="jxr_linenumber" name="304" href="#304">304</a>                 LOG.debug(<span class="jxr_string">"Waiting for start signal"</span>);
+<a class="jxr_linenumber" name="305" href="#305">305</a>                 startSignal.await();
+<a class="jxr_linenumber" name="306" href="#306">306</a>                 serverRunner.exec();
+<a class="jxr_linenumber" name="307" href="#307">307</a>             } <strong class="jxr_keyword">else</strong> {
+<a class="jxr_linenumber" name="308" href="#308">308</a>                 LOG.info(<span class="jxr_string">"Server handler ["</span> + instance + <span class="jxr_string">":"</span> + childInstance
+<a class="jxr_linenumber" name="309" href="#309">309</a>                         + <span class="jxr_string">"] is not running"</span>);
+<a class="jxr_linenumber" name="310" href="#310">310</a>                 serverRunner.exec();
+<a class="jxr_linenumber" name="311" href="#311">311</a>             }
+<a class="jxr_linenumber" name="312" href="#312">312</a> 
+<a class="jxr_linenumber" name="313" href="#313">313</a>             <strong class="jxr_keyword">return</strong> result;
+<a class="jxr_linenumber" name="314" href="#314">314</a>         }
+<a class="jxr_linenumber" name="315" href="#315">315</a>     }
+<a class="jxr_linenumber" name="316" href="#316">316</a> 
+<a class="jxr_linenumber" name="317" href="#317">317</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerManager</a>(Configuration conf, <a href="../../../../org/trafodion/dcs/zookeeper/ZkClient.html">ZkClient</a> zkc,
+<a class="jxr_linenumber" name="318" href="#318">318</a>             <a href="../../../../org/trafodion/dcs/util/DcsNetworkConfiguration.html">DcsNetworkConfiguration</a> netConf, String instance, <strong class="jxr_keyword">int</strong> infoPort,
+<a class="jxr_linenumber" name="319" href="#319">319</a>             <strong class="jxr_keyword">int</strong> childServers) <strong class="jxr_keyword">throws</strong> Exception {
+<a class="jxr_linenumber" name="320" href="#320">320</a>         <strong class="jxr_keyword">this</strong>.conf = conf;
+<a class="jxr_linenumber" name="321" href="#321">321</a>         <strong class="jxr_keyword">this</strong>.zkc = zkc;
+<a class="jxr_linenumber" name="322" href="#322">322</a>         <strong class="jxr_keyword">this</strong>.netConf = netConf;
+<a class="jxr_linenumber" name="323" href="#323">323</a>         <strong class="jxr_keyword">this</strong>.hostName = netConf.getHostName();
+<a class="jxr_linenumber" name="324" href="#324">324</a>         <strong class="jxr_keyword">this</strong>.instance = Integer.parseInt(instance);
+<a class="jxr_linenumber" name="325" href="#325">325</a>         <strong class="jxr_keyword">this</strong>.infoPort = infoPort;
+<a class="jxr_linenumber" name="326" href="#326">326</a>         <strong class="jxr_keyword">this</strong>.childServers = childServers;
+<a class="jxr_linenumber" name="327" href="#327">327</a>         <strong class="jxr_keyword">this</strong>.parentZnode = <strong class="jxr_keyword">this</strong>.conf.get(Constants.ZOOKEEPER_ZNODE_PARENT,
+<a class="jxr_linenumber" name="328" href="#328">328</a>                 Constants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
+<a class="jxr_linenumber" name="329" href="#329">329</a>         <strong class="jxr_keyword">this</strong>.connectingTimeout = <strong class="jxr_keyword">this</strong>.conf.getInt(
+<a class="jxr_linenumber" name="330" href="#330">330</a>                 Constants.DCS_SERVER_USER_PROGRAM_CONNECTING_TIMEOUT,
+<a class="jxr_linenumber" name="331" href="#331">331</a>                 Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_CONNECTING_TIMEOUT);
+<a class="jxr_linenumber" name="332" href="#332">332</a>         <strong class="jxr_keyword">this</strong>.zkSessionTimeout = <strong class="jxr_keyword">this</strong>.conf
+<a class="jxr_linenumber" name="333" href="#333">333</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_ZOOKEEPER_SESSION_TIMEOUT,
+<a class="jxr_linenumber" name="334" href="#334">334</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_ZOOKEEPER_SESSION_TIMEOUT);
+<a class="jxr_linenumber" name="335" href="#335">335</a>         <strong class="jxr_keyword">this</strong>.userProgExitAfterDisconnect = <strong class="jxr_keyword">this</strong>.conf
+<a class="jxr_linenumber" name="336" href="#336">336</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_EXIT_AFTER_DISCONNECT,
+<a class="jxr_linenumber" name="337" href="#337">337</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_EXIT_AFTER_DISCONNECT);
+<a class="jxr_linenumber" name="338" href="#338">338</a>         <strong class="jxr_keyword">this</strong>.maxHeapPctExit = <strong class="jxr_keyword">this</strong>.conf.getInt(
+<a class="jxr_linenumber" name="339" href="#339">339</a>                 Constants.DCS_SERVER_USER_PROGRAM_MAX_HEAP_PCT_EXIT,
+<a class="jxr_linenumber" name="340" href="#340">340</a>                 Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_MAX_HEAP_PCT_EXIT);
+<a class="jxr_linenumber" name="341" href="#341">341</a>         <strong class="jxr_keyword">this</strong>.statisticsIntervalTime = <strong class="jxr_keyword">this</strong>.conf
+<a class="jxr_linenumber" name="342" href="#342">342</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_INTERVAL_TIME,
+<a class="jxr_linenumber" name="343" href="#343">343</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_INTERVAL_TIME);
+<a class="jxr_linenumber" name="344" href="#344">344</a>         <strong class="jxr_keyword">this</strong>.statisticsLimitTime = <strong class="jxr_keyword">this</strong>.conf
+<a class="jxr_linenumber" name="345" href="#345">345</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_LIMIT_TIME,
+<a class="jxr_linenumber" name="346" href="#346">346</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_LIMIT_TIME);
+<a class="jxr_linenumber" name="347" href="#347">347</a>         <strong class="jxr_keyword">this</strong>.statisticsType = <strong class="jxr_keyword">this</strong>.conf.get(
+<a class="jxr_linenumber" name="348" href="#348">348</a>                 Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_TYPE,
+<a class="jxr_linenumber" name="349" href="#349">349</a>                 Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_TYPE);
+<a class="jxr_linenumber" name="350" href="#350">350</a>         <strong class="jxr_keyword">this</strong>.statisticsEnable = <strong class="jxr_keyword">this</strong>.conf.get(
+<a class="jxr_linenumber" name="351" href="#351">351</a>                 Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_ENABLE,
+<a class="jxr_linenumber" name="352" href="#352">352</a>                 Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_ENABLE);
+<a class="jxr_linenumber" name="353" href="#353">353</a>         <strong class="jxr_keyword">this</strong>.sqlplanEnable = <strong class="jxr_keyword">this</strong>.conf
+<a class="jxr_linenumber" name="354" href="#354">354</a>                 .get(Constants.DCS_SERVER_USER_PROGRAM_STATISTICS_SQLPLAN_ENABLE,
+<a class="jxr_linenumber" name="355" href="#355">355</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_STATISTICS_SQLPLAN_ENABLE);
+<a class="jxr_linenumber" name="356" href="#356">356</a>         <strong class="jxr_keyword">this</strong>.userProgPortMapToSecs = <strong class="jxr_keyword">this</strong>.conf
+<a class="jxr_linenumber" name="357" href="#357">357</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_PORT_MAP_TIMEOUT_SECONDS,
+<a class="jxr_linenumber" name="358" href="#358">358</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_PORT_MAP_TIMEOUT_SECONDS);
+<a class="jxr_linenumber" name="359" href="#359">359</a>         <strong class="jxr_keyword">this</strong>.userProgPortBindToSecs = <strong class="jxr_keyword">this</strong>.conf
+<a class="jxr_linenumber" name="360" href="#360">360</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_PORT_BIND_TIMEOUT_SECONDS,
+<a class="jxr_linenumber" name="361" href="#361">361</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_PORT_BIND_TIMEOUT_SECONDS);
+<a class="jxr_linenumber" name="362" href="#362">362</a>         <strong class="jxr_keyword">this</strong>.maxRestartAttempts = conf
+<a class="jxr_linenumber" name="363" href="#363">363</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_RESTART_HANDLER_ATTEMPTS,
+<a class="jxr_linenumber" name="364" href="#364">364</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_RESTART_HANDLER_ATTEMPTS);
+<a class="jxr_linenumber" name="365" href="#365">365</a>         <strong class="jxr_keyword">this</strong>.retryIntervalMillis = conf
+<a class="jxr_linenumber" name="366" href="#366">366</a>                 .getInt(Constants.DCS_SERVER_USER_PROGRAM_RESTART_HANDLER_RETRY_INTERVAL_MILLIS,
+<a class="jxr_linenumber" name="367" href="#367">367</a>                         Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_RESTART_HANDLER_RETRY_INTERVAL_MILLIS);
+<a class="jxr_linenumber" name="368" href="#368">368</a>         <strong class="jxr_keyword">this</strong>.retryCounterFactory = <strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/util/RetryCounterFactory.html">RetryCounterFactory</a>(
+<a class="jxr_linenumber" name="369" href="#369">369</a>                 <strong class="jxr_keyword">this</strong>.maxRestartAttempts, <strong class="jxr_keyword">this</strong>.retryIntervalMillis);
+<a class="jxr_linenumber" name="370" href="#370">370</a>     }
 <a class="jxr_linenumber" name="371" href="#371">371</a> 
-<a class="jxr_linenumber" name="372" href="#372">372</a>             <em class="jxr_comment">// When started from bin/dcs-start.sh script childServers will</em>
-<a class="jxr_linenumber" name="373" href="#373">373</a>             <em class="jxr_comment">// contain the</em>
-<a class="jxr_linenumber" name="374" href="#374">374</a>             <em class="jxr_comment">// count passed in from the servers.sh script. However when</em>
-<a class="jxr_linenumber" name="375" href="#375">375</a>             <em class="jxr_comment">// DcsServer is</em>
-<a class="jxr_linenumber" name="376" href="#376">376</a>             <em class="jxr_comment">// killed or dies for any reason DcsMaster restarts it using</em>
-<a class="jxr_linenumber" name="377" href="#377">377</a>             <em class="jxr_comment">// /bin/dcs-daemon script</em>
-<a class="jxr_linenumber" name="378" href="#378">378</a>             <em class="jxr_comment">// which DOES NOT set childServers count.</em>
-<a class="jxr_linenumber" name="379" href="#379">379</a>             <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> childInstance = 1; childInstance &lt;= childServers; childInstance++) {
-<a class="jxr_linenumber" name="380" href="#380">380</a>                 completionService.submit(<strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerHandler</a>(childInstance));
-<a class="jxr_linenumber" name="381" href="#381">381</a>                 LOG.debug(<span class="jxr_string">"Started server handler ["</span> + instance + <span class="jxr_string">":"</span>
-<a class="jxr_linenumber" name="382" href="#382">382</a>                         + childInstance + <span class="jxr_string">"]"</span>);
-<a class="jxr_linenumber" name="383" href="#383">383</a>             }
+<a class="jxr_linenumber" name="372" href="#372">372</a>     @Override
+<a class="jxr_linenumber" name="373" href="#373">373</a>     <strong class="jxr_keyword">public</strong> Boolean call() <strong class="jxr_keyword">throws</strong> Exception {
+<a class="jxr_linenumber" name="374" href="#374">374</a> 
+<a class="jxr_linenumber" name="375" href="#375">375</a>         ExecutorService executorService = Executors
+<a class="jxr_linenumber" name="376" href="#376">376</a>                 .newFixedThreadPool(childServers);
+<a class="jxr_linenumber" name="377" href="#377">377</a>         CompletionService&lt;Integer&gt; completionService = <strong class="jxr_keyword">new</strong> ExecutorCompletionService&lt;Integer&gt;(
+<a class="jxr_linenumber" name="378" href="#378">378</a>                 executorService);
+<a class="jxr_linenumber" name="379" href="#379">379</a> 
+<a class="jxr_linenumber" name="380" href="#380">380</a>         <strong class="jxr_keyword">try</strong> {
+<a class="jxr_linenumber" name="381" href="#381">381</a>             getMaster();
+<a class="jxr_linenumber" name="382" href="#382">382</a>             featureCheck();
+<a class="jxr_linenumber" name="383" href="#383">383</a>             registerInRunning(instance);
 <a class="jxr_linenumber" name="384" href="#384">384</a> 
-<a class="jxr_linenumber" name="385" href="#385">385</a>             <strong class="jxr_keyword">while</strong> (<strong class="jxr_keyword">true</strong>) {
-<a class="jxr_linenumber" name="386" href="#386">386</a>                 LOG.debug(<span class="jxr_string">"Waiting for any server handler to finish"</span>);
-<a class="jxr_linenumber" name="387" href="#387">387</a>                 Future&lt;Integer&gt; f = completionService.take();<em class="jxr_comment">// blocks waiting</em>
-<a class="jxr_linenumber" name="388" href="#388">388</a>                                                              <em class="jxr_comment">// for any</em>
-<a class="jxr_linenumber" name="389" href="#389">389</a>                                                              <em class="jxr_comment">// ServerHandler to</em>
-<a class="jxr_linenumber" name="390" href="#390">390</a>                                                              <em class="jxr_comment">// finish</em>
-<a class="jxr_linenumber" name="391" href="#391">391</a>                 <strong class="jxr_keyword">if</strong> (f != <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="392" href="#392">392</a>                     Integer result = f.get();
-<a class="jxr_linenumber" name="393" href="#393">393</a>                     LOG.debug(<span class="jxr_string">"Server handler ["</span> + instance + <span class="jxr_string">":"</span> + result
-<a class="jxr_linenumber" name="394" href="#394">394</a>                             + <span class="jxr_string">"] finished, restarting"</span>);
-<a class="jxr_linenumber" name="395" href="#395">395</a>                     completionService.submit(<strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerHandler</a>(result));
-<a class="jxr_linenumber" name="396" href="#396">396</a>                 }
-<a class="jxr_linenumber" name="397" href="#397">397</a>             }
-<a class="jxr_linenumber" name="398" href="#398">398</a> 
-<a class="jxr_linenumber" name="399" href="#399">399</a>         } <strong class="jxr_keyword">catch</strong> (Exception e) {
-<a class="jxr_linenumber" name="400" href="#400">400</a>             e.printStackTrace();
-<a class="jxr_linenumber" name="401" href="#401">401</a>             LOG.error(e);
-<a class="jxr_linenumber" name="402" href="#402">402</a>             <strong class="jxr_keyword">if</strong> (executorService != <strong class="jxr_keyword">null</strong>)
-<a class="jxr_linenumber" name="403" href="#403">403</a>                 executorService.shutdown();
-<a class="jxr_linenumber" name="404" href="#404">404</a>             <strong class="jxr_keyword">throw</strong> e;
-<a class="jxr_linenumber" name="405" href="#405">405</a>         }
-<a class="jxr_linenumber" name="406" href="#406">406</a>         <em class="jxr_comment">/*</em>
-<a class="jxr_linenumber" name="407" href="#407">407</a> <em class="jxr_comment">         * ExecutorService pool = Executors.newSingleThreadExecutor();</em>
-<a class="jxr_linenumber" name="408" href="#408">408</a> <em class="jxr_comment">         * </em>
-<a class="jxr_linenumber" name="409" href="#409">409</a> <em class="jxr_comment">         * try { getMaster(); registerInRunning(); featureCheck();</em>
-<a class="jxr_linenumber" name="410" href="#410">410</a> <em class="jxr_comment">         * </em>
-<a class="jxr_linenumber" name="411" href="#411">411</a> <em class="jxr_comment">         * Callable&lt;Boolean&gt; serverMonitor = new ServerMonitor();</em>
-<a class="jxr_linenumber" name="412" href="#412">412</a> <em class="jxr_comment">         * Callable&lt;ScriptContext&gt; serverRunner = new ServerRunner();</em>
-<a class="jxr_linenumber" name="413" href="#413">413</a> <em class="jxr_comment">         * </em>
-<a class="jxr_linenumber" name="414" href="#414">414</a> <em class="jxr_comment">         * long timeoutMillis=5000;</em>
-<a class="jxr_linenumber" name="415" href="#415">415</a> <em class="jxr_comment">         * </em>
-<a class="jxr_linenumber" name="416" href="#416">416</a> <em class="jxr_comment">         * while(true) { Future&lt;Boolean&gt; monitor = pool.submit(serverMonitor);</em>
-<a class="jxr_linenumber" name="417" href="#417">417</a> <em class="jxr_comment">         * if(false == monitor.get().booleanValue()) { //blocking call</em>
-<a class="jxr_linenumber" name="418" href="#418">418</a> <em class="jxr_comment">         * LOG.info("User program is not running"); Future&lt;ScriptContext&gt; runner</em>
-<a class="jxr_linenumber" name="419" href="#419">419</a> <em class="jxr_comment">         * = pool.submit(serverRunner); ScriptContext scriptContext =</em>
-<a class="jxr_linenumber" name="420" href="#420">420</a> <em class="jxr_comment">         * runner.get();//blocking call</em>
+<a class="jxr_linenumber" name="385" href="#385">385</a>             <em class="jxr_comment">// When started from bin/dcs-start.sh script childServers will</em>
+<a class="jxr_linenumber" name="386" href="#386">386</a>             <em class="jxr_comment">// contain the</em>
+<a class="jxr_linenumber" name="387" href="#387">387</a>             <em class="jxr_comment">// count passed in from the servers.sh script. However when</em>
+<a class="jxr_linenumber" name="388" href="#388">388</a>             <em class="jxr_comment">// DcsServer is</em>
+<a class="jxr_linenumber" name="389" href="#389">389</a>             <em class="jxr_comment">// killed or dies for any reason DcsMaster restarts it using</em>
+<a class="jxr_linenumber" name="390" href="#390">390</a>             <em class="jxr_comment">// /bin/dcs-daemon script</em>
+<a class="jxr_linenumber" name="391" href="#391">391</a>             <em class="jxr_comment">// which DOES NOT set childServers count.</em>
+<a class="jxr_linenumber" name="392" href="#392">392</a>             <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> childInstance = 1; childInstance &lt;= childServers; childInstance++) {
+<a class="jxr_linenumber" name="393" href="#393">393</a>                 completionService.submit(<strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerHandler</a>(childInstance));
+<a class="jxr_linenumber" name="394" href="#394">394</a>                 LOG.debug(<span class="jxr_string">"Started server handler ["</span> + instance + <span class="jxr_string">":"</span>
+<a class="jxr_linenumber" name="395" href="#395">395</a>                         + childInstance + <span class="jxr_string">"]"</span>);
+<a class="jxr_linenumber" name="396" href="#396">396</a>             }
+<a class="jxr_linenumber" name="397" href="#397">397</a> 
+<a class="jxr_linenumber" name="398" href="#398">398</a>             <strong class="jxr_keyword">while</strong> (<strong class="jxr_keyword">true</strong>) {
+<a class="jxr_linenumber" name="399" href="#399">399</a>                 LOG.debug(<span class="jxr_string">"Waiting for any server handler to finish"</span>);
+<a class="jxr_linenumber" name="400" href="#400">400</a>                 Future&lt;Integer&gt; f = completionService.take();<em class="jxr_comment">// blocks waiting</em>
+<a class="jxr_linenumber" name="401" href="#401">401</a>                                                              <em class="jxr_comment">// for any</em>
+<a class="jxr_linenumber" name="402" href="#402">402</a>                                                              <em class="jxr_comment">// ServerHandler to</em>
+<a class="jxr_linenumber" name="403" href="#403">403</a>                                                              <em class="jxr_comment">// finish</em>
+<a class="jxr_linenumber" name="404" href="#404">404</a>                 <strong class="jxr_keyword">if</strong> (f != <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="405" href="#405">405</a>                     Integer result = f.get();
+<a class="jxr_linenumber" name="406" href="#406">406</a>                     LOG.debug(<span class="jxr_string">"Server handler ["</span> + instance + <span class="jxr_string">":"</span> + result
+<a class="jxr_linenumber" name="407" href="#407">407</a>                             + <span class="jxr_string">"] finished, restarting"</span>);
+<a class="jxr_linenumber" name="408" href="#408">408</a>                     completionService.submit(<strong class="jxr_keyword">new</strong> <a href="../../../../org/trafodion/dcs/server/ServerManager.html">ServerHandler</a>(result));
+<a class="jxr_linenumber" name="409" href="#409">409</a>                 }
+<a class="jxr_linenumber" name="410" href="#410">410</a>             }
+<a class="jxr_linenumber" name="411" href="#411">411</a> 
+<a class="jxr_linenumber" name="412" href="#412">412</a>         } <strong class="jxr_keyword">catch</strong> (Exception e) {
+<a class="jxr_linenumber" name="413" href="#413">413</a>             e.printStackTrace();
+<a class="jxr_linenumber" name="414" href="#414">414</a>             LOG.error(e);
+<a class="jxr_linenumber" name="415" href="#415">415</a>             <strong class="jxr_keyword">if</strong> (executorService != <strong class="jxr_keyword">null</strong>)
+<a class="jxr_linenumber" name="416" href="#416">416</a>                 executorService.shutdown();
+<a class="jxr_linenumber" name="417" href="#417">417</a>             <strong class="jxr_keyword">throw</strong> e;
+<a class="jxr_linenumber" name="418" href="#418">418</a>         }
+<a class="jxr_linenumber" name="419" href="#419">419</a>         <em class="jxr_comment">/*</em>
+<a class="jxr_linenumber" name="420" href="#420">420</a> <em class="jxr_comment">         * ExecutorService pool = Executors.newSingleThreadExecutor();</em>
 <a class="jxr_linenumber" name="421" href="#421">421</a> <em class="jxr_comment">         * </em>
-<a class="jxr_linenumber" name="422" href="#422">422</a> <em class="jxr_comment">         * StringBuilder sb = new StringBuilder(); sb.append("exit code [" +</em>
-<a class="jxr_linenumber" name="423" href="#423">423</a> <em class="jxr_comment">         * scriptContext.getExitCode() + "]"); if(!</em>
-<a class="jxr_linenumber" name="424" href="#424">424</a> <em class="jxr_comment">         * scriptContext.getStdOut().toString().isEmpty())</em>
-<a class="jxr_linenumber" name="425" href="#425">425</a> <em class="jxr_comment">         * sb.append(", stdout [" + scriptContext.getStdOut().toString() + "]");</em>
-<a class="jxr_linenumber" name="426" href="#426">426</a> <em class="jxr_comment">         * if(! scriptContext.getStdErr().toString().isEmpty())</em>
-<a class="jxr_linenumber" name="427" href="#427">427</a> <em class="jxr_comment">         * sb.append(", stderr [" + scriptContext.getStdErr().toString() + "]");</em>
-<a class="jxr_linenumber" name="428" href="#428">428</a> <em class="jxr_comment">         * LOG.info(sb.toString());</em>
-<a class="jxr_linenumber" name="429" href="#429">429</a> <em class="jxr_comment">         * </em>
-<a class="jxr_linenumber" name="430" href="#430">430</a> <em class="jxr_comment">         * switch(scriptContext.getExitCode()) { case 3:</em>
-<a class="jxr_linenumber" name="431" href="#431">431</a> <em class="jxr_comment">         * LOG.error("Trafodion is not running"); timeoutMillis=60000; break;</em>
-<a class="jxr_linenumber" name="432" href="#432">432</a> <em class="jxr_comment">         * case 127: LOG.error("Cannot find user program executable");</em>
-<a class="jxr_linenumber" name="433" href="#433">433</a> <em class="jxr_comment">         * timeoutMillis=60000; break; default: timeoutMillis=5000; }</em>
+<a class="jxr_linenumber" name="422" href="#422">422</a> <em class="jxr_comment">         * try { getMaster(); registerInRunning(); featureCheck();</em>
+<a class="jxr_linenumber" name="423" href="#423">423</a> <em class="jxr_comment">         * </em>
+<a class="jxr_linenumber" name="424" href="#424">424</a> <em class="jxr_comment">         * Callable&lt;Boolean&gt; serverMonitor = new ServerMonitor();</em>
+<a class="jxr_linenumber" name="425" href="#425">425</a> <em class="jxr_comment">         * Callable&lt;ScriptContext&gt; serverRunner = new ServerRunner();</em>
+<a class="jxr_linenumber" name="426" href="#426">426</a> <em class="jxr_comment">         * </em>
+<a class="jxr_linenumber" name="427" href="#427">427</a> <em class="jxr_comment">         * long timeoutMillis=5000;</em>
+<a class="jxr_linenumber" name="428" href="#428">428</a> <em class="jxr_comment">         * </em>
+<a class="jxr_linenumber" name="429" href="#429">429</a> <em class="jxr_comment">         * while(true) { Future&lt;Boolean&gt; monitor = pool.submit(serverMonitor);</em>
+<a class="jxr_linenumber" name="430" href="#430">430</a> <em class="jxr_comment">         * if(false == monitor.get().booleanValue()) { //blocking call</em>
+<a class="jxr_linenumber" name="431" href="#431">431</a> <em class="jxr_comment">         * LOG.info("User program is not running"); Future&lt;ScriptContext&gt; runner</em>
+<a class="jxr_linenumber" name="432" href="#432">432</a> <em class="jxr_comment">         * = pool.submit(serverRunner); ScriptContext scriptContext =</em>
+<a class="jxr_linenumber" name="433" href="#433">433</a> <em class="jxr_comment">         * runner.get();//blocking call</em>
 <a class="jxr_linenumber" name="434" href="#434">434</a> <em class="jxr_comment">         * </em>
-<a class="jxr_linenumber" name="435" href="#435">435</a> <em class="jxr_comment">         * } else { timeoutMillis=5000; }</em>
-<a class="jxr_linenumber" name="436" href="#436">436</a> <em class="jxr_comment">         * </em>
-<a class="jxr_linenumber" name="437" href="#437">437</a> <em class="jxr_comment">         * try { Thread.sleep(timeoutMillis); } catch (InterruptedException e) {</em>
-<a class="jxr_linenumber" name="438" href="#438">438</a> <em class="jxr_comment">         * } }</em>
-<a class="jxr_linenumber" name="439" href="#439">439</a> <em class="jxr_comment">         * </em>
-<a class="jxr_linenumber" name="440" href="#440">440</a> <em class="jxr_comment">         * } catch (Exception e) { e.printStackTrace(); LOG.error(e);</em>
-<a class="jxr_linenumber" name="441" href="#441">441</a> <em class="jxr_comment">         * pool.shutdown(); throw e; }</em>
-<a class="jxr_linenumber" name="442" href="#442">442</a> <em class="jxr_comment">         */</em>
-<a class="jxr_linenumber" name="443" href="#443">443</a>     }
-<a class="jxr_linenumber" name="444" href="#444">444</a> 
-<a class="jxr_linenumber" name="445" href="#445">445</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> featureCheck() {
-<a class="jxr_linenumber" name="446" href="#446">446</a>         <strong class="jxr_keyword">final</strong> String msg1 = <span class="jxr_string">"Property "</span>
-<a class="jxr_linenumber" name="447" href="#447">447</a>                 + Constants.DCS_SERVER_USER_PROGRAM
-<a class="jxr_linenumber" name="448" href="#448">448</a>                 + <span class="jxr_string">" is false. "</span>
-<a class="jxr_linenumber" name="449" href="#449">449</a>                 + <span class="jxr_string">"Please add to your dcs-site.xml file and set &lt;value&gt;false&lt;/value&gt; to &lt;value&gt;true&lt;/value&gt;."</span>;
-<a class="jxr_linenumber" name="450" href="#450">450</a>         <strong class="jxr_keyword">final</strong> String msg2 = <span class="jxr_string">"Environment variable $MY_SQROOT is not set."</span>;
-<a class="jxr_linenumber" name="451" href="#451">451</a> 
-<a class="jxr_linenumber" name="452" href="#452">452</a>         <strong class="jxr_keyword">boolean</strong> ready = false;
-<a class="jxr_linenumber" name="453" href="#453">453</a>         <strong class="jxr_keyword">while</strong> (!ready) {
-<a class="jxr_linenumber" name="454" href="#454">454</a>             userProgEnabled = conf.getBoolean(
-<a class="jxr_linenumber" name="455" href="#455">455</a>                     Constants.DCS_SERVER_USER_PROGRAM,
-<a class="jxr_linenumber" name="456" href="#456">456</a>                     Constants.DEFAULT_DCS_SERVER_USER_PROGRAM);
-<a class="jxr_linenumber" name="457" href="#457">457</a>             userProgramHome = System.getProperty(<span class="jxr_string">"dcs.user.program.home"</span>);
-<a class="jxr_linenumber" name="458" href="#458">458</a>             userProgramCommand = conf.get(
-<a class="jxr_linenumber" name="459" href="#459">459</a>                     Constants.DCS_SERVER_USER_PROGRAM_COMMAND,
-<a class="jxr_linenumber" name="460" href="#460">460</a>                     Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_COMMAND);
-<a class="jxr_linenumber" name="461" href="#461">461</a> 
-<a class="jxr_linenumber" name="462" href="#462">462</a>             <strong class="jxr_keyword">if</strong> (userProgEnabled == <strong class="jxr_keyword">true</strong> &amp;&amp; userProgramHome.isEmpty() == false
-<a class="jxr_linenumber" name="463" href="#463">463</a>                     &amp;&amp; userProgramCommand.isEmpty() == false) {
-<a class="jxr_linenumber" name="464" href="#464">464</a>                 ready = <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="465" href="#465">465</a>                 <strong class="jxr_keyword">continue</strong>;
-<a class="jxr_linenumber" name="466" href="#466">466</a>             }
-<a class="jxr_linenumber" name="467" href="#467">467</a> 
-<a class="jxr_linenumber" name="468" href="#468">468</a>             <strong class="jxr_keyword">if</strong> (userProgEnabled == false)
-<a class="jxr_linenumber" name="469" href="#469">469</a>                 LOG.error(msg1);
-<a class="jxr_linenumber" name="470" href="#470">470</a>             <strong class="jxr_keyword">if</strong> (userProgramHome.isEmpty())
-<a class="jxr_linenumber" name="471" href="#471">471</a>                 LOG.error(msg2);
-<a class="jxr_linenumber" name="472" href="#472">472</a> 
-<a class="jxr_linenumber" name="473" href="#473">473</a>             <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="474" href="#474">474</a>                 Thread.sleep(60000);
-<a class="jxr_linenumber" name="475" href="#475">475</a>             } <strong class="jxr_keyword">catch</strong> (InterruptedException e) {
-<a class="jxr_linenumber" name="476" href="#476">476</a>             }
-<a class="jxr_linenumber" name="477" href="#477">477</a>         }
-<a class="jxr_linenumber" name="478" href="#478">478</a> 
-<a class="jxr_linenumber" name="479" href="#479">479</a>         LOG.info(<span class="jxr_string">"User program enabled"</span>);
-<a class="jxr_linenumber" name="480" href="#480">480</a>     }
-<a class="jxr_linenumber" name="481" href="#481">481</a> 
-<a class="jxr_linenumber" name="482" href="#482">482</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> getMaster() {
-<a class="jxr_linenumber" name="483" href="#483">483</a>         <strong class="jxr_keyword">boolean</strong> found = false;
-<a class="jxr_linenumber" name="484" href="#484">484</a> 
-<a class="jxr_linenumber" name="485" href="#485">485</a>         <strong class="jxr_keyword">while</strong> (!found) {
-<a class="jxr_linenumber" name="486" href="#486">486</a>             LOG.info(<span class="jxr_string">"Checking DcsMaster znode ["</span> + parentZnode
-<a class="jxr_linenumber" name="487" href="#487">487</a>                     + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER + <span class="jxr_string">"]"</span>);
-<a class="jxr_linenumber" name="488" href="#488">488</a>             <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="489" href="#489">489</a>                 Stat stat = zkc.exists(parentZnode
-<a class="jxr_linenumber" name="490" href="#490">490</a>                         + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER, false);
-<a class="jxr_linenumber" name="491" href="#491">491</a>                 <strong class="jxr_keyword">if</strong> (stat != <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="492" href="#492">492</a>                     List&lt;String&gt; nodes = zkc.getChildren(parentZnode
-<a class="jxr_linenumber" name="493" href="#493">493</a>                             + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER, <strong class="jxr_keyword">null</strong>);
-<a class="jxr_linenumber" name="494" href="#494">494</a>                     <strong class="jxr_keyword">if</strong> (!nodes.isEmpty()) {
-<a class="jxr_linenumber" name="495" href="#495">495</a>                         StringTokenizer st = <strong class="jxr_keyword">new</strong> StringTokenizer(nodes.get(0),
-<a class="jxr_linenumber" name="496" href="#496">496</a>                                 <span class="jxr_string">":"</span>);
-<a class="jxr_linenumber" name="497" href="#497">497</a>                         <strong class="jxr_keyword">while</strong> (st.hasMoreTokens()) {
-<a class="jxr_linenumber" name="498" href="#498">498</a>                             masterHostName = st.nextToken();
-<a class="jxr_linenumber" name="499" href="#499">499</a>                             port = Integer.parseInt(st.nextToken());
-<a class="jxr_linenumber" name="500" href="#500">500</a>                             portRange = Integer.parseInt(st.nextToken());
-<a class="jxr_linenumber" name="501" href="#501">501</a>                             masterStartTime = Long.parseLong(st.nextToken());
-<a class="jxr_linenumber" name="502" href="#502">502</a>                         }
-<a class="jxr_linenumber" name="503" href="#503">503</a>                         found = <strong class="jxr_keyword">true</strong>;
-<a class="jxr_linenumber" name="504" href="#504">504</a>                         LOG.info(<span class="jxr_string">"DcsMaster znode ["</span> + parentZnode
-<a class="jxr_linenumber" name="505" href="#505">505</a>                                 + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER
-<a class="jxr_linenumber" name="506" href="#506">506</a>                                 + <span class="jxr_string">"] found"</span>);
-<a class="jxr_linenumber" name="507" href="#507">507</a>                     }
-<a class="jxr_linenumber" name="508" href="#508">508</a>                 } <strong class="jxr_keyword">else</strong> {
-<a class="jxr_linenumber" name="509" href="#509">509</a>                     LOG.info(<span class="jxr_string">"DcsMaster znode ["</span> + parentZnode
-<a class="jxr_linenumber" name="510" href="#510">510</a>                             + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER
-<a class="jxr_linenumber" name="511" href="#511">511</a>                             + <span class="jxr_string">"] not found"</span>);
-<a class="jxr_linenumber" name="512" href="#512">512</a>                 }
-<a class="jxr_linenumber" name="513" href="#513">513</a> 
-<a class="jxr_linenumber" name="514" href="#514">514</a>                 <strong class="jxr_keyword">if</strong> (!found) {
-<a class="jxr_linenumber" name="515" href="#515">515</a>                     <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="516" href="#516">516</a>                         Thread.sleep(5000);
-<a class="jxr_linenumber" name="517" href="#517">517</a>                     } <strong class="jxr_keyword">catch</strong> (InterruptedException e) {
-<a class="jxr_linenumber" name="518" href="#518">518</a>                     }
-<a class="jxr_linenumber" name="519" href="#519">519</a>                 }
-<a class="jxr_linenumber" name="520" href="#520">520</a> 
-<a class="jxr_linenumber" name="521" href="#521">521</a>             } <strong class="jxr_keyword">catch</strong> (Exception e) {
-<a class="jxr_linenumber" name="522" href="#522">522</a>                 e.printStackTrace();
-<a class="jxr_linenumber" name="523" href="#523">523</a>                 LOG.error(e);
-<a class="jxr_linenumber" name="524" href="#524">524</a>             }
-<a class="jxr_linenumber" name="525" href="#525">525</a>         }
-<a class="jxr_linenumber" name="526" href="#526">526</a>     }
-<a class="jxr_linenumber" name="527" href="#527">527</a> 
-<a class="jxr_linenumber" name="528" href="#528">528</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> registerInRunning(<strong class="jxr_keyword">int</strong> instance) {
-<a class="jxr_linenumber" name="529" href="#529">529</a>         String znode = parentZnode
-<a class="jxr_linenumber" name="530" href="#530">530</a>                 + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_RUNNING + <span class="jxr_string">"/"</span>
-<a class="jxr_linenumber" name="531" href="#531">531</a>                 + hostName + <span class="jxr_string">":"</span> + instance + <span class="jxr_string">":"</span> + infoPort + <span class="jxr_string">":"</span>
-<a class="jxr_linenumber" name="532" href="#532">532</a>                 + System.currentTimeMillis();
-<a class="jxr_linenumber" name="533" href="#533">533</a>         <strong class="jxr_keyword">try</strong> {
-<a class="jxr_linenumber" name="534" href="#534">534</a>             Stat stat = zkc.exists(znode, false);
-<a class="jxr_linenumber" name="535" href="#535">535</a>             <strong class="jxr_keyword">if</strong> (stat == <strong class="jxr_keyword">null</strong>) {
-<a class="jxr_linenumber" name="536" href="#536">536</a>                 zkc.create(znode, <strong class="jxr_keyword">new</strong> byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE,
-<a class="jxr_linenumber" name="537" href="#537">537</a>                         CreateMode.EPHEMERAL);
-<a class="jxr_linenumber" name="538" href="#538">538</a>                 LOG.info(<span class="jxr_string">"Created znode ["</span> + znode + <span class="jxr_string">"]"</span>);
-<a class="jxr_linenumber" name="539" href="#539">539</a>             }
-<a class="jxr_linenumber" name="540" href="#540">540</a>         } <strong class="jxr_keyword">catch</strong> (KeeperException.NodeExistsException e) {
-<a class="jxr_linenumber" name="541" href="#541">541</a>             <em class="jxr_comment">// do nothing...leftover from previous shutdown</em>
-<a class="jxr_linenumber" name="542" href="#542">542</a>         } <strong class="jxr_keyword">catch</strong> (Exception e) {
-<a class="jxr_linenumber" name="543" href="#543">543</a>             e.printStackTrace();
-<a class="jxr_linenumber" name="544" href="#544">544</a>             LOG.error(e);
-<a class="jxr_linenumber" name="545" href="#545">545</a>         }
-<a class="jxr_linenumber" name="546" href="#546">546</a>     }
-<a class="jxr_linenumber" name="547" href="#547">547</a> 
-<a class="jxr_linenumber" name="548" href="#548">548</a>     <strong class="jxr_keyword">public</strong> String getMasterHostName() {
-<a class="jxr_linenumber" name="549" href="#549">549</a>         <strong class="jxr_keyword">return</strong> masterHostName;
-<a class="jxr_linenumber" name="550" href="#550">550</a>     }
-<a class="jxr_linenumber" name="551" href="#551">551</a> 
-<a class="jxr_linenumber" name="552" href="#552">552</a>     <strong class="jxr_keyword">public</strong> String getZKParentZnode() {
-<a class="jxr_linenumber" name="553" href="#553">553</a>         <strong class="jxr_keyword">return</strong> parentZnode;
-<a class="jxr_linenumber" name="554" href="#554">554</a>     }
-<a class="jxr_linenumber" name="555" href="#555">555</a> 
-<a class="jxr_linenumber" name="556" href="#556">556</a>     <strong class="jxr_keyword">public</strong> String getUserProgramHome() {
-<a class="jxr_linenumber" name="557" href="#557">557</a>         <strong class="jxr_keyword">return</strong> userProgramHome;
-<a class="jxr_linenumber" name="558" href="#558">558</a>     }
-<a class="jxr_linenumber" name="559" href="#559">559</a> }
+<a class="jxr_linenumber" name="435" href="#435">435</a> <em class="jxr_comment">         * StringBuilder sb = new StringBuilder(); sb.append("exit code [" +</em>
+<a class="jxr_linenumber" name="436" href="#436">436</a> <em class="jxr_comment">         * scriptContext.getExitCode() + "]"); if(!</em>
+<a class="jxr_linenumber" name="437" href="#437">437</a> <em class="jxr_comment">         * scriptContext.getStdOut().toString().isEmpty())</em>
+<a class="jxr_linenumber" name="438" href="#438">438</a> <em class="jxr_comment">         * sb.append(", stdout [" + scriptContext.getStdOut().toString() + "]");</em>
+<a class="jxr_linenumber" name="439" href="#439">439</a> <em class="jxr_comment">         * if(! scriptContext.getStdErr().toString().isEmpty())</em>
+<a class="jxr_linenumber" name="440" href="#440">440</a> <em class="jxr_comment">         * sb.append(", stderr [" + scriptContext.getStdErr().toString() + "]");</em>
+<a class="jxr_linenumber" name="441" href="#441">441</a> <em class="jxr_comment">         * LOG.info(sb.toString());</em>
+<a class="jxr_linenumber" name="442" href="#442">442</a> <em class="jxr_comment">         * </em>
+<a class="jxr_linenumber" name="443" href="#443">443</a> <em class="jxr_comment">         * switch(scriptContext.getExitCode()) { case 3:</em>
+<a class="jxr_linenumber" name="444" href="#444">444</a> <em class="jxr_comment">         * LOG.error("Trafodion is not running"); timeoutMillis=60000; break;</em>
+<a class="jxr_linenumber" name="445" href="#445">445</a> <em class="jxr_comment">         * case 127: LOG.error("Cannot find user program executable");</em>
+<a class="jxr_linenumber" name="446" href="#446">446</a> <em class="jxr_comment">         * timeoutMillis=60000; break; default: timeoutMillis=5000; }</em>
+<a class="jxr_linenumber" name="447" href="#447">447</a> <em class="jxr_comment">         * </em>
+<a class="jxr_linenumber" name="448" href="#448">448</a> <em class="jxr_comment">         * } else { timeoutMillis=5000; }</em>
+<a class="jxr_linenumber" name="449" href="#449">449</a> <em class="jxr_comment">         * </em>
+<a class="jxr_linenumber" name="450" href="#450">450</a> <em class="jxr_comment">         * try { Thread.sleep(timeoutMillis); } catch (InterruptedException e) {</em>
+<a class="jxr_linenumber" name="451" href="#451">451</a> <em class="jxr_comment">         * } }</em>
+<a class="jxr_linenumber" name="452" href="#452">452</a> <em class="jxr_comment">         * </em>
+<a class="jxr_linenumber" name="453" href="#453">453</a> <em class="jxr_comment">         * } catch (Exception e) { e.printStackTrace(); LOG.error(e);</em>
+<a class="jxr_linenumber" name="454" href="#454">454</a> <em class="jxr_comment">         * pool.shutdown(); throw e; }</em>
+<a class="jxr_linenumber" name="455" href="#455">455</a> <em class="jxr_comment">         */</em>
+<a class="jxr_linenumber" name="456" href="#456">456</a>     }
+<a class="jxr_linenumber" name="457" href="#457">457</a> 
+<a class="jxr_linenumber" name="458" href="#458">458</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> featureCheck() {
+<a class="jxr_linenumber" name="459" href="#459">459</a>         <strong class="jxr_keyword">final</strong> String msg1 = <span class="jxr_string">"Property "</span>
+<a class="jxr_linenumber" name="460" href="#460">460</a>                 + Constants.DCS_SERVER_USER_PROGRAM
+<a class="jxr_linenumber" name="461" href="#461">461</a>                 + <span class="jxr_string">" is false. "</span>
+<a class="jxr_linenumber" name="462" href="#462">462</a>                 + <span class="jxr_string">"Please add to your dcs-site.xml file and set &lt;value&gt;false&lt;/value&gt; to &lt;value&gt;true&lt;/value&gt;."</span>;
+<a class="jxr_linenumber" name="463" href="#463">463</a>         <strong class="jxr_keyword">final</strong> String msg2 = <span class="jxr_string">"Environment variable $MY_SQROOT is not set."</span>;
+<a class="jxr_linenumber" name="464" href="#464">464</a> 
+<a class="jxr_linenumber" name="465" href="#465">465</a>         <strong class="jxr_keyword">boolean</strong> ready = false;
+<a class="jxr_linenumber" name="466" href="#466">466</a>         <strong class="jxr_keyword">while</strong> (!ready) {
+<a class="jxr_linenumber" name="467" href="#467">467</a>             userProgEnabled = conf.getBoolean(
+<a class="jxr_linenumber" name="468" href="#468">468</a>                     Constants.DCS_SERVER_USER_PROGRAM,
+<a class="jxr_linenumber" name="469" href="#469">469</a>                     Constants.DEFAULT_DCS_SERVER_USER_PROGRAM);
+<a class="jxr_linenumber" name="470" href="#470">470</a>             userProgramHome = System.getProperty(<span class="jxr_string">"dcs.user.program.home"</span>);
+<a class="jxr_linenumber" name="471" href="#471">471</a>             userProgramCommand = conf.get(
+<a class="jxr_linenumber" name="472" href="#472">472</a>                     Constants.DCS_SERVER_USER_PROGRAM_COMMAND,
+<a class="jxr_linenumber" name="473" href="#473">473</a>                     Constants.DEFAULT_DCS_SERVER_USER_PROGRAM_COMMAND);
+<a class="jxr_linenumber" name="474" href="#474">474</a> 
+<a class="jxr_linenumber" name="475" href="#475">475</a>             <strong class="jxr_keyword">if</strong> (userProgEnabled == <strong class="jxr_keyword">true</strong> &amp;&amp; userProgramHome.isEmpty() == false
+<a class="jxr_linenumber" name="476" href="#476">476</a>                     &amp;&amp; userProgramCommand.isEmpty() == false) {
+<a class="jxr_linenumber" name="477" href="#477">477</a>                 ready = <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="478" href="#478">478</a>                 <strong class="jxr_keyword">continue</strong>;
+<a class="jxr_linenumber" name="479" href="#479">479</a>             }
+<a class="jxr_linenumber" name="480" href="#480">480</a> 
+<a class="jxr_linenumber" name="481" href="#481">481</a>             <strong class="jxr_keyword">if</strong> (userProgEnabled == false)
+<a class="jxr_linenumber" name="482" href="#482">482</a>                 LOG.error(msg1);
+<a class="jxr_linenumber" name="483" href="#483">483</a>             <strong class="jxr_keyword">if</strong> (userProgramHome.isEmpty())
+<a class="jxr_linenumber" name="484" href="#484">484</a>                 LOG.error(msg2);
+<a class="jxr_linenumber" name="485" href="#485">485</a> 
+<a class="jxr_linenumber" name="486" href="#486">486</a>             <strong class="jxr_keyword">try</strong> {
+<a class="jxr_linenumber" name="487" href="#487">487</a>                 Thread.sleep(60000);
+<a class="jxr_linenumber" name="488" href="#488">488</a>             } <strong class="jxr_keyword">catch</strong> (InterruptedException e) {
+<a class="jxr_linenumber" name="489" href="#489">489</a>             }
+<a class="jxr_linenumber" name="490" href="#490">490</a>         }
+<a class="jxr_linenumber" name="491" href="#491">491</a> 
+<a class="jxr_linenumber" name="492" href="#492">492</a>         LOG.info(<span class="jxr_string">"User program enabled"</span>);
+<a class="jxr_linenumber" name="493" href="#493">493</a>     }
+<a class="jxr_linenumber" name="494" href="#494">494</a> 
+<a class="jxr_linenumber" name="495" href="#495">495</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> getMaster() {
+<a class="jxr_linenumber" name="496" href="#496">496</a>         <strong class="jxr_keyword">boolean</strong> found = false;
+<a class="jxr_linenumber" name="497" href="#497">497</a> 
+<a class="jxr_linenumber" name="498" href="#498">498</a>         <strong class="jxr_keyword">while</strong> (!found) {
+<a class="jxr_linenumber" name="499" href="#499">499</a>             LOG.info(<span class="jxr_string">"Checking DcsMaster znode ["</span> + parentZnode
+<a class="jxr_linenumber" name="500" href="#500">500</a>                     + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER + <span class="jxr_string">"]"</span>);
+<a class="jxr_linenumber" name="501" href="#501">501</a>             <strong class="jxr_keyword">try</strong> {
+<a class="jxr_linenumber" name="502" href="#502">502</a>                 Stat stat = zkc.exists(parentZnode
+<a class="jxr_linenumber" name="503" href="#503">503</a>                         + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER, false);
+<a class="jxr_linenumber" name="504" href="#504">504</a>                 <strong class="jxr_keyword">if</strong> (stat != <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="505" href="#505">505</a>                     List&lt;String&gt; nodes = zkc.getChildren(parentZnode
+<a class="jxr_linenumber" name="506" href="#506">506</a>                             + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER, <strong class="jxr_keyword">null</strong>);
+<a class="jxr_linenumber" name="507" href="#507">507</a>                     <strong class="jxr_keyword">if</strong> (!nodes.isEmpty()) {
+<a class="jxr_linenumber" name="508" href="#508">508</a>                         StringTokenizer st = <strong class="jxr_keyword">new</strong> StringTokenizer(nodes.get(0),
+<a class="jxr_linenumber" name="509" href="#509">509</a>                                 <span class="jxr_string">":"</span>);
+<a class="jxr_linenumber" name="510" href="#510">510</a>                         <strong class="jxr_keyword">while</strong> (st.hasMoreTokens()) {
+<a class="jxr_linenumber" name="511" href="#511">511</a>                             masterHostName = st.nextToken();
+<a class="jxr_linenumber" name="512" href="#512">512</a>                             port = Integer.parseInt(st.nextToken());
+<a class="jxr_linenumber" name="513" href="#513">513</a>                             portRange = Integer.parseInt(st.nextToken());
+<a class="jxr_linenumber" name="514" href="#514">514</a>                             masterStartTime = Long.parseLong(st.nextToken());
+<a class="jxr_linenumber" name="515" href="#515">515</a>                         }
+<a class="jxr_linenumber" name="516" href="#516">516</a>                         found = <strong class="jxr_keyword">true</strong>;
+<a class="jxr_linenumber" name="517" href="#517">517</a>                         LOG.info(<span class="jxr_string">"DcsMaster znode ["</span> + parentZnode
+<a class="jxr_linenumber" name="518" href="#518">518</a>                                 + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER
+<a class="jxr_linenumber" name="519" href="#519">519</a>                                 + <span class="jxr_string">"] found"</span>);
+<a class="jxr_linenumber" name="520" href="#520">520</a>                     }
+<a class="jxr_linenumber" name="521" href="#521">521</a>                 } <strong class="jxr_keyword">else</strong> {
+<a class="jxr_linenumber" name="522" href="#522">522</a>                     LOG.info(<span class="jxr_string">"DcsMaster znode ["</span> + parentZnode
+<a class="jxr_linenumber" name="523" href="#523">523</a>                             + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER
+<a class="jxr_linenumber" name="524" href="#524">524</a>                             + <span class="jxr_string">"] not found"</span>);
+<a class="jxr_linenumber" name="525" href="#525">525</a>                 }
+<a class="jxr_linenumber" name="526" href="#526">526</a> 
+<a class="jxr_linenumber" name="527" href="#527">527</a>                 <strong class="jxr_keyword">if</strong> (!found) {
+<a class="jxr_linenumber" name="528" href="#528">528</a>                     <strong class="jxr_keyword">try</strong> {
+<a class="jxr_linenumber" name="529" href="#529">529</a>                         Thread.sleep(5000);
+<a class="jxr_linenumber" name="530" href="#530">530</a>                     } <strong class="jxr_keyword">catch</strong> (InterruptedException e) {
+<a class="jxr_linenumber" name="531" href="#531">531</a>                     }
+<a class="jxr_linenumber" name="532" href="#532">532</a>                 }
+<a class="jxr_linenumber" name="533" href="#533">533</a> 
+<a class="jxr_linenumber" name="534" href="#534">534</a>             } <strong class="jxr_keyword">catch</strong> (Exception e) {
+<a class="jxr_linenumber" name="535" href="#535">535</a>                 e.printStackTrace();
+<a class="jxr_linenumber" name="536" href="#536">536</a>                 LOG.error(e);
+<a class="jxr_linenumber" name="537" href="#537">537</a>             }
+<a class="jxr_linenumber" name="538" href="#538">538</a>         }
+<a class="jxr_linenumber" name="539" href="#539">539</a>     }
+<a class="jxr_linenumber" name="540" href="#540">540</a> 
+<a class="jxr_linenumber" name="541" href="#541">541</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> registerInRunning(<strong class="jxr_keyword">int</strong> instance) {
+<a class="jxr_linenumber" name="542" href="#542">542</a>         String znode = parentZnode
+<a class="jxr_linenumber" name="543" href="#543">543</a>                 + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_RUNNING + <span class="jxr_string">"/"</span>
+<a class="jxr_linenumber" name="544" href="#544">544</a>                 + hostName + <span class="jxr_string">":"</span> + instance + <span class="jxr_string">":"</span> + infoPort + <span class="jxr_string">":"</span>
+<a class="jxr_linenumber" name="545" href="#545">545</a>                 + System.currentTimeMillis();
+<a class="jxr_linenumber" name="546" href="#546">546</a>         <strong class="jxr_keyword">try</strong> {
+<a class="jxr_linenumber" name="547" href="#547">547</a>             Stat stat = zkc.exists(znode, false);
+<a class="jxr_linenumber" name="548" href="#548">548</a>             <strong class="jxr_keyword">if</strong> (stat == <strong class="jxr_keyword">null</strong>) {
+<a class="jxr_linenumber" name="549" href="#549">549</a>                 zkc.create(znode, <strong class="jxr_keyword">new</strong> byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE,
+<a class="jxr_linenumber" name="550" href="#550">550</a>                         CreateMode.EPHEMERAL);
+<a class="jxr_linenumber" name="551" href="#551">551</a>                 LOG.info(<span class="jxr_string">"Created znode ["</span> + znode + <span class="jxr_string">"]"</span>);
+<a class="jxr_linenumber" name="552" href="#552">552</a>             }
+<a class="jxr_linenumber" name="553" href="#553">553</a>         } <strong class="jxr_keyword">catch</strong> (KeeperException.NodeExistsException e) {
+<a class="jxr_linenumber" name="554" href="#554">554</a>             <em class="jxr_comment">// do nothing...leftover from previous shutdown</em>
+<a class="jxr_linenumber" name="555" href="#555">555</a>         } <strong class="jxr_keyword">catch</strong> (Exception e) {
+<a class="jxr_linenumber" name="556" href="#556">556</a>             e.printStackTrace();
+<a class="jxr_linenumber" name="557" href="#557">557</a>             LOG.error(e);
+<a class="jxr_linenumber" name="558" href="#558">558</a>         }
+<a class="jxr_linenumber" name="559" href="#559">559</a>     }
+<a class="jxr_linenumber" name="560" href="#560">560</a> 
+<a class="jxr_linenumber" name="561" href="#561">561</a>     <strong class="jxr_keyword">public</strong> String getMasterHostName() {
+<a class="jxr_linenumber" name="562" href="#562">562</a>         <strong class="jxr_keyword">return</strong> masterHostName;
+<a class="jxr_linenumber" name="563" href="#563">563</a>     }
+<a class="jxr_linenumber" name="564" href="#564">564</a> 
+<a class="jxr_linenumber" name="565" href="#565">565</a>     <strong class="jxr_keyword">public</strong> String getZKParentZnode() {
+<a class="jxr_linenumber" name="566" href="#566">566</a>         <strong class="jxr_keyword">return</strong> parentZnode;
+<a class="jxr_linenumber" name="567" href="#567">567</a>     }
+<a class="jxr_linenumber" name="568" href="#568">568</a> 
+<a class="jxr_linenumber" name="569" href="#569">569</a>     <strong class="jxr_keyword">public</strong> String getUserProgramHome() {
+<a class="jxr_linenumber" name="570" href="#570">570</a>         <strong class="jxr_keyword">return</strong> userProgramHome;
+<a class="jxr_linenumber" name="571" href="#571">571</a>     }
+<a class="jxr_linenumber" name="572" href="#572">572</a> }
 </pre>
 <hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
 </html>


Mime
View raw message