From: <tho...@us...> - 2014-03-13 15:51:45
|
Revision: 7954 http://sourceforge.net/p/bigdata/code/7954 Author: thompsonbry Date: 2014-03-13 15:51:39 +0000 (Thu, 13 Mar 2014) Log Message: ----------- - I have changed the dependency to jetty 9.1. I have also brought in the jetty-proxy jar in anticipation of using the ProxyServlet to support transparent load balancing. This required several changes to jetty.xml. - I have eliminated the code paths in the NanoSparqlServer that relied on manual configuration (in code) of the NSS. All code paths now rely on jetty.xml and web.xml, even for embedded use. You can override the location of the jetty.xml file if necessary to customize the deployment. You can also override properties in jetty.xml using environment variables and init parameters in web.xml using the NSS command line options. Note: It appears to be impossible to override the init parameters set on a WebAppContext that is configured from a web.xml file. This appears to be in accordance with the Servlet 3.0 specification. To work around this, I attach the overrides for the init parameters as an attribute to the WebAppContext. The life cycle listener then consults both the init parameters from web.xml and those from the overrides and generates a map of the effective init parameters. This is done in BigdataRDFServletContextListener. There is also a new unit test to verify that we can override these parameters. This is TestNanoSparqlServer. - I added an override for the resourceBase for jetty as deployed for the HA CI test suite. - The InferenceServlet has been entered into web.xml so it should continue to function (are there unit tests for this yet?). - done: test CI (GOM, HA) - done: test NSS command line script startup (tests for ability to find the embedded web.xml file in the compiled JAR). The jetty.xml file is located in bigdata-war/src/jetty.xml. This file is in the jar, but it is not located in that position since it is looking for jetty.xml. To run the NSS, you need to override the location using "-DjettyXml=bigdata-war/src/jetty.xml" or any other jetty.xml file that you want to use. I added a "-jettyXml" option to the NSS main() routine and set the default to locate the jetty.xml resource inside of the jar (bigdata-war/src/jetty.xml). - done: test distribution (HA service starter) {{{ # Laptop setup. cd /Users/bryan/Documents/workspace/RDR_NEW_SVN #svn update ant clean stage export wd=/Users/bryan/Documents/workspace/RDR_NEW_SVN export FEDNAME=benchmark3 export LOGICAL_SERVICE_ID=HAJournal-1 export FED_DIR=$wd export LOCATORS="jini://localhost" export ZK_SERVERS="localhost:2081" export JETTY_XML=${wd}/dist/bigdata/var/jetty/jetty.xml export JETTY_WEB_XML=${wd}/dist/bigdata/var/jetty/WEB-INF/web.xml export JETTY_PORT=8090 dist/bigdata/bin/startHAServices tail -f HAJournalServer.log | egrep '(ERROR|WARN|FATAL)' }}} - done: test WAR See #730 (jetty.xml configuration) Modified Paths: -------------- branches/RDR/.classpath branches/RDR/bigdata-gom/src/test/com/bigdata/gom/RemoteGOMTestCase.java branches/RDR/bigdata-gom/src/test/com/bigdata/gom/TestRemoteGOM.java branches/RDR/bigdata-jini/src/java/com/bigdata/journal/jini/ha/HAJournalServer.java branches/RDR/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHA3JournalServerTestCase.java branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/BigdataRDFServletContextListener.java branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/NanoSparqlServer.java branches/RDR/bigdata-sails/src/samples/com/bigdata/samples/NSSEmbeddedExample.java branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractNanoSparqlServerTestCase.java branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractTestNanoSparqlClient.java branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestAll.java branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestFederatedQuery.java branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlServerWithProxyIndexManager.java branches/RDR/bigdata-war/src/WEB-INF/web.xml branches/RDR/bigdata-war/src/jetty.xml branches/RDR/build.properties branches/RDR/build.xml branches/RDR/pom.xml Added Paths: ----------- branches/RDR/LEGAL/ branches/RDR/LEGAL/apache-license-2_0.txt branches/RDR/LEGAL/sesame2.x-license.txt branches/RDR/bigdata/lib/jetty/jetty-continuation-9.1.3.v20140225.jar branches/RDR/bigdata/lib/jetty/jetty-http-9.1.3.v20140225.jar branches/RDR/bigdata/lib/jetty/jetty-io-9.1.3.v20140225.jar branches/RDR/bigdata/lib/jetty/jetty-proxy-9.1.3.v20140225.jar branches/RDR/bigdata/lib/jetty/jetty-rewrite-9.1.3.v20140225.jar branches/RDR/bigdata/lib/jetty/jetty-security-9.1.3.v20140225.jar branches/RDR/bigdata/lib/jetty/jetty-server-9.1.3.v20140225.jar branches/RDR/bigdata/lib/jetty/jetty-servlet-9.1.3.v20140225.jar branches/RDR/bigdata/lib/jetty/jetty-util-9.1.3.v20140225.jar branches/RDR/bigdata/lib/jetty/jetty-webapp-9.1.3.v20140225.jar branches/RDR/bigdata/lib/jetty/jetty-xml-9.1.3.v20140225.jar branches/RDR/bigdata/lib/jetty/servlet-api-3.1.0.jar branches/RDR/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlServer.java Modified: branches/RDR/.classpath =================================================================== --- branches/RDR/.classpath 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/.classpath 2014-03-13 15:51:39 UTC (rev 7954) @@ -32,18 +32,9 @@ <classpathentry kind="src" path="bigdata-gas/src/java"/> <classpathentry kind="src" path="bigdata-gas/src/test"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/dsi-utils-1.0.6-020610.jar"/> - <classpathentry kind="lib" path="bigdata/lib/lgpl-utils-1.0.7-270114.jar"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/lgpl-utils-1.0.7-270114.jar"/> <classpathentry exported="true" kind="lib" path="bigdata-jini/lib/apache/zookeeper-3.3.3.jar"/> - <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-continuation-7.2.2.v20101205.jar"/> - <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-http-7.2.2.v20101205.jar"/> - <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-io-7.2.2.v20101205.jar"/> - <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-server-7.2.2.v20101205.jar"/> - <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-util-7.2.2.v20101205.jar"/> - <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/servlet-api-2.5.jar"/> - <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-servlet-7.2.2.v20101205.jar" sourcepath="/Users/bryan/Downloads/jetty-hightide-7.2.2.v20101205-src"/> - <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-security-7.2.2.v20101205.jar"/> - <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-webapp-7.2.2.v20101205.jar"/> - <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-xml-7.2.2.v20101205.jar"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/servlet-api-3.1.0.jar"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/unimi/colt-1.2.0.jar"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/icu/icu4j-4.8.jar"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/icu/icu4j-charset-4.8.jar"/> @@ -67,7 +58,6 @@ <classpathentry exported="true" kind="lib" path="bigdata/lib/unimi/fastutil-5.1.5.jar"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/lucene/lucene-analyzers-3.0.0.jar"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/lucene/lucene-core-3.0.0.jar"/> - <classpathentry kind="lib" path="bigdata/lib/jetty/jetty-rewrite-7.2.2.v20101205.jar"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/high-scale-lib-v1.1.2.jar"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/junit-ext-1.1-b3-dev.jar"/> @@ -87,5 +77,16 @@ <classpathentry exported="true" kind="lib" path="bigdata-sails/lib/sesame-sparql-testsuite-2.6.10.jar"/> <classpathentry exported="true" kind="lib" path="bigdata-sails/lib/sesame-store-testsuite-2.6.10.jar"/> <classpathentry exported="true" kind="lib" path="bigdata-rdf/lib/nxparser-1.2.3.jar"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-continuation-9.1.3.v20140225.jar"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-http-9.1.3.v20140225.jar"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-io-9.1.3.v20140225.jar"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-proxy-9.1.3.v20140225.jar"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-rewrite-9.1.3.v20140225.jar"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-security-9.1.3.v20140225.jar"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-server-9.1.3.v20140225.jar" sourcepath="/Users/bryan/Documents/workspace/org.eclipse.jetty.project-jetty-9.1-wsbatch"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-servlet-9.1.3.v20140225.jar" sourcepath="/Users/bryan/Documents/workspace/org.eclipse.jetty.project-jetty-9.1-wsbatch"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-util-9.1.3.v20140225.jar" sourcepath="/Users/bryan/Documents/workspace/org.eclipse.jetty.project-jetty-9.1-wsbatch"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-webapp-9.1.3.v20140225.jar"/> + <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-xml-9.1.3.v20140225.jar"/> <classpathentry kind="output" path="bin"/> </classpath> Added: branches/RDR/LEGAL/apache-license-2_0.txt =================================================================== --- branches/RDR/LEGAL/apache-license-2_0.txt (rev 0) +++ branches/RDR/LEGAL/apache-license-2_0.txt 2014-03-13 15:51:39 UTC (rev 7954) @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. Property changes on: branches/RDR/LEGAL/apache-license-2_0.txt ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: branches/RDR/LEGAL/sesame2.x-license.txt =================================================================== --- branches/RDR/LEGAL/sesame2.x-license.txt (rev 0) +++ branches/RDR/LEGAL/sesame2.x-license.txt 2014-03-13 15:51:39 UTC (rev 7954) @@ -0,0 +1,25 @@ +Copyright Aduna (http://www.aduna-software.com/) \xA9 2001-2007 +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Property changes on: branches/RDR/LEGAL/sesame2.x-license.txt ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: branches/RDR/bigdata/lib/jetty/jetty-continuation-9.1.3.v20140225.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/jetty-continuation-9.1.3.v20140225.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/jetty-continuation-9.1.3.v20140225.jar 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata/lib/jetty/jetty-continuation-9.1.3.v20140225.jar 2014-03-13 15:51:39 UTC (rev 7954) Property changes on: branches/RDR/bigdata/lib/jetty/jetty-continuation-9.1.3.v20140225.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/RDR/bigdata/lib/jetty/jetty-http-9.1.3.v20140225.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/jetty-http-9.1.3.v20140225.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/jetty-http-9.1.3.v20140225.jar 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata/lib/jetty/jetty-http-9.1.3.v20140225.jar 2014-03-13 15:51:39 UTC (rev 7954) Property changes on: branches/RDR/bigdata/lib/jetty/jetty-http-9.1.3.v20140225.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/RDR/bigdata/lib/jetty/jetty-io-9.1.3.v20140225.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/jetty-io-9.1.3.v20140225.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/jetty-io-9.1.3.v20140225.jar 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata/lib/jetty/jetty-io-9.1.3.v20140225.jar 2014-03-13 15:51:39 UTC (rev 7954) Property changes on: branches/RDR/bigdata/lib/jetty/jetty-io-9.1.3.v20140225.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/RDR/bigdata/lib/jetty/jetty-proxy-9.1.3.v20140225.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/jetty-proxy-9.1.3.v20140225.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/jetty-proxy-9.1.3.v20140225.jar 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata/lib/jetty/jetty-proxy-9.1.3.v20140225.jar 2014-03-13 15:51:39 UTC (rev 7954) Property changes on: branches/RDR/bigdata/lib/jetty/jetty-proxy-9.1.3.v20140225.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/RDR/bigdata/lib/jetty/jetty-rewrite-9.1.3.v20140225.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/jetty-rewrite-9.1.3.v20140225.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/jetty-rewrite-9.1.3.v20140225.jar 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata/lib/jetty/jetty-rewrite-9.1.3.v20140225.jar 2014-03-13 15:51:39 UTC (rev 7954) Property changes on: branches/RDR/bigdata/lib/jetty/jetty-rewrite-9.1.3.v20140225.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/RDR/bigdata/lib/jetty/jetty-security-9.1.3.v20140225.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/jetty-security-9.1.3.v20140225.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/jetty-security-9.1.3.v20140225.jar 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata/lib/jetty/jetty-security-9.1.3.v20140225.jar 2014-03-13 15:51:39 UTC (rev 7954) Property changes on: branches/RDR/bigdata/lib/jetty/jetty-security-9.1.3.v20140225.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/RDR/bigdata/lib/jetty/jetty-server-9.1.3.v20140225.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/jetty-server-9.1.3.v20140225.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/jetty-server-9.1.3.v20140225.jar 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata/lib/jetty/jetty-server-9.1.3.v20140225.jar 2014-03-13 15:51:39 UTC (rev 7954) Property changes on: branches/RDR/bigdata/lib/jetty/jetty-server-9.1.3.v20140225.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/RDR/bigdata/lib/jetty/jetty-servlet-9.1.3.v20140225.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/jetty-servlet-9.1.3.v20140225.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/jetty-servlet-9.1.3.v20140225.jar 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata/lib/jetty/jetty-servlet-9.1.3.v20140225.jar 2014-03-13 15:51:39 UTC (rev 7954) Property changes on: branches/RDR/bigdata/lib/jetty/jetty-servlet-9.1.3.v20140225.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/RDR/bigdata/lib/jetty/jetty-util-9.1.3.v20140225.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/jetty-util-9.1.3.v20140225.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/jetty-util-9.1.3.v20140225.jar 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata/lib/jetty/jetty-util-9.1.3.v20140225.jar 2014-03-13 15:51:39 UTC (rev 7954) Property changes on: branches/RDR/bigdata/lib/jetty/jetty-util-9.1.3.v20140225.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/RDR/bigdata/lib/jetty/jetty-webapp-9.1.3.v20140225.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/jetty-webapp-9.1.3.v20140225.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/jetty-webapp-9.1.3.v20140225.jar 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata/lib/jetty/jetty-webapp-9.1.3.v20140225.jar 2014-03-13 15:51:39 UTC (rev 7954) Property changes on: branches/RDR/bigdata/lib/jetty/jetty-webapp-9.1.3.v20140225.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/RDR/bigdata/lib/jetty/jetty-xml-9.1.3.v20140225.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/jetty-xml-9.1.3.v20140225.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/jetty-xml-9.1.3.v20140225.jar 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata/lib/jetty/jetty-xml-9.1.3.v20140225.jar 2014-03-13 15:51:39 UTC (rev 7954) Property changes on: branches/RDR/bigdata/lib/jetty/jetty-xml-9.1.3.v20140225.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/RDR/bigdata/lib/jetty/servlet-api-3.1.0.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/servlet-api-3.1.0.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/servlet-api-3.1.0.jar 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata/lib/jetty/servlet-api-3.1.0.jar 2014-03-13 15:51:39 UTC (rev 7954) Property changes on: branches/RDR/bigdata/lib/jetty/servlet-api-3.1.0.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Modified: branches/RDR/bigdata-gom/src/test/com/bigdata/gom/RemoteGOMTestCase.java =================================================================== --- branches/RDR/bigdata-gom/src/test/com/bigdata/gom/RemoteGOMTestCase.java 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata-gom/src/test/com/bigdata/gom/RemoteGOMTestCase.java 2014-03-13 15:51:39 UTC (rev 7954) @@ -30,11 +30,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.PrintWriter; import java.io.Reader; import java.net.URL; -import java.net.URLConnection; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Properties; @@ -47,20 +44,14 @@ import org.apache.http.impl.client.DefaultHttpClient; import org.apache.log4j.Logger; import org.eclipse.jetty.server.Server; -import org.openrdf.model.Resource; -import org.openrdf.model.URI; import org.openrdf.model.ValueFactory; import org.openrdf.repository.RepositoryException; import org.openrdf.rio.RDFFormat; import org.openrdf.rio.RDFParseException; import com.bigdata.BigdataStatics; -import com.bigdata.gom.gpo.IGPO; -import com.bigdata.gom.gpo.ILinkSet; import com.bigdata.gom.om.IObjectManager; import com.bigdata.gom.om.NanoSparqlObjectManager; -import com.bigdata.gom.om.ObjectManager; -import com.bigdata.gom.om.ObjectMgrModel; import com.bigdata.journal.BufferMode; import com.bigdata.journal.IIndexManager; import com.bigdata.journal.ITx; @@ -193,7 +184,7 @@ m_server.start(); - final int port = m_server.getConnectors()[0].getLocalPort(); + final int port = NanoSparqlServer.getLocalPort(m_server); final String hostAddr = NicUtil.getIpAddress("default.nic", "default", true/* loopbackOk */); Modified: branches/RDR/bigdata-gom/src/test/com/bigdata/gom/TestRemoteGOM.java =================================================================== --- branches/RDR/bigdata-gom/src/test/com/bigdata/gom/TestRemoteGOM.java 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata-gom/src/test/com/bigdata/gom/TestRemoteGOM.java 2014-03-13 15:51:39 UTC (rev 7954) @@ -163,7 +163,7 @@ m_server.start(); - final int port = m_server.getConnectors()[0].getLocalPort(); + final int port = NanoSparqlServer.getLocalPort(m_server); final String hostAddr = NicUtil.getIpAddress("default.nic", "default", true/* loopbackOk */); Modified: branches/RDR/bigdata-jini/src/java/com/bigdata/journal/jini/ha/HAJournalServer.java =================================================================== --- branches/RDR/bigdata-jini/src/java/com/bigdata/journal/jini/ha/HAJournalServer.java 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata-jini/src/java/com/bigdata/journal/jini/ha/HAJournalServer.java 2014-03-13 15:51:39 UTC (rev 7954) @@ -449,7 +449,7 @@ * * @see #DEFAULT_JETTY_XML */ - String JETTY_XML = "jettyXml"; + String JETTY_XML = NanoSparqlServer.SystemProperties.JETTY_XML; /** * The default value works when deployed under the IDE with the @@ -457,7 +457,7 @@ * deploying outside of that context, the value needs to be set * explicitly. */ - String DEFAULT_JETTY_XML = "jetty.xml"; + String DEFAULT_JETTY_XML = NanoSparqlServer.SystemProperties.DEFAULT_JETTY_XML; } @@ -4576,7 +4576,8 @@ // } // Setup the embedded jetty server for NSS webapp. - jettyServer = NanoSparqlServer.newInstance(jettyXml, journal); + jettyServer = NanoSparqlServer + .newInstance(jettyXml, journal, null/* initParams */); // } @@ -4659,13 +4660,8 @@ */ int getNSSPort() { - final Server tmp = jettyServer; + return NanoSparqlServer.getLocalPort(jettyServer); - if (tmp == null) - throw new IllegalStateException("Server is not running"); - - return tmp.getConnectors()[0].getLocalPort(); - } /** Modified: branches/RDR/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHA3JournalServerTestCase.java =================================================================== --- branches/RDR/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHA3JournalServerTestCase.java 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata-jini/src/test/com/bigdata/journal/jini/ha/AbstractHA3JournalServerTestCase.java 2014-03-13 15:51:39 UTC (rev 7954) @@ -2173,6 +2173,14 @@ * connection. */ private final String TEST_JETTY_PORT = "jetty.port"; + + /** + * The path in the local file system to the root of the web + * application. This is <code>bigdata-war/src</code> in the source + * code, but the webapp gets deployed to the serviceDir for this + * test suite. + */ + private final String JETTY_RESOURCE_BASE = "jetty.resourceBase"; /** * The absolute effective path of the service directory. This is @@ -2216,8 +2224,12 @@ cmds.add("-D" + TEST_LOGICAL_SERVICE_ID + "=" + getLogicalServiceId()); + // Override the HTTP port for jetty. cmds.add("-D" + TEST_JETTY_PORT + "=" + jettyPort); + // Override the location of the webapp as deployed. + cmds.add("-D" + JETTY_RESOURCE_BASE + "=\".\""); + super.addCommandArgs(cmds); for (String arg : args) { Modified: branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/BigdataRDFServletContextListener.java =================================================================== --- branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/BigdataRDFServletContextListener.java 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/BigdataRDFServletContextListener.java 2014-03-13 15:51:39 UTC (rev 7954) @@ -29,10 +29,14 @@ import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; import java.util.Date; +import java.util.Enumeration; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.Properties; import javax.servlet.ServletContext; @@ -40,6 +44,7 @@ import javax.servlet.ServletContextListener; import org.apache.log4j.Logger; +import org.eclipse.jetty.webapp.WebAppContext; import com.bigdata.Banner; import com.bigdata.bop.engine.QueryEngine; @@ -83,6 +88,13 @@ private long readLockTx; private BigdataRDFContext rdfContext; // private SparqlCache sparqlCache; + + /** + * The set of init parameters from the <code>web.xml</code> file after we + * have applied any overrides specified by the + * {@link BigdataRDFServletContextListener#INIT_PARAM_OVERRIDES} attributes. + */ + private Map<String,String> effectiveInitParams; /** * <code>true</code> iff this class opened the {@link IIndexManager}, in @@ -90,6 +102,33 @@ */ private boolean closeIndexManager; + /** + * The name of the {@link WebAppContext} attribute under which we store any + * overrides for the init parameters of the {@link WebAppContext}. Note that + * it is NOT possible to actual modify the init parameters specified in the + * <code>web.xml</code> file. Therefore, we attach the overrides as an + * attribute and then consult them from within + * {@link BigdataRDFServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)} + * . + */ + public static final String INIT_PARAM_OVERRIDES = "INIT_PARAMS_OVERRIDES"; + + /** + * Return the effective value of the given init parameter, respecting any + * overrides that were specified to the {@link NanoSparqlServer} when it + * initialized the server. + * + * @param key + * The name of the desired init parameter. + * + * @return The effective value of that init parameter. + */ + protected String getInitParameter(final String key) { + + return effectiveInitParams.get(key); + + } + public BigdataRDFServletContextListener() { super(); } @@ -110,10 +149,50 @@ final ServletContext context = e.getServletContext(); + /* + * Figure out the effective init parameters that we want to use + * for this initialization procedure. + */ + { + + effectiveInitParams = new LinkedHashMap<String, String>(); + + /* + * Copy the init params from web.xml into a local map. + */ + final Enumeration<String> names = context.getInitParameterNames(); + while(names.hasMoreElements()) { + final String name = names.nextElement(); + final String value = context.getInitParameter(name); + effectiveInitParams.put(name, value); + } + + /* + * Look for init parameter overrides that have been attached to the + * WebAppContext by the NanoSparqlServer. If found, then apply them + * before doing anything else. This is how we apply overrides to the + * init parameters that were specified in "web.xml". + */ + { + + @SuppressWarnings("unchecked") + final Map<String, String> initParamOverrides = (Map<String, String>) context + .getAttribute(BigdataRDFServletContextListener.INIT_PARAM_OVERRIDES); + + if (initParamOverrides != null) { + + effectiveInitParams.putAll(initParamOverrides); + + } + + } + + } + final String namespace; { - String s = context.getInitParameter(ConfigParams.NAMESPACE); + String s = getInitParameter(ConfigParams.NAMESPACE); if (s == null) s = ConfigParams.DEFAULT_NAMESPACE; @@ -128,7 +207,7 @@ final boolean create; { - final String s = context.getInitParameter(ConfigParams.CREATE); + final String s = getInitParameter(ConfigParams.CREATE); if (s != null) create = Boolean.valueOf(s); @@ -170,9 +249,9 @@ + ConfigParams.PROPERTY_FILE; // The default value is taken from the web.xml file. - final String defaultValue = context - .getInitParameter(ConfigParams.PROPERTY_FILE); - + final String defaultValue = getInitParameter( + ConfigParams.PROPERTY_FILE); + // The effective location of the property file. final String propertyFile = System.getProperty(// FQN_PROPERTY_FILE,// @@ -213,7 +292,7 @@ final long timestamp; { - final String s = context.getInitParameter(ConfigParams.READ_LOCK); + final String s = getInitParameter( ConfigParams.READ_LOCK); readLock = s == null ? null : Long.valueOf(s); @@ -257,8 +336,7 @@ final int queryThreadPoolSize; { - final String s = context - .getInitParameter(ConfigParams.QUERY_THREAD_POOL_SIZE); + final String s = getInitParameter( ConfigParams.QUERY_THREAD_POOL_SIZE); queryThreadPoolSize = s == null ? ConfigParams.DEFAULT_QUERY_THREAD_POOL_SIZE : Integer.valueOf(s); @@ -279,8 +357,7 @@ final boolean describeEachNamedGraph; { - final String s = context - .getInitParameter(ConfigParams.DESCRIBE_EACH_NAMED_GRAPH); + final String s = getInitParameter( ConfigParams.DESCRIBE_EACH_NAMED_GRAPH); describeEachNamedGraph = s == null ? ConfigParams.DEFAULT_DESCRIBE_EACH_NAMED_GRAPH : Boolean.valueOf(s); @@ -294,7 +371,7 @@ final boolean readOnly; { - final String s = context.getInitParameter(ConfigParams.READ_ONLY); + final String s = getInitParameter( ConfigParams.READ_ONLY); readOnly = s == null ? ConfigParams.DEFAULT_READ_ONLY : Boolean .valueOf(s); @@ -307,8 +384,7 @@ final long queryTimeout; { - final String s = context - .getInitParameter(ConfigParams.QUERY_TIMEOUT); + final String s = getInitParameter( ConfigParams.QUERY_TIMEOUT); queryTimeout = s == null ? ConfigParams.DEFAULT_QUERY_TIMEOUT : Integer.valueOf(s); @@ -356,8 +432,8 @@ { - final boolean forceOverflow = Boolean.valueOf(context - .getInitParameter(ConfigParams.FORCE_OVERFLOW)); + final boolean forceOverflow = Boolean + .valueOf(getInitParameter(ConfigParams.FORCE_OVERFLOW)); if (forceOverflow && indexManager instanceof IBigdataFederation<?>) { @@ -414,6 +490,10 @@ + readLockTx, ex); } + + txs = null; + readLock = null; + } if (jnl != null) { @@ -442,6 +522,8 @@ // sparqlCache = null; // // } + + effectiveInitParams = null; /* * Terminate various threads which should no longer be executing once we @@ -469,15 +551,37 @@ */ private IIndexManager openIndexManager(final String propertyFile) { - final File file = new File(propertyFile); + // Locate the named .properties or .config file. + final URL propertyFileUrl; + if (new File(propertyFile).exists()) { - if (!file.exists()) { + // Check the file system. + try { + propertyFileUrl = new URL("file:" + propertyFile); + } catch (MalformedURLException ex) { + throw new RuntimeException(ex); + } - throw new RuntimeException("Could not find file: file=" + file - + ", user.dir=" + System.getProperty("user.dir")); + } else { + // Check the classpath. + propertyFileUrl = BigdataRDFServletContextListener.class + .getClassLoader().getResource(propertyFile); + } + if (log.isInfoEnabled()) + log.info("bigdata configuration: propertyFile=" + propertyFile + + ", propertyFileUrl=" + propertyFileUrl); + + if (propertyFileUrl == null) { + + throw new RuntimeException("Could not find file: file=" + + propertyFile + ", user.dir=" + + System.getProperty("user.dir")); + + } + boolean isJini = false; if (propertyFile.endsWith(".config")) { // scale-out. @@ -493,7 +597,7 @@ */ throw new RuntimeException( "File must have '.config' or '.properties' extension: " - + file); + + propertyFile); } final IIndexManager indexManager; @@ -503,6 +607,16 @@ /* * A bigdata federation. + * + * Note: The Apache River configuration mechanism will search + * both the file system and the classpath, much as we have done + * above. + * + * TODO This will use the ClassLoader associated with the + * JiniClient if that is different from the ClassLoader used + * above, then it could be possible for one ClassLoader to find + * the propertyFile resource and the other to not find that + * resource. */ jiniClient = new JiniClient(new String[] { propertyFile }); @@ -522,7 +636,7 @@ { // Read the properties from the file. final InputStream is = new BufferedInputStream( - new FileInputStream(propertyFile)); + propertyFileUrl.openStream()); try { properties.load(is); } finally { Modified: branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/NanoSparqlServer.java =================================================================== --- branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/NanoSparqlServer.java 2014-03-13 13:55:47 UTC (rev 7953) +++ branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/NanoSparqlServer.java 2014-03-13 15:51:39 UTC (rev 7954) @@ -32,25 +32,19 @@ import javax.servlet.ServletContextListener; import org.apache.log4j.Logger; -import org.eclipse.jetty.server.Handler; +import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.handler.ContextHandler; -import org.eclipse.jetty.server.handler.DefaultHandler; -import org.eclipse.jetty.server.handler.HandlerList; -import org.eclipse.jetty.server.handler.ResourceHandler; -import org.eclipse.jetty.servlet.DefaultServlet; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.xml.XmlConfiguration; import com.bigdata.Banner; -import com.bigdata.BigdataStatics; import com.bigdata.journal.IIndexManager; import com.bigdata.journal.ITx; import com.bigdata.journal.Journal; import com.bigdata.journal.TimestampUtility; +import com.bigdata.resources.IndexManager; import com.bigdata.util.config.NicUtil; /** @@ -109,6 +103,37 @@ static private final Logger log = Logger.getLogger(NanoSparqlServer.class); + public interface SystemProperties { + + /** + * The name of the system property that can be used to override the default + * HTTP port in the bundled <code>jetty.xml</code> file. + */ + String JETTY_PORT = "jetty.port"; + + /** + * The name of the system property that can be used to override the + * location of the <code>jetty.xml</code> file that will be used to + * configure jetty (default {@value #DEFAULT_JETTY_XML}). + * + * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/730" > + * Allow configuration of embedded NSS jetty server using + * jetty-web.xml </a> + * + * @see #DEFAULT_JETTY_XML + */ + String JETTY_XML = "jettyXml"; + + /** + * The default value works when deployed under the IDE with the + * <code>bigdata-war/src</code> directory on the classpath. When + * deploying outside of that context, the value needs to be set + * explicitly. + */ + String DEFAULT_JETTY_XML = "jetty.xml"; + + } + /** * Run an httpd service exposing a SPARQL endpoint. The service will respond * to the following URL paths: @@ -145,6 +170,16 @@ * </dl> * and <i>options</i> are any of: * <dl> + * <dt>-jettyXml</dt> + * <dd>The location of the jetty.xml resource that will be used + * to start the {@link Server} (default is the file in the JAR). + * * The default will locate the <code>jetty.xml</code> resource + * that is bundled with the JAR. This preserves the historical + * behavior. If you want to use a different + * <code>jetty.xml</code> file, just override this property on + * the command line -or- specify the + * {@link NanoSparqlServer.SystemProperties#JETTY_XML} system + * property.</dd> * <dt>-nthreads</dt> * <dd>The #of threads which will be used to answer SPARQL * queries (default @@ -184,6 +219,14 @@ boolean forceOverflow = false; Long readLock = null; String servletContextListenerClass = ConfigParams.DEFAULT_SERVLET_CONTEXT_LISTENER_CLASS; + + /* + * Note: This default will locate the jetty.xml resource that is bundled + * with the JAR. This preserves the historical behavior. If you want to + * use a different jetty.xml file, just override this property on the + * command line. + */ + String jettyXml = "bigdata-war/src/jetty.xml"; /* * Handle all arguments starting with "-". These should appear before @@ -214,6 +257,8 @@ } } else if (arg.equals("-servletContextListenerClass")) { servletContextListenerClass = args[++i]; + } else if (arg.equals("-jettyXml")) { + jettyXml = args[++i]; } else { usage(1/* status */, "Unknown argument: " + arg); } @@ -309,12 +354,26 @@ initParams.put(ConfigParams.SERVLET_CONTEXT_LISTENER_CLASS, servletContextListenerClass); - // Create the service. - final Server server = NanoSparqlServer.newInstance(port, propertyFile, - initParams); + final Server server; - // Start the service. - server.start(); + boolean ok = false; + try { + // Create the service. + server = NanoSparqlServer.newInstance(port, jettyXml, + null/* indexManager */, initParams); + // Start Server. + server.start(); + // Await running. + while (server.isStarting() && !server.isRunning()) { + Thread.sleep(100/* ms */); + } + ok = true; + } finally { + if (!ok) { + // Complain if Server did not start. + System.err.println("Server did not start."); + } + } /* * Report *an* effective URL of this service. @@ -327,7 +386,7 @@ final String serviceURL; { - final int actualPort = server.getConnectors()[0].getLocalPort(); + final int actualPort = getLocalPort(server); String hostAddr = NicUtil.getIpAddress("default.nic", "default", true/* loopbackOk */); @@ -351,118 +410,196 @@ } /** - * Variant used when you already have the {@link IIndexManager} on hand and - * DO NOT want to use <code>web.xml</code> and <code>jetty.xml</code>. For - * this case, the caller must specify the port and a default connection will - * be established at that port. This form is used by code that wants to - * embed a simple NSS end point. + * Start the embedded {@link Server}. + * <p> + * Note: The port override argument given here is applied by setting the + * {@link NanoSparqlServer.SystemProperties#JETTY_PORT} System property. The + * old value of that property is restored afterwards, but there is a + * side-effect which could be visible to concurrent threads. * * @param port * The port on which the service will run -OR- ZERO (0) for any * open port. * @param indexManager - * The {@link IIndexManager}. + * The {@link IIndexManager} (optional). * @param initParams * Initialization parameters for the web application as specified - * by {@link ConfigParams}. + * by {@link ConfigParams} (optional). * * @return The server instance. * - * @see <a href="http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty"> - * Embedding Jetty </a> + * @see SystemProperties */ static public Server newInstance(final int port, final IIndexManager indexManager, final Map<String, String> initParams) throws Exception { - - final Server server = new Server(port); - - final ServletContextHandler context = getContextHandler(initParams); - - final ResourceHandler resourceHandler = new ResourceHandler(); - setupStaticResources(NanoSparqlServer.class.getClassLoader(), - resourceHandler); - - // same resource base. - context.setResourceBase(resourceHandler.getResourceBase()); - context.setWelcomeFiles(resourceHandler.getWelcomeFiles()); + // The jetty.xml resource to be used. + final String jettyXml = System.getProperty(SystemProperties.JETTY_XML, + SystemProperties.DEFAULT_JETTY_XML); - final HandlerList handlers = new HandlerList(); - - handlers.setHandlers(new Handler[] { - context,// maps servlets - resourceHandler,// maps welcome files. - new DefaultHandler() // responsible for anything not explicitly served. - }); - - server.setHandler(handlers); + return newInstance(port, jettyXml, indexManager, initParams); - // Force the use of the caller's IIndexManager. - context.setAttribute(IIndexManager.class.getName(), indexManager); - - return server; - } - + /** - * Variant used when the life cycle of the {@link IIndexManager} will be - * managed by the server - this form is used by {@link #main(String[])}. + * Start the embedded {@link Server}. * <p> - * Note: This is mostly a convenience for scripts that do not need to take - * over the detailed control of the jetty container and the bigdata webapp. + * Note: The port override argument given here is applied by setting the + * {@link NanoSparqlServer.SystemProperties#JETTY_PORT} System property. The + * old value of that property is restored afterwards, but there is a + * side-effect which could be visible to concurrent threads. * * @param port * The port on which the service will run -OR- ZERO (0) for any * open port. - * @param propertyFile - * The <code>.properties</code> file (for a standalone database - * instance) or the <code>.config</code> file (for a federation). + * @param jettyXml + * The location of the <code>jetty.xml</code> resource. + * @param indexManager + * The {@link IIndexManager} (optional). * @param initParams * Initialization parameters for the web application as specified - * by {@link ConfigParams}. + * by {@link ConfigParams} (optional). * * @return The server instance. + * + * @see SystemProperties */ - static public Server newInstance... [truncated message content] |