Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 56904 invoked from network); 28 Jan 2008 06:54:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Jan 2008 06:54:47 -0000 Received: (qmail 11554 invoked by uid 500); 28 Jan 2008 06:54:38 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 11414 invoked by uid 500); 28 Jan 2008 06:54:38 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 11403 invoked by uid 99); 28 Jan 2008 06:54:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Jan 2008 22:54:38 -0800 X-ASF-Spam-Status: No, hits=-98.0 required=10.0 tests=ALL_TRUSTED,URIBL_BLACK X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jan 2008 06:54:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4D1301A9832; Sun, 27 Jan 2008 22:54:25 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r615738 - in /geronimo/server/trunk/plugins/monitoring: ./ agent-car-jmx/ agent-car-jmx/src/ agent-car-jmx/src/main/ agent-car-jmx/src/main/plan/ agent-jar/src/main/java/org/apache/geronimo/monitoring/snapshot/ agent-jmx/ agent-jmx/src/ age... Date: Mon, 28 Jan 2008 06:54:22 -0000 To: scm@geronimo.apache.org From: ecraig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080128065425.4D1301A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ecraig Date: Sun Jan 27 22:54:18 2008 New Revision: 615738 URL: http://svn.apache.org/viewvc?rev=615738&view=rev Log: GERONIMO-3790 monitoring agent should provide jmx support Patch by Viet Nguyen Committing this as thus far it is functional, keep jira open until confirmed no problems Added: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/ geronimo/server/trunk/plugins/monitoring/agent-car-jmx/LICENSE.txt (with props) geronimo/server/trunk/plugins/monitoring/agent-car-jmx/NOTICE.txt (with props) geronimo/server/trunk/plugins/monitoring/agent-car-jmx/pom.xml (with props) geronimo/server/trunk/plugins/monitoring/agent-car-jmx/src/ geronimo/server/trunk/plugins/monitoring/agent-car-jmx/src/main/ geronimo/server/trunk/plugins/monitoring/agent-car-jmx/src/main/plan/ geronimo/server/trunk/plugins/monitoring/agent-car-jmx/src/main/plan/plan.xml (with props) geronimo/server/trunk/plugins/monitoring/agent-jmx/ geronimo/server/trunk/plugins/monitoring/agent-jmx/LICENSE.txt (with props) geronimo/server/trunk/plugins/monitoring/agent-jmx/NOTICE.txt (with props) geronimo/server/trunk/plugins/monitoring/agent-jmx/pom.xml (with props) geronimo/server/trunk/plugins/monitoring/agent-jmx/src/ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java (with props) geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotProcessor.java (with props) geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java (with props) Modified: geronimo/server/trunk/plugins/monitoring/agent-jar/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotConfigXMLBuilder.java geronimo/server/trunk/plugins/monitoring/pom.xml Added: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/LICENSE.txt URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-car-jmx/LICENSE.txt?rev=615738&view=auto ============================================================================== --- geronimo/server/trunk/plugins/monitoring/agent-car-jmx/LICENSE.txt (added) +++ geronimo/server/trunk/plugins/monitoring/agent-car-jmx/LICENSE.txt Sun Jan 27 22:54:18 2008 @@ -0,0 +1,203 @@ + + 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. + Propchange: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/LICENSE.txt ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/LICENSE.txt ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/LICENSE.txt ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/NOTICE.txt URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-car-jmx/NOTICE.txt?rev=615738&view=auto ============================================================================== --- geronimo/server/trunk/plugins/monitoring/agent-car-jmx/NOTICE.txt (added) +++ geronimo/server/trunk/plugins/monitoring/agent-car-jmx/NOTICE.txt Sun Jan 27 22:54:18 2008 @@ -0,0 +1,6 @@ +Apache Geronimo +Copyright 2003-2007 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + Propchange: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/NOTICE.txt ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/NOTICE.txt ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/NOTICE.txt ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-car-jmx/pom.xml?rev=615738&view=auto ============================================================================== --- geronimo/server/trunk/plugins/monitoring/agent-car-jmx/pom.xml (added) +++ geronimo/server/trunk/plugins/monitoring/agent-car-jmx/pom.xml Sun Jan 27 22:54:18 2008 @@ -0,0 +1,74 @@ + + + + + + + + 4.0.0 + + + org.apache.geronimo.plugins.monitoring + monitoring + 2.1-SNAPSHOT + ../pom.xml + + + agent-car-jmx + Geronimo Plugins :: Monitoring Agent (JMX) + car + + + + org.apache.geronimo.plugins.monitoring + agent-jmx + ${monitoringConsoleVersion} + jar + + + + org.apache.geronimo.plugins.monitoring + agent-jar + ${monitoringConsoleVersion} + jar + + + + org.apache.geronimo.plugins + agent-ds + ${monitoringConsoleVersion} + car + + + + + + + org.apache.geronimo.buildsupport + car-maven-plugin + + + true + true + + Monitoring + + + + + Propchange: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/pom.xml ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/pom.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/src/main/plan/plan.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-car-jmx/src/main/plan/plan.xml?rev=615738&view=auto ============================================================================== --- geronimo/server/trunk/plugins/monitoring/agent-car-jmx/src/main/plan/plan.xml (added) +++ geronimo/server/trunk/plugins/monitoring/agent-car-jmx/src/main/plan/plan.xml Sun Jan 27 22:54:18 2008 @@ -0,0 +1,46 @@ + + + + + + + + + org.apache.geronimo.plugins.monitoring + agent-car-jmx + ${monitoringConsoleVersion} + + + + + org.apache.geronimo.plugins.monitoring + agent-jar + ${monitoringConsoleVersion} + jar + + + org.apache.geronimo.plugins + agent-ds + ${monitoringConsoleVersion} + car + + + + + + Propchange: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/src/main/plan/plan.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/src/main/plan/plan.xml ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/plugins/monitoring/agent-car-jmx/src/main/plan/plan.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: geronimo/server/trunk/plugins/monitoring/agent-jar/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotConfigXMLBuilder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-jar/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotConfigXMLBuilder.java?rev=615738&r1=615737&r2=615738&view=diff ============================================================================== --- geronimo/server/trunk/plugins/monitoring/agent-jar/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotConfigXMLBuilder.java (original) +++ geronimo/server/trunk/plugins/monitoring/agent-jar/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotConfigXMLBuilder.java Sun Jan 27 22:54:18 2008 @@ -257,6 +257,9 @@ */ public static void saveDocument(Document document, String path) { try { + // before saving, make sure the directory is present + ensureMonitorDir(); + //TODO GERONIMO-3719. Hack to use xmlbeans to write out xml instead of sun specific classes. XmlObject xmlObject = XmlObject.Factory.parse(document.getDocumentElement()); xmlObject.save(new File(path)); Added: geronimo/server/trunk/plugins/monitoring/agent-jmx/LICENSE.txt URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-jmx/LICENSE.txt?rev=615738&view=auto ============================================================================== --- geronimo/server/trunk/plugins/monitoring/agent-jmx/LICENSE.txt (added) +++ geronimo/server/trunk/plugins/monitoring/agent-jmx/LICENSE.txt Sun Jan 27 22:54:18 2008 @@ -0,0 +1,203 @@ + + 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. + Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/LICENSE.txt ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/LICENSE.txt ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/LICENSE.txt ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/plugins/monitoring/agent-jmx/NOTICE.txt URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-jmx/NOTICE.txt?rev=615738&view=auto ============================================================================== --- geronimo/server/trunk/plugins/monitoring/agent-jmx/NOTICE.txt (added) +++ geronimo/server/trunk/plugins/monitoring/agent-jmx/NOTICE.txt Sun Jan 27 22:54:18 2008 @@ -0,0 +1,5 @@ +Apache Geronimo +Copyright 2003-2006 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/NOTICE.txt ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/NOTICE.txt ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/NOTICE.txt ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/plugins/monitoring/agent-jmx/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-jmx/pom.xml?rev=615738&view=auto ============================================================================== --- geronimo/server/trunk/plugins/monitoring/agent-jmx/pom.xml (added) +++ geronimo/server/trunk/plugins/monitoring/agent-jmx/pom.xml Sun Jan 27 22:54:18 2008 @@ -0,0 +1,70 @@ + + + + + + 4.0.0 + + org.apache.geronimo.plugins.monitoring + monitoring + 2.1-SNAPSHOT + ../pom.xml + + + agent-jmx + Geronimo Monitoring :: Monitoring Agent :: JMX + Geronimo Monitoring Agent JMX + + + + + org.apache.geronimo.framework + geronimo-kernel + ${version} + provided + + + org.apache.geronimo.specs + geronimo-j2ee-management_1.1_spec + provided + + + org.apache.geronimo.plugins.monitoring + agent-jar + 2.1-SNAPSHOT + + + + org.apache.xbean + xbean-naming + provided + 3.4-SNAPSHOT + + + + org.apache.geronimo.modules + geronimo-connector + ${version} + jar + + + + + Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/pom.xml ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/pom.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java?rev=615738&view=auto ============================================================================== --- geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java (added) +++ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java Sun Jan 27 22:54:18 2008 @@ -0,0 +1,509 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.apache.geronimo.monitoring; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.TreeMap; + +import javax.management.Attribute; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.management.ObjectName; +import javax.management.j2ee.Management; +import javax.management.j2ee.ManagementHome; +import javax.management.j2ee.statistics.BoundedRangeStatistic; +import javax.management.j2ee.statistics.RangeStatistic; +import javax.management.j2ee.statistics.Stats; +import javax.management.j2ee.statistics.CountStatistic; +import javax.management.j2ee.statistics.Statistic; +import javax.management.j2ee.statistics.TimeStatistic; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + + +import org.apache.geronimo.connector.outbound.ManagedConnectionFactoryWrapper; +import org.apache.geronimo.gbean.AbstractName; +import org.apache.geronimo.gbean.GBeanInfo; +import org.apache.geronimo.gbean.GBeanInfoBuilder; +import org.apache.geronimo.gbean.GBeanLifecycle; + +import org.apache.geronimo.monitoring.MBeanHelper; + +import org.apache.xbean.naming.context.WritableContext.NestedWritableContext; + +import org.apache.geronimo.monitoring.snapshot.SnapshotThread; +import org.apache.geronimo.monitoring.snapshot.SnapshotConfigXMLBuilder; +import org.apache.geronimo.monitoring.snapshot.SnapshotDBHelper; + +/** + * This is the GBean that will be the bottleneck for the communication + * between the management node and the data in the server node. + */ +public class MasterRemoteControlJMX implements GBeanLifecycle { + private static Log log = LogFactory.getLog(MasterRemoteControlJMX.class); + // constants + private static final String GERONIMO_DEFAULT_DOMAIN = "geronimo"; + private static final Long DEFAULT_DURATION = new Long(5000); + private static final int DEFAULT_RETENTION = 30; + private static final String RETENTION = "retention"; + + // mbean server to talk to other components + private static MBeanServer mbServer = null; + + // threads + private static SnapshotThread snapshotThread = null; + + // datasources + private DataSource activeDS; + private DataSource archiveDS; + + private SnapshotDBHelper snapshotDBHelper; + + public MasterRemoteControlJMX() { + // retrieve the mbean server + ArrayList mbServerList = MBeanServerFactory.findMBeanServer(null); + if(mbServerList.size() >= 1) { + mbServer = (MBeanServer) mbServerList.get(0); + for(int i = 0; i < mbServerList.size(); i++) { + String domain = ((MBeanServer)mbServerList.get(i)).getDefaultDomain(); + if(domain.equals(GERONIMO_DEFAULT_DOMAIN)) { + mbServer = (MBeanServer)mbServerList.get(i); + break; + } + } + } + // ensure that the mbServer has something in it + if(mbServer == null) { + mbServer = MBeanServerFactory.createMBeanServer(GERONIMO_DEFAULT_DOMAIN); + } + + // set up SnaphotDBHelper with the necessary data sources + // Note: do not put this in the constructor...datasources are not injected by then + try { + InitialContext ic = new InitialContext(); + activeDS = (DataSource)((ManagedConnectionFactoryWrapper)ic.lookup("jca:/org.apache.geronimo.plugins/agent-ds/JCAManagedConnectionFactory/jdbc/ActiveDS")).$getResource(); + archiveDS = (DataSource)((ManagedConnectionFactoryWrapper)ic.lookup("jca:/org.apache.geronimo.plugins/agent-ds/JCAManagedConnectionFactory/jdbc/ArchiveDS")).$getResource(); +// activeDS = (DataSource)((NestedWritableContext)ic.lookup("jms:conn")).lookup("jdbc/ActiveDS"); +// archiveDS = (DataSource)((NestedWritableContext)ic.lookup("jms:conn")).lookup("jdbc/ArchiveDS"); + } catch(Exception e) { + log.error(e.getMessage()); + e.printStackTrace(); + } + snapshotDBHelper = new SnapshotDBHelper(activeDS, archiveDS); + } + + /** + * Looks up the JSR-77 statistics associated with this object name. + * + * @param objectName + * @return HashMap + * @throws Exception + */ + public static HashMap getStats(String objectName) throws Exception { + HashMap statsMap = new HashMap(); + Stats stats = (Stats)mbServer.getAttribute(new ObjectName(objectName), "stats"); + String[] sttsName = stats.getStatisticNames(); + Statistic[] stts = stats.getStatistics(); + for(int i = 0; i < sttsName.length; i++) { + Statistic aStat = stats.getStatistic(sttsName[i]); + if(aStat instanceof RangeStatistic) { + Long current = new Long(((RangeStatistic)aStat).getCurrent()); + Long high = new Long(((RangeStatistic)aStat).getHighWaterMark()); + Long low = new Long(((RangeStatistic)aStat).getLowWaterMark()); + statsMap.put(stts[i].getName() + " Current", current); + statsMap.put(stts[i].getName() + " Max", high); + statsMap.put(stts[i].getName() + " Min", low); + } else if(aStat instanceof CountStatistic) { + Long current = new Long(((CountStatistic)aStat).getCount()); + statsMap.put(stts[i].getName(), current); + } else if(aStat instanceof TimeStatistic) { + Long current = new Long(((TimeStatistic)aStat).getCount()); + Long max = new Long(((TimeStatistic)aStat).getMaxTime()); + Long min = new Long(((TimeStatistic)aStat).getMinTime()); + Long total = new Long(((TimeStatistic)aStat).getTotalTime()); + statsMap.put(stts[i].getName() + " CurrentTime", current); + statsMap.put(stts[i].getName() + " MaxTime", max); + statsMap.put(stts[i].getName() + " MinTime", min); + statsMap.put(stts[i].getName() + " TotalTime", total); + } else { + // this should never happen + throw new Exception(); + } + } + return statsMap; + } + + /** + * Changes the objectName's attrName's value to attrValue + * + * @param objectName + * @param attrName + * @param attrValue + * @throws Exception + */ + public void setAttribute(String objectName, String attrName, Object attrValue) throws Exception { + Attribute attr = new Attribute(attrName, attrValue); + mbServer.setAttribute(new ObjectName(objectName), attr); + } + + /** + * Stops the snapshot thread + */ + public void stopSnapshot() { + if(snapshotThread != null) { + if(snapshotThread.getSnapshotDuration() == Long.MAX_VALUE) { + saveDuration(DEFAULT_DURATION); + } else { + saveDuration(snapshotThread.getSnapshotDuration()); + } + snapshotThread.setSnapshotDuration(Long.MAX_VALUE); + log.info("Snapshot thread stopped."); + } else { + log.error("There is not a snapshot thread running. Stopping aborted."); + } + } + + /** + * Fetches the data stored from the snapshot thread and returns + * it in a ArrayList with each element being a HashMap of the attribute + * mapping to the statistic. All stats will be the average of + * 1 - n, n+1 - 2n, ..., cn+1 - c(n+1) + * + * Grabs 'numberOfSnapshots' snapshots. Grabs one snapshot per + * 'everyNthsnapshot' + * + * @param numberOfSnapshot + * @param everyNthSnapshot + * @return ArrayList + */ + public ArrayList>> fetchSnapshotData(Integer numberOfSnapshot, Integer everyNthSnapshot) { + return (ArrayList>>)snapshotDBHelper.fetchData(numberOfSnapshot, everyNthSnapshot); + } + + /** + * Fetches the max amount for each statistic stored from the snapshot thread + * and returns it in a HashMap + * + * @param numberOfSnapshot + * @return HashMap + */ + public HashMap> fetchMaxSnapshotData(Integer numberOfSnapshot) { + return (HashMap>)snapshotDBHelper.fetchMaxSnapshotData(numberOfSnapshot); + } + + /** + * Fetches the min amount for each statistic stored from the snapshot thread + * and returns it in a HashMap + * + * @param numberOfSnapshot + * @return HashMap + */ + public HashMap> fetchMinSnapshotData(Integer numberOfSnapshot) { + return (HashMap>)snapshotDBHelper.fetchMinSnapshotData(numberOfSnapshot); + } + + /** + * Gets the elapsed time in milliseconds between each snapshot. + * + * @return Long + */ + public Long getSnapshotDuration() { + if(snapshotThread != null) { + return new Long(snapshotThread.getSnapshotDuration()); + } else { + return null; + } + } + + /** + * Sets the elapsed time in milliseconds between each snapshot. + * + * @param snapshotDuration + */ + public void setSnapshotDuration(Long snapshotDuration) { + if(snapshotThread != null) { + snapshotThread.setSnapshotDuration(snapshotDuration.longValue()); + saveDuration(snapshotThread.getSnapshotDuration()); + } else { + log.warn("There is not a snapshot thread instantiated."); + } + } + + public void setSnapshotRetention(Integer retention) { + saveRetention(retention.intValue()); + } + + /** + * Begins the snapshot process given the time interval between snapshots + * + * Precondition: + * interval is given in milli seconds + * + * @param interval + */ + public boolean startSnapshot(Long interval) { + // get the saved/default retention period + String retentionStr = null; + try { + retentionStr = SnapshotConfigXMLBuilder.getAttributeValue(RETENTION); + } catch(Exception e){ + // happens when there is not an instance of "retention" in the config + // which is okay. + } + int retention; + if(retentionStr == null) { + retention = DEFAULT_RETENTION; + } else { + retention = Integer.parseInt(retentionStr); + } + return startSnapshot(interval, new Integer(retention)); + } + + /** + * Begins the snapshot process given the time interval between snapshots + * + * Precondition: + * interval is given in milli seconds + * + * @param interval + */ + public boolean startSnapshot(Long interval, Integer retention) { + if((snapshotThread == null || (snapshotThread != null && !snapshotThread.isAlive())) && interval.longValue() > 0) { + saveDuration(interval.longValue()); + saveRetention(retention.intValue()); + snapshotThread = new SnapshotThread(interval.longValue(), mbServer); + snapshotThread.start(); + log.info("Snapshot thread successfully created."); + return true; + } else { + log.warn("There is already a snapshot thread running."); + return false; + } + } + + public Long getSnapshotCount() { + return snapshotDBHelper.getSnapshotCount(); + } + + /** + * Fetches all mbean names that provide JSR-77 statistics + * + * @return A set containing all mbean names of mbeans that provide + * statistics + */ + public Set getStatisticsProviderMBeanNames() { + return (Set)MBeanHelper.getStatsProvidersMBeans( getAllMBeanNames() ); + } + + /** + * Fetches all mbean names + * + * @return A set containing all mbean names + */ + public Set getAllMBeanNames() { + try { + Set names = (Set)mbServer.queryNames(null, null); + Set strNames = new HashSet(); + for(Iterator it = names.iterator(); it.hasNext(); ) { + strNames.add(it.next().getCanonicalName()); + } + return strNames; + } catch(Exception e) { + log.error(e.getMessage(), e); + return new HashSet(); + } + } + + public void doFail() { + doStop(); + } + + /** + * Executes when the GBean starts up. Also starts the snapshot thread. + */ + public void doStart() { + + } + + /** + * Executes when the GBean stops. Also stops the snapshot thread. + */ + public void doStop() { + if(isSnapshotRunning()) { + stopSnapshot(); + } + } + + private void saveDuration(long duration) { + SnapshotConfigXMLBuilder.saveDuration(duration); + } + + private void saveRetention(int retention) { + SnapshotConfigXMLBuilder.saveRetention(retention); + } + + /** + * Adds a record of the mbean via its name to take snapshots of. As a result + * the mbeanName will be written to snapshot-config.xml + * + * @param mbeanName + */ + public boolean addMBeanForSnapshot(String mbeanName) { + return SnapshotConfigXMLBuilder.addMBeanName(mbeanName); + } + + /** + * Removes a record of the mbean via its name to take snapshots of. As a result + * the mbeanName will be removed from snapshot-config.xml + * + * @param mbeanName + */ + public boolean removeMBeanForSnapshot(String mbeanName) { + return SnapshotConfigXMLBuilder.removeMBeanName(mbeanName); + } + + /** + * @return A map: mbeanName --> ArrayList of statistic attributes for that mbean + */ + public HashMap> getAllSnapshotStatAttributes() { + HashMap> snapshotAttributes = new HashMap>(); + Set mbeans = getTrackedMBeans(); + // for each mbean name + for(Iterator it = mbeans.iterator(); it.hasNext(); ) { + ArrayList mbeanStatsList = new ArrayList(); + String mbeanName = it.next(); + try { + Stats stats = (Stats)mbServer.getAttribute(new ObjectName(mbeanName), "stats"); + String[] sttsName = stats.getStatisticNames(); + Statistic[] stts = stats.getStatistics(); + for(int i = 0; i < sttsName.length; i++) { + Statistic aStat = stats.getStatistic(sttsName[i]); + if(aStat instanceof RangeStatistic) { + mbeanStatsList.add(stts[i].getName() + " Current"); + mbeanStatsList.add(stts[i].getName() + " Max"); + mbeanStatsList.add(stts[i].getName() + " Min"); + } else if(aStat instanceof CountStatistic) { + mbeanStatsList.add(stts[i].getName()); + } else if(aStat instanceof TimeStatistic) { + mbeanStatsList.add(stts[i].getName() + " Count"); + mbeanStatsList.add(stts[i].getName() + " MaxTime"); + mbeanStatsList.add(stts[i].getName() + " MinTime"); + mbeanStatsList.add(stts[i].getName() + " TotalTime"); + } else { + // for the time being, only numbers should be returned + } + } + } catch (Exception e) { + log.error(e.getMessage(), e); + } + // save attributes to the returning list + snapshotAttributes.put(mbeanName, mbeanStatsList); + } + return snapshotAttributes; + } + + public Set getTrackedMBeans() { + ArrayList mbeans = (ArrayList)SnapshotConfigXMLBuilder.getMBeanNames(); + Set set = new HashSet(); + for(int i = 0; i < mbeans.size(); i++) { + set.add(mbeans.get(i)); + } + return set; + } + + public Integer getSnapshotRetention() { + try { + return new Integer(SnapshotConfigXMLBuilder.getAttributeValue( RETENTION )); + } catch(Exception e) { + return new Integer(DEFAULT_RETENTION); // the default + } + } + + /** + * @param name - object name of the mbean + * @param operationName - method within the class + * @param params - parameters for the method + * @param signature - types for the parameters + * @return Invokes the method of a class defined. + */ + public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws Exception { + return mbServer.invoke(name, operationName, params, signature); + } + + /** + * @param mbeanName + * @param statsName + * @param numberOfSnapshots + * @param everyNthSnapshot + * @return HashMap which maps from a snapshot_time --> value of the mbean.statsName at that time + */ + public TreeMap getSpecificStatistics( String mbeanName, + String statsName, + int numberOfSnapshots, + int everyNthSnapshot, + boolean showArchived) { + return snapshotDBHelper.getSpecificStatistics(mbeanName, statsName, numberOfSnapshots, everyNthSnapshot, showArchived); + } + + /** + * @return Returns true if snapshot is running. + */ + public boolean isSnapshotRunning() { + // TODO: check if the snapshot thread is running + return false; + } + + public static final GBeanInfo GBEAN_INFO; + + static { + GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("MasterRemoteControlJMX", MasterRemoteControlJMX.class); + infoFactory.addOperation("getStats", new Class[] {String.class}, "HashMap"); + infoFactory.addOperation("setAttribute", new Class[] {String.class, String.class, Object.class}, "void"); + infoFactory.addOperation("startSnapshot", new Class[] {Long.class}, "Boolean"); + infoFactory.addOperation("startSnapshot", new Class[] {Long.class, Integer.class}, "Boolean"); + infoFactory.addOperation("stopSnapshot", new Class[] {}, "void"); + infoFactory.addOperation("fetchSnapshotData", new Class[] {Integer.class, Integer.class}, "ArrayList"); + infoFactory.addOperation("fetchMaxSnapshotData", new Class[] {Integer.class}, "HashMap"); + infoFactory.addOperation("fetchMinSnapshotData", new Class[] {Integer.class}, "HashMap"); + infoFactory.addOperation("getSnapshotDuration", new Class[] {}, "Long"); + infoFactory.addOperation("getSnapshotCount", new Class[] {}, "Long"); + infoFactory.addOperation("setSnapshotDuration", new Class[] {Long.class}, "void"); + infoFactory.addOperation("getStatisticsProviderMBeanNames", new Class[] {}, "Set"); + infoFactory.addOperation("getAllMBeanNames", new Class[] {}, "Set"); + infoFactory.addOperation("getAllSnapshotStatAttributes", new Class[] {}, "HashMap"); + infoFactory.addOperation("addMBeanForSnapshot", new Class[] {String.class}, "void"); + infoFactory.addOperation("removeMBeanForSnapshot", new Class[] {String.class}, "void"); + infoFactory.addOperation("getSnapshotRetention", new Class[] {}, "Integer"); + infoFactory.addOperation("setSnapshotRetention", new Class[] {Integer.class}, "void"); + infoFactory.setConstructor(new String[] {}); + GBEAN_INFO = infoFactory.getBeanInfo(); + } + + public static GBeanInfo getGBeanInfo() { + return GBEAN_INFO; + } +} Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotProcessor.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotProcessor.java?rev=615738&view=auto ============================================================================== --- geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotProcessor.java (added) +++ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotProcessor.java Sun Jan 27 22:54:18 2008 @@ -0,0 +1,150 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.apache.geronimo.monitoring.snapshot; + +import java.io.File; +import java.lang.reflect.UndeclaredThrowableException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Properties; +import java.util.Set; + +import javax.management.ObjectName; +import javax.management.ReflectionException; +import javax.naming.Context; +import javax.naming.InitialContext; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.monitoring.MBeanHelper; +import org.apache.geronimo.monitoring.MasterRemoteControlJMX; +import org.apache.geronimo.monitoring.snapshot.SnapshotConfigXMLBuilder; + +/** + * Thread that is in charge of executing every x milliseconds. Upon each + * iteration, a snapshot of the server's information is recorded. + */ +public class SnapshotProcessor { + + private static Log log = LogFactory.getLog(SnapshotProcessor.class); + + /** + * Collects JSR-77 statistics for all mbeans that have been chosen to + * be monitored and stores it in a DB. Will also, archive snapshots + * if they have passed their retention period. + * @param username + * @param password + */ + public static void takeSnapshot(/*String username, String password*/) { + // ensure that there is a 'monitoring' directory + SnapshotConfigXMLBuilder.ensureMonitorDir(); + // get any saved mbean names from snapshot-config.xml + ArrayList mbeanNames = SnapshotConfigXMLBuilder.getMBeanNames(); + // get a handle on the mrc + MasterRemoteControlJMX mrc = getMRC(/*username, password*/); + // in the case where nothing is present, grab a set of default mbeans + if(mbeanNames.size() <= 0) { + mbeanNames = getDefaultMBeanList(mrc); + } + // turn on all stats in the list + setStatsOn(mbeanNames, mrc); + try { + // take a snapshot + log.info("======SNAPSHOT======"); + // instantiate map + HashMap> aggregateStats = new HashMap>(); + // for each mbean name in the list, get its stats + for(int i = 0; i < mbeanNames.size(); i++) { + String mbeanName = mbeanNames.get(i); + HashMap stats = (HashMap)mrc.getStats(mbeanName); + aggregateStats.put(mbeanName, stats); + } + + // store the data in a DB + (new SnapshotDBHelper()).addSnapshotToDB(aggregateStats); + + for(Iterator itt = aggregateStats.keySet().iterator(); itt.hasNext(); ) { + String mbean = (String)itt.next(); + HashMap stats = aggregateStats.get(mbean); + log.info(mbean); + for(Iterator it = stats.keySet().iterator(); it.hasNext(); ) { + String key = (String)it.next(); + Long value = (Long)stats.get(key); + log.info(key + ": " + value); + } + } + } catch(Exception e) { + log.error(e.getMessage(), e); + } + } + + /** + * Turns all statistics on for each mbean in the list. + * + * @param mbeanList + */ + private static void setStatsOn(ArrayList mbeanList, MasterRemoteControlJMX mrc) { + // for each mbean name in the list + for(int i = 0; i < mbeanList.size(); i++) { + // turn the statistics collection on + String methodName = "setStatsOn"; + Object[] params = new Object[] { Boolean.TRUE }; + String[] signatures = new String[] { "boolean" }; + try { + ObjectName objName = new ObjectName(mbeanList.get(i)); + mrc.invoke(objName, methodName, params, signatures); + log.info("Stats for " + mbeanList.get(i) + " was turned on."); + } catch (UndeclaredThrowableException e) { + // HACK : this will happen for components that always collect statistics + // and do not have StatsOn method. + } catch(ReflectionException e) { + // HACK : this will happen for components that do not have setStatsOn() + } catch(Exception e) { + log.error(e.getMessage(), e); + } + } + } + + /** + * @return A list of all default mbeans; namely, all connector or container mbean names + * Prereq: in order to be a connector or container mbean the name must contain "Connector"/"Container" + * and "Tomcat"/"Jetty" or JVM. + */ + private static ArrayList getDefaultMBeanList(MasterRemoteControlJMX mrc) { + Set mbeans = MBeanHelper.getStatsProvidersMBeans( mrc.getAllMBeanNames() ); + ArrayList retval = new ArrayList(); + for(Iterator it = mbeans.iterator(); it.hasNext(); ) { + String name = (String)it.next(); + if(((name.contains("Connector") || name.contains("Container")) && (name.contains("Jetty") || name.contains("Tomcat"))) + || name.contains("JVM")) { + // this is a connector or JVM, so add to the list + retval.add(name); + // update the snapshot-config.xml to include these + SnapshotConfigXMLBuilder.addMBeanName(name); + } + } + return retval; + } + + /** + * @return An instance of a MRC. + */ + public static MasterRemoteControlJMX getMRC(/*String username, String password*/) { + return new MasterRemoteControlJMX(); + } +} Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotProcessor.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotProcessor.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotProcessor.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java?rev=615738&view=auto ============================================================================== --- geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java (added) +++ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java Sun Jan 27 22:54:18 2008 @@ -0,0 +1,122 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.apache.geronimo.monitoring.snapshot; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Set; + +import javax.management.MBeanServer; +import javax.management.ObjectName; + +import org.apache.geronimo.monitoring.MasterRemoteControlJMX; + +/** + * Thread that is in charge of executing every x milliseconds. Upon each + * iteration, a snapshot of the server's information is recorded. + */ +public class SnapshotThread extends Thread { + + private long SNAPSHOT_DURATION; + private MBeanServer mbServer = null; + // list of mbean names that we will be taking snapshots of + private ArrayList mbeanNames; + + public SnapshotThread(long snapshot_length, MBeanServer mbServer) { + SNAPSHOT_DURATION = snapshot_length; + this.mbServer = mbServer; + mbeanNames = new ArrayList(); + } + + /** + * Gets the elapsed time in milliseconds between each snapshot. + * + * @return long + */ + public long getSnapshotDuration() { + return SNAPSHOT_DURATION; + } + + /** + * Adds the mbean name to list in memory. To update the snapshot-config.xml + * coder must use SnapshotConfigXMLBuilder class. + * @param mbeanName + */ + public void addMBeanForSnapshot(String mbeanName) { + mbeanNames.add(mbeanName); + } + + /** + * Removes the mbean name to list in memory. To update the snapshot-config.xml + * coder must use SnapshotConfigXMLBuilder class. + * @param mbeanName + */ + public void removeMBeanForSnapshot(String mbeanName) { + mbeanNames.remove(mbeanName); + } + + /** + * Sets the elapsed time in milliseconds between each snapshot. + * + * @param snapshotDuration + */ + public void setSnapshotDuration(long snapshot_length) { + SNAPSHOT_DURATION = snapshot_length; + } + + public void run() { + // get any saved mbean names from snapshot-config.xml + mbeanNames = SnapshotConfigXMLBuilder.getMBeanNames(); + // in the case where nothing is present, grab a set of default mbeans + if(mbeanNames.size() <= 0) { + mbeanNames = getDefaultMBeanList(); + } + // pause the thread from running every SNAPSHOT_DURATION seconds + while(true && SNAPSHOT_DURATION != Long.MAX_VALUE) { + try { + // store the data + SnapshotProcessor.takeSnapshot(); + // wait for next snapshot + Thread.sleep(SNAPSHOT_DURATION); + } catch(Exception e) { + e.printStackTrace(); + } + } + } + + /** + * @return A list of all default mbeans; namely, all connector or container mbean names + * Prereq: in order to be a connector or container mbean the name must contain "Connector"/"Container" + * and "Tomcat"/"Jetty" + */ + private ArrayList getDefaultMBeanList() { + Set mbeans = (new MasterRemoteControlJMX()).getStatisticsProviderMBeanNames(); + ArrayList retval = new ArrayList(); + for(Iterator it = mbeans.iterator(); it.hasNext(); ) { + String name = (String)it.next(); + if((name.contains("Connector") || name.contains("Container")) && + (name.contains("Jetty") || name.contains("Tomcat"))) { + // this is a connector, so add to the list + retval.add(name); + // update the snapshot-config.xml to include these + SnapshotConfigXMLBuilder.addMBeanName(name); + } + } + return retval; + } +} Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: geronimo/server/trunk/plugins/monitoring/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/pom.xml?rev=615738&r1=615737&r2=615738&view=diff ============================================================================== --- geronimo/server/trunk/plugins/monitoring/pom.xml (original) +++ geronimo/server/trunk/plugins/monitoring/pom.xml Sun Jan 27 22:54:18 2008 @@ -66,7 +66,8 @@ agent-jar agent-ear agent-ejb - + agent-jmx + agent-car-jmx agent-sql mconsole-ds mconsole-ear