Initial populations

This commit is contained in:
2021-11-16 11:19:21 +07:00
parent cdac14e7fd
commit bee21d279a
2168 changed files with 849329 additions and 0 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+411
View File
@@ -0,0 +1,411 @@
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.fourelementscapital:lib-scheduler-engines:jar:1.0
[WARNING] 'dependencies.dependency.systemPath' for com.bloomberglp.blpapi:blpapi:jar should not point at files within the project directory, ${basedir}/lib/blpapi3.jar will be unresolvable by dependent projects @ line 104, column 16
[WARNING] 'dependencies.dependency.systemPath' for org.apache.jcs:jcs:jar should not point at files within the project directory, ${basedir}/lib/jcs-1.3.3.1-RC.jar will be unresolvable by dependent projects @ line 111, column 16
[WARNING] 'dependencies.dependency.systemPath' for org.mozilla.javascript.tools.shell:js-14:jar should not point at files within the project directory, ${basedir}/lib/js-14.jar will be unresolvable by dependent projects @ line 118, column 16
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] lib-scheduler [pom]
[INFO] lib-scheduler-exception [jar]
[INFO] lib-scheduler-common [jar]
[INFO] lib-scheduler-p2p [jar]
[INFO] lib-scheduler-engines [jar]
[INFO] lib-scheduler-queue [jar]
[INFO]
[INFO] ---------------< com.fourelementscapital:lib-scheduler >----------------
[INFO] Building lib-scheduler 1.0 [1/6]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ lib-scheduler ---
[INFO] Deleting /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ lib-scheduler ---
[INFO] Installing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/pom.xml to /Users/bernarto/.m2/repository/com/fourelementscapital/lib-scheduler/1.0/lib-scheduler-1.0.pom
[INFO]
[INFO] --- maven-site-plugin:3.7.1:site (attach-javadocs) @ lib-scheduler ---
[INFO] configuring report plugin org.apache.maven.plugins:maven-javadoc-plugin:2.10.4
[INFO] preparing maven-javadoc-plugin:javadoc report requires 'generate-sources' forked phase execution
[INFO]
[INFO] >>> maven-javadoc-plugin:2.10.4:javadoc > generate-sources @ lib-scheduler >>>
[INFO]
[INFO] <<< maven-javadoc-plugin:2.10.4:javadoc < generate-sources @ lib-scheduler <<<
[INFO]
[INFO] 'generate-sources' forked phase execution for maven-javadoc-plugin:javadoc report preparation done
[INFO] preparing maven-javadoc-plugin:test-javadoc report requires 'generate-test-sources' forked phase execution
[INFO]
[INFO] >>> maven-javadoc-plugin:2.10.4:test-javadoc > generate-test-sources @ lib-scheduler >>>
[INFO]
[INFO] <<< maven-javadoc-plugin:2.10.4:test-javadoc < generate-test-sources @ lib-scheduler <<<
[INFO]
[INFO] 'generate-test-sources' forked phase execution for maven-javadoc-plugin:test-javadoc report preparation done
[INFO] 2 reports configured for maven-javadoc-plugin:2.10.4: javadoc, test-javadoc
[WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plugin has an empty version.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.2
[INFO] 16 reports detected for maven-project-info-reports-plugin:3.1.2: ci-management, dependencies, dependency-convergence, dependency-info, dependency-management, distribution-management, index, issue-management, licenses, mailing-lists, modules, plugin-management, plugins, scm, summary, team
[INFO] Rendering site with default locale English (en)
[INFO] Relativizing decoration links with respect to localized project URL: http://www.fourelementscapital.com
[INFO] Rendering content with org.apache.maven.skins:maven-default-skin:jar:1.2 skin.
[INFO] Generating "Dependencies" report --- maven-project-info-reports-plugin:3.1.2:dependencies
[INFO] Generating "Dependency Convergence" report --- maven-project-info-reports-plugin:3.1.2:dependency-convergence
[WARNING] Missing POM for com.fourelementscapital:lib-db:jar:1.0
[WARNING] Missing POM for com.fourelementscapital:lib-r:jar:1.0
[WARNING] Missing POM for org.jfree:jfreechart:jar:1.0.17-SNAPSHOT
[INFO] Generating "Dependency Information" report --- maven-project-info-reports-plugin:3.1.2:dependency-info
[INFO] Generating "Distribution Management" report --- maven-project-info-reports-plugin:3.1.2:distribution-management
[INFO] Generating "About" report --- maven-project-info-reports-plugin:3.1.2:index
[INFO] Generating "Licenses" report --- maven-project-info-reports-plugin:3.1.2:licenses
[INFO] Generating "Project Modules" report --- maven-project-info-reports-plugin:3.1.2:modules
[INFO] Generating "Plugin Management" report --- maven-project-info-reports-plugin:3.1.2:plugin-management
[INFO] Generating "Plugins" report --- maven-project-info-reports-plugin:3.1.2:plugins
[INFO] Generating "Summary" report --- maven-project-info-reports-plugin:3.1.2:summary
[INFO]
[INFO] --- maven-site-plugin:3.7.1:stage (attach-javadocs) @ lib-scheduler ---
[INFO] Using this base directory for staging: /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target/staging
[INFO] Pushing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target/site
[INFO] >>> to file:///Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target/staging/./
[INFO]
[INFO] ----------< com.fourelementscapital:lib-scheduler-exception >-----------
[INFO] Building lib-scheduler-exception 1.0 [2/6]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ lib-scheduler-exception ---
[INFO] Deleting /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lib-scheduler-exception ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ lib-scheduler-exception ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 15 source files to /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ lib-scheduler-exception ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ lib-scheduler-exception ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ lib-scheduler-exception ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.0.1:jar (default-jar) @ lib-scheduler-exception ---
[INFO] Building jar: /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/lib-scheduler-exception-1.0.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ lib-scheduler-exception ---
[INFO] Installing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/lib-scheduler-exception-1.0.jar to /Users/bernarto/.m2/repository/com/fourelementscapital/lib-scheduler-exception/1.0/lib-scheduler-exception-1.0.jar
[INFO] Installing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/pom.xml to /Users/bernarto/.m2/repository/com/fourelementscapital/lib-scheduler-exception/1.0/lib-scheduler-exception-1.0.pom
[INFO]
[INFO] --- maven-site-plugin:3.7.1:site (attach-javadocs) @ lib-scheduler-exception ---
[INFO] configuring report plugin org.apache.maven.plugins:maven-javadoc-plugin:2.10.4
[INFO] preparing maven-javadoc-plugin:javadoc report requires 'generate-sources' forked phase execution
[INFO]
[INFO] >>> maven-javadoc-plugin:2.10.4:javadoc > generate-sources @ lib-scheduler-exception >>>
[INFO]
[INFO] <<< maven-javadoc-plugin:2.10.4:javadoc < generate-sources @ lib-scheduler-exception <<<
[INFO]
[INFO] 'generate-sources' forked phase execution for maven-javadoc-plugin:javadoc report preparation done
[INFO] preparing maven-javadoc-plugin:test-javadoc report requires 'generate-test-sources' forked phase execution
[INFO]
[INFO] >>> maven-javadoc-plugin:2.10.4:test-javadoc > generate-test-sources @ lib-scheduler-exception >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lib-scheduler-exception ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ lib-scheduler-exception ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< maven-javadoc-plugin:2.10.4:test-javadoc < generate-test-sources @ lib-scheduler-exception <<<
[INFO]
[INFO] 'generate-test-sources' forked phase execution for maven-javadoc-plugin:test-javadoc report preparation done
[INFO] 2 reports configured for maven-javadoc-plugin:2.10.4: javadoc, test-javadoc
[WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plugin has an empty version.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.2
[INFO] 15 reports detected for maven-project-info-reports-plugin:3.1.2: ci-management, dependencies, dependency-info, dependency-management, distribution-management, index, issue-management, licenses, mailing-lists, modules, plugin-management, plugins, scm, summary, team
[INFO] Rendering site with default locale English (en)
[INFO] Relativizing decoration links with respect to localized project URL: http://www.fourelementscapital.com
[INFO] Rendering content with org.apache.maven.skins:maven-default-skin:jar:1.2 skin.
[INFO] Generating "JavaDocs" report --- maven-javadoc-plugin:2.10.4:javadoc
[INFO]
Loading source files for package com.fourelementscapital.scheduler.exception...
Constructing Javadoc information...
Standard Doclet version 1.8.0_212
Building tree for all the packages and classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionDependencyTimeout.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionExecutionTimeout.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionPeerNoResponse.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionPeerRejected.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionPeerUnknown.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionRemoveFromQ.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionRemoveFromQNotInPeer.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionRscriptError.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionRScriptNullError.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionRServeUnixFailure.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionRServeWindowsFailure.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionSchedulerTeamRelated.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionUnixPeerUnknown.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionWarningNoFullData.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/SchedulerException.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/package-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/package-summary.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/package-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/constant-values.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/serialized-form.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionRServeUnixFailure.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionRServeWindowsFailure.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionDependencyTimeout.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionPeerRejected.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionSchedulerTeamRelated.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionPeerUnknown.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/SchedulerException.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionRemoveFromQNotInPeer.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionRscriptError.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionRScriptNullError.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionRemoveFromQ.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionPeerNoResponse.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionWarningNoFullData.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionExecutionTimeout.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionUnixPeerUnknown.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/package-use.html...
Building index for all the packages and classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/overview-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/index-all.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/deprecated-list.html...
Building index for all classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/allclasses-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/allclasses-noframe.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/index.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/help-doc.html...
[INFO] Generating "Test JavaDocs" report --- maven-javadoc-plugin:2.10.4:test-javadoc
[INFO]
Loading source files for package com.fourelementscapital.scheduler.exception...
Constructing Javadoc information...
Standard Doclet version 1.8.0_212
Building tree for all the packages and classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/com/fourelementscapital/scheduler/exception/AppTest.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/com/fourelementscapital/scheduler/exception/package-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/com/fourelementscapital/scheduler/exception/package-summary.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/com/fourelementscapital/scheduler/exception/package-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/constant-values.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/com/fourelementscapital/scheduler/exception/class-use/AppTest.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/com/fourelementscapital/scheduler/exception/package-use.html...
Building index for all the packages and classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/overview-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/index-all.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/deprecated-list.html...
Building index for all classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/allclasses-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/allclasses-noframe.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/index.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/help-doc.html...
[INFO] Generating "Dependencies" report --- maven-project-info-reports-plugin:3.1.2:dependencies
[INFO] Generating "Dependency Information" report --- maven-project-info-reports-plugin:3.1.2:dependency-info
[INFO] Generating "Distribution Management" report --- maven-project-info-reports-plugin:3.1.2:distribution-management
[INFO] Generating "About" report --- maven-project-info-reports-plugin:3.1.2:index
[INFO] Generating "Licenses" report --- maven-project-info-reports-plugin:3.1.2:licenses
[INFO] Generating "Plugin Management" report --- maven-project-info-reports-plugin:3.1.2:plugin-management
[INFO] Generating "Plugins" report --- maven-project-info-reports-plugin:3.1.2:plugins
[INFO] Generating "Summary" report --- maven-project-info-reports-plugin:3.1.2:summary
[INFO]
[INFO] --- maven-site-plugin:3.7.1:stage (attach-javadocs) @ lib-scheduler-exception ---
[INFO] Using this base directory for staging: /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target/staging
[INFO] Pushing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site
[INFO] >>> to file:///Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target/staging/lib-scheduler-exception
[INFO]
[INFO] ------------< com.fourelementscapital:lib-scheduler-common >------------
[INFO] Building lib-scheduler-common 1.0 [3/6]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ lib-scheduler-common ---
[INFO] Deleting /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lib-scheduler-common ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ lib-scheduler-common ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ lib-scheduler-common ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ lib-scheduler-common ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ lib-scheduler-common ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.0.1:jar (default-jar) @ lib-scheduler-common ---
[INFO] Building jar: /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/lib-scheduler-common-1.0.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ lib-scheduler-common ---
[INFO] Installing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/lib-scheduler-common-1.0.jar to /Users/bernarto/.m2/repository/com/fourelementscapital/lib-scheduler-common/1.0/lib-scheduler-common-1.0.jar
[INFO] Installing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/pom.xml to /Users/bernarto/.m2/repository/com/fourelementscapital/lib-scheduler-common/1.0/lib-scheduler-common-1.0.pom
[INFO]
[INFO] --- maven-site-plugin:3.7.1:site (attach-javadocs) @ lib-scheduler-common ---
[INFO] configuring report plugin org.apache.maven.plugins:maven-javadoc-plugin:2.10.4
[INFO] preparing maven-javadoc-plugin:javadoc report requires 'generate-sources' forked phase execution
[INFO]
[INFO] >>> maven-javadoc-plugin:2.10.4:javadoc > generate-sources @ lib-scheduler-common >>>
[INFO]
[INFO] <<< maven-javadoc-plugin:2.10.4:javadoc < generate-sources @ lib-scheduler-common <<<
[INFO]
[INFO] 'generate-sources' forked phase execution for maven-javadoc-plugin:javadoc report preparation done
[INFO] preparing maven-javadoc-plugin:test-javadoc report requires 'generate-test-sources' forked phase execution
[INFO]
[INFO] >>> maven-javadoc-plugin:2.10.4:test-javadoc > generate-test-sources @ lib-scheduler-common >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lib-scheduler-common ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ lib-scheduler-common ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< maven-javadoc-plugin:2.10.4:test-javadoc < generate-test-sources @ lib-scheduler-common <<<
[INFO]
[INFO] 'generate-test-sources' forked phase execution for maven-javadoc-plugin:test-javadoc report preparation done
[INFO] 2 reports configured for maven-javadoc-plugin:2.10.4: javadoc, test-javadoc
[WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plugin has an empty version.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.2
[INFO] 15 reports detected for maven-project-info-reports-plugin:3.1.2: ci-management, dependencies, dependency-info, dependency-management, distribution-management, index, issue-management, licenses, mailing-lists, modules, plugin-management, plugins, scm, summary, team
[INFO] Rendering site with default locale English (en)
[INFO] Relativizing decoration links with respect to localized project URL: http://www.fourelementscapital.com
[INFO] Rendering content with org.apache.maven.skins:maven-default-skin:jar:1.2 skin.
[INFO] Generating "JavaDocs" report --- maven-javadoc-plugin:2.10.4:javadoc
[INFO]
Loading source files for package com.fourelementscapital.scheduler.config...
Loading source files for package com.fourelementscapital.scheduler.error...
Constructing Javadoc information...
Standard Doclet version 1.8.0_212
Building tree for all the packages and classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/com/fourelementscapital/scheduler/config/Config.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/com/fourelementscapital/scheduler/error/ClientError.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/overview-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/com/fourelementscapital/scheduler/config/package-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/com/fourelementscapital/scheduler/config/package-summary.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/com/fourelementscapital/scheduler/config/package-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/com/fourelementscapital/scheduler/error/package-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/com/fourelementscapital/scheduler/error/package-summary.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/com/fourelementscapital/scheduler/error/package-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/constant-values.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/com/fourelementscapital/scheduler/config/class-use/Config.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/com/fourelementscapital/scheduler/error/class-use/ClientError.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/com/fourelementscapital/scheduler/config/package-use.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/com/fourelementscapital/scheduler/error/package-use.html...
Building index for all the packages and classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/overview-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/index-all.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/deprecated-list.html...
Building index for all classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/allclasses-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/allclasses-noframe.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/index.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/overview-summary.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/apidocs/help-doc.html...
6 warnings
[WARNING] Javadoc Warnings
[WARNING] /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/src/main/java/com/fourelementscapital/scheduler/config/Config.java:92: warning: no description for @param
[WARNING] * @param key
[WARNING] ^
[WARNING] /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/src/main/java/com/fourelementscapital/scheduler/config/Config.java:93: warning: no description for @return
[WARNING] * @return
[WARNING] ^
[WARNING] /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/src/main/java/com/fourelementscapital/scheduler/config/Config.java:119: warning: no description for @param
[WARNING] * @param key
[WARNING] ^
[WARNING] /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/src/main/java/com/fourelementscapital/scheduler/config/Config.java:120: warning: no description for @return
[WARNING] * @return
[WARNING] ^
[WARNING] /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/src/main/java/com/fourelementscapital/scheduler/error/ClientError.java:39: warning: no description for @param
[WARNING] * @param ex
[WARNING] ^
[WARNING] /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/src/main/java/com/fourelementscapital/scheduler/error/ClientError.java:40: warning: no description for @param
[WARNING] * @param msg
[WARNING] ^
[INFO] Generating "Test JavaDocs" report --- maven-javadoc-plugin:2.10.4:test-javadoc
[INFO]
Loading source files for package com.fourelementscapital.scheduler.common...
Constructing Javadoc information...
Standard Doclet version 1.8.0_212
Building tree for all the packages and classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/com/fourelementscapital/scheduler/common/AppTest.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/com/fourelementscapital/scheduler/common/package-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/com/fourelementscapital/scheduler/common/package-summary.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/com/fourelementscapital/scheduler/common/package-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/constant-values.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/com/fourelementscapital/scheduler/common/class-use/AppTest.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/com/fourelementscapital/scheduler/common/package-use.html...
Building index for all the packages and classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/overview-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/index-all.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/deprecated-list.html...
Building index for all classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/allclasses-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/allclasses-noframe.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/index.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site/testapidocs/help-doc.html...
[INFO] Generating "Dependencies" report --- maven-project-info-reports-plugin:3.1.2:dependencies
[INFO] Generating "Dependency Information" report --- maven-project-info-reports-plugin:3.1.2:dependency-info
[INFO] Generating "Distribution Management" report --- maven-project-info-reports-plugin:3.1.2:distribution-management
[INFO] Generating "About" report --- maven-project-info-reports-plugin:3.1.2:index
[INFO] Generating "Licenses" report --- maven-project-info-reports-plugin:3.1.2:licenses
[INFO] Generating "Plugin Management" report --- maven-project-info-reports-plugin:3.1.2:plugin-management
[INFO] Generating "Plugins" report --- maven-project-info-reports-plugin:3.1.2:plugins
[INFO] Generating "Summary" report --- maven-project-info-reports-plugin:3.1.2:summary
[INFO]
[INFO] --- maven-site-plugin:3.7.1:stage (attach-javadocs) @ lib-scheduler-common ---
[INFO] Using this base directory for staging: /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target/staging
[INFO] Pushing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-common/target/site
[INFO] >>> to file:///Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target/staging/lib-scheduler-common
[INFO]
[INFO] -------------< com.fourelementscapital:lib-scheduler-p2p >--------------
[INFO] Building lib-scheduler-p2p 1.0 [4/6]
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.fourelementscapital:lib-db:jar:1.0 is missing, no dependency information available
[WARNING] The POM for com.fourelementscapital:lib-r:jar:1.0 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for lib-scheduler 1.0:
[INFO]
[INFO] lib-scheduler ...................................... SUCCESS [ 3.805 s]
[INFO] lib-scheduler-exception ............................ SUCCESS [ 3.794 s]
[INFO] lib-scheduler-common ............................... SUCCESS [ 2.694 s]
[INFO] lib-scheduler-p2p .................................. FAILURE [ 0.049 s]
[INFO] lib-scheduler-engines .............................. SKIPPED
[INFO] lib-scheduler-queue ................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.455 s
[INFO] Finished at: 2021-10-21T17:03:04+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project lib-scheduler-p2p: Could not resolve dependencies for project com.fourelementscapital:lib-scheduler-p2p:jar:1.0: The following artifacts could not be resolved: com.fourelementscapital:lib-db:jar:1.0, com.fourelementscapital:lib-r:jar:1.0: Failure to find com.fourelementscapital:lib-db:jar:1.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :lib-scheduler-p2p
File diff suppressed because it is too large Load Diff
+262
View File
@@ -0,0 +1,262 @@
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.fourelementscapital:lib-scheduler-engines:jar:1.0
[WARNING] 'dependencies.dependency.systemPath' for com.bloomberglp.blpapi:blpapi:jar should not point at files within the project directory, ${basedir}/lib/blpapi3.jar will be unresolvable by dependent projects @ line 104, column 16
[WARNING] 'dependencies.dependency.systemPath' for org.apache.jcs:jcs:jar should not point at files within the project directory, ${basedir}/lib/jcs-1.3.3.1-RC.jar will be unresolvable by dependent projects @ line 111, column 16
[WARNING] 'dependencies.dependency.systemPath' for org.mozilla.javascript.tools.shell:js-14:jar should not point at files within the project directory, ${basedir}/lib/js-14.jar will be unresolvable by dependent projects @ line 118, column 16
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] lib-scheduler [pom]
[INFO] lib-scheduler-exception [jar]
[INFO] lib-scheduler-common [jar]
[INFO] lib-scheduler-p2p [jar]
[INFO] lib-scheduler-engines [jar]
[INFO] lib-scheduler-queue [jar]
[INFO]
[INFO] ---------------< com.fourelementscapital:lib-scheduler >----------------
[INFO] Building lib-scheduler 1.0 [1/6]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ lib-scheduler ---
[INFO] Deleting /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ lib-scheduler ---
[INFO] Installing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/pom.xml to /Users/bernarto/.m2/repository/com/fourelementscapital/lib-scheduler/1.0/lib-scheduler-1.0.pom
[INFO]
[INFO] --- maven-site-plugin:3.7.1:site (attach-javadocs) @ lib-scheduler ---
[INFO] configuring report plugin org.apache.maven.plugins:maven-javadoc-plugin:2.10.4
[INFO] preparing maven-javadoc-plugin:javadoc report requires 'generate-sources' forked phase execution
[INFO]
[INFO] >>> maven-javadoc-plugin:2.10.4:javadoc > generate-sources @ lib-scheduler >>>
[INFO]
[INFO] <<< maven-javadoc-plugin:2.10.4:javadoc < generate-sources @ lib-scheduler <<<
[INFO]
[INFO] 'generate-sources' forked phase execution for maven-javadoc-plugin:javadoc report preparation done
[INFO] preparing maven-javadoc-plugin:test-javadoc report requires 'generate-test-sources' forked phase execution
[INFO]
[INFO] >>> maven-javadoc-plugin:2.10.4:test-javadoc > generate-test-sources @ lib-scheduler >>>
[INFO]
[INFO] <<< maven-javadoc-plugin:2.10.4:test-javadoc < generate-test-sources @ lib-scheduler <<<
[INFO]
[INFO] 'generate-test-sources' forked phase execution for maven-javadoc-plugin:test-javadoc report preparation done
[INFO] 2 reports configured for maven-javadoc-plugin:2.10.4: javadoc, test-javadoc
[WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plugin has an empty version.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.2
[INFO] 16 reports detected for maven-project-info-reports-plugin:3.1.2: ci-management, dependencies, dependency-convergence, dependency-info, dependency-management, distribution-management, index, issue-management, licenses, mailing-lists, modules, plugin-management, plugins, scm, summary, team
[INFO] Rendering site with default locale English (en)
[INFO] Relativizing decoration links with respect to localized project URL: http://www.fourelementscapital.com
[INFO] Rendering content with org.apache.maven.skins:maven-default-skin:jar:1.2 skin.
[INFO] Generating "Dependencies" report --- maven-project-info-reports-plugin:3.1.2:dependencies
[INFO] Generating "Dependency Convergence" report --- maven-project-info-reports-plugin:3.1.2:dependency-convergence
Downloading from central: https://repo.maven.apache.org/maven2/com/fourelementscapital/lib-alarm/2.0/lib-alarm-2.0.pom
[WARNING] Missing POM for com.fourelementscapital:lib-alarm:jar:2.0
[WARNING] Missing POM for com.fourelementscapital:lib-fileutils:jar:2.1.0
[WARNING] Missing POM for com.fourelementscapital:lib-db:jar:2.1.0
[WARNING] Missing POM for com.fourelementscapital:lib-r:jar:2.1.0
[WARNING] Missing POM for org.jfree:jfreechart:jar:1.0.17-SNAPSHOT
[INFO] Generating "Dependency Information" report --- maven-project-info-reports-plugin:3.1.2:dependency-info
[INFO] Generating "Distribution Management" report --- maven-project-info-reports-plugin:3.1.2:distribution-management
[INFO] Generating "About" report --- maven-project-info-reports-plugin:3.1.2:index
[INFO] Generating "Licenses" report --- maven-project-info-reports-plugin:3.1.2:licenses
[INFO] Generating "Project Modules" report --- maven-project-info-reports-plugin:3.1.2:modules
[INFO] Generating "Plugin Management" report --- maven-project-info-reports-plugin:3.1.2:plugin-management
[INFO] Generating "Plugins" report --- maven-project-info-reports-plugin:3.1.2:plugins
[INFO] Generating "Summary" report --- maven-project-info-reports-plugin:3.1.2:summary
[INFO]
[INFO] --- maven-site-plugin:3.7.1:stage (attach-javadocs) @ lib-scheduler ---
[INFO] Using this base directory for staging: /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target/staging
[INFO] Pushing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target/site
[INFO] >>> to file:///Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target/staging/./
[INFO]
[INFO] ----------< com.fourelementscapital:lib-scheduler-exception >-----------
[INFO] Building lib-scheduler-exception 1.0 [2/6]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ lib-scheduler-exception ---
[INFO] Deleting /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lib-scheduler-exception ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ lib-scheduler-exception ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 15 source files to /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ lib-scheduler-exception ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ lib-scheduler-exception ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ lib-scheduler-exception ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.0.1:jar (default-jar) @ lib-scheduler-exception ---
[INFO] Building jar: /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/lib-scheduler-exception-1.0.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ lib-scheduler-exception ---
[INFO] Installing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/lib-scheduler-exception-1.0.jar to /Users/bernarto/.m2/repository/com/fourelementscapital/lib-scheduler-exception/1.0/lib-scheduler-exception-1.0.jar
[INFO] Installing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/pom.xml to /Users/bernarto/.m2/repository/com/fourelementscapital/lib-scheduler-exception/1.0/lib-scheduler-exception-1.0.pom
[INFO]
[INFO] --- maven-site-plugin:3.7.1:site (attach-javadocs) @ lib-scheduler-exception ---
[INFO] configuring report plugin org.apache.maven.plugins:maven-javadoc-plugin:2.10.4
[INFO] preparing maven-javadoc-plugin:javadoc report requires 'generate-sources' forked phase execution
[INFO]
[INFO] >>> maven-javadoc-plugin:2.10.4:javadoc > generate-sources @ lib-scheduler-exception >>>
[INFO]
[INFO] <<< maven-javadoc-plugin:2.10.4:javadoc < generate-sources @ lib-scheduler-exception <<<
[INFO]
[INFO] 'generate-sources' forked phase execution for maven-javadoc-plugin:javadoc report preparation done
[INFO] preparing maven-javadoc-plugin:test-javadoc report requires 'generate-test-sources' forked phase execution
[INFO]
[INFO] >>> maven-javadoc-plugin:2.10.4:test-javadoc > generate-test-sources @ lib-scheduler-exception >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lib-scheduler-exception ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ lib-scheduler-exception ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< maven-javadoc-plugin:2.10.4:test-javadoc < generate-test-sources @ lib-scheduler-exception <<<
[INFO]
[INFO] 'generate-test-sources' forked phase execution for maven-javadoc-plugin:test-javadoc report preparation done
[INFO] 2 reports configured for maven-javadoc-plugin:2.10.4: javadoc, test-javadoc
[WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plugin has an empty version.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:3.1.2
[INFO] 15 reports detected for maven-project-info-reports-plugin:3.1.2: ci-management, dependencies, dependency-info, dependency-management, distribution-management, index, issue-management, licenses, mailing-lists, modules, plugin-management, plugins, scm, summary, team
[INFO] Rendering site with default locale English (en)
[INFO] Relativizing decoration links with respect to localized project URL: http://www.fourelementscapital.com
[INFO] Rendering content with org.apache.maven.skins:maven-default-skin:jar:1.2 skin.
[INFO] Generating "JavaDocs" report --- maven-javadoc-plugin:2.10.4:javadoc
[INFO]
Loading source files for package com.fourelementscapital.scheduler.exception...
Constructing Javadoc information...
Standard Doclet version 1.8.0_212
Building tree for all the packages and classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionDependencyTimeout.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionExecutionTimeout.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionPeerNoResponse.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionPeerRejected.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionPeerUnknown.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionRemoveFromQ.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionRemoveFromQNotInPeer.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionRscriptError.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionRScriptNullError.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionRServeUnixFailure.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionRServeWindowsFailure.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionSchedulerTeamRelated.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionUnixPeerUnknown.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/ExceptionWarningNoFullData.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/SchedulerException.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/package-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/package-summary.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/package-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/constant-values.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/serialized-form.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionRServeUnixFailure.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionRServeWindowsFailure.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionDependencyTimeout.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionPeerRejected.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionSchedulerTeamRelated.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionPeerUnknown.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/SchedulerException.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionRemoveFromQNotInPeer.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionRscriptError.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionRScriptNullError.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionRemoveFromQ.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionPeerNoResponse.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionWarningNoFullData.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionExecutionTimeout.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/class-use/ExceptionUnixPeerUnknown.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/com/fourelementscapital/scheduler/exception/package-use.html...
Building index for all the packages and classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/overview-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/index-all.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/deprecated-list.html...
Building index for all classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/allclasses-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/allclasses-noframe.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/index.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/apidocs/help-doc.html...
[INFO] Generating "Test JavaDocs" report --- maven-javadoc-plugin:2.10.4:test-javadoc
[INFO]
Loading source files for package com.fourelementscapital.scheduler.exception...
Constructing Javadoc information...
Standard Doclet version 1.8.0_212
Building tree for all the packages and classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/com/fourelementscapital/scheduler/exception/AppTest.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/com/fourelementscapital/scheduler/exception/package-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/com/fourelementscapital/scheduler/exception/package-summary.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/com/fourelementscapital/scheduler/exception/package-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/constant-values.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/com/fourelementscapital/scheduler/exception/class-use/AppTest.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/com/fourelementscapital/scheduler/exception/package-use.html...
Building index for all the packages and classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/overview-tree.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/index-all.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/deprecated-list.html...
Building index for all classes...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/allclasses-frame.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/allclasses-noframe.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/index.html...
Generating /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site/testapidocs/help-doc.html...
[INFO] Generating "Dependencies" report --- maven-project-info-reports-plugin:3.1.2:dependencies
[INFO] Generating "Dependency Information" report --- maven-project-info-reports-plugin:3.1.2:dependency-info
[INFO] Generating "Distribution Management" report --- maven-project-info-reports-plugin:3.1.2:distribution-management
[INFO] Generating "About" report --- maven-project-info-reports-plugin:3.1.2:index
[INFO] Generating "Licenses" report --- maven-project-info-reports-plugin:3.1.2:licenses
[INFO] Generating "Plugin Management" report --- maven-project-info-reports-plugin:3.1.2:plugin-management
[INFO] Generating "Plugins" report --- maven-project-info-reports-plugin:3.1.2:plugins
[INFO] Generating "Summary" report --- maven-project-info-reports-plugin:3.1.2:summary
[INFO]
[INFO] --- maven-site-plugin:3.7.1:stage (attach-javadocs) @ lib-scheduler-exception ---
[INFO] Using this base directory for staging: /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target/staging
[INFO] Pushing /Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/lib-scheduler-exception/target/site
[INFO] >>> to file:///Users/bernarto/devel/4e/JavaApps-2.1.2/Scheduler/scheduler_libraries/target/staging/lib-scheduler-exception
[INFO]
[INFO] ------------< com.fourelementscapital:lib-scheduler-common >------------
[INFO] Building lib-scheduler-common 1.0 [3/6]
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.fourelementscapital:lib-alarm:jar:2.0 is missing, no dependency information available
Downloading from central: https://repo.maven.apache.org/maven2/com/fourelementscapital/lib-alarm/2.0/lib-alarm-2.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for lib-scheduler 1.0:
[INFO]
[INFO] lib-scheduler ...................................... SUCCESS [ 4.998 s]
[INFO] lib-scheduler-exception ............................ SUCCESS [ 3.755 s]
[INFO] lib-scheduler-common ............................... FAILURE [ 0.673 s]
[INFO] lib-scheduler-p2p .................................. SKIPPED
[INFO] lib-scheduler-engines .............................. SKIPPED
[INFO] lib-scheduler-queue ................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.540 s
[INFO] Finished at: 2021-10-22T12:26:11+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project lib-scheduler-common: Could not resolve dependencies for project com.fourelementscapital:lib-scheduler-common:jar:1.0: Could not find artifact com.fourelementscapital:lib-alarm:jar:2.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :lib-scheduler-common
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler</artifactId>
<version>1.0</version>
</parent>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler-common</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>lib-scheduler-common</name>
<description>Scheduler Libraries related to common component</description>
<url>http://www.fourelementscapital.com</url>
<dependencies>
<dependency>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-alarm</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,187 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.config;
import java.io.File;
import java.io.FileInputStream;
import java.util.MissingResourceException;
import java.util.Properties;
import java.util.ResourceBundle;
import org.apache.logging.log4j.LogManager;
/**
* This class populates the configuration value from property file
*
*
*/
public class Config {
/**
* Ignores authentication for the user
*/
public static final String CONFIG_IGNORE_AUTH="ignore.authentication";
/**
* Number of maximum thread in Rserve
*/
public static final String CONFIG_NUMBEROF_RSERVE_THREADS="rserve.thread.size";
/**
* Accepts anonymous users
*/
public static final String USER_ANONYMOUS="anonymous";
/**
* windows server/tomcat peer configuration file
*/
private static final String BUNDLE_NAME = "com.fe.config_windows"; //$NON-NLS-1$
/**
* unix server/tomcat peer configuration file
*/
private static final String BUNDLE_NAME_UNIX = "com.fe.config_unix"; //$NON-NLS-1$
/**
* windows peer configuration
*/
private static final String PROPERTY_FILE_WIN = "peer_windows.properties"; //$NON-NLS-1$
/**
* unix peer/server configuration file
*/
private static final String PROPERTY_FILE_UNIX = "peer_unix.properties"; //$NON-NLS-1$
public static String CONFIG_PROPERTY_LOCATION=null;
/**
* ignore p2p multicasting
*/
public static String P2P_NO_MULTICAST="p2p.nomulticast";
/**
* hsql data file property
*/
public static String HSQLDB_QUEUE_FILE="hsql.queue.datafile";
private static Properties confpro=null;
//private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
private Config() {
}
/**
* returns the property value of specified key.
* @param key
* @return
*/
public static String getString(String key) {
if(CONFIG_PROPERTY_LOCATION==null){
try {
//return RESOURCE_BUNDLE.getString(key);
return getResourceBuddle().getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}else{
try {
String ky= getPeerProperty(key);
if(ky==null) throw new Exception();
else return ky;
} catch (Exception e) {
return '!' + key + '!';
}
}
}
/**
* returns the property value of specified key.
* @param key
* @return
*/
public static String getValue(String key) {
if(CONFIG_PROPERTY_LOCATION==null){
try {
return getResourceBuddle().getString(key);
} catch (MissingResourceException e) {
return null;
}
}else{
try {
return getPeerProperty(key);
} catch (Exception e) {
return null;
}
}
}
private static ResourceBundle resourceBundle=null;
private synchronized static ResourceBundle getResourceBuddle(){
if(resourceBundle==null){
String os="win";
resourceBundle= ResourceBundle.getBundle(BUNDLE_NAME); //windows
if(System.getProperty("os.name").toLowerCase().equals("freebsd")) {
resourceBundle=ResourceBundle.getBundle(BUNDLE_NAME_UNIX);
os="freebsd";
}
if(System.getProperty("os.name").toLowerCase().contains("linux")) {
resourceBundle=ResourceBundle.getBundle(BUNDLE_NAME_UNIX);
os="linux";
}
LogManager.getLogger(Config.class.getName()).info("resourceBundle:"+resourceBundle+" os:"+os);
}
return resourceBundle;
}
private static String getPeerProperty(String key) throws Exception {
try{
if(confpro==null){
String propertyfilename=PROPERTY_FILE_WIN;
if(System.getProperty("os.name").toLowerCase().equals("freebsd"))
propertyfilename=PROPERTY_FILE_UNIX;
if(System.getProperty("os.name").toLowerCase().contains("linux"))
propertyfilename=PROPERTY_FILE_UNIX;
String folder=CONFIG_PROPERTY_LOCATION;
folder=folder.endsWith(File.separator)?folder:folder+File.separator;
confpro=new Properties();
String filename=folder+"conf"+File.separator+propertyfilename;
confpro.load(new FileInputStream(filename));
}
return confpro.getProperty(key);
}catch(Exception e){
e.printStackTrace();
throw e;
}
}
}
@@ -0,0 +1,153 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.error;
import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.fourelementscapital.scheduler.config.Config;
/**
* This class handles error logging of the system.
* <br>
* <pre>
* property to configure the folder "log_error_folder"
* and also property that sends error log into console if a config property "log_error_to_console" is set to "yes"
* </pre>
* @author Rams Kannan
*
*/
public class ClientError {
private static String nextLineChar="\r\n";
/**
* This method wil be invoked when there was error and the error log will be sent to an external file.
* One log file per day will be created in this
* <pre>
* property to configure the folder "log_error_folder"
* and also property that sends error log into console if a config property "log_error_to_console" is set to "yes"
* </pre>
* @param ex
* @param msg
*/
public static void reportError(Exception ex, String msg){
msg=(msg==null)?"":msg;
String root=Config.getString("log_error_folder");
Date d = new Date();
String folder =root+"errorlogs";
if (!new File(folder).isDirectory()) {
new File(folder).mkdirs();
}
String fname=root+"errorlogs"+File.separator+"error"+new SimpleDateFormat("dd_MM_yyyy").format(d)+".log";
File file=new File(fname);
try {
boolean append = true;
FileWriter fw = new FileWriter(file,append);
SimpleDateFormat sd=new SimpleDateFormat("dd-MM-yyy h:mm:ss a");
String logmessage="-------- "+sd.format(new Date())+" ------"+
nextLineChar+collectErrorStack(ex,msg)+"***********************"+nextLineChar;
if (!file.exists()) {
file.createNewFile();
}
fw.append(logmessage+nextLineChar+" "+nextLineChar);
fw.flush();
fw.close();
String consoleoutput=Config.getString("log_error_to_console");
if(consoleoutput!=null && consoleoutput.equalsIgnoreCase("yes")){
System.out.println(logmessage);
}
//
}
catch (Exception ex1) {
ex1.printStackTrace();
}
}
private static String collectErrorStack(Exception ex,String msg) throws Exception {
StackTraceElement[] stacks=ex.getStackTrace();
String rtn="";
if(msg!=null) rtn+=msg.trim()+nextLineChar;
rtn+="ERROR MSG:"+ex.getMessage()+nextLineChar;
int startat=0;
for(int i=0;i<stacks.length;i++){
if(stacks[i].getClassName().startsWith("com.fe.")){
startat=i;
}
}
int numbefore=4;
startat=(startat>numbefore)?startat-numbefore:0;
int counter=1;
String consoleoutputfull=Config.getString("log_error_to_console_full");
if(consoleoutputfull!=null && consoleoutputfull.equalsIgnoreCase("yes")){
for(int i=startat;i<stacks.length;i++){
//if((i>(startat+numbefore)) && !stacks[i].getClassName().startsWith("com.fe.")){
//}else{
String space=" ";
//for(int ab=0;ab<counter;ab++) space+=" "; counter++;
if(stacks[i].getClassName().startsWith("com.fe.")){
rtn+="->"+stacks[i].getClassName()+"."+stacks[i].getMethodName()+"()"+nextLineChar;;
}else{
rtn+=space+""+stacks[i].getClassName()+"."+stacks[i].getMethodName()+"()"+nextLineChar;
}
//}
}
}else{
for(int i=startat;i<stacks.length;i++){
if((i>(startat+numbefore)) && !stacks[i].getClassName().startsWith("com.fe.")){
}else{
String space="";
for(int ab=0;ab<counter;ab++) space+=" "; counter++;
if(stacks[i].getClassName().startsWith("com.fe.")){
space+="->";
}
rtn+=space+""+stacks[i].getClassName()+"."+stacks[i].getMethodName()+"()"+nextLineChar;
}
}
}
return rtn;
}
}
@@ -0,0 +1,47 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.common;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for App
*/
public class AppTest extends TestCase {
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Empty Test
*/
public void testApp()
{
assertTrue( true );
}
}
@@ -0,0 +1,156 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler</artifactId>
<version>1.0</version>
</parent>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler-engines</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>lib-scheduler-engines</name>
<description>Scheduler Libraries related to Engines</description>
<url>http://www.fourelementscapital.com</url>
<dependencies>
<dependency>
<groupId>com.googlecode.cqengine</groupId>
<artifactId>cqengine</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.50</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.9.Final</version>
</dependency>
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart-swt</artifactId>
<version>1.0.17</version>
</dependency>
<dependency>
<groupId>net.jxta</groupId>
<artifactId>jxta-jxse</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jcommon</artifactId>
<version>1.0.23</version>
</dependency>
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.19</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.42</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-coyote</artifactId>
<version>7.0.39</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.bloomberglp.blpapi</groupId>
<artifactId>blpapi</artifactId>
<version>3.2.2.0</version>
<systemPath>${basedir}/lib/blpapi3.jar</systemPath>
<scope>system</scope>
</dependency>
<dependency>
<groupId>org.apache.jcs</groupId>
<artifactId>jcs</artifactId>
<version>1.3.3.1</version>
<systemPath>${basedir}/lib/jcs-1.3.3.1-RC.jar</systemPath>
<scope>system</scope>
</dependency>
<dependency>
<groupId>org.mozilla.javascript.tools.shell</groupId>
<artifactId>js-14</artifactId>
<version>1.2.3</version>
<systemPath>${basedir}/lib/js-14.jar</systemPath>
<scope>system</scope>
</dependency>
<dependency>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-fileutils</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-db</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-r</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler-exception</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler-common</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler-p2p</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,81 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.util.Vector;
import com.fourelementscapital.db.vo.FlexiField;
public abstract class AbstractRScript extends ScheduledTask{
public AbstractRScript(String name, String uid) {
super(name, uid);
try{
addFormFields(getMyFields());
}catch(Exception e){
e.printStackTrace();
}
}
protected Vector<ScheduledTaskField> getMyFields(){
Vector fields=new Vector();
//list
ScheduledTaskField f3=new ScheduledTaskField();
f3.setShortname("rscript_param");
f3.setFieldlabel("");
f3.setFieldtype(FlexiField.TYPE_RSCRIPTEDITOR_PARAM);
f3.setPlacementform("codeinject");
//f3.setFineprint("header code fine print");
fields.add(f3);
ScheduledTaskField f4=new ScheduledTaskField();
f4.setShortname("rscript");
f4.setFieldlabel("R Script");
f4.setFieldtype(FlexiField.TYPE_RSCRIPTEDITOR);
fields.add(f4);
//fields.add(f5);
fields.addAll(getAdditionalRScriptField());
return fields;
}
public Vector<ScheduledTaskField> getAdditionalRScriptField(){
Vector fields=new Vector();
ScheduledTaskField f5=new ScheduledTaskField();
f5.setShortname("trigger_commodity");
f5.setFieldlabel("Trigger Commodity");
f5.setFieldtype(FlexiField.TYPE_TEXTBOX);
//f5.setFineprint("Commodity research ticker that defines the trigger time for Zero-day lag indicators e.g: CL,C");
f5.setFineprint("Building block which fixing time defines the trigger time for Zero-day lag indicators e.g: CL,C,JNso");
f5.setPlacementform("buildingblock");
fields.add(f5);
ScheduledTaskField f6=new ScheduledTaskField();
f6.setShortname("trigger_frequency");
f6.setFieldlabel("Trigger Frequency");
f6.setFieldtype(FlexiField.TYPE_TEXTBOX);
f6.setFineprint("Specific Intervals: 1/3 (starting at 1 and every 3 minutes)");
f6.setPlacementform("buildingblock");
fields.add(f6);
return fields;
}
}
@@ -0,0 +1,195 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.StringReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.quartz.JobExecutionException;
import org.rosuda.REngine.Rserve.RConnection;
import com.fourelementscapital.scheduler.config.Config;
import com.fourelementscapital.scheduler.exception.ExceptionRServeUnixFailure;
import com.fourelementscapital.scheduler.exception.ExceptionUnixPeerUnknown;
import com.fourelementscapital.scheduler.exception.SchedulerException;
import com.fourelementscapital.scheduler.p2p.P2PService;
import com.fourelementscapital.scheduler.rserve.RServeSession;
public abstract class AbstractRServe extends AbstractRScript{
public AbstractRServe(String name, String uid) {
super(name, uid);
}
private Logger log = LogManager.getLogger(AbstractRServe.class.getName());
protected StackFrame stackframe=null;
public abstract RServeSession getRServeSession(int nid,String name) throws Exception;
public abstract void evalScript(RServeSession rs, String rscript) throws Exception;
public abstract void closeRconnection(RServeSession rs) throws Exception;
public void execute(StackFrame sframe) throws JobExecutionException,Exception {
this.stackframe=sframe;
Map<String, Object> data=sframe.getData();
String rscript=(String)data.get("rscript");
Number nid=(Number)data.get("id");
String name=sframe.getData().get("name").toString();
if(rscript==null) { throw new JobExecutionException("Task Failed because no R script found or empty"); }
//log.debug("R Engine initiated.");
if(rscript!=null && !rscript.equals("")){
try{
//System.out.println(" RServeLowPriorityTask.execute(): executed 11");
String line;
log.debug("R init source file initiated.");
StringBuffer sb=new StringBuffer();
log.debug("------------------<<<<r_script_init:"+Config.getString("r_script_init"));
//collecting Rinit.r content into stringbuffer
if(Config.getString("r_script_init")!=null && new File(Config.getString("r_script_init")).exists()){
log.debug("including r_script_init");
//adding Rinit.r file on top of the script...
BufferedReader reader1 = new BufferedReader(new FileReader(Config.getString("r_script_init")));
String line1;
while ((line1 = reader1.readLine()) != null) {
if(line1!=null && !line1.equals("")){
sb.append(line1+"\n");
}
}
reader1.close();
log.debug("R init source file initiated.");
}
//collecting main script...
BufferedReader reader = new BufferedReader(new StringReader(rscript));
while ((line = reader.readLine()) != null) {
if(line!=null && !line.equals("")){
//out.write(line+"\n");
sb.append(line+"\n");
}
}
//out.close();
reader.close();
RConnection c=null;
RServeSession rs=null;
File temp=null;
try{
rs=getRServeSession(nid.intValue(), name);
//c=getRconnection(nid.intValue(), name);
if(rs!=null && rs.getRconnection()!=null ){
new SchedulerExePlanLogs(nid.intValue(),sframe.getTrigger_time()).log("RServe session started..",SchedulerExePlanLogs.PEER_OK_RESPOND_RSERVE_SESSIONSTARTED);
c=rs.getRconnection();
c.assign(".trigger_time", sframe.getTrigger_time()+"");
c.assign(".scheduler_id", nid+"");
c.assign(".machine", P2PService.getComputerName());
c.assign(".enginetype","RServeUnix");
c.assign(".connection_ids","");
//sink staring here....
temp = File.createTempFile(nid.intValue()+"_"+sframe.getTrigger_time(),".log");
temp.getParentFile().setWritable(true, false);
String ff=temp.getPath();
if(ff.contains("\\")){
ff=ff.replaceAll("\\\\", "\\\\\\\\");
}
temp.delete();
log.debug("---- deleting ff:"+ff);
String fileass="file(\""+ff+"\", open = \"wt\");";
log.debug("file assign------fileass:"+fileass);
c.eval(".console_msg_zz<-"+fileass);
c.eval("sink(.console_msg_zz)");
c.eval("sink(.console_msg_zz, type = \"message\")") ;
log.debug("----sink----");
if(false){
//ignored as it is not useful anymore
c.eval("if(length(.r_scripts)>12){ .r_scripts=.r_scripts[(length(.r_scripts)-10):length(.r_scripts)] }"); //keep only last 10 when it goes more than 12 to avoid keeping too many things in memory.
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd_HHmmss");
String tl=nid+"|"+sframe.getTrigger_time()+"|"+sdf.format(new Date());
c.eval(".r_scripts=append(.r_scripts,\""+tl+"\")");
}
new SchedulerExePlanLogs(nid.intValue(),sframe.getTrigger_time()).log("RServe Script evaluation starting..",SchedulerExePlanLogs.PEER_OK_RSERVE_SCRIPT_EVAL_STARTING);
evalScript(rs,sb.toString());
}else{
throw new ExceptionRServeUnixFailure("Couldn't start RServ Connection!, Connection is null");
}
}catch(SchedulerException se){
throw se;
}catch(Exception e){
sframe.setTasklog(e.getMessage());
throw new ExceptionUnixPeerUnknown("RServeUnixTask: Error:"+e.getMessage());
}finally{
if(temp!=null && temp.exists()){
FileInputStream inputStream = new FileInputStream(temp);
try{
sframe.setConsole_message(IOUtils.toString(inputStream));
}catch(Exception e){
log.error("error while accessing the file, Error:"+e.getMessage());
}finally{
inputStream.close();
}
temp.delete();
}
if(c!=null){
//sink ending here....
c.eval("sink(type = \"message\")");
c.eval("sink()");
c.eval("close(.console_msg_zz)");
closeRconnection(rs);
}
//Runtime.getRuntime().gc();
}
try{ Thread.sleep(200); }catch(Exception e){} //200 milliseconds to remove the resource completely from memory
log.debug(" end of execute() script :"+name);
}catch(Exception e){
//ClientErrorMgmt.reportError(e,null);
throw e;
}
}
}
}
@@ -0,0 +1,171 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jfree.util.Log;
import org.quartz.JobExecutionException;
import com.fourelementscapital.db.BBSyncDB;
import com.fourelementscapital.db.vo.FlexiField;
import com.fourelementscapital.scheduler.exception.ExceptionWarningNoFullData;
import com.fourelementscapital.scheduler.pluggin.SchedulerBloombergPlugin;
public class BloombergDownload extends ScheduledTask {
Logger log = LogManager.getLogger(BloombergDownload.class.getName());
public BloombergDownload(String name, String taskuid) {
//super("Bloomberg Download","bb_download");
super(name,taskuid);
try{
addFormFields(getMyFields());
}catch(Exception e){
e.printStackTrace();
}
}
public synchronized void execute(StackFrame sframe) throws JobExecutionException,ExceptionWarningNoFullData,Exception {
Map data=sframe.getData();
if(data.get("download_id")==null || (data.get("download_id")!=null && ((String)data.get("download_id")).equals("")) ) {
throw new JobExecutionException("Job can't be executed as you did not not select download query");
}else{
try{
String id=(String)data.get("download_id");
String id1=data.get("id").toString();
log.debug("sc_id:"+id1+":before opening database ...");
String rlsdt_adjustment=(String)data.get("rlsdt_adjustment");
BBSyncDB syncdb=BBSyncDB.getBBSyncDB();
log.debug("sc_id:"+id1+":syncdb init");
syncdb.connectDB();
if(true){
//BoneCP bcp=syncdb.getConnectionPool();
//log.debug("sc_id:"+id1+"----------------------------------------");
//if(bcp!=null){
//log.debug("sc_id:"+id1+":syncdb CP Free connection :"+bcp.getStatistics().getTotalFree());
//log.debug("sc_id:"+id1+":syncdb CP Leased connection :"+bcp.getStatistics().getTotalLeased());
//log.debug("sc_id:"+id1+":syncdb CP Total Created connection :"+bcp.getStatistics().getTotalCreatedConnections());
//log.debug("sc_id:"+id1+":syncdb CP Cache Hits :"+bcp.getStatistics().getCacheHits());
//log.debug("sc_id:"+id1+":syncdb CP Cache miss:"+bcp.getStatistics().getCacheMiss());
//}
}
log.debug("sc_id:"+id1+":connected");
Map data1=syncdb.getDownloadQuery(Integer.parseInt(id));
log.debug("sc_id:"+id1+":after getDownloadQuery called");
if(rlsdt_adjustment!=null && !rlsdt_adjustment.equals("")){
try{
int dadj=Integer.parseInt(rlsdt_adjustment);
data1.put("enddt_adjustment",new Integer(dadj));
}catch(Exception e){
//ClientErrorMgmt.reportError(e, "Error while parsing release date adjument to Integer");
throw e;
}
}
if(data1!=null){
log.debug("sc_id:"+id+":after before bloombergDownloadJob init");
BloombergDownloadJob bjdo= new BloombergDownloadJob();
bjdo.setInvokedByScheduler();
try{
bjdo.downloadData(data1,sframe);
log.debug("sc_id:"+id1+":after before downloadData called");
}catch(ExceptionWarningNoFullData wnd){
throw wnd;
}catch(Exception e1){
throw new JobExecutionException(e1);
}finally{
sframe.setTasklog(bjdo.getSchedulerLog());
if(bjdo.getSchedulerLog()!=null && !bjdo.getSchedulerLog().equals("")){
sframe.setStatus(ScheduledTask.EXCECUTION_WARNING);
}
}
}else{
throw new JobExecutionException("Job can't be executed, relevant download query not found (you may have deleted)");
}
syncdb.closeDB();
}catch(ExceptionWarningNoFullData wnd1){
throw wnd1;
}catch(Exception e){
//ClientErrorMgmt.reportError(e, "id:"+id);
throw new JobExecutionException(e);
}
}
}
public List<ScheduledTaskField> listFormFields(){
super.removeAllFields();
try{
super.addFormFields(getMyFields());
}catch(Exception e){
Log.error("Error in refreshing fields");
}
return super.listFormFields();
}
private Vector<ScheduledTaskField> getMyFields() throws Exception {
Vector fields=new Vector();
ScheduledTaskField f3=new ScheduledTaskField();
f3.setShortname("rlsdt_adjustment");
f3.setFieldlabel("Release Date Adjustment");
f3.setFieldtype(FlexiField.TYPE_TEXTBOX);
fields.add(f3);
ScheduledTaskField f1=new ScheduledTaskField();
f1.setShortname(SchedulerBloombergPlugin.PLUGGIN_IN);
f1.setFieldlabel("Bloomberg Query");
f1.setFieldtype(FlexiField.TYPE_BLOOMBERG_PLUGGIN);
f1.setPluggindata(new SchedulerBloombergPlugin().getPlugginData());
fields.add(f1);
ScheduledTaskField f2=new ScheduledTaskField();
f2.setShortname(new SchedulerBloombergPlugin().getPlugginData().getFieldreference());
f2.setFieldlabel("download_id");
f2.setFieldtype(FlexiField.TYPE_HIDDENFIED);
fields.add(f2);
return fields;
}
}
@@ -0,0 +1,487 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.io.File;
import java.io.FileWriter;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.TreeMap;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import com.fourelementscapital.db.BBSyncDB;
import com.fourelementscapital.db.InfrastructureDB;
import com.fourelementscapital.fileutils.SplitString;
import com.fourelementscapital.scheduler.config.Config;
import com.fourelementscapital.scheduler.exception.ExceptionWarningNoFullData;
public class BloombergDownloadJob implements Job {
private Logger log = LogManager.getLogger(BloombergDownloadJob.class.getName());
public static String BB_DOWNLOAD_GROUP="BB_DOWNLOAD_GROUP";
private Vector<String> uniqueContracts=new Vector<String>();
private boolean invokedByUser=true;
private String schedulerLog=null;
public void execute(JobExecutionContext context) throws JobExecutionException {
this.invokedByUser=false;
Map data=(Map)context.getJobDetail().getJobDataMap().get("data");
//log.debug("triggered data:"+data);
int id=(Integer)data.get("id");
String name=(String)data.get("name");
Date started=new Date();
try{
//downloadData(data);
}catch(Exception e){
//logging
//externalLog(id,name,started,new Date(), null,null,0,false);
//ClientErrorMgmt.reportError(e, "error while synchronizing download id:"+data.get("id")+" name:"+data.get("name"));
throw e;
}
}
public void setInvokedByScheduler(){
this.invokedByUser=false;
}
/**
* @deprecated
* @param bb_syncid
* @throws Exception
*/
public void rescheduleJobs(long bb_syncid) throws Exception {
}
private String checkCommoditySpecified(String contract, Map scommodities,HashMap<String,String> mc) {
String commodity=null;
//parses data rediction tickers (For Example: CLZ9->CLZ99 ) download CLZ9 ticker and keep it in both CLZ9 and CLZ99
Pattern pattern = Pattern.compile("^(.*?)->(.*?)$");
Matcher matcher = pattern.matcher(contract);
if (matcher.find()) {
contract = matcher.group(1);
String copy=matcher.group(2);
if(copy!=null){
//StringTokenizer st=new StringTokenizer(copy,",");
//while(st.hasMoreTokens()) list.add(st.nextToken());
String cont=contract;
if(cont.indexOf("{")>=0 && cont.indexOf("}")>0){
String comm=cont.substring(cont.indexOf("{")+1,cont.indexOf("}"));
cont=cont.replaceAll("\\{"+comm+"\\}", "");
}
mc.put(cont, copy);
}
}
if(contract.indexOf("{")>=0 && contract.indexOf("}")>0){
commodity=contract.substring(contract.indexOf("{")+1,contract.indexOf("}"));
contract=contract.replaceAll("\\{"+commodity+"\\}", "");
scommodities.put(contract, commodity);
}
return contract;
}
private ArrayList<ArrayList<String>> splitTickers(ArrayList<String> tickers, int each) {
ArrayList<ArrayList<String>> all=new ArrayList<ArrayList<String>>();
if(tickers.size()>each) {
all.add(new ArrayList<String>());
for(String tick:tickers){
if((all.get(all.size()-1).size()>each)){
all.add(new ArrayList<String>());
}
all.get(all.size()-1).add(tick);
}
}else{
all.add(tickers);
}
return all;
/*
for(ArrayList<String> t1:all){
System.out.print("\n----------------");
for(String tick:t1){
System.out.print(tick +",");
}
}
*/
}
public synchronized void downloadData(Map m,StackFrame sframe) throws Exception {
int scheduler_id=((Number)sframe.getData().get("id")).intValue();
long trigger_time=sframe.getTrigger_time();
java.sql.Timestamp startedat=new java.sql.Timestamp(new Date().getTime());
TreeMap fields=new TreeMap();
processDate(m);
String date_from=(String)m.get("date_from");
String date_to=(String)m.get("date_to");
String marketsector=(String)m.get("marketsector");
String commString=(String)m.get("tickers");
ArrayList<String> tickers=new ArrayList<String>();
List tickers1=SplitString.split(commString);
HashMap scommodities=new HashMap ();
HashMap<String,String> multiplecopy=new HashMap<String,String>();
for(Iterator<String>i = tickers1.iterator();i.hasNext();){
String contractraw=i.next();
tickers.add(checkCommoditySpecified(contractraw,scommodities,multiplecopy));
}
BBSyncDB syncdb=BBSyncDB.getBBSyncDB();
syncdb.connectDB();
int id=(Integer)m.get("id");
ArrayList fmap=syncdb.fieldMapping4BBSync(id);
for(int i=0;i<fmap.size();i++){
Map rdata=(Map)fmap.get(i);
fields.put(rdata.get("bb_field"),rdata.get("db_field"));
}
syncdb.closeDB();
log.debug("date_from:"+date_from);
log.debug("date_to:"+date_to);
log.debug("market sector:"+marketsector);
log.debug("fields:"+fields.keySet()); //Bloomberg field names i.e "PX_CLOSE"
log.debug("db fields:"+fields.values()); //friendly field names i.e "Close Price"
log.debug("tickers:"+tickers);
boolean is_market_sec=false;
if(m.get("is_mkt_securitydb")!=null && ((String)m.get("is_mkt_securitydb")).toLowerCase().equals("true")){
is_market_sec=true;
}
ArrayList bb_fields=new ArrayList(fields.keySet());
if(date_from!=null && date_to!=null && marketsector!=null && bb_fields.size()>0 && tickers.size()>0){
ArrayList<ArrayList<String>> all=splitTickers(tickers,100);
for(ArrayList<String> batch:all){
//TreeMap data=new ConnectBloomberg(tickers,date_from,date_to,bb_fields,marketsector,new MigrationMgmt(),true).getMultipleData();
//processBBData(null,data,is_market_sec,fields,tickers,scommodities,multiplecopy); //original
//processBBData(marketsector,data,is_market_sec,fields,tickers,scommodities,multiplecopy); //cloned copy of market sector for example CL_Commdty_CLOSE_Price
new SchedulerExePlanLogs(scheduler_id,trigger_time).log("# of tickers in this request:"+batch.size(),SchedulerExePlanLogs.PEER_OK_BLOOMBERG_DOWNLOAD);
//TreeMap data=new ConnectBloomberg(batch,date_from,date_to,bb_fields,marketsector,new MigrationMgmt(),true).getMultipleData();
//processBBData(null,data,is_market_sec,fields,batch,scommodities,multiplecopy); //original
//processBBData(marketsector,data,is_market_sec,fields,batch,scommodities,multiplecopy); //cloned copy of market sector for example CL_Commdty_CLOSE_Price
}
}
//UPDATE CONTRACT LOGS.
log.debug("unique contracts:"+uniqueContracts);
syncdb.closeDB();
BBSyncDB syncdb1=BBSyncDB.getBBSyncDB();
syncdb1.connectDB();
if(uniqueContracts.size()>0 && !is_market_sec){
java.sql.Timestamp lastsync=new java.sql.Timestamp(new Date().getTime());
syncdb1.updateContractLogs(uniqueContracts,marketsector,lastsync,scommodities,fields.values());
}else if(uniqueContracts.size()>0 && is_market_sec){
java.sql.Timestamp lastsync=new java.sql.Timestamp(new Date().getTime());
syncdb1.updateSecuritiesLogs(uniqueContracts,marketsector, lastsync,fields.values());
}
//update bloomberg counter;
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
sdf.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));
String japan_time=sdf.format(new Date());
int count=uniqueContracts.size()* fields.keySet().size();
InfrastructureDB infrastructureDB = InfrastructureDB.getInfrastructureDB();
infrastructureDB.connectDB();
if(count>0){
infrastructureDB.updateBloomberDailyCounter(japan_time, count);
}
infrastructureDB.closeDB();
//log.debug("job "+name+" excecuted");
log.debug("after updated unique tickers on ref database");
java.sql.Timestamp endedat=new java.sql.Timestamp(new Date().getTime());
syncdb1.updateTriggeredDate(id, startedat, endedat);
Date st=(Date)m.get("date_from_date");
Date end=(Date)m.get("date_to_date");
String name=(String)m.get("name");
log.debug("writting external log");
externalLog(id,name,startedat,endedat,st,end,uniqueContracts.size(),true,syncdb1);
syncdb1.closeDB();
schedulerLog="";
log.debug("writting scheduler logs");
schedulerLog=schedulerLog+"Date Between "+new SimpleDateFormat("dd-MMM-yy").format(st)+" and "+new SimpleDateFormat("dd-MMM-yy").format(end);
schedulerLog=schedulerLog+"\nNo of Tickers Requested:"+tickers.size();
schedulerLog=schedulerLog+"\nNo of Tickers Responded:"+uniqueContracts.size();
String missingtick=null;
for(Iterator it=tickers.iterator();it.hasNext();){
String tick=(String)it.next();
if(tick!=null && !tick.equals("") && uniqueContracts.indexOf(tick)<0){
missingtick=(missingtick==null)?tick:missingtick+"\n"+tick;
}
}
if(missingtick!=null){
schedulerLog=schedulerLog+"\nNo data found for the following tickers:\n"+missingtick;
throw new ExceptionWarningNoFullData("No data found for some tickers ");
}else{
schedulerLog=null;
}
log.debug("--------------end of downloadData() -----------------------");
}
public String getSchedulerLog(){
return this.schedulerLog;
}
private void processDate(Map m){
String date_option=(String)m.get("date_option");
int date_recentnumber=(Integer)m.get("date_recentnumber");
Date date_from=null;
Date date_to=null;
try{
if(m.get("date_from") instanceof Date){
date_from=(Date)m.get("date_from");
}else{
log.error("date_from is not date instance");
}
if(m.get("date_to") instanceof Date){
date_to=(Date)m.get("date_to");
}else{
log.error("date_to is not date instance");
}
}catch(Exception e){
//ClientErrorMgmt.reportError(e, "Error while parsing date, download ID:"+m.get("id"));
throw e;
}
if(date_option.toLowerCase().equals("daterange")){
}else if(date_option.toLowerCase().equals("datefrom")){
date_to=new Date();
}else{
date_to=new Date();
date_from=null;
Calendar today=Calendar.getInstance();
today.setTime(date_to);
boolean processed=false;
if(date_option.toLowerCase().equals("ndays")){
today.add(Calendar.DAY_OF_YEAR, -(date_recentnumber-1));
processed=true;
}else if(date_option.toLowerCase().equals("nweeks")){
today.add(Calendar.WEEK_OF_YEAR, -date_recentnumber );
processed=true;
}else if(date_option.toLowerCase().equals("nmonths")){
today.add(Calendar.MONTH, -date_recentnumber );
processed=true;
}else if(date_option.toLowerCase().equals("nyears")){
today.add(Calendar.YEAR, -date_recentnumber );
processed=true;
}
if(processed){
date_from=today.getTime();
}
}
if(date_from!=null){
m.put("date_from",new SimpleDateFormat("yyyyMMdd").format((Date)date_from));
m.put("date_from_date",date_from);
}
if(date_to!=null){
if(m.get("enddt_adjustment")!=null){
Integer dadj=(Integer)m.get("enddt_adjustment");
Calendar dt=Calendar.getInstance();
dt.setTime(date_to);
dt.add(Calendar.DAY_OF_YEAR, dadj);
m.put("date_to",new SimpleDateFormat("yyyyMMdd").format(dt.getTime()));
m.put("date_to_date",dt.getTime());
}else{
m.put("date_to",new SimpleDateFormat("yyyyMMdd").format((Date)date_to));
m.put("date_to_date",date_to);
}
}
}
private void externalLog(int id,String name,Date started, Date ended,Date period_from,Date period_to,long num_contracts, boolean flag ,BBSyncDB syncdb){
boolean SUCCESS=true;
boolean FAILED=false;
//String filename=new File(job.getConfolder()).getParent()+File.separator+"scheduler.log";
//File file=new File(filename);
String root=Config.getString("log_error_folder");
Date d = new Date();
String folder =root+"bloomberg_sync";
if (!new File(folder).isDirectory()) {
new File(folder).mkdirs();
}
String fname=root+"bloomberg_sync"+File.separator+""+new SimpleDateFormat("dd_MM_yyyy").format(d)+".csv";
File file=new File(fname);
if (!file.exists()) {
try {
//file.createNewFile();
FileWriter fw1 = new FileWriter(file,true);
fw1.append("Date, Time, Duration(mins), Period, # of Tickers, Manual/Scheduler, Status, ID, Download Name \r\n");
fw1.flush();
fw1.close();
}catch(Exception e){
log.error("error while creating file: Error:"+e.getMessage());
}
}
try {
boolean append = true;
FileWriter fw = new FileWriter(file,append);
//String timeformat="dd-MMM hh:mm:ss aaa ";
SimpleDateFormat timeformat=new SimpleDateFormat("h:mm a");
SimpleDateFormat durationformat =new SimpleDateFormat("mm:ss");
durationformat.setTimeZone(TimeZone.getTimeZone("GMT"));
SimpleDateFormat dateformat=new SimpleDateFormat("dd MMM-yy");
String logmessage="";
logmessage+=dateformat.format(started)+",";
logmessage+=timeformat.format(started)+",";
long diff=ended.getTime()-started.getTime();
logmessage+=durationformat.format(new Date(diff))+",";
long mills_per_day = 1000 * 60 * 60 * 24;
long day_diff = ( period_to.getTime() - period_from.getTime() ) / mills_per_day;
logmessage+=(Math.round(day_diff)+1)+" days from "+dateformat.format(period_from)+",";
logmessage+=num_contracts+",";
logmessage+=(this.invokedByUser?"Manual":"Scheduler")+",";
logmessage+=( flag==SUCCESS?"Success":"Failed")+",";
logmessage+=id+",";
logmessage+=name+",";
/*
logmessage+="ID:"+id;
logmessage+="\tDownload Name:"+name;
logmessage+="\tStarted At:"+new SimpleDateFormat(format).format(started);
if(flag==SUCCESS){
logmessage+="\tEnded At:"+new SimpleDateFormat(format).format(ended);
logmessage+="\tStatus:Success";
}else{
logmessage+="\tStatus:Failed";
}
if(period_from!=null && period_to!=null){
logmessage+="\t Date Between("+sf.format(period_from)+" AND "+sf.format(period_to)+")";
}
*/
fw.append(logmessage+"\r\n");
fw.flush();
fw.close();
//add to database.
//BBSyncDB syncdb=BBSyncDB.getBBSyncDB();
//syncdb.connectDB();
syncdb.addSyncLogs(id, new Timestamp(started.getTime()), new Timestamp(ended.getTime()), null, ((flag)?"Success":"Failed"),(this.invokedByUser?"M":"S"));
//syncdb.closeDB();
//syncdb.closeDB();
}
catch (Exception ex) {
log.error("Error:"+ex.getMessage());
//ClientErrorMgmt.reportError(ex,"Error in external log file writing");
ex.printStackTrace();
}
}
}
@@ -0,0 +1,261 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.quartz.JobExecutionException;
import org.rosuda.REngine.REXP;
import org.rosuda.REngine.RList;
import org.rosuda.REngine.Rserve.RConnection;
import com.fourelementscapital.scheduler.config.Config;
import com.fourelementscapital.scheduler.exception.ExceptionRServeUnixFailure;
import com.fourelementscapital.scheduler.p2p.P2PService;
import com.fourelementscapital.scheduler.rserve.RServeConnectionPool;
import com.fourelementscapital.scheduler.rserve.RServeSession;
//import com.fourelementscapital.client.ClientErrorMgmt;
public abstract class ExecuteRUnix extends ScheduledTask {
private Logger log = LogManager.getLogger(ExecuteRUnix.class.getName());
private StackFrame stackframe=null;
public ExecuteRUnix(String name,String taskuid ) {
super(name,taskuid);
}
public void execute(StackFrame sframe) throws JobExecutionException,Exception {
this.stackframe=sframe;
Map<String, Object> data=sframe.getData();
if(sframe.getRscript()==null) throw new JobExecutionException("Script failed as StackFrame doesn't containt RScript object");
String rscript=sframe.getRscript().getScript();
if(rscript==null) { throw new JobExecutionException("Task Failed because no R script found or empty"); }
log.debug("R Engine initiated.");
if(rscript!=null && !rscript.equals("")){
try{
//System.out.println(" RServeLowPriorityTask.execute(): executed 11");
String line;
log.debug("R init source file initiated.");
//BufferedReader reader = new BufferedReader(new StringReader(rscript));
String tempDir = System.getProperty("java.io.tmpdir");
log.debug("set temporary directory:"+tempDir);
File file=new File(tempDir+File.separator+"rscript"+new SimpleDateFormat("mmddyyy_hh_mmss_").format(new Date())+new Random().nextInt()+".R");
BufferedWriter out = new BufferedWriter(new FileWriter(file));
//adding Rinit.r file on top of the script...
BufferedReader reader1 = new BufferedReader(new FileReader(Config.getString("r_script_init")));
StringBuffer sb=new StringBuffer();
String line1;
while ((line1 = reader1.readLine()) != null) {
if(line1!=null && !line1.equals("")){
//out.write(line1+"\n");
sb.append(line1+"\n");
}
}
reader1.close();
log.debug("R init source file initiated.");
String filepath=file.getPath().replaceAll("\\\\", "\\\\\\\\");
RConnection c=null;
RServeSession rs=null;
try{
log.debug("before opening session----<");
log.debug("rs:"+rs);
rs=getRServeSession(sframe.getRscript().getUid(),sb.toString());
if(rs!=null && rs.getRconnection()!=null ){
c=rs.getRconnection();
log.debug("c:"+c.isConnected());
REXP sid1=c.eval(".r_session_id");
if(sid1!=null){
String sess_id=sid1.asString();
log.debug(".r_session_id:"+sess_id);
}
c.assign(".machine", P2PService.getComputerName());
log.debug("rscript:"+rscript);
REXP x1= c.parseAndEval(rscript);
String result=parse(x1);
sframe.getRscript().setResultXML(result);
log.debug("Script from temp file Evaluated");
log.debug("x1:"+x1);
if (x1!=null && x1.inherits("try-error")) {
throw new Exception("Error in R Script: "+x1.asString());
}
if(x1==null) {
throw new Exception("R script:"+data.get("name")+" failed");
}else{
sframe.setTasklog(null);
}
}
file.delete();
}catch(Exception e){
sframe.setTasklog(e.getMessage());
sframe.getRscript().setError(e.getMessage());
throw new Exception ("Error:"+e.getMessage());
//throw e;
}finally{
if(c!=null){
//ConnectionPool.done(c.detach());
closeRconnection(rs);
//c.close();
//c.shutdown();
}
Runtime.getRuntime().gc();
}
//try{ Thread.sleep(5); }catch(Exception e){} //200 milliseconds to remove the resource completely from memory
}catch(Exception e){
//e.printStackTrace();
//ClientErrorMgmt.reportError(e,null);
throw e;
}
}
}
/**
*
* @param rxps
* @return
* @throws Exception
*/
private String parse(REXP rxp) throws Exception {
String rtn="";
if(rxp.isNumeric()){
rtn+="<double>"+rxp.asDouble()+"</double>";
}
if(rxp.isInteger()){
rtn+="<integer>"+rxp.asInteger()+"</integer>";
}
if(rxp.isList()){
RList ar=rxp.asList();
rtn+="<array>";
for(Iterator i=ar.iterator();i.hasNext();){
Object obj=i.next();
if(obj instanceof REXP){
if(rxp.isNumeric()) rtn+="<double>"+((REXP)obj).asDouble()+"</double>";
if(rxp.isString()) rtn+="<string>"+((REXP)obj).asString()+"</string>";
if(rxp.isString()) rtn+="<integer>"+((REXP)obj).asInteger()+"</integer>";
}
}
rtn+="</array>";
}
if(rxp.isString()){
rtn+="<string>"+rxp.asString()+"</string>";
}
//if(rxp.getType()==REXP.XT_STR || rxp.getType()==REXP.XT_VECTOR || rxp.getType()==REXP.XT_DOUBLE || rxp.getType()==REXP.XT_ARRAY_DOUBLE){}
//else log.debug("rxp.getType():"+rxp.getType());
return rtn;
}
public RServeSession getRServeSession(String script_uid, String startup_rinit) throws Exception {
RServeSession rs=null;
RConnection c=null;
try{
rs=RServeConnectionPool.getRSession(startup_rinit);
}catch(Exception e){
throw new ExceptionRServeUnixFailure("Not able to get RSession from ConnectionPool!, Error:"+e.getMessage());
}
try{
log.debug("+++++++attaches Rconnection from RServeSession....+++");
c=(rs.getRconnection()!=null) ? rs.getRconnection(): rs.getRsession().attach();
rs.setRconnection(c);
}catch(Exception e){
throw new ExceptionRServeUnixFailure("Not able to attach connection to RSession!, Error:"+e.getMessage());
}
if(c!=null){
log.debug("c:"+c.isConnected());
rs.setRunning(true);
rs.setExecute_r_uid(script_uid);
rs.setStarted_time(new Date().getTime());
rs.setThread(Thread.currentThread());
}
return rs;
}
private void closeRconnection(RServeSession rs) throws Exception {
try{
rs.finished(rs.getRconnection());
RServeConnectionPool.done(rs);
}catch(Exception e){
if(rs.getKillmessage()!=null){
throw new ExceptionRServeUnixFailure(rs.getKillmessage());
}else{
throw new ExceptionRServeUnixFailure("Not able to detach RSession!, Error:"+e.getMessage());
}
}
}
}
@@ -0,0 +1,170 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.StringReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.quartz.JobExecutionException;
import org.rosuda.JRI.REXP;
import com.fourelementscapital.scheduler.config.Config;
import com.fourelementscapital.scheduler.exception.ExceptionPeerUnknown;
import com.fourelementscapital.scheduler.exception.ExceptionRscriptError;
import com.fourelementscapital.scheduler.exception.SchedulerException;
import com.fourelementscapital.scheduler.p2p.P2PService;
public abstract class ExecuteRWindows extends ScheduledTask {
public ExecuteRWindows(String name,String taskuid ) {
//super("Medium Priority (RServe)","rscript4rserve");
super(name,taskuid);
}
private Logger log = LogManager.getLogger(ExecuteRWindows.class.getName());
protected static MyRengine re=null;
public synchronized void execute(StackFrame sframe) throws JobExecutionException,Exception {
log.debug("execute() called");
if(Config.getString("p2p.ignorejri")!=null && Config.getString("p2p.ignorejri").equalsIgnoreCase("true")){
throw new Exception("JRI is not enalbed");
}
String rscript=sframe.getRscript().getScript();
if(rscript==null) { throw new JobExecutionException("Task Failed because no R script found or empty"); }
MyRengineCallbacks myrenging=new MyRengineCallbacks(); //new MyRengineCallbacks();
if(re==null){
log.debug("Rengine is null, creating one.......");
re=new MyRengine(null, false, myrenging );
re.setStackFrame(sframe);
//for the first time it loads Rinit;
BufferedReader reader1 = new BufferedReader(new FileReader(Config.getString("r_script_init")));
String line;
while ((line = reader1.readLine()) != null) {
if(line!=null && !line.equals("")){
REXP x=re.eval(line);
}
}
reader1.close();
}else{
re.setStackFrame(sframe);
//re.addMainLoopCallbacks(myrenging);
}
re.getRMailLoopCallback().setConsoleOutput(null);
if(rscript!=null && !rscript.equals("")){
try{
re.assign(".machine", P2PService.getComputerName());
sframe.setStarted_time(new Date().getTime());
log.debug("before executing script....");
BufferedReader reader = new BufferedReader(new StringReader(rscript));
StringBuffer sb=new StringBuffer();
String tempDir = System.getProperty("java.io.tmpdir");
File file=new File(tempDir+File.separator+"rscript"+new SimpleDateFormat("mmddyyy_hh_mmss_").format(new Date())+new Random().nextInt()+".R");
String line;
BufferedWriter out = new BufferedWriter(new FileWriter(file));
while ((line = reader.readLine()) != null) {
if(line!=null && !line.equals("")){
out.write(line+"\n");
}
}
out.close();
reader.close();
String filepath=file.getPath().replaceAll("\\\\", "\\\\\\\\");
log.debug("file:"+file.getPath()+" re:"+re);
REXP x1= re.eval("source(\""+filepath+"\")");
sframe.getRscript().setResult(x1);
log.debug("x1:"+x1);
file.delete();
if(x1==null) {
//sframe.setTasklog("R Script failed. See log file for more info");
REXP x3= re.eval("as.character(.Traceback)");
if(x3.rtype==REXP.STRSXP){
String a[]=x3.asStringArray();
String err="\n----Error stack----";
if(a.length>=2){
for(int i=a.length-2;i>=0;i--){
if(!a[i].startsWith("eval.with.vis")){
String ind="\n-";
ind+=">"+a[i];
err+=ind;
}
}
}
myrenging.externalLog(re, err);
String all_err="";
if(sframe.getTasklog()!=null){
all_err=err+"\n"+sframe.getTasklog();
}else{
all_err=err;
}
throw new ExceptionRscriptError("R Script Error:"+all_err);
}else{
throw new ExceptionRscriptError("R script:"+rscript+" failed, "+sframe.getTasklog());
}
}else{
//sframe.setTasklog(x1.toString());
//executed successfully so don't store log messages
sframe.setTasklog(null);
re.setStackFrame(null);
}
}catch(SchedulerException se){
throw se;
}catch(Exception e){
throw new ExceptionPeerUnknown("REngineScriptTask: Error:"+e.getMessage());
}
}
//setMessages(myrenging.logMessages());
log.debug("~~~~~~~~~~~R Script finishing execution...");
}
}
@@ -0,0 +1,50 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.rosuda.JRI.RMainLoopCallbacks;
import org.rosuda.JRI.Rengine;
public class MyRengine extends Rengine{
private StackFrame sframe=null;
Logger log = LogManager.getLogger(MyRengine.class.getName());
private RMainLoopCallbacks mlc=null;
public MyRengine(String[] args, boolean runMainLoop, RMainLoopCallbacks initialCallbacks){
super(args,runMainLoop,initialCallbacks);
this.mlc=initialCallbacks;
}
public void setStackFrame(StackFrame sframe){
log.debug("setting stack frame:"+sframe);
this.sframe=sframe;
}
public StackFrame getStackFrame(){
return this.sframe;
}
public MyRengineCallbacks getRMailLoopCallback(){
return (MyRengineCallbacks)this.mlc;
}
public void jriWriteConsole(String text, String text1){
log.debug("jriWriteConsole"+text+" text2:"+text1);
}
public void jriShowMessage(String message){
log.debug("jriShowMessage"+message);
}
}
@@ -0,0 +1,212 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.awt.FileDialog;
import java.awt.Frame;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.rosuda.JRI.RMainLoopCallbacks;
import org.rosuda.JRI.Rengine;
import com.fourelementscapital.scheduler.config.Config;
import com.fourelementscapital.scheduler.rscript.RScript;
public class MyRengineCallbacks implements RMainLoopCallbacks {
private Logger log = LogManager.getLogger(MyRengineCallbacks.class.getName());
//private Vector errorMessages=new Vector();
private File outputConsole=null;
private String logmessages=null;
public String logMessages() {
return this.logmessages;
}
public void setConsoleOutput(File file) {
this.outputConsole=file;
}
public void rWriteConsole(Rengine re, String text, int oType) {
if(this.outputConsole!=null ){
try{
FileWriter fstream = new FileWriter(this.outputConsole,true);
BufferedWriter out = new BufferedWriter(fstream);
out.write(text);
out.close();
}catch(Exception e) {log.error("error:"+e.getMessage());}
// log.debug("$$$$$$$$$$ log file folder not exist, folder:"+con_out);
//}
}
if(oType==1){
log.debug("rWriteConsole():");
externalLog((MyRengine)re,text);
}
}
public void rBusy(Rengine re, int which) {
// System.out.println("MyRengine.rBusy("+which+")");
}
public String rReadConsole(Rengine re, String prompt, int addToHistory) {
// System.out.print("prompt:"+prompt);
try {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s=br.readLine();
log.debug("rReadConsole():s");
return (s==null||s.length()==0)?s:s+"\n";
} catch (Exception e) {
System.out.println("jriReadConsole exception: "+e.getMessage());
}
return null;
}
public void rShowMessage(Rengine re, String message) {
log.debug("rShowMessage():message:");
//System.out.println("MyRengine.rShowMessage \""+message+"\"");
//log.debug("Renginge instanceof:"+(re instanceof MyRengine)+" obj:"+((MyRengine)re).getStackFrame().getData());
externalLog((MyRengine)re,message);
}
//public Vector getErrorMessages(){
// return this.errorMessages;
//}
public String rChooseFile(Rengine re, int newFile) {
FileDialog fd = new FileDialog(new Frame(), (newFile==0)?"Select a file":"Select a new file", (newFile==0)?FileDialog.LOAD:FileDialog.SAVE);
fd.show();
String res=null;
if (fd.getDirectory()!=null) res=fd.getDirectory();
if (fd.getFile()!=null) res=(res==null)?fd.getFile():(res+fd.getFile());
return res;
}
public void rFlushConsole (Rengine re) {
}
public void rLoadHistory (Rengine re, String filename) {
}
public void rSaveHistory (Rengine re, String filename) {
}
public void externalLog(MyRengine mre, String message ){
if(mre.getStackFrame()!=null && mre.getStackFrame().getRscript()!=null){
RScript rs=mre.getStackFrame().getRscript();
if(rs.getError()==null){
rs.setError(message);
}else{
rs.setError(rs.getError()+"\n"+message);
}
}else{
externalLog1(mre,message);
}
}
public void externalLog1(MyRengine mre, String message ){
this.logmessages=(this.logmessages==null)?message:this.logmessages+"\n"+message;
log.debug("mre.getStackFrame():"+mre.getStackFrame());
if(mre.getStackFrame()!=null){
if(mre.getStackFrame().getTasklog()==null) {
mre.getStackFrame().setTasklog(message);
}else{
mre.getStackFrame().setTasklog(mre.getStackFrame().getTasklog()+" "+message);
}
}
//log.debug("setting log message on sframe:"+message);
//log.debug("setting log message on sframe11:"+mre.getStackFrame().getTasklog());
String root=Config.getString("log_error_folder");
Date d = new Date();
String folder =root+"r_scripts";
if (!new File(folder).isDirectory()) {
new File(folder).mkdirs();
}
String fname=root+"r_scripts"+File.separator+""+new SimpleDateFormat("dd_MM_yyyy").format(d)+".txt";
File file=new File(fname);
if (!file.exists()) {
try {
//file.createNewFile();
FileWriter fw1 = new FileWriter(file,true);
//fw1.append("Date, Time, Error Message\r\n");
fw1.flush();
fw1.close();
}catch(Exception e){
//log.error("error while creating file: Error:"+e.getMessage());
}
}
try {
boolean append = true;
FileWriter fw = new FileWriter(file,append);
//String timeformat="dd-MMM hh:mm:ss aaa ";
SimpleDateFormat timeformat=new SimpleDateFormat("h:mm a");
SimpleDateFormat dateformat=new SimpleDateFormat("dd MMM-yy");
String logmessage="";
logmessage+="Date:"+dateformat.format(new Date())+" Time:"+timeformat.format(new Date())+":";
//logmessage+="Error/Warning:"+message+"\n";
logmessage+=""+message+"\n";
fw.append(logmessage+"\r\n");
fw.flush();
fw.close();
}
catch (Exception ex) {
//log.error("Error:"+ex.getMessage());
//ClientErrorMgmt.reportError(ex,"Error in external log file writing");
ex.printStackTrace();
}
}
}
@@ -0,0 +1,321 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.StringReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Random;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.quartz.JobExecutionException;
import org.rosuda.JRI.REXP;
import com.fourelementscapital.scheduler.config.Config;
import com.fourelementscapital.scheduler.exception.ExceptionPeerUnknown;
import com.fourelementscapital.scheduler.exception.ExceptionRScriptNullError;
import com.fourelementscapital.scheduler.exception.ExceptionRscriptError;
import com.fourelementscapital.scheduler.exception.SchedulerException;
import com.fourelementscapital.scheduler.p2p.P2PService;
public abstract class REngineWindows extends AbstractRScript {
private Logger log = LogManager.getLogger(REngineWindows.class.getName());
private StackFrame stackframe=null;
protected static MyRengine re=null;
private static String rVersion=null;
private static boolean jriCompatible=false;
private static String packageVersions=null;
public REngineWindows(String name,String taskuid ) {
super(name,taskuid);
}
public synchronized void execute(StackFrame sframe) throws JobExecutionException,Exception {
log.debug("RScriptScheduledTask.execute() called");
this.stackframe=sframe;
Map<String, Object> data=sframe.getData();
Number nid=(Number)data.get("id");
String rscript=(String)data.get("rscript");
log.debug("before starting R script log id:"+sframe.getLogid());
log.debug("~~~~~~~~~~R Script started excecuting...");
if(rscript==null) { throw new JobExecutionException("Task Failed because no R script found or empty"); }
MyRengineCallbacks myrenging=new MyRengineCallbacks();
if(re==null){
re=new MyRengine(null, false, myrenging );
re.setStackFrame(sframe);
}else{
re.setStackFrame(sframe);
//re.addMainLoopCallbacks(myrenging);
}
re.getRMailLoopCallback().setConsoleOutput(null);
log.debug("R Engine initiated.");
if(rscript!=null && !rscript.equals("")){
File temp=null;
//bug fix that sink close has been put in finally method/
boolean sinked=false;
try{
BufferedReader reader1 = new BufferedReader(new FileReader(Config.getString("r_script_init")));
String line;
re.assign(".trigger_time", sframe.getTrigger_time()+"");
re.assign(".scheduler_id", nid+"");
re.assign(".machine", P2PService.getComputerName());
re.assign(".enginetype","REngine");
re.assign(".connection_ids","");
while ((line = reader1.readLine()) != null) {
if(line!=null && !line.equals("")){
REXP x=re.eval(line);
}
}
reader1.close();
log.debug("R init source file initiated.");
BufferedReader reader = new BufferedReader(new StringReader(rscript));
StringBuffer sb=new StringBuffer();
String tempDir = System.getProperty("java.io.tmpdir");
File file=new File(tempDir+File.separator+"rscript"+new SimpleDateFormat("mmddyyy_hh_mmss_").format(new Date())+new Random().nextInt()+".R");
BufferedWriter out = new BufferedWriter(new FileWriter(file));
while ((line = reader.readLine()) != null)
{
if(line!=null && !line.equals("")){
//System.out.println("--------->line:"+line);
//REXP x1= re.eval(line);
//System.out.println("Content"+x1.toString());
out.write(line+"\n");
}
}
out.close();
reader.close();
log.debug("R written to temp file :"+file.getPath());
//System.out.println("RScriptScheduledTask.execute() file:"+file.getPath());
String filepath=file.getPath().replaceAll("\\\\", "\\\\\\\\");
//sink staring here....
temp = File.createTempFile(nid.intValue()+"_"+sframe.getTrigger_time(),".log");
String ff=temp.getPath();
if(ff.contains("\\")){
ff=ff.replaceAll("\\\\", "\\\\\\\\");
}
temp.delete();
log.debug("---- deleting ff:"+ff);
String fileass="file(\""+ff+"\", open = \"wt\");";
log.debug("file assign------fileass:"+fileass);
re.eval(".console_msg_zz<-"+fileass);
re.eval("sink(.console_msg_zz)");
re.eval("sink(.console_msg_zz, type = \"message\")") ;
log.debug("----sink----");
sinked=true;
/*
String con_out=Config.getString("r_script_console_logs");
if(con_out!=null && new File(con_out).isDirectory()){
File file1=new File(con_out+nid+"_"+sframe.getTrigger_time()+".log");
re.getRMailLoopCallback().setConsoleOutput(file1);
}
*/
new SchedulerExePlanLogs(nid.intValue(),sframe.getTrigger_time()).log("REngine Script evaluation starting..",SchedulerExePlanLogs.PEER_OK_RENGINE_SCRIPT_EVAL_STARTING);
REXP x1= re.eval("source(\""+filepath+"\")");
try{
REXP genv=null;
REXP x5=re.eval("as.character(.connection_ids)");
log.debug("~~~~~~~~~~~~~~x5:"+x5.rtype);
log.debug("~~~~~~~~~~~~~~x5:asString:"+x5.asStringArray());
String ar[]=x5.asStringArray();
if(ar!=null){
for(int i=0;i<ar.length;i++){
//log.debug("~~~~~~~~~~~ ar["+i+"]:"+ar[i]);
if(ar[i]!=null && !ar[i].equals("")) {
sframe.getDbConnectionIds().add(ar[i]);
}
}
}
}catch(Exception e){
log.error("Error:"+e.getMessage());
}
log.debug("Script from temp file Evaluated");
log.debug("x1:"+x1);
if(!file.delete()){
file.deleteOnExit();
}
if(x1==null) {
//sframe.setTasklog("R Script failed. See log file for more info");
REXP x3= re.eval("as.character(.Traceback)");
if(x3.rtype==REXP.STRSXP){
String a[]=x3.asStringArray();
String err="\n----Error stack----";
if(a.length>=2){
for(int i=a.length-2;i>=0;i--){
if(!a[i].startsWith("eval.with.vis")){
String ind="\n-";
for(int ia=0;ia<i;ia++){
ind+="-";
}
ind+=">"+a[i];
err+=ind;
}
}
}
myrenging.externalLog(re, err);
String all_err="";
if(sframe.getTasklog()!=null){
all_err=err+"\n"+sframe.getTasklog();
}else{
all_err=err;
}
throw new ExceptionRscriptError("R Script Error:"+all_err);
}else{
throw new ExceptionRScriptNullError("R script:"+data.get("name")+" failed");
}
//System.out.println("x3:"+x3);
//System.out.println("x3.rtype:"+x3.rtype);
}else{
//sframe.setTasklog(x1.toString());
//executed successfully so don't store log messages
sframe.setTasklog(null);
re.setStackFrame(null);
}
//sink ending here....
updatePackageVersion();
}catch(SchedulerException se){
throw se;
}catch(Exception e){
//e.printStackTrace();
//ClientErrorMgmt.reportError(e,null);
//sframe.setTasklog("RServe is not running on "+P2PService.getComputerName());
throw new ExceptionPeerUnknown("RserveScheduleedTask: Error:"+e.getMessage());
} finally{
if(sinked && re!=null){
re.eval("sink(type = \"message\")");
re.eval("sink()");
re.eval("close(.console_msg_zz)");
}
if(temp!=null && temp.exists()){
FileInputStream inputStream = new FileInputStream(temp);
try{
sframe.setConsole_message(IOUtils.toString(inputStream));
}catch(Exception e){
log.error("error while accessing the file, Error:"+e.getMessage());
}finally{
inputStream.close();
}
temp.delete();
}
}
}
if(re==null){
re.end();
re=null;
}
//setMessages(myrenging.logMessages());
log.debug("~~~~~~~~~~~R Script finishing execution...");
}
public static void updatePackageVersion(){
//updates R Package version.
if(Config.getString("p2p.ignorejri")!=null && Config.getString("p2p.ignorejri").equalsIgnoreCase("true")){
}else{
if(re==null){
re=new MyRengine(null, false, new MyRengineCallbacks() );
}
//REXP x=re.eval("necessaryRemote <- as.character(read.table(file='//10.153.64.10/Public/Libs/mandatoryPackages.txt')[,1]);");
//REXP x=re.eval("necessaryRemote2 <- as.character(read.table(file='//10.153.64.10/Public/Libs/mandatoryExternalPackages.txt')[,1]);");
REXP x=re.eval("necessaryRemote2 <- c(as.character(read.table(file='//10.153.64.10/Public/Libs/mandatoryExternalPackages.txt')[,1]),as.character(read.table(file='//10.153.64.10/Public/Libs/mandatory4ecapPackages.txt')[,1]))");
x=re.eval("IP = installed.packages(); ");
x=re.eval("paste(as.character(IP[, 'Package'])[as.character(IP[, 'Package']) %in% necessaryRemote2], as.character(IP[, 'Version'])[as.character(IP[, 'Package']) %in% necessaryRemote2], sep=\"=\");");
if(x!=null){
String st1[]=x.asStringArray();
String result="PEER="+P2PService.getComputerName();
for(int i=0;i<st1.length;i++){
result+="|"+st1[i];
}
packageVersions=result;
}
}
}
}
@@ -0,0 +1,115 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.util.Date;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.rosuda.REngine.REXP;
import org.rosuda.REngine.Rserve.RConnection;
import com.fourelementscapital.scheduler.exception.ExceptionRScriptNullError;
import com.fourelementscapital.scheduler.exception.ExceptionRServeUnixFailure;
import com.fourelementscapital.scheduler.exception.ExceptionRscriptError;
import com.fourelementscapital.scheduler.rserve.RServeConnectionPool;
import com.fourelementscapital.scheduler.rserve.RServeSession;
public abstract class RServeUnix extends AbstractRServe {
public RServeUnix(String name, String uid) {
super(name, uid);
}
//private RConnection c=null;
//private RServeSession rs=null;
private Logger log = LogManager.getLogger(RServeUnix.class.getName());
public RServeSession getRServeSession(int nid, String name) throws Exception {
log.debug("before opening session----:script name:"+name);
RServeSession rs=null;
RConnection c=null;
try{
String startup_rinit=null;
rs=RServeConnectionPool.getRSession(startup_rinit);
}catch(Exception e){
throw new ExceptionRServeUnixFailure("Not able to get RSession from ConnectionPool!, Error:"+e.getMessage());
}
try{
log.debug("+++++++attaches Rconnection from RServeSession....+++");
c=(rs.getRconnection()!=null) ? rs.getRconnection(): rs.getRsession().attach();
rs.setRconnection(c);
}catch(Exception e){
throw new ExceptionRServeUnixFailure("Not able to attach connection to RSession!, Error:"+e.getMessage());
}
if(c!=null){
log.debug("c:"+c.isConnected());
rs.setScriptname(name);
rs.setRunning(true);
rs.setScheduler_id(nid);
rs.setTrigger_time(super.stackframe.getTrigger_time());
rs.setStarted_time(new Date().getTime());
rs.setThread(Thread.currentThread());
new SchedulerExePlanLogs(nid,super.stackframe.getTrigger_time()).log("RConnection process id:"+rs.getProcessid()+" Current Hits:"+rs.getNoexecutions(),SchedulerExePlanLogs.PEER_OK_UNIX_RSERVE_CAPTURE_PROCESSINFO);
}
return rs;
}
@Override
public void evalScript(RServeSession rs,String rscript)
throws Exception {
RConnection c=rs.getRconnection();
c.assign(".tmp.",rscript);
log.debug("----script:----");
log.debug(rscript);
log.debug("-----:----");
REXP r = c.parseAndEval("try(eval(parse(text=.tmp.)),silent=TRUE)");
if (r!=null && r.inherits("try-error")) {
log.debug("r.asString:"+r.asString());
String msg=r.asString();
throw new ExceptionRscriptError("Error in R Script: "+msg);
}
if(r==null) {
throw new ExceptionRScriptNullError("Rscript Executed but unknown error message returned by RServe");
}else{
this.stackframe.setTasklog(null);
}
}
@Override
public void closeRconnection(RServeSession rs) throws Exception {
try{
rs.finished(rs.getRconnection());
RServeConnectionPool.done(rs);
log.debug("-------attaches Rconnection from RServeSession....----");
}catch(Exception e){
if(rs.getKillmessage()!=null){
throw new ExceptionRServeUnixFailure(rs.getKillmessage());
}else{
throw new ExceptionRServeUnixFailure("Not able to detach RSession!, Error:"+e.getMessage());
}
}
}
}
@@ -0,0 +1,150 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.StringReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Random;
import java.util.TreeMap;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.rosuda.REngine.REXP;
import org.rosuda.REngine.Rserve.RConnection;
import com.fourelementscapital.scheduler.exception.ExceptionRScriptNullError;
import com.fourelementscapital.scheduler.exception.ExceptionRServeWindowsFailure;
import com.fourelementscapital.scheduler.exception.ExceptionRscriptError;
import com.fourelementscapital.scheduler.rserve.RServeSession;
public abstract class RServeWindows extends AbstractRServe{
//private RConnection c=null;
private Process p=null;
private Logger log = LogManager.getLogger(RServeWindows.class.getName());
public RServeWindows(String name, String uid) {
super(name, uid);
}
public RServeSession getRServeSession(int nid, String name) throws Exception {
RServeSession rs=null;
this.p=Runtime.getRuntime().exec("c:\\rJava\\rserve1.bat");
int count=0;
TreeMap error=new TreeMap();
RConnection c=null;
while(c==null && count<20) {
try{c=new RConnection();}catch(Exception e){
//errorMessage+=""
String msg=e.getMessage();
if(error.keySet().contains(msg)){
int cnt=(Integer)error.get(msg);
cnt++;error.put(msg, cnt);
}else{
error.put(msg, 1);
}
}
try{ Thread.sleep(500); }catch(Exception e){}
count++;
}
if(c==null){
String msg="";
for(Iterator i=error.keySet().iterator();i.hasNext();){
String ky=(String)i.next();
int cnt=(Integer)error.get(ky);
msg+=ky+ ((cnt>1)?"("+cnt+")":"");
}
throw new ExceptionRServeWindowsFailure("Couldn't start RServ Connection! Error MSG:"+msg);
}else{
rs=new RServeSession();
rs.setRconnection(c);
}
return rs;
}
public void evalScript(RServeSession rs,String rscript) throws Exception {
RConnection c=rs.getRconnection();
String tempDir = System.getProperty("java.io.tmpdir");
File file=new File(tempDir+File.separator+"rscript"+new SimpleDateFormat("mmddyyy_hh_mmss_").format(new Date())+new Random().nextInt()+".R");
BufferedWriter out = new BufferedWriter(new FileWriter(file));
BufferedReader reader = new BufferedReader(new StringReader(rscript));
String line;
while ((line = reader.readLine()) != null) {
if(line!=null && !line.equals("")){
//System.out.println("--------->line:"+line);
//REXP x1= re.eval(line);
//System.out.println("Content"+x1.toString());
out.write(line+"\n");
}
}
out.close();
reader.close();
log.debug("R written to temp file :"+file.getPath());
//System.out.println("RScriptScheduledTask.execute() file:"+file.getPath());
String filepath=file.getPath().replaceAll("\\\\", "\\\\\\\\");
REXP x1= c.parseAndEval("try(source(\""+filepath+"\"),silent=TRUE)");
log.debug("Script from temp file Evaluated");
log.debug("x1:"+x1);
log.debug("error messages:"+c.getLastError());
if (x1!=null && x1.inherits("try-error") ) {
//throw new Exception("Error in R Script: "+x1.asString());
throw new ExceptionRscriptError(x1.asString());
}
if(x1==null) {
//sframe.setTasklog("R Script failed. See log file for more info");
//throw new Exception("R script:"+data.get("name")+" failed");
throw new ExceptionRScriptNullError("Rscript Executed but unknown error message returned by RServe");
}else{
this.stackframe.setTasklog(null);
}
}
public void closeRconnection(RServeSession rs) throws Exception {
RConnection c=rs.getRconnection();
if(c!=null){
c.shutdown();
if(this.p!=null){
p.destroy();
}
}
}
}
@@ -0,0 +1,217 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.quartz.JobExecutionException;
import com.fourelementscapital.db.SchedulerDB;
import com.fourelementscapital.db.vo.FlexiField;
import com.fourelementscapital.scheduler.exception.SchedulerException;
public abstract class ScheduledTask {
public static String FIELD_DEPENDENCY_IDS="dependentids";
public static String FIELD_DEPENDENCY_CHECKTIME="dependentchecktime";
public static String FIELD_DEPENDENCY_SUCCESS="onsuccess";
public static String FIELD_DEPENDENCY_FAIL="onfail";
public static String FIELD_DEPENDENCY_TIMEOUT="ontimeout";
public static String FIELD_CONCURRENT_EXEC="concurrent_execution";
private String name=null;
private String uniqueid=null;
private Vector<ScheduledTaskField> flexifields=new Vector<ScheduledTaskField>();
public static String EXCECUTION_SUCCESS="success";
public static String EXCECUTION_FAIL="fail";
public static String DEPENDENCY_TIMEOUT="dep_timeout";
public static String EXCECUTION_OVERLAPPED="overlapped";
public static String EXCECUTION_WARNING="warning";
public static String TIMOUT_WARNING="timeout";
public static String TASK_QUEUED="queued";
public static String TASK_EVENT_CALL_EXP_ID_VARIABLE=".caller_id";
public static String TASK_EVENT_CALL_EXP_TRIGGERTIME_VARIABLE=".caller_trigger_time";
public static String TASK_EVENT_CALL_EXP_ERRORMSG_VARIABLE=".caller_error_message";
public static final int PEER_ASSOCIATION_HISTORY_ADDED=1;
public static final int PEER_ASSOCIATION_HISTORY_REMOVED=0;
public static final int PEER_ASSOCIATION_HISTORY_PEER_ACTIVE=1;
public static final int PEER_ASSOCIATION_HISTORY_PEER_NOACTIVE=0;
private Logger log = LogManager.getLogger(ScheduledTask.class.getName());
public ScheduledTask(String name, String uid) {
this.name=name;
this.uniqueid=uid;
addNameField();
}
public String getName() {
return this.name;
}
public String getUniqueid() {
return this.uniqueid;
}
public List<ScheduledTaskField> listFormFields(){
return this.flexifields;
}
private void addNameField(){
SchedulerDB sdb=SchedulerDB.getSchedulerDB();
try{
sdb.connectDB();
List<Map> folders=sdb.listOfFolders(getUniqueid());
ScheduledTaskField f1=new ScheduledTaskField();
f1.setShortname("folder_id");
f1.setFieldlabel("Folder");
f1.setFieldtype(FlexiField.TYPE_DROP_DOWNLIST);
String foption="";
for(Map record: folders){
String line=record.get("id")+"~"+record.get("folder_name");
foption+=foption.equals("")?line:"|"+line;
}
f1.setFieldoptions(foption);
this.flexifields.add(f1);
}catch(Exception e){
log.error("error:"+e.getMessage());
}finally{
try{
sdb.closeDB();
}catch(Exception e1){
log.error("couldn't close sdb");
}
}
ScheduledTaskField fname=new ScheduledTaskField();
fname.setShortname("name");
fname.setFieldtype(FlexiField.TYPE_TEXTBOX);
fname.setFieldlabel("Name");
ScheduledTaskField depids=new ScheduledTaskField();
depids.setShortname(FIELD_DEPENDENCY_IDS);
depids.setFieldtype(FlexiField.TYPE_TEXTBOX);
depids.setFieldlabel("Dependent Task IDs");
depids.setFineprint("Runs only when those were successfully executed. Multiple IDs separated by comma. For example: 243,140,245 (Leave empty if not applicable)");
depids.setPlacementform("dependency");
ScheduledTaskField deptime=new ScheduledTaskField();
deptime.setShortname(FIELD_DEPENDENCY_CHECKTIME);
deptime.setFieldtype(FlexiField.TYPE_TEXTBOX);
deptime.setFieldlabel("Dependents Recency");
deptime.setFineprint(" Recency of all dependent task in Minutes (applicable only if Dependent task IDs entered)");
deptime.setPlacementform("dependency");
this.flexifields.add(fname);
this.flexifields.add(depids);
this.flexifields.add(deptime);
ScheduledTaskField success=new ScheduledTaskField();
success.setShortname(FIELD_DEPENDENCY_SUCCESS);
success.setFieldtype(FlexiField.TYPE_FREETEXT);
success.setFieldlabel("On Success");
//success.setFineprint(" Execute tasks when the status is success");
success.setPlacementform("events");
this.flexifields.add(success);
ScheduledTaskField fail=new ScheduledTaskField();
fail.setShortname(FIELD_DEPENDENCY_FAIL);
fail.setFieldtype(FlexiField.TYPE_FREETEXT);
fail.setFieldlabel("On Error/Fail");
//fail.setFineprint(" Execute tasks when there is an error");
fail.setPlacementform("events");
this.flexifields.add(fail);
ScheduledTaskField timeout=new ScheduledTaskField();
timeout.setShortname(FIELD_DEPENDENCY_TIMEOUT);
timeout.setFieldtype(FlexiField.TYPE_FREETEXT);
timeout.setFieldlabel("On Timeout");
//timeout.setFineprint(" Execute tasks when there is timeout.");
timeout.setPlacementform("events");
this.flexifields.add(timeout);
ScheduledTaskField overlap=new ScheduledTaskField();
overlap.setShortname(FIELD_CONCURRENT_EXEC);
overlap.setFieldtype(FlexiField.TYPE_DROP_DOWNLIST);
overlap.setPlacementform("concur");
overlap.setFieldlabel("Number of Concurrent Executions");
overlap.setFineprint(" >1 will allow task overlapping");
overlap.setFieldoptions("2|3|4|5|6|7|8|9|10");
overlap.setDropdowninitial("1");
this.flexifields.add(overlap);
}
protected void removeAllFields(){
this.flexifields.removeAllElements();
addNameField();
}
public void addFormFields(Collection<ScheduledTaskField> fields ) throws Exception{
for(Iterator<ScheduledTaskField> ffi=fields.iterator();ffi.hasNext();){
ScheduledTaskField ff=ffi.next();
if(!flexifields.contains(ff)){
this.flexifields.add(ff);
}else{
throw new Exception("Shortname is unique, Duplicate shortname are not allowed, or name shortname is already reserved.");
}
}
}
public abstract void execute(StackFrame sframe) throws JobExecutionException,SchedulerException,Exception ;
/*
public void setAddhocListener(String triggername,ScheduledTaskJobAdhocListener listner) {
this.adhoclisteners.put(triggername,listner);
}
public ScheduledTaskJobAdhocListener getAddhocListener(String triggername) {
return this.adhoclisteners.get(triggername);
}
public ScheduledTaskJobAdhocListener removeAddhocListener(String triggername) {
return this.adhoclisteners.remove(triggername);
}
*/
}
@@ -0,0 +1,75 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import com.fourelementscapital.db.vo.FlexiField;
import com.fourelementscapital.scheduler.pluggin.PlugginData;
public class ScheduledTaskField extends FlexiField {
private String shortname;
private PlugginData pluggindata;
private String fineprint;
private String placementform="general"; //default is general
public String getPlacementform() {
return placementform;
}
public void setPlacementform(String placementform) {
this.placementform = placementform;
}
public String getFineprint() {
return fineprint;
}
public void setFineprint(String fineprint) {
this.fineprint = fineprint;
}
public PlugginData getPluggindata() {
return pluggindata;
}
public void setPluggindata(PlugginData pluggindata) {
this.pluggindata = pluggindata;
}
public String getShortname() {
return shortname;
}
public void setShortname(String shortname) {
this.shortname = shortname;
}
public boolean equals(Object other) {
if(other instanceof ScheduledTaskField){
if(((ScheduledTaskField)other).getShortname().equals(this.getShortname())){
return true;
}else{
return false;
}
}
return false;
}
public String toString(){
return getShortname()+"."+getFieldlabel();
}
}
@@ -0,0 +1,202 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.db.SchedulerDB;
import com.fourelementscapital.scheduler.p2p.P2PService;
public class SchedulerExePlanLogs {
public static final int SERVER_OK_FIXEDPEER=2000;
public static final int SERVER_OK_REMOVED_FROM_PQUEUE=2001;
public static final int SERVER_OK_RECEIVED_STATUS_FROM_PEER=2002;
public static final int SERVER_OK_PEER_ACCEPTED_TASK=2003;
public static final int SERVER_ERROR_EXEC_TIMEDOUT=3000;
//3001,3002 & 3003 needs to mapped on flow chart
public static final int SERVER_ERROR_QUEUE_KILLED_BYUSER=3001;
public static final int SERVER_ERROR_PEER_CRASHED_REMOVED_QUEUE=3002;
public static final int SERVER_ERROR_PEER_NORESP_REMOVED_QUEUE=3003;
public static final int SERVER_ERROR_WHILE_ADDING_QUEUE=3004;
public static final int SERVER_ERROR_ALARM_SENT=3005;
//3006 needs to mapped on flow chart
public static final int SERVER_ERROR_REMOVING_QUEUE_BASEDON_LOG=3006;
public static final int SERVER_ERROR_DEPENDENCY_TIMEDOUT=3007;
//3008 & 3009 needs to mapped on flow chart
public static final int SERVER_ERROR_REMOVING_QUEUE_PEER_NO_RESPONSE=3008;
public static final int SERVER_ERROR_REMOVE_QUEUE_NOTRUNNING_INPEER=3009;
public static final int SERVER_WARNING_OVERLAPPED=4000;
public static final int SERVER_WARNING_BOUNCEDTASK_FROMPEER=4002;
public static final int PEER_OK_BLOOMBERG_DOWNLOAD=5000;
public static final int PEER_OK_UNIX_RSERVE_CAPTURE_PROCESSINFO=5001;
public static final int PEER_OK_RSERVE_SCRIPT_EVAL_STARTING=5002;
public static final int PEER_OK_RENGINE_SCRIPT_EVAL_STARTING=5003;
public static final int PEER_OK_ADDED_PEER_QUEUE=5004;
public static final int PEER_OK_EXECUTION_STARTING=5005;
public static final int PEER_OK_EXECUTION_COMPLETED_WITH_NOEXCEPTION=5006;
public static final int PEER_OK_PEER_RECEVED_TASK=5007;
public static final int PEER_OK_RESPOND_TASKCOMPLETED_WITHSTATUS=5008;
public static final int PEER_OK_RESPOND_RSERVE_SESSIONSTARTED=5009;
public static final int PEER_ERROR_WHILE_RECEIVINGTASK=6000;
public static final int PEER_ERROR_EXECUTION_FAILURE=6001;
public static final int PEER_ERROR_EXECUTION_COMPLETED_WITH_EXCEPTION=6002;
public static final int PEER_WARNING_NOROOM_TO_EXEC=7000;
public static final int IGNORE_CODE=0;
private long trigger_time;
private int scheduler_id;
private Logger log = LogManager.getLogger(SchedulerExePlanLogs.class.getName());
public SchedulerExePlanLogs(int scheduler_id, long trigger_time){
this.scheduler_id=scheduler_id;
this.trigger_time=trigger_time;
}
/**
* @deprecated
* @param message
*/
public void log(String message, int repcode) {
SchedulerDB sdb=SchedulerDB.getSchedulerDB();
try{
//calculates different and adds in server's time
sdb.connectDB();
sdb.addSchedulerExeLogs(this.scheduler_id, this.trigger_time, new Date(), message,repcode, P2PService.getComputerName());
}catch(Exception e){
log.error("error:"+e.getMessage());
}finally{
try{
sdb.closeDB();
}catch(Exception e1){
log.error("error:"+e1.getMessage());
}
}
}
public void log(String key,Map data,int repCode) {
try{
String mess=getMessage(key, data);
log(mess,repCode);
}catch(Exception e){
//throw e;
log.error("Error:"+e.getMessage());
}
//System.out.print("Message:"+mess);
}
/*
public void log(String key,Map data,SchedulerDB sdb) {
try{
String mess=getMessage(key, data);
log(mess,sdb);
}catch(Exception e){
log.error("Error:"+e.getMessage());
}
//System.out.print("Message:"+mess);
}
*/
/**
* @deprecated
* @param message
* @param sdb
*/
public void log(String message,SchedulerDB sdb,int repCode) {
try{
//calculates different and adds in server's time
sdb.addSchedulerExeLogs(this.scheduler_id, this.trigger_time, new Date(), message,repCode, P2PService.getComputerName());
}catch(Exception e){
log.error("error:"+e.getMessage());
}
}
private String getMessage(String key, Map data) throws Exception {
ResourceBundle rb=ResourceBundle.getBundle("com.fe.scheduler.logmessages");
String val=key;
try{
val=rb.getString(key);
}catch(MissingResourceException miex){
val=key+" !key:not_found!";
}
//if(data!=null && data.size()>0){
val=replaceNewValues(val,data!=null?data:new HashMap());
//}
return val;
}
private String replaceNewValues(final String log,
final Map values){
final StringBuffer sb = new StringBuffer();
final Pattern pattern =
Pattern.compile("\\[(.*?)\\]", Pattern.DOTALL);
final Matcher matcher = pattern.matcher(log);
while(matcher.find()){
final String key = matcher.group(1);
if( values.get(key)!=null){
final String replacement = values.get(key).toString();
if(replacement == null){
matcher.appendReplacement(sb, "");
}else{
matcher.appendReplacement(sb, replacement);
}
}else{
matcher.appendReplacement(sb, "");
}
}
matcher.appendTail(sb);
return sb.toString();
}
}
@@ -0,0 +1,236 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import java.util.Map;
import java.util.Vector;
import com.fourelementscapital.scheduler.p2p.MessageBean;
import com.fourelementscapital.scheduler.rscript.RScript;
public class StackFrame {
public ScheduledTask task = null;
public Map data = null;
private long trigger_time=0;
private long nexttrigger_time=0;
private long started_time=0;
private String status=null;
private RScript rscript=null;
private String replyTo;
private String invokedby="";
private Vector dbConnectionIds=new Vector();
private String executed_code=null;
private String console_message=null;
private String queue_uid=null;
public String getQueue_uid() {
return queue_uid;
}
public void setQueue_uid(String queue_uid) {
this.queue_uid = queue_uid;
}
public String getConsole_message() {
return console_message;
}
public void setConsole_message(String console_message) {
this.console_message = console_message;
}
public String getExecuted_code() {
return executed_code;
}
public void setExecuted_code(String executed_code) {
this.executed_code = executed_code;
}
public Vector getDbConnectionIds() {
return dbConnectionIds;
}
public String getInvokedby() {
return invokedby;
}
public void setInvokedby(String invokedby) {
this.invokedby = invokedby;
}
public String getReplyTo() {
return replyTo;
}
public void setReplyTo(String replyTo) {
this.replyTo = replyTo;
}
public RScript getRscript() {
return rscript;
}
public void setRscript(RScript rscript) {
this.rscript = rscript;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
private String tasklog=null;
private boolean dependencyfailed=false;
public boolean isDependencyfailed() {
return dependencyfailed;
}
public void setDependencyfailed(boolean dependencyfailed) {
this.dependencyfailed = dependencyfailed;
}
private StackFrameCallBack callback=null;
private MessageBean mbean=null;
/**
* @deprecated
*
*/
public MessageBean getMbean() {
return mbean;
}
/**
* @deprecated
* @param mbean
*/
public void setMbean(MessageBean mbean) {
this.mbean = mbean;
}
public void addCallBack(StackFrameCallBack callback){
this.callback=callback;
}
public StackFrameCallBack getCallBack(){
return this.callback;
}
public String getTasklog() {
return tasklog;
}
public void setTasklog(String tasklog) {
this.tasklog = tasklog;
}
public long getNexttrigger_time() {
return nexttrigger_time;
}
public void setNexttrigger_time(long nexttrigger_time) {
this.nexttrigger_time = nexttrigger_time;
}
public long getTrigger_time() {
return trigger_time;
}
public void setTrigger_time(long trigger_time) {
this.trigger_time = trigger_time;
}
private int logid=0;
public int getLogid() {
return logid;
}
public void setLogid(int logid) {
this.logid = logid;
}
public StackFrame(ScheduledTask task, Map data) {
this.task = task;
this.data = data;
}
public ScheduledTask getTask(){
return this.task;
}
public Map getData(){
return this.data;
}
public long getStarted_time() {
return started_time;
}
public void setStarted_time(long started_time) {
this.started_time = started_time;
}
public boolean equals(Object other) {
if (!(other instanceof StackFrame) ) return false;
final StackFrame other1 = (StackFrame) other;
if(this.rscript!=null){
if(this.rscript!=null && other1.rscript!=null && this.rscript.getUid().equals(other1.rscript.getUid())){
return true;
}else{
return false;
}
}else{
//validation for all types
return equals1(other);
}
}
public boolean equals1(Object other) {
if(this.data==null) return false;
//if ( !(other instanceof StackFrame) ) return false;
final StackFrame other1 = (StackFrame) other;
if(other1.data==null) return false;
if(other1.data.get("id")!=null && this.data.get("id")!=null){
Number onid=(Number)other1.data.get("id");
Number nid=(Number)this.data.get("id");
if (onid.intValue()==nid.intValue()) return true;
}
if(other1.data.get("script_id")!=null && this.data.get("script_id")!=null){
Number onid=(Number)other1.data.get("script_id");
Number nid=(Number)this.data.get("script_id");
if (onid.intValue()==nid.intValue()) return true;
}
return false;
}
}
@@ -0,0 +1,18 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import com.fourelementscapital.scheduler.exception.SchedulerException;
public interface StackFrameCallBack {
public void callBack(StackFrame sframe, String status,SchedulerException se);
}
@@ -0,0 +1,29 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.group;
import com.fourelementscapital.scheduler.engines.BloombergDownload;
public class BBDownloadScheduledTask extends BloombergDownload {
public BBDownloadScheduledTask(String name, String taskuid) {
super(name,taskuid);
}
}
@@ -0,0 +1,20 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.group;
import com.fourelementscapital.scheduler.engines.ExecuteRUnix;
public class DirectRServeExecuteRUnix extends ExecuteRUnix {
public DirectRServeExecuteRUnix(String name,String taskuid ) {
super(name,taskuid);
}
}
@@ -0,0 +1,20 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.group;
import com.fourelementscapital.scheduler.engines.ExecuteRWindows;
public class ExecuteRWindowsHighPriority extends ExecuteRWindows {
public ExecuteRWindowsHighPriority(String name, String taskuid) {
super(name, taskuid);
}
}
@@ -0,0 +1,28 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.group;
import com.fourelementscapital.scheduler.engines.ExecuteRWindows;
public class REngineScriptTask extends ExecuteRWindows{
public REngineScriptTask(String name, String taskuid) {
super(name, taskuid);
}
}
@@ -0,0 +1,213 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.group;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.StringReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Random;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.quartz.JobExecutionException;
import org.rosuda.JRI.REXP;
import com.fourelementscapital.scheduler.config.Config;
import com.fourelementscapital.scheduler.engines.MyRengine;
import com.fourelementscapital.scheduler.engines.MyRengineCallbacks;
import com.fourelementscapital.scheduler.engines.REngineWindows;
import com.fourelementscapital.scheduler.engines.StackFrame;
public class RScriptScheduledTask extends REngineWindows {
protected static MyRengine re=null;
private Logger log = LogManager.getLogger(RScriptScheduledTask.class.getName());
private StackFrame stackframe=null;
public RScriptScheduledTask(String name, String taskuid) {
//super("High Priority (R Engine)","rscript");
super(name,taskuid);
}
private static String rVersion=null;
private static boolean jriCompatible=false;
private static String packageVersions=null;
/**
* @deprecated
*/
public static String getRVersion(){
if(rVersion==null){
//getRVersionFirstTime();
}
return rVersion;
}
/**
* @deprecated
*/
public static String getRPackageVersion(){
if(packageVersions==null){
//updatePackageVersion();
}
return packageVersions;
}
/**
* @deprecated
*/
public static boolean getJRICompatible(){
if(rVersion==null){
//getRVersionFirstTime();
}
return jriCompatible;
}
/**
* @deprecated
*/
public static void updatePackageVersion(){
//updates R Package version.
}
/**
* @deprecated
*/
public void executeScript(StackFrame sframe) throws JobExecutionException,Exception {
if(Config.getString("p2p.ignorejri")!=null && Config.getString("p2p.ignorejri").equalsIgnoreCase("true")){
throw new Exception("JRI is not enalbed");
}
//log.debug("RScriptScheduledTask.execute() called");
this.stackframe=sframe;
Map<String, Object> data=sframe.getData();
String rscript=(String)data.get("script");
Number restart=(Number)data.get("restart");
Number script_id=(Number)data.get("script_id");
if(rscript==null) { throw new JobExecutionException("Task Failed because no R script found or empty"); }
MyRengineCallbacks myrenging=new MyRengineCallbacks();
if(re!=null && restart.intValue()==1){
re.end();
//log.debug("restarting R session....");
//re.interrupt();
log.debug("interupting R thread....");
re=null;
try{
Thread.sleep(2000);
}catch(Exception e){ }
}
if(re==null){
log.debug("Rengine is null, creating one.......");
re=new MyRengine(null, false, myrenging );
re.setStackFrame(sframe);
}else{
re.setStackFrame(sframe);
//re.addMainLoopCallbacks(myrenging);
}
if(rscript!=null && !rscript.equals("")){
try{
BufferedReader reader = new BufferedReader(new StringReader(rscript));
StringBuffer sb=new StringBuffer();
String tempDir = System.getProperty("java.io.tmpdir");
File file=new File(tempDir+File.separator+"rscript"+new SimpleDateFormat("mmddyyy_hh_mmss_").format(new Date())+new Random().nextInt()+".R");
String line;
BufferedWriter out = new BufferedWriter(new FileWriter(file));
while ((line = reader.readLine()) != null) {
if(line!=null && !line.equals("")){
out.write(line+"\n");
}
}
out.close();
reader.close();
String filepath=file.getPath().replaceAll("\\\\", "\\\\\\\\");
REXP x1= re.eval("source(\""+filepath+"\")");
log.debug("x1:"+x1);
file.delete();
if(x1==null) {
//sframe.setTasklog("R Script failed. See log file for more info");
throw new Exception("R script:"+data.get("name")+" failed");
}else{
sframe.setTasklog(null);
re.setStackFrame(null);
}
}catch(Exception e){
//e.printStackTrace();
//ClientErrorMgmt.reportError(e,null);
throw e;
}
}
//setMessages(myrenging.logMessages());
log.debug("~~~~~~~~~~~R Script finishing execution...");
}
public static String codeInjectConcatenate(String default_param, String rscript, String injected_code) throws Exception {
String finalcode="";
if(default_param!=null && !default_param.equals("")) {
finalcode+="## Default Header Code ##\n";
finalcode+=default_param+"\n";
finalcode+="## --------------------## \n";
}
if(injected_code!=null && !injected_code.equals("")) {
finalcode+="\n\n## Injected Code ##\n";
finalcode+=injected_code+"\n";
finalcode+="## --------------## \n";
}
if(rscript!=null && !rscript.equals("")) {
finalcode+=rscript+"\n";
}
return finalcode;
}
}
@@ -0,0 +1,31 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.group;
import com.fourelementscapital.scheduler.engines.RServeWindows;
public class RServeScheduledTask extends RServeWindows {
public RServeScheduledTask(String name,String taskuid ) {
super(name,taskuid);
}
}
@@ -0,0 +1,28 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.group;
import com.fourelementscapital.scheduler.engines.RServeUnix;
public class RServeUnixTask extends RServeUnix {
public static final String ENGINE_NAME="rscript4rserveunix";
public static final String ENGINE_EXECUTER_UNIX_NAME="direct_script_unix";
public RServeUnixTask(String name,String taskuid ) {
super(name,taskuid);
}
}
@@ -0,0 +1,62 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.pluggin;
public class PlugginData {
private String jsnew;
private String jscreate;
private String jsfetch;
public String getJsfetch() {
return jsfetch;
}
public void setJsfetch(String jsfetch) {
this.jsfetch = jsfetch;
}
//private String jsmodify;
//private String jsdelete;
private String fieldreference;
public String getFieldreference() {
return fieldreference;
}
public void setFieldreference(String fieldreference) {
this.fieldreference = fieldreference;
}
public String getJsnew() {
return jsnew;
}
public void setJsnew(String jsnew) {
this.jsnew = jsnew;
}
public String getJscreate() {
return jscreate;
}
public void setJscreate(String jscreate) {
this.jscreate = jscreate;
}
/*
public String getJsmodify() {
return jsmodify;
}
public void setJsmodify(String jsmodify) {
this.jsmodify = jsmodify;
}
public String getJsdelete() {
return jsdelete;
}
public void setJsdelete(String jsdelete) {
this.jsdelete = jsdelete;
}
*/
}
@@ -0,0 +1,29 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.pluggin;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
public interface PlugginInterface {
public int addAction(Map data, HttpServletRequest request) throws Exception ;
public int updateAction(int scheduler_id, Map data,HttpServletRequest request) throws Exception ;
public Map fetchData(int record_id, HttpServletRequest request) throws Exception ;
public void deleteAction(int scheduler_id, HttpServletRequest request) throws Exception ;
//public void upadteAction(int recordid, Map data,HttpServletRequest request) throws Exception;
//public boolean deleteAction(int recordid,HttpServletRequest request) throws Exception;
public PlugginData getPlugginData();
public String getText(Map data);
}
@@ -0,0 +1,429 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.pluggin;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import com.fourelementscapital.db.BBSyncDB;
import com.fourelementscapital.db.SchedulerDB;
import com.fourelementscapital.db.vo.BBSyncTrigger;
public class SchedulerBloombergPlugin implements PlugginInterface {
public static String PLUGGIN_IN="bloomberg_pluggin";
public int addAction(Map data,HttpServletRequest request) throws Exception {
try{
//BBSyncMgmt bbsyncmgmt=new BBSyncMgmt(request);
//System.out.println("data:"+data);
String name=(String)data.get("qdata.name");
String mkt_securities=(String)data.get("mkt_securities");
boolean mkt_securities1=false;
if(mkt_securities.equalsIgnoreCase("true")){
mkt_securities1=true;
}
String filtervalue=(String)data.get("filtervalue");
String date1s=(String)data.get("date1s");
String date2s=(String)data.get("date2s");
String number=(String)data.get("number");
String fieldids=(String)data.get("fieldids");
StringTokenizer token=new StringTokenizer(fieldids,",");
Vector fieldids1=new Vector();
while(token.hasMoreTokens()){
fieldids1.add(token.nextToken());
}
String contracts=(String)data.get("contracts");
String marketsector=(String)data.get("marketsector");
//System.out.println("name:"+name+" mkt_securities:"+ mkt_securities1+" filtervalue:"+filtervalue+" date1s:"+ date1s+" date2s:"+date2s+" number:"+ number+" fieldids:"+ fieldids+" contracts:"+ contracts+" marketsector:"+marketsector);
//int downloadid=bbsyncmgmt.saveSchedule2(0, name, mkt_securities1, filtervalue, date1s, date2s, number, fieldids1, contracts, null, null, null, marketsector, null);
int downloadid=saveSchedule2(0, name, mkt_securities1, filtervalue, date1s, date2s, number, fieldids1, contracts, null, null, null, marketsector, null);
return downloadid;
}catch(Exception e){
throw e;
}
}
private int saveSchedule2(
int id,
String name,
boolean mkt_secdb,
String dateoption,
String datefrom,
String dateto,
String datenumber,
Vector fields,
String contracts,
BBSyncTrigger daily,
BBSyncTrigger weekly,
BBSyncTrigger monthly,
String marketsector,
String timezone
) throws Exception {
try{
//log.debug("saveSchedule called");
//String fields="";
//if(blbfields.size()==dbfields.size()){
// for(int i=0;i<blbfields.size();i++){
// String f=blbfields.get(i)+"~"+dbfields.get(i);
// fields+=(i>0)?"|"+f:f;
// }
//}
BBSyncDB syncdb=BBSyncDB.getBBSyncDB();
BBSyncTrigger trigobj=new BBSyncTrigger();
if(daily!=null && weekly==null && monthly==null){
trigobj=daily;
trigobj.setSynctype(BBSyncTrigger.HOURLY);
}
if(daily==null && weekly!=null && monthly==null){
trigobj=weekly;
trigobj.setSynctype(BBSyncTrigger.WEEKLY);
}
if(daily==null && weekly==null && monthly!=null){
trigobj=monthly;
trigobj.setSynctype(BBSyncTrigger.MONTHLY);
}
//log.debug("trigobj:"+trigobj);
try{
syncdb.connectDB();
//log.debug("after connected");
java.sql.Date d1=null;
java.sql.Date d2=null;
//log.debug("before parsing:"+datefrom);
SimpleDateFormat sf=new SimpleDateFormat("DD/mm/yyyy");
if(datefrom!=null){
//log.debug("parseing:"+sf.parse(datefrom));
d1=new java.sql.Date((sf.parse(datefrom)).getTime());
//new java.sql.Date(datefrom.getTime());
}
if(dateto!=null){
d2=new java.sql.Date((sf.parse(dateto)).getTime());
}
int datenumber1=0;
try{
datenumber1=Integer.parseInt(datenumber);
}catch(Exception e){}
int nid=syncdb.saveSchedule(
id,
name,
mkt_secdb+"",
dateoption,
d1,
d2,
datenumber1,
fields,
contracts,
trigobj,
marketsector,
timezone
);
syncdb.closeDB();
return nid;
}catch(Exception e){
//ClientErrorMgmt.reportError(e, "Couldn't save scheduling data");
//e.printStackTrace();
throw e;
}
}catch(Exception e){
//ClientErrorMgmt.reportError(e, null);
throw e;
}
}
public int updateAction(int scheduler_id,Map data,HttpServletRequest request) throws Exception {
try{
//BBSyncMgmt bbsyncmgmt=new BBSyncMgmt(request);
SchedulerDB sdb=SchedulerDB.getSchedulerDB();
sdb.connectDB();
Map sdata=sdb.getScheduler(scheduler_id);
sdb.closeDB();
String d_id=(String)sdata.get(getPlugginData().getFieldreference());
if(d_id!=null){
//System.out.println("data:"+data);
String name=(String)data.get("qdata.name");
String mkt_securities=(String)data.get("mkt_securities");
boolean mkt_securities1=false;
if(mkt_securities.equalsIgnoreCase("true")){
mkt_securities1=true;
}
String filtervalue=(String)data.get("filtervalue");
String date1s=(String)data.get("date1s");
String date2s=(String)data.get("date2s");
String number=(String)data.get("number");
String fieldids=(String)data.get("fieldids");
StringTokenizer token=new StringTokenizer(fieldids,",");
Vector fieldids1=new Vector();
while(token.hasMoreTokens()){
fieldids1.add(token.nextToken());
}
String contracts=(String)data.get("contracts");
String marketsector=(String)data.get("marketsector");
//System.out.println("name:"+name+" mkt_securities:"+ mkt_securities1+" filtervalue:"+filtervalue+" date1s:"+ date1s+" date2s:"+date2s+" number:"+ number+" fieldids:"+ fieldids+" contracts:"+ contracts+" marketsector:"+marketsector);
//int downloadid=bbsyncmgmt.saveSchedule2(Integer.parseInt(d_id), name, mkt_securities1, filtervalue, date1s, date2s, number, fieldids1, contracts, null, null, null, marketsector, null);
int downloadid=saveSchedule2(Integer.parseInt(d_id), name, mkt_securities1, filtervalue, date1s, date2s, number, fieldids1, contracts, null, null, null, marketsector, null);
return downloadid;
}else{
throw new Exception("Problem in updating Bloomberg data for this task");
}
}catch(Exception e){
throw e;
}
}
//public boolean deleteAction(int recordid,HttpServletRequest request) throws Exception {
//
// return true;
//}
public PlugginData getPlugginData() {
PlugginData pdata=new PlugginData();
pdata.setJsnew("bbpl_jsNew");
pdata.setJscreate("bbpl_jsCreate");
pdata.setJsfetch("bbpl_jsFetch");
//pdata.setJsmodify("bbpl_jsUpdate");
pdata.setFieldreference("download_id");
return pdata;
}
public Map fetchData(int recordid, HttpServletRequest request) throws Exception {
//BBSyncMgmt bbsyncmgmt=new BBSyncMgmt(request);
//return bbsyncmgmt.getDownloadQuery(recordid);
return getDownloadQuery(recordid);
}
private Map getDownloadQuery(long id) throws Exception {
try{
BBSyncDB syncdb=BBSyncDB.getBBSyncDB();
syncdb.connectDB();
Map m=syncdb.getDownloadQuery(id);
//System.out.println("BBSyncMgmt.getDownloadQuery():m:"+m);
Object b=m.get("date_from");
if(b!=null){
m.put("date_from",new SimpleDateFormat("dd/MM/yyyy").format((Date)b));
}
Object b1=m.get("date_to");
if(b1!=null){
m.put("date_to",new SimpleDateFormat("dd/MM/yyyy").format((Date)b1));
}
if(m.get("trigger_time")!=null){
try{
Date d=new SimpleDateFormat("HH:mm").parse((String)m.get("trigger_time"));
Calendar c=Calendar.getInstance();
c.setTime(d);
m.put("trigger_hour",c.get(Calendar.HOUR_OF_DAY));
m.put("trigger_minute",c.get(Calendar.MINUTE));
}catch(Exception e){}
}
if(m.get("fields")!=null){
String fields1=(String)m.get("fields");
StringTokenizer st=new StringTokenizer(fields1,"|");
TreeMap fields=new TreeMap();
while(st.hasMoreTokens()){
String cfield=st.nextToken();
StringTokenizer st1=new StringTokenizer(cfield,"~");
if(st1.countTokens()==2){
String ky=st1.nextToken();
String value=st1.nextToken();
fields.put(ky,value);
}
}
m.put("fieldsmap",fields);
}
//put logs if there is
/*
Vector logs=syncdb.getSyncLogs((int)id);
for(Iterator<Map>i= logs.iterator();i.hasNext();) {
Map record=i.next();
try{
Timestamp s=(Timestamp)record.get("start_time");
Timestamp e=(Timestamp)record.get("end_time");
if(s!=null && e!=null){
SimpleDateFormat df=new SimpleDateFormat("dd MMM, yyyy");
SimpleDateFormat tf=new SimpleDateFormat("h:mm a");
record.put("start_time",tf.format(s));
record.put("end_time",tf.format(e));
record.put("start_date",df.format(s));
SimpleDateFormat dateFormat =new SimpleDateFormat("mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
long diff=e.getTime()-s.getTime();
record.put("duration", dateFormat.format(new Date(diff)));
}
}catch(Exception e){
}
}
m.put("logs",logs );
*/
syncdb.closeDB();
return m;
}catch(Exception e){
//ClientErrorMgmt.reportError(e, null);
throw e;
}
}
public void deleteAction(int scheduler_id, HttpServletRequest request) throws Exception {
SchedulerDB sdb=SchedulerDB.getSchedulerDB();
sdb.connectDB();
Map sdata=sdb.getScheduler(scheduler_id);
sdb.closeDB();
String d_id=(String)sdata.get(getPlugginData().getFieldreference());
if(d_id!=null){
//BBSyncMgmt bbsyncmgmt=new BBSyncMgmt(request);
//bbsyncmgmt.deleteQuery(Integer.parseInt(d_id));
deleteQuery(Integer.parseInt(d_id));
} else{
throw new Exception("Problem in deleting Bloomberg data for this task");
}
}
private Map deleteQuery(int id) throws Exception {
try{
BBSyncDB syncdb=BBSyncDB.getBBSyncDB();
syncdb.connectDB();
syncdb.deleteQuery(id);
//new BloombergDownloadJob().scheduleDownloadQueries();
Map rtn=loadFirst();
rtn.remove("field_mapping");
syncdb.closeDB();
return rtn;
}catch(Exception e){
//e.printStackTrace();
//ClientErrorMgmt.reportError(e, "id:"+id);
throw e;
}
}
private Map loadFirst() throws Exception {
BBSyncDB syncdb=BBSyncDB.getBBSyncDB();
syncdb.connectDB();
TreeMap rtn=new TreeMap();
Vector v=syncdb.listAll();
Vector fields=syncdb.getFieldMapping();
for(int i=0;i<v.size();i++){
Map m=(Map)v.get(i);
Object b=m.get("last_executed");
if(b instanceof java.sql.Timestamp && b!=null ){
String recent=new SimpleDateFormat("d MMM,yy HH:mm").format((Date)b);
//m.put("name",((m.get("name")!=null)?m.get("name"):"")+ " <small>(Last Executed:"+recent+")</small>") ;
m.put("last_executed", recent) ;
}
}
syncdb.closeDB();
rtn.put("schedules",v);
rtn.put("field_mapping", fields);
return rtn;
}
public String getText(Map data) {
String rtn="Name:"+data.get("qdata.name")+"\n";
rtn+="Is_securities:"+data.get("mkt_securities")+"\n";
rtn+="Filter:"+data.get("filtervalue")+"\n";
rtn+="Date_option1:"+data.get("date1s")+"\n";
rtn+="Date_option2:"+data.get("date2s")+"\n";
rtn+="Date_option3:"+data.get("number")+"\n";
rtn+="Fieldids:"+data.get("fieldids")+"\n";
rtn+="Tickers:"+data.get("contracts")+"\n";
rtn+="Sector:"+data.get("marketsector")+"\n";
return rtn;
}
//public void upadteAction(int recordid, Map data,HttpServletRequest request)throws Exception {
//
//}
}
@@ -0,0 +1,25 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.pluggin;
public class SchedulerPlugginRegister {
public static PlugginInterface getPluggin(String plugginid){
if(plugginid.equalsIgnoreCase(SchedulerBloombergPlugin.PLUGGIN_IN)){
return new SchedulerBloombergPlugin();
}else{
return null;
}
}
}
@@ -0,0 +1,220 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.rscript;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
import org.rosuda.JRI.REXP;
import com.fourelementscapital.scheduler.p2p.msg.MessageHandler;
public class RScript extends MessageHandler {
private String uid;
private String script;
private REXP result;
private String resultXML;
private String error;
private boolean executing;
private String taskuid;
private String peer;
private String executeAt;
private Long queued_time;
private String uniquename;
private String requesthost;
private long delay;
private Date startedtime;
private String resultJSON;
//private String queuefriendlytime;
public String getResultJSON() {
return resultJSON;
}
public void setResultJSON(String resultJSON) {
this.resultJSON = resultJSON;
}
public Date getStartedtime() {
return startedtime;
}
public void setStartedtime(Date startedtime) {
this.startedtime = startedtime;
}
public String getRequesthost() {
return requesthost;
}
public long getDelay() {
return delay;
}
public void setDelay(long delay) {
this.delay = delay;
}
public void setRequesthost(String requesthost) {
this.requesthost = requesthost;
}
public String getUniquename() {
return uniquename;
}
public void setUniquename(String uniquename) {
this.uniquename = uniquename;
}
public Long getQueued_time() {
return queued_time;
}
public void setQueued_time(Long queued_time) {
this.queued_time = queued_time;
}
public String getExecuteAt() {
return executeAt;
}
public void setExecuteAt(String executeAt) {
this.executeAt = executeAt;
}
public String getPeer() {
return peer;
}
public void setPeer(String peer) {
this.peer = peer;
}
public String getTaskuid() {
return taskuid;
}
public void setTaskuid(String taskuid) {
this.taskuid = taskuid;
}
public boolean isExecuting() {
return executing;
}
public void setExecuting(boolean executing) {
this.executing = executing;
}
public RScript() {
this.uid=UUID.randomUUID().toString();
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getScript() {
return script;
}
public void setScript(String script) {
this.script = script;
}
public REXP getResult() {
return result;
}
public void setResult(REXP result) {
this.result = result;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public String getResultXML() {
return resultXML;
}
public void setResultXML(String resultXML) {
this.resultXML = resultXML;
}
public boolean equals(Object o) {
RScript other=(RScript)o;
if(other!=null && other.getUid().equals(this.getUid()) ){
return true;
} else{
return false;
}
}
public int compareTo(RScript o) {
return this.queued_time<o.queued_time?-1:
this.queued_time>o.queued_time?1:0;
}
public Map executeAtDestination() {
return null;
}
public String getScriptPreview(){
if(this.script.trim().length()>=100){
return this.script.trim().substring(0,99)+"....";
}else{
return this.script.trim();
}
}
public String getQueuefriendlytime(){
try{
SimpleDateFormat sdf=new SimpleDateFormat("dd-MMM HH:mm:ss");
Date d=new Date(this.queued_time);
d.setTime(this.queued_time);
return sdf.format(d);
}catch(Exception e){
return e.getMessage();
}
}
@Override
public void onSendingFailed() {
// TODO Auto-generated method stub
}
}
@@ -0,0 +1,189 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.rscript;
import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.jcs.JCS;
import org.apache.jcs.engine.behavior.IElementAttributes;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.scheduler.config.Config;
import com.fourelementscapital.scheduler.error.ClientError;
public class RScriptAsyncListenerImpl implements RScriptListener{
private Logger log = LogManager.getLogger(RScriptAsyncListenerImpl.class.getName());
private String peer=null;
private String result=null;
//private HttpSession session=null;
private JCS cache;
private IElementAttributes att;
private Date started=null;
public static String ALIVE="alive";
public RScriptAsyncListenerImpl(JCS cache, IElementAttributes att) throws Exception {
//this.session=session;
this.cache=cache;
this.att=att;
}
public void onScriptSent(RScript rscript, String peer) throws Exception {
// TODO Auto-generated method stub
this.peer=peer;
log.debug("+++++ Script started....started:"+rscript.getScript()+" peer:"+peer);
if(this.cache!=null){
this.cache.put(rscript.getUid(),ALIVE,this.att);
}
this.started=new Date();
}
public String getPeer(){
return this.peer;
}
public String getResult(){
return this.result;
}
public void onScriptFinished(RScript rscript, String peer, String result, String status)throws Exception {
this.peer=peer;
this.result=result;
//if(this.session!=null){
// this.session.setAttribute(rscript.getUid(),this);
//}
log.debug("~~~~~~ rscript.getUid():"+rscript.getUid()+" result:"+result+" this.att:"+this.att);
if(this.cache!=null){
this.cache.put(rscript.getUid(),result,this.att);
}
String logmessage="";
//SimpleDateFormat timeformat=new SimpleDateFormat("HH:mm:ss SSS");
//SimpleDateFormat dateformat=new SimpleDateFormat("dd MMM-yy HH:mm:ss SSS");
//logmessage+="UID:"+rscript.getUid()+"\tStatus:"+status+"\tPeer:"+rscript.getPeer()+"\tStarted:"+dateformat.format(this.started)+"\tEnded:"+timeformat.format(new Date())+"\tScript:"+readFirst(rscript.getScript(),50);
String st_time=this.started!=null ? this.started.getTime()+"":"";
logmessage+=status+"\t"+rscript.getPeer()+"\t"+rscript.getQueued_time()+"\t"+st_time+"\t"+new Date().getTime()+"\t"+rscript.getRequesthost()+"\t"+rscript.getUniquename();
log.debug("~~~~~~ Script started....rscript.getError():"+rscript.getError());
if(status.equalsIgnoreCase("fail") && rscript.getError()!=null){
logmessage+="\tError:"+readFirst(rscript.getError(), 100);
}
log(logmessage);
}
public void onScriptTimedOut(RScript rscript) throws Exception {
this.result="<?xml version=\"1.0\"?><output status=\"TimedOut\">Script kicked out from the queue because scheduler couldn't find peer within the time limit</output>";
//if(this.session!=null){
// this.session.setAttribute(rscript.getUid(),this);
//}
if(this.cache!=null){
this.cache.put(rscript.getUid(),this.result,this.att);
}
SimpleDateFormat timeformat=new SimpleDateFormat("HH:mm SSS");
SimpleDateFormat dateformat=new SimpleDateFormat("dd MMM-yy HH:mm:ss SSS");
//String logmessage="UID:"+rscript.getUid()+"\tStatus:TimedOut\tAt:"+dateformat.format(new Date())+"\tScript:"+readFirst(rscript.getScript(),50);
String logmessage="TimedOut\t"+""+"\t"+rscript.getQueued_time()+"\t\t"+new Date().getTime()+"\t"+rscript.getRequesthost()+"\t"+rscript.getUniquename();
log(logmessage);
}
protected static String readFirst(String result, int no_char) {
String rtn=result.length()>no_char ?result.substring(0,no_char)+"....": result;
rtn=rtn.trim();
rtn=rtn.replaceAll("\n", " ");
rtn=rtn.replaceAll("\r", " ");
return rtn;
}
protected static void log(String logmessage){
Date d = new Date();
String root;
if(Config.getString("log_executeR_folder")!=null && !Config.getString("log_executeR_folder").equals("") ){
root=Config.getString("log_executeR_folder");
}else{
root=Config.getString("log_error_folder");
}
String folder =root+"direct_scripts";
if (!new File(folder).isDirectory()) {
new File(folder).mkdirs();
}
String fname=root+"direct_scripts"+File.separator+""+new SimpleDateFormat("dd_MM_yyyy").format(d)+".txt";
File file=new File(fname);
if (!file.exists()) {
try {
//file.createNewFile();
FileWriter fw1 = new FileWriter(file,true);
//fw1.append("Date, Time, Error Message\r\n");
fw1.flush();
fw1.close();
}catch(Exception e){
//log.error("error while creating file: Error:"+e.getMessage());
}
}
try {
boolean append = true;
FileWriter fw = new FileWriter(file,append);
//String timeformat="dd-MMM hh:mm:ss aaa ";
//logmessage+="Error/Warning:"+message+"\n";
//logmessage+=""+message+"\n";
fw.append(logmessage+"\r\n");
fw.flush();
fw.close();
}
catch (Exception ex) {
//log.error("Error:"+ex.getMessage());
ClientError.reportError(ex,"Error in external log file writing");
}
}
}
@@ -0,0 +1,136 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.rscript;
import java.nio.CharBuffer;
import java.util.Date;
import org.apache.catalina.websocket.MessageInbound;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class RScriptAsyncWebsocket implements RScriptListener{
Logger log = LogManager.getLogger(RScriptAsyncWebsocket.class.getName());
private MessageInbound messageinbound;
private String uniqueid;
private Date started=null;
public RScriptAsyncWebsocket(String uid,MessageInbound mib){
this.uniqueid=uid;
this.messageinbound=mib;
}
@Override
public void onScriptSent(RScript rscript, String peer) throws Exception {
this.started=new Date();
}
@Override
public void onScriptFinished(RScript rscript, String peer, String result,
String status) throws Exception {
log.debug("script :"+rscript.getUid()+" finished, thread:"+Thread.currentThread().getName() );
String logmessage="";
String st_time=this.started!=null ? this.started.getTime()+"":"";
logmessage+=status+"\t"+rscript.getPeer()+"\t"+rscript.getQueued_time()+"\t"+st_time+"\t"+new Date().getTime()+"\t"+rscript.getRequesthost()+"\t"+rscript.getUniquename();
//log.debug("~~~~~~ Script started....rscript.getError():"+rscript.getError());
if(status.equalsIgnoreCase("fail") && rscript.getError()!=null){
logmessage+="\tError:"+RScriptAsyncListenerImpl.readFirst(rscript.getError(), 100);
}
RScriptAsyncListenerImpl.log(logmessage);
long duration=new Date().getTime()-this.started.getTime();
String rtn=this.uniqueid+"~~"+result;
try{
this.messageinbound.getWsOutbound().writeTextMessage(CharBuffer.wrap(rtn));
this.messageinbound.getWsOutbound().flush();
}catch(Exception e){
log.error("Error, :onScriptFinished:"+e.getMessage());
}
/*
Future fu=IOExcecutors.threadpool.submit(
new Callable<String>() {
public String call(){
String logmessage="";
String st_time=this.started!=null ? this.started.getTime()+"":"";
logmessage+=status+"\t"+rscript.getPeer()+"\t"+rscript.getQueued_time()+"\t"+st_time+"\t"+new Date().getTime()+"\t"+rscript.getRequesthost()+"\t"+rscript.getUniquename();
//log.debug("~~~~~~ Script started....rscript.getError():"+rscript.getError());
if(status.equalsIgnoreCase("fail") && rscript.getError()!=null){
logmessage+="\tError:"+RScriptAsyncListenerImpl.readFirst(rscript.getError(), 100);
}
RScriptAsyncListenerImpl.log(logmessage);
long duration=new Date().getTime()-this.started.getTime();
String rtn=this.uid+"~~"+result;
try{
this.messageinbound.getWsOutbound().writeTextMessage(CharBuffer.wrap(rtn));
this.messageinbound.getWsOutbound().flush();
}catch(Exception e){
log.error("Error, :onScriptFinished:"+e.getMessage());
}
return "";
}
private RScript rscript;
private String peer;
private String result;
private String status;
private Date started;
private MessageInbound messageinbound;
private String uid;
public Callable<String> init(String u,MessageInbound mib, RScript rs, String p, String r, String st, Date std){
this.uid=u;
this.messageinbound=mib;
this.rscript=rs;
this.peer=p;
this.result=r;
this.status=st;
this.started=std;
return this;
}
}.init(this.uniqueid,this.messageinbound,rscript, peer,result,status,this.started)
);
*/
}
@Override
public void onScriptTimedOut(RScript rscript) throws Exception {
}
}
@@ -0,0 +1,20 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.rscript;
import com.fourelementscapital.scheduler.rscript.RScript;
public interface RScriptListener {
public void onScriptSent(RScript rscript, String peer) throws Exception ;
public void onScriptFinished(RScript rscript, String peer, String result, String status) throws Exception;
public void onScriptTimedOut(RScript rscript) throws Exception;
}
@@ -0,0 +1,174 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.rserve;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.rosuda.REngine.Rserve.RConnection;
import com.fourelementscapital.scheduler.p2p.peer.PeerSpecificConfigurations;
public class RServeConnectionPool {
private static ConcurrentLinkedQueue<RServeSession> sessions=new ConcurrentLinkedQueue();
private static ConcurrentLinkedQueue<RServeSession> sessInUse=new ConcurrentLinkedQueue();
private static final Semaphore sessLock=new Semaphore(1,true);
private static long TIMEOUT_MS=2000;
/**
* gets RSession from connection pool, if no live connection available, it creates new and store it in pool
* @return
* @throws Exception
*/
private static void acquireLock(){
try{
Date start=new Date();
RServeConnectionPool.sessLock.tryAcquire(TIMEOUT_MS, TimeUnit.MILLISECONDS);
}catch(Exception e){
LogManager.getLogger(RServeConnectionPool.class.getName()).error("acquireLock() error:"+e.getMessage());
}
}
private static void releaseLock(){
try{
RServeConnectionPool.sessLock.release();
//log.debug("....releasing lock: thread:"+Thread.currentThread().getId());
}catch(Exception e){
LogManager.getLogger(RServeConnectionPool.class.getName()).error("releaseLock() error:"+e.getMessage());
}
}
public static synchronized RServeSession getRSession(String rinit) throws Exception {
//new RConnection()
acquireLock();
try{
RServeSession rtn=null;
if(RServeConnectionPool.sessions.size()>0){
//rtn=(RServeSession)RServeConnectionPool.sessions.lastElement();
rtn=(RServeSession)RServeConnectionPool.sessions.poll();
//RServeConnectionPool.sessions.remove(rtn);
RServeConnectionPool.sessInUse.add(rtn);
}else{
int count=0;
RConnection c=null;
while(c==null && count<10) {
try{c= new RConnection();}catch(Exception e){ ;}
try{ Thread.sleep(200); }catch(Exception e){}
count++;
}
if(c!=null){
rtn=new RServeSession();
c.assign(".r_session_id",rtn.getUid());
//loading rinit at the first time of opening connection.
if(rinit!=null && !rinit.trim().equals("")){
try{
c.parseAndEval(rinit);
}catch(Exception e){
throw new Exception("Not able to load Rnint at RServeConnectionPool.getRsession(), for rinit: "+rinit);
}
}
//c.eval(".r_scripts=NULL");
int processid=c.eval("Sys.getpid()").asInteger();
rtn.setProcessid(processid);
rtn.setRconnection(c);
//rtn.setRsession(c.detach());
RServeConnectionPool.sessInUse.add(rtn);
}
}
if(rtn!=null){
rtn.setNoexecutions(rtn.getNoexecutions()+1);
}
return rtn;
}finally{
releaseLock();
}
}
public static List<RServeSession> getAllSessions(){
ArrayList rtn=new ArrayList();
for(RServeSession rs: RServeConnectionPool.sessions){
rtn.add(rs);
}
for(RServeSession rs: RServeConnectionPool.sessInUse){
rtn.add(rs);
}
return rtn;
}
public static void remove(RServeSession rs){
if(RServeConnectionPool.sessInUse.contains(rs))RServeConnectionPool.sessInUse.remove(rs);
if(RServeConnectionPool.sessions.contains(rs))RServeConnectionPool.sessions.remove(rs);
}
public static synchronized void done(RServeSession rs) throws Exception {
acquireLock();
try{
int rtn=0;
String val=PeerSpecificConfigurations.getProperties().getProperty(PeerSpecificConfigurations.KEY_MAX_EXEC_SESSION);
if(val!=null && !val.trim().equals("")){
rtn=Integer.parseInt(val);
}
if(rtn>0 && rs.getNoexecutions()>=rtn){
Process p=Runtime.getRuntime().exec("kill -9 " + rs.getProcessid());
processOutput(p);
remove(rs);
}else{
RServeConnectionPool.sessInUse.remove(rs);
RServeConnectionPool.sessions.add(rs);
}
}finally{
releaseLock();
}
}
private static void processOutput(Process p) throws Exception {
InputStream inputStream = p.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String line;
while ((line = bufferedReader.readLine()) != null)
{
//System.out.println("RServeSessionQuery. console_output:"+line);
}
}
}
@@ -0,0 +1,165 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.rserve;
import org.rosuda.REngine.Rserve.RConnection;
import org.rosuda.REngine.Rserve.RSession;
import com.fourelementscapital.fileutils.RandomString;
public class RServeSession {
private RSession rsession=null;
private RConnection rconnection=null;
private String scriptname;
private String execute_r_uid=null;
private boolean running=false;
private int scheduler_id;
private long trigger_time;
private Thread thread;
private int processid=0;
private String killmessage=null;
private int noexecutions=0;
public int getNoexecutions() {
return noexecutions;
}
public void setNoexecutions(int noexecutions) {
this.noexecutions = noexecutions;
}
public String getKillmessage() {
return killmessage;
}
public void setKillmessage(String killmessage) {
this.killmessage = killmessage;
}
private String uid=null;
public RServeSession(){
this.uid=RandomString.getString(40);
}
public String getUid() {
return uid;
}
public String getScriptname() {
return scriptname;
}
public void setScriptname(String scriptname) {
this.scriptname = scriptname;
}
public void finished(RConnection rc) throws Exception {
try{
this.rsession=rc.detach();
this.running=false;
this.scheduler_id=0;
this.trigger_time=0;
this.started_time=0;
this.thread=null;
this.rconnection=null;
this.scriptname=null;
}catch(Exception e){
throw e;
}
}
public int getProcessid() {
return processid;
}
public void setProcessid(int processid) {
this.processid = processid;
}
public RConnection getRconnection() {
return rconnection;
}
public void setRconnection(RConnection rconnection) {
this.rconnection = rconnection;
}
public Thread getThread() {
return thread;
}
public void setThread(Thread thread) {
this.thread = thread;
}
public long getTrigger_time() {
return trigger_time;
}
public void setTrigger_time(long trigger_time) {
this.trigger_time = trigger_time;
}
public RSession getRsession() {
return rsession;
}
public void setRsession(RSession rsession) {
this.rsession = rsession;
}
public boolean isRunning() {
return running;
}
public void setRunning(boolean running) {
this.running = running;
}
public int getScheduler_id() {
return scheduler_id;
}
public void setScheduler_id(int scheduler_id) {
this.scheduler_id = scheduler_id;
}
public long getStarted_time() {
return started_time;
}
public void setStarted_time(long started_time) {
this.started_time = started_time;
}
public String getExecute_r_uid() {
return execute_r_uid;
}
public void setExecute_r_uid(String execute_r_uid) {
this.execute_r_uid = execute_r_uid;
}
private long started_time;
public boolean equals(Object other) {
RServeSession rs=(RServeSession)other;
if(rs.uid.equals(this.uid)){
return true;
}else{
return false;
}
}
}
@@ -0,0 +1,47 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.engines;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for App
*/
public class AppTest extends TestCase {
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Empty Test
*/
public void testApp()
{
assertTrue( true );
}
}
@@ -0,0 +1,23 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler</artifactId>
<version>1.0</version>
</parent>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler-exception</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>lib-scheduler-exception</name>
<description>Scheduler Libraries related to Exception</description>
<url>http://www.fourelementscapital.com</url>
<dependencies>
</dependencies>
</project>
@@ -0,0 +1,23 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionDependencyTimeout extends SchedulerException {
public ExceptionDependencyTimeout(String msg) {
super(msg);
}
public int getErrorcode() {
return DEPENDENCY_TIMEDOUT;
}
}
@@ -0,0 +1,22 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionExecutionTimeout extends ExceptionSchedulerTeamRelated {
public ExceptionExecutionTimeout(String msg) {
super(msg);
}
public int getErrorcode() {
return EXECUTION_TIMEOUT;
}
}
@@ -0,0 +1,24 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionPeerNoResponse extends SchedulerException {
public ExceptionPeerNoResponse(String msg) {
super(msg);
}
public int getErrorcode() {
return ERROR_SERVER_REMOVE_PEER_NO_RESPONSE;
}
}
@@ -0,0 +1,25 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionPeerRejected extends SchedulerException {
public ExceptionPeerRejected(String msg) {
super(msg==null?"No Room to Execute the Script":msg);
}
public int getErrorcode() {
return FAIL_PEER_REJECTED;
}
}
@@ -0,0 +1,28 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionPeerUnknown extends ExceptionSchedulerTeamRelated {
public ExceptionPeerUnknown(String msg) {
super(msg);
}
public int getErrorcode() {
return ERROR_PEER_UNKNOWN;
}
}
@@ -0,0 +1,25 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionRScriptNullError extends ExceptionSchedulerTeamRelated {
public ExceptionRScriptNullError(String msg) {
super(msg);
}
public int getErrorcode() {
return ERROR_PEER_R_RETURN_NULL;
}
}
@@ -0,0 +1,25 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionRServeUnixFailure extends ExceptionSchedulerTeamRelated {
public ExceptionRServeUnixFailure(String msg) {
super(msg);
}
public int getErrorcode() {
return ERROR_PEER_FAILED_2START_UNIX_RSERVE;
}
}
@@ -0,0 +1,27 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionRServeWindowsFailure extends ExceptionSchedulerTeamRelated {
public ExceptionRServeWindowsFailure(String msg) {
super(msg);
}
public int getErrorcode() {
return ERROR_PEER_FAILED_2START_WIN_RSERVE;
}
}
@@ -0,0 +1,25 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionRemoveFromQ extends ExceptionSchedulerTeamRelated {
public ExceptionRemoveFromQ(String msg) {
super(msg);
}
public int getErrorcode() {
return ERROR_SERVER_GENERAL_QUEUE_KICKCOUT;
}
}
@@ -0,0 +1,25 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionRemoveFromQNotInPeer extends SchedulerException {
public ExceptionRemoveFromQNotInPeer(String msg) {
super(msg);
}
public int getErrorcode() {
return ERROR_SERVER_REMOVE_NOT_RUNNING_INPEER;
}
}
@@ -0,0 +1,25 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionRscriptError extends SchedulerException {
public ExceptionRscriptError(String msg) {
super(msg);
}
public int getErrorcode() {
return ERROR_SERVER_GENERAL_SCRIPT_ERROR;
}
}
@@ -0,0 +1,18 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public abstract class ExceptionSchedulerTeamRelated extends SchedulerException {
public ExceptionSchedulerTeamRelated(String msg) {
super(msg);
}
}
@@ -0,0 +1,25 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionUnixPeerUnknown extends ExceptionSchedulerTeamRelated {
public ExceptionUnixPeerUnknown(String msg) {
super(msg);
}
public int getErrorcode() {
return ERROR_UNIX_PEER_UNKNOWN;
}
}
@@ -0,0 +1,23 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public class ExceptionWarningNoFullData extends SchedulerException {
public ExceptionWarningNoFullData(String msg) {
super(msg);
}
public int getErrorcode() {
return 0;
}
}
@@ -0,0 +1,55 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
public abstract class SchedulerException extends Exception {
public static final int ERROR_PEER_R_RETURN_NULL=2311;
public static final int ERROR_SERVER_GENERAL_SCRIPT_ERROR=2312;
public static final int ERROR_PEER_FAILED_2START_WIN_RSERVE=2113;
public static final int ERROR_PEER_FAILED_2START_UNIX_RSERVE=2214;
//public static final int ERROR_SERVER_GENERAL_EXE_TIMEOUT=2315;
public static final int ERROR_SERVER_GENERAL_QUEUE_KICKCOUT=2316;
public static final int ERROR_PEER_UNKNOWN=2319;
public static final int ERROR_SERVER_UNKNOWN=2320;
public static final int FAIL_PEER_REJECTED=2317;
public static final int ERROR_UNIX_PEER_UNKNOWN= 2220;
public static final int EXECUTION_TIMEOUT= 2315;
public static final int DEPENDENCY_TIMEDOUT=2321;
public static final int ERROR_SERVER_REMOVE_PEER_NO_RESPONSE=2317;
public static final int ERROR_SERVER_REMOVE_NOT_RUNNING_INPEER=2318;
private String message;
public SchedulerException(String msg){
this.message=msg;
}
public String getExceptionclass() {
return this.getClass().getName();
}
public abstract int getErrorcode();
public String getMessage() {
return message;
}
protected void setMessage(String msg) {
message=msg;
}
}
@@ -0,0 +1,47 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.exception;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for App
*/
public class AppTest extends TestCase {
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Empty Test
*/
public void testApp()
{
assertTrue( true );
}
}
@@ -0,0 +1,107 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler</artifactId>
<version>1.0</version>
</parent>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler-p2p</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>lib-scheduler-p2p</name>
<description>Scheduler Libraries related to P2P</description>
<url>http://www.fourelementscapital.com</url>
<dependencies>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>net.jxta</groupId>
<artifactId>jxta-jxse</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.19</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.42</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-coyote</artifactId>
<version>7.0.39</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.jcs</groupId>
<artifactId>jcs</artifactId>
<version>1.3.3.1</version>
<systemPath>${pom.basedir}/lib/jcs-1.3.3.1-RC.jar</systemPath>
<scope>system</scope>
</dependency>
<dependency>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-fileutils</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-db</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-r</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler-exception</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.fourelementscapital</groupId>
<artifactId>lib-scheduler-common</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,60 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p;
public class MessageBean {
public static String REPLYBACK="reply";
public static String TYPE_REQUEST="request";
public static String TYPE_RESPONSE="response";
public static String TYPE_INFO="info";
private String sender="";
private String type=TYPE_INFO;
private String command="";
private String reply="";
public String getSender() {
if(sender.equals("")){
sender=P2PService.getComputerName();
}
return sender;
}
public void setSender(String sender) {
this.sender = sender;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCommand() {
return command;
}
public void setCommand(String command) {
this.command = command;
}
public String getReply() {
return reply;
}
public void setReply(String reply) {
this.reply = reply;
}
}
@@ -0,0 +1,151 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p;
import java.net.URISyntaxException;
import java.security.MessageDigest;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.scheduler.config.Config;
import net.jxta.document.AdvertisementFactory;
import net.jxta.id.IDFactory;
import net.jxta.peer.PeerID;
import net.jxta.peergroup.PeerGroup;
import net.jxta.peergroup.PeerGroupID;
import net.jxta.pipe.PipeID;
import net.jxta.pipe.PipeService;
import net.jxta.protocol.PeerAdvertisement;
import net.jxta.protocol.PipeAdvertisement;
public class P2PAdvertisement {
public final static String PIPEIDSTR = "urn:jxta:uuid-59616261646162614E50472050325033C0C1DE89719B456691A596B983BA0E1004";
private String taskpip="taskpip";
private Logger log = LogManager.getLogger(P2PAdvertisement.class.getName());
public P2PAdvertisement () {
if(Config.getValue("p2p.taskpip")!=null && !Config.getValue("p2p.taskpip").equals("") ){
taskpip= Config.getValue("p2p.taskpip");
}
}
public P2PAdvertisement (boolean flag_helper) {
//taskpip="taskpip_helper";
//if(Config.getValue("p2p.taskpip.helper")!=null && !Config.getValue("p2p.taskpip.helper").equals("") ){
// taskpip= Config.getValue("p2p.taskpip.helper");
//}
if(Config.getValue("p2p.taskpip")!=null && !Config.getValue("p2p.taskpip").equals("") ){
taskpip= Config.getValue("p2p.taskpip");
}
}
public PipeAdvertisement getPipeAdvertisement(String computername,PeerGroup pg) {
//if(Config.getValue("p2p.taskpip")!=null && !Config.getValue("p2p.taskpip").equals("") ){
// taskpip= Config.getValue("p2p.taskpip");
//}
log.debug("creating advertishment for computer:"+computername+" pg:"+pg.getPeerGroupName()+" peerrname:"+pg.getPeerName());
PipeID pipeID = null;
try {
pipeID =createPipeID(pg.getPeerGroupID(),computername,taskpip);
log.debug("Pipe Advert ID:"+pipeID);
} catch (URISyntaxException use) {
use.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
PipeAdvertisement advertisement = (PipeAdvertisement) AdvertisementFactory.newAdvertisement(PipeAdvertisement.getAdvertisementType());
advertisement.setPipeID(pipeID);
advertisement.setType(PipeService.PropagateType);
advertisement.setName(computername);
return advertisement;
}
public PipeAdvertisement getPipeAdvertisement(PipeID pipeID, PeerGroup pg) {
PipeAdvertisement advertisement = (PipeAdvertisement) AdvertisementFactory.newAdvertisement(PipeAdvertisement.getAdvertisementType());
advertisement.setPipeID(pipeID);
advertisement.setType(PipeService.PropagateType);
return advertisement;
}
public PeerAdvertisement getPeerAdvertisement(String computername,PeerGroup pg) throws Exception {
PeerID peerID = null;
// if(Config.getValue("p2p.taskpip")!=null && !Config.getValue("p2p.taskpip").equals("") ){
// taskpip= Config.getValue("p2p.taskpip");
// }
log.debug("creating advertishment for computer:"+computername+" pg:"+pg.getPeerGroupName()+" peerrname:"+pg.getPeerName());
try {
peerID =createPeerID(pg.getPeerGroupID(),computername+"peer",taskpip);
} catch (URISyntaxException use) {
use.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
PeerAdvertisement advertisement = (PeerAdvertisement) AdvertisementFactory.newAdvertisement(PeerAdvertisement.getAdvertisementType());
//PipeID pipeID =MD4ID.createPipeID(pg.getPeerGroupID(),computername,"taskpip");
advertisement.setPeerID(IDFactory.newPeerID(PeerGroupID.worldPeerGroupID));
//advertisement.setPeerID(peerID);
advertisement.setPeerGroupID(IDFactory.newPeerGroupID(PeerGroupID.defaultNetPeerGroupID));
advertisement.setName(computername);
return advertisement;
}
private final byte[] generateHash(String clearTextID, String function) throws Exception {
String id;
if (function == null) {
id = clearTextID;
} else {
id = clearTextID + "" + function;
}
byte[] buffer = id.getBytes();
MessageDigest algorithm = null;
algorithm = MessageDigest.getInstance("MD5");
// Generate the digest.
algorithm.reset();
algorithm.update(buffer);
byte[] digest1 = algorithm.digest();
return digest1;
}
private final PipeID createPipeID( PeerGroupID peerGroupID
, String clearTextID
, String function) throws Exception {
byte[] digest = generateHash(clearTextID, function);
return IDFactory.newPipeID(peerGroupID, digest );
}
private final PeerID createPeerID(PeerGroupID peerGroupID
, String clearTextID
, String function) throws Exception {
byte[] digest = generateHash(clearTextID, function);
return IDFactory.newPeerID(peerGroupID, digest );
}
}
@@ -0,0 +1,360 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p;
import java.io.File;
import java.net.InetAddress;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.scheduler.config.Config;
import net.jxta.discovery.DiscoveryEvent;
import net.jxta.discovery.DiscoveryListener;
import net.jxta.discovery.DiscoveryService;
import net.jxta.peergroup.PeerGroup;
import net.jxta.pipe.PipeService;
import net.jxta.platform.NetworkConfigurator;
import net.jxta.platform.NetworkManager;
import net.jxta.protocol.DiscoveryResponseMsg;
import net.jxta.protocol.PeerAdvertisement;
import net.jxta.protocol.PipeAdvertisement;
public class P2PService extends Thread implements DiscoveryListener {
public final static String MESSAGE_NAME_SPACE = "PipeTaskMsg";
private static transient NetworkManager manager=null;
protected static HashMap machineList=new HashMap();
//protected static Vector messages=new Vector();
public static Vector messages=new Vector();
//private static long discoveryWaitTime=1000L;
private static transient DiscoveryService discovery=null;
private static PipeService pipeService=null;
//private static InputPipe inputPipe = null;
//private static PipeAdvertisement pipeAdv;
private static PeerGroup netPeerGroup=null;
private static Date startedTime=null;
//private static PeerAdvertisement peerAdv=null;
private Logger log=LogManager.getLogger(P2PService.class.getName());
private static String defaultP2PGroup="DiscoveryServer";
private static String defaultP2PCache=""; // addition because there is a possibility that .cache folder cause an error when restarting .. bug when restarting (20140411)
public static void setCache(){
// Addition because there is a possibility that .cache folder cause an error when restarting .. bug when restarting (20140411)
if(Config.getValue("p2p.cachepath")!=null && !Config.getValue("p2p.cachepath").equals("") ){
defaultP2PCache=Config.getValue("p2p.cachepath")+".cache";
} else{
defaultP2PCache=".cache";
}
}
public static void removeCache(){
setCache();
String cachePath=defaultP2PCache;
File tempFile = new File(cachePath);
try {
if(tempFile.isDirectory()){
FileUtils.deleteDirectory(tempFile);
System.out.println("removing .Cache Directory: " + cachePath);
} else {
System.out.println(".Cache Directory Does Not Exits");
}
} catch (Exception e) {
// e.printStackTrace();
// System.out.println("P2PService.Removing .cache :Error::"+e.getMessage());
}
}
public static NetworkManager getManager(){
Logger log = LogManager.getLogger(P2PService.class.getName());
if(P2PService.manager==null){
try {
if(Config.getValue("p2p.groupname")!=null && !Config.getValue("p2p.groupname").equals("") ){
defaultP2PGroup= Config.getValue("p2p.groupname");
}
String manname=defaultP2PGroup+getComputerName();
setCache();
String cachePath=defaultP2PCache;
System.out.println("set .Cache Directory: " + cachePath);
P2PService.manager = new NetworkManager(NetworkManager.ConfigMode.ADHOC, manname, new File(new File(cachePath), manname).toURI());
if(Config.getValue(Config.P2P_NO_MULTICAST)!=null
&& Config.getValue(Config.P2P_NO_MULTICAST).equalsIgnoreCase("true")){
NetworkConfigurator configurator=P2PService.manager.getConfigurator();
try{
configurator.setUseMulticast(false);
configurator.setHttpEnabled(true);
configurator.setHttpIncoming(true);
//configurator.setTcpEnabled(true);
//configurator.setTcpIncoming(true);
log.info("Disabling IP Multicast");
}catch(Exception e){
log.error("Error while configuring network, e:"+e.getMessage());
}
}
//Logger log= Logger.getLogger(P2PService.class);
PeerGroup pg= P2PService.manager.startNetwork();
log.debug("pg: group_name:"+pg.getPeerGroupName());
log.debug("pg: peer_peer:"+pg.getPeerName());
log.debug("pg: peer name:"+pg.getPeerAdvertisement().getName());
//log.debug("pg: pipe advertisment:"+));
log.debug("pg: getPeerID unique value:"+pg.getPeerID().getUniqueValue());
} catch (Exception e) {
e.printStackTrace();
System.out.println("----------------------- P2PService.getManager() :Error::"+e.getMessage());
//System.exit(-1);
}
}
return P2PService.manager;
}
public static void stopNetwork(){
if(P2PService.manager!=null){
try {
P2PService.manager.stopNetwork();
P2PService.discovery=null;
P2PService.netPeerGroup=null;
P2PService.manager=null;
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static PeerGroup getPeerGroup(){
if(netPeerGroup==null){
netPeerGroup = getManager().getNetPeerGroup();
}
return netPeerGroup;
}
public static DiscoveryService getDiscoveryService() {
if(discovery==null){
discovery = getPeerGroup().getDiscoveryService();
}
return discovery;
}
public static PipeService getPipeService() {
if(pipeService==null){
pipeService = getPeerGroup().getPipeService();
}
return pipeService;
}
public static PipeService getNewPipeService() {
pipeService = getPeerGroup().getPipeService();
return pipeService;
}
/*
public static PeerAdvertisement getPeerAdvertisement() {
if(peerAdv==null){
P2PAdvertisement ad=new P2PAdvertisement();
try{
peerAdv = ad.getPeerAdvertisement(getComputerName(),getPeerGroup());
}catch(Exception e){
e.printStackTrace();
}
}
return peerAdv;
}
*/
/*
public void run() {
try{
netPeerGroup = getManager().getNetPeerGroup();
// get the discovery service
discovery = netPeerGroup.getDiscoveryService();
pipeService = netPeerGroup.getPipeService();
long waittime = 10 * 1000L;
String computername=getComputerName();
P2PAdvertisement ad=new P2PAdvertisement();
PeerAdvertisement mdadv = ad.getPeerAdvertisement(computername,netPeerGroup);
discovery.publish(mdadv,DiscoveryService.INFINITE_LIFETIME,DiscoveryService.INFINITE_LIFETIME);
discovery.remotePublish(mdadv,DiscoveryService.INFINITE_LIFETIME);
pipeAdv = ad.getPipeAdvertisement(computername,netPeerGroup);
inputPipe = pipeService.createInputPipe(pipeAdv, new IncomingMessage(null) );
log.debug("----------->publishing client node:"+computername);
//while (true) {
// try {
// // System.out.println("Sleeping for :" + waittime);
// Thread.sleep(waittime);
// log.debug("thread sleeping "+waittime);
// } catch (Exception e) {// ignored
// }
//}
}catch(Exception e){
log.error("p2p thread couldn't be started, task scheduler load balancing might not work in this computer");
}
}
*/
public static Date getPeerStartedTime(){
return startedTime;
}
//protected static void setPeerStarted(){
public static void setPeerStarted(){
startedTime=new Date();
}
/**
* @deprecated
* @param clientname
* @param message
* @throws Exception
*/
public static void sendMessage(String clientname, String message) throws Exception {
try{
manager.getNetPeerGroup();
PipeAdvertisement pipeAdv = new P2PAdvertisement().getPipeAdvertisement(clientname,netPeerGroup);
//OutgoingMessageCompose omc=new OutgoingMessageCompose(){
//};
//OutgoingMessage ogM=new OutgoingMessage(null,message);
//pipeService = P2PService.getPipeService();
//pipeService.createOutputPipe(pipeAdv,ogM);
}catch(Exception e){
e.printStackTrace();
}
}
private static String THIS_HOST_NAME=null;
public synchronized static String getComputerName() {
String computername="[unknown]";
try{
if(P2PService.THIS_HOST_NAME==null){
computername=InetAddress.getLocalHost().getHostName();
P2PService.THIS_HOST_NAME=computername;
}else{
computername=P2PService.THIS_HOST_NAME;
}
}catch(Exception e){
e.printStackTrace();
}
return computername;
}
public Map getClientList() {
DiscoveryService discovery = P2PService.getDiscoveryService();
new Thread("Adv poll") {
public void run() {
int sleepy=3000;
DiscoveryService discovery = P2PService.getDiscoveryService();
discovery.addDiscoveryListener(new P2PService());
P2PService.getDiscoveryService().getRemoteAdvertisements(null,DiscoveryService.PEER,null,null,1);
log.debug("Adv poll created");
try {
sleep(sleepy);
}
catch(InterruptedException e) {}
}
}.start();
try {
sleep(1000);
} catch(InterruptedException e) {}
return machineList;
}
public static Map getClientListFromMemory() {
return machineList;
}
public void discoveryEvent(DiscoveryEvent ev) {
if(Config.getValue("p2p.groupname")!=null && !Config.getValue("p2p.groupname").equals("") ){
defaultP2PGroup= Config.getValue("p2p.groupname");
}
DiscoveryResponseMsg res = ev.getResponse();
PeerAdvertisement adv;
Enumeration en = ev.getSearchResults();
log.debug("discoveryEvent() called");
if (en != null) {
while (en.hasMoreElements()) {
adv = (PeerAdvertisement) en.nextElement();
log.debug(" adv.getName(): "+adv.getName());
if(adv.getName().startsWith(defaultP2PGroup)){
//String s = adv.getName().replace("DiscoveryServer","");
//PipeAdvertisement av=new P2PAdvertisement().getPipeAdvertisement(s,P2PService.getManager().getNetPeerGroup());
//P2PService.machineList.put(av.getPipeID(),s);
}else{
PipeAdvertisement av=new P2PAdvertisement().getPipeAdvertisement(adv.getName(),P2PService.getManager().getNetPeerGroup());
P2PService.machineList.put(av.getPipeID(),adv.getName());
}
}
}
//System.out.println("Module specific id :"+res.getPeerAdvertisement());
}
}
@@ -0,0 +1,389 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.listener;
import java.io.StringReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.Vector;
import org.apache.commons.digester.Digester;
import org.apache.jcs.JCS;
import org.apache.jcs.engine.behavior.IElementAttributes;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.scheduler.p2p.MessageBean;
import com.fourelementscapital.scheduler.p2p.msg.MessageNames;
import com.fourelementscapital.scheduler.p2p.msg.ReceiveMessage;
import net.jxta.endpoint.Message;
import net.jxta.endpoint.MessageElement;
import net.jxta.pipe.PipeMsgEvent;
import net.jxta.pipe.PipeMsgListener;
public class IncomingMessage implements PipeMsgListener {
private IncomingMessageCallBack imi=null;
public IncomingMessage(IncomingMessageCallBack imi ){
this.imi=imi;
}
private Logger log = LogManager.getLogger(IncomingMessage.class.getName());
public final static String MESSAGE_NAME_SPACE = "PipeTaskMsg";
//protected static Vector<MessageBean> messages=new Vector<MessageBean>();
public static Vector<MessageBean> messages=new Vector<MessageBean>();
//protected static TreeMap<String,String> cachedPeers=new TreeMap<String,String>();
private static JCS cachedPeers=null;
protected static Map<String,Integer> executingpeers=Collections.synchronizedMap(new TreeMap<String,Integer>());
protected static Map<String,Map> executingpeerstime=Collections.synchronizedMap(new TreeMap<String,Map>());
protected static TreeMap<String,String> cachedStatistics=new TreeMap<String,String>();
protected static TreeMap<String,String> cachedRPackages=new TreeMap<String,String>();
protected static TreeMap<String,String> cachedPeerQueueStat=new TreeMap<String,String>();
/*
private static ExecutorService incomingService= Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
public void pipeMsgEvent(PipeMsgEvent event) {
Future fu=incomingService.submit(
new Callable<String>() {
public String call(){
//return new Integer(new LoadBalancingHSQLQueue().startedIfNotStarted1(sc_id,tri_time,peer));
IncomingMessage im=new IncomingMessage(this.imi);
im.pipeMsgEvent2(this.event);
return "";
}
private IncomingMessageCallBack imi=null;
private PipeMsgEvent event=null;
public Callable<String> init(IncomingMessageCallBack imi,PipeMsgEvent event){
this.imi=imi;
this.event=event;
return this;
}
}.init(this.imi, event));
}
*/
public void pipeMsgEvent(PipeMsgEvent event) {
log.debug("message received...");
try{
if(this.imi!=null){this.imi.before(event);}
Message msg;
try {
msg = event.getMessage();
if (msg == null) {
log.error("message is null");
return;
}
} catch (Exception e) {
e.printStackTrace();
return;
}
// get all the message elements
Message.ElementIterator en = msg.getMessageElements();
if (!en.hasNext()) {
log.error("en has no elements");
return;
}
// get the message element in the name space PipeClient.MESSAGE_NAME_SPACE
MessageElement msgElement = msg.getMessageElement(null, MESSAGE_NAME_SPACE);
MessageBean mb=null;
String xmsg=msgElement.toString();
try{
mb= parseMessage(xmsg);
log.debug("message from :"+mb.getSender()+" msg:"+mb.getCommand());
}catch(Exception e){
//e.printStackTrace();
log.error("Error 1:"+e.getMessage());
}
if(this.imi!=null){this.imi.after(event);}
if(mb!=null){
HashMap attachments=new HashMap();
while(en.hasNext()){
MessageElement me=(MessageElement)en.next();
if(!me.getElementName().equals(MESSAGE_NAME_SPACE)){
//attachmentName=me.getElementName();
//attachment=me.toString();
attachments.put(me.getElementName(),me.toString());
}
}
//new P2PPipeLog().logIncoming(mb);
try{
if(attachments.get(MessageNames.MESSAGE_BEAN_NAME)!=null ){
new ReceiveMessage(attachments).process();
}else{
/*
IncomingMessageParser imp= new IncomingMessageParser(mb,msgElement);
imp.setAttachement(attachments);
imp.parse();
*/
}
}catch(Exception e){
log.error("Error while msg:"+msgElement.toString()+" Error:"+e.getMessage());
}
}
}catch(Exception e){
// log.error("Error Msg:"+e.getMessage());
log.error("Error while parsing or getting data:"+e.getMessage());
e.printStackTrace();
}
}
public static Vector<MessageBean> getMessages(){
return messages;
}
private MessageBean parseMessage(String msg) throws Exception {
Digester digester = new Digester();
digester.setValidating(false);
digester.addObjectCreate("message", MessageBean.class);
digester.addBeanPropertySetter("message/type");
digester.addBeanPropertySetter("message/command");
digester.addBeanPropertySetter("message/sender");
digester.addBeanPropertySetter("message/reply");
MessageBean ve= (MessageBean) digester.parse(new StringReader(msg));
return ve;
}
//0 to delete
//-1 delete all
//
public static int ACTION_PEER_ADD=1;
public static int ACTION_PEER_REMOVE=0;
public static int ACTION_PEER_REMOVEALL=-1;
/*
public synchronized static void peersUpdate(int action, String peer,String status){
if(action==ACTION_PEER_REMOVE && cachedPeers.containsKey(peer)) cachedPeers.remove(peer);
if(action==ACTION_PEER_REMOVEALL) cachedPeers.clear();
if(action==ACTION_PEER_ADD) cachedPeers.put(peer,status);
}
*/
public synchronized static void peersUpdate(String peer,String status){
try{
if(cachedPeers==null){
cachedPeers=JCS.getInstance("cachedPeers$$");
}
IElementAttributes att= cachedPeers.getDefaultElementAttributes();
att.setMaxLifeSeconds(4);
cachedPeers.put(peer, status,att);
}catch(Exception e){
}
//if(action==ACTION_PEER_REMOVE && cachedPeers.containsKey(peer)) cachedPeers.remove(peer);
//if(action==ACTION_PEER_REMOVEALL) cachedPeers.clear();
//if(action==ACTION_PEER_ADD) cachedPeers.put(peer,status);
}
public synchronized static void updateExecutingPeers(String peer,String status, int scheduler_id) {
if(status.equalsIgnoreCase("BUSY")&& scheduler_id>0){
executingpeers.put(peer, scheduler_id);
}
if(status.equalsIgnoreCase("NOBUSY")){
executingpeers.remove(peer);
}
}
/**
* @deprecated
* @param peer
* @param status
* @param scheduler_id
* @param tr_time
* this method should be removed eventually once all the HSQL supported peer
*/
public synchronized static void updateExecutingPeersTime(String peer,String status, int scheduler_id,long tr_time) {
if(status.equalsIgnoreCase("BUSY")&& scheduler_id>0){
Map tm;
if(executingpeerstime.get(peer)==null){
tm=Collections.synchronizedMap(new TreeMap());
}else{
tm=(Map)executingpeerstime.get(peer);
}
if(tm!=null){
tm.put(scheduler_id, tr_time);
executingpeerstime.put(peer, tm);
}
}
if(status.equalsIgnoreCase("NOBUSY")){
executingpeerstime.remove(peer);
}
}
/**
* @deprecated
* @param peer
* @param scheduler_id
* @param trigger_timg
* this method should be removed eventually once all the HSQL supported peer
*/
public synchronized static void updateFinishedPeersTime(String peer, int scheduler_id, long trigger_timg) {
if(scheduler_id>0){
Map tm;
if(executingpeerstime.get(peer)!=null){
tm=(Map)executingpeerstime.get(peer);
if(tm!=null && tm.get(scheduler_id)!=null && ((Long)tm.get(scheduler_id)).longValue()==trigger_timg || trigger_timg==0){
if(tm!=null){
tm.remove(scheduler_id);
}
}
if(tm!=null && tm.keySet().size()==0){
executingpeerstime.remove(peer);
}
}
}
}
public synchronized static void updatePeerStatistics(String peer,String status) {
cachedStatistics.put(peer, status);
}
public synchronized static Map getPeerStatistics() {
return cachedStatistics;
}
public synchronized static void updatePeerQueueStat(String peer,String status) {
cachedPeerQueueStat.put(peer, status);
}
public synchronized static Map getPeerQueueStat() {
return cachedPeerQueueStat;
}
public synchronized static void updatePeerRPackages(String peer,String pkgs) {
cachedRPackages.put(peer, pkgs);
}
public synchronized static Map getPeerRPackages() {
return cachedRPackages;
}
public static Map<String,Integer> getExecutingPeers(){
return executingpeers;
}
public static synchronized Map<String,Map> getExecutingPeersTime(){
return executingpeerstime;
}
public static HashMap getCachedPeers(){
HashMap rtn=null;
if(cachedPeers!=null){
rtn=cachedPeers.getMatching("^[A-Za-z0-9]+$");
}
return (rtn!=null)?rtn:new HashMap(); //all alpha numeric keys.
}
private static JCS cachedPeerResp4Task=null;
/**
* This method is to store the executing task in cache that expires
* after certain period, so that scheduler kicks out the task from the queue, after 5 minutes of non-response of the task of the peer.
* @param scheduler_id
* @param trigger_time
*/
public synchronized static void peerRespRecencyOnTask(int scheduler_id, long trigger_time){
try{
if(cachedPeerResp4Task==null){
cachedPeerResp4Task=JCS.getInstance("cachedPeerResp4Task$$$");
}
IElementAttributes att= cachedPeerResp4Task.getDefaultElementAttributes();
att.setMaxLifeSeconds(180); //3 minutes
String value=scheduler_id+"_"+trigger_time;
//if(cachedPeerResp4Task.get(value)!=null) cachedPeerResp4Task.remove(value);
cachedPeerResp4Task.put(value,"true",att);
}catch(Exception e){
Logger log = LogManager.getLogger(IncomingMessage.class.getName());
log.error("Error:"+e.getMessage());
}
}
/**
* this method to check wheather the executing task is responded by the peer
* to kick out the task from the queue, after 5 minutes of non-response of the task of the peer.
* @param scheduler_id
* @param trigger_time
* @return
*/
public synchronized static boolean isRespRecencyOnTask(int scheduler_id, long trigger_time){
String value=scheduler_id+"_"+trigger_time;
if(cachedPeerResp4Task!=null && cachedPeerResp4Task.get(value)!=null){
return true;
}
return false;
}
}
@@ -0,0 +1,17 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.listener;
import net.jxta.pipe.PipeMsgEvent;
public class IncomingMessageCallBack {
public void before(PipeMsgEvent event){}
public void after(PipeMsgEvent event){}
}
@@ -0,0 +1,156 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.listener;
import java.io.IOException;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.scheduler.p2p.MessageBean;
import com.fourelementscapital.scheduler.p2p.msg.CommunicationTrace;
import net.jxta.document.Advertisement;
import net.jxta.endpoint.Message;
import net.jxta.endpoint.StringMessageElement;
import net.jxta.pipe.OutputPipe;
import net.jxta.pipe.OutputPipeEvent;
import net.jxta.pipe.OutputPipeListener;
public class OutgoingMessage implements OutputPipeListener{
private static int maxDebugErrCounter=0;
private OutgoingMessageCallBack omc=null;
public final static String MESSAGE_NAME_SPACE = "PipeTaskMsg";
private MessageBean smsg;
private Logger log = LogManager.getLogger(OutgoingMessage.class.getName());
private String destination=null;
private boolean messageSent=false;
private Map<String,String> attachments=null;
//private String attachmentName=null;
public OutgoingMessage(OutgoingMessageCallBack omc, MessageBean msg, String destination){
this.omc=omc;
this.smsg=msg;
this.destination=destination;
if(this.omc!=null){
this.omc.setDestination(destination);
}
}
public void setAttachment(Map<String,String> attachments) {
this.attachments=attachments;
}
public void outputPipeEvent(OutputPipeEvent event) {
//log.debug("message sent...cmd:"+this.smsg.getCommand());
OutputPipe outputPipe = event.getOutputPipe();
if(this.omc!=null){this.omc.before(event);}
Message msg;
try {
Advertisement adv=outputPipe.getAdvertisement();
//log.debug("message sent...cmd:"+this.smsg.getCommand()+", adv:type:");
msg = new Message();
StringMessageElement sme = new StringMessageElement(MESSAGE_NAME_SPACE, getXML(this.smsg), null);
msg.addMessageElement(null, sme);
if(attachments!=null){
for(Iterator<String> it=attachments.keySet().iterator();it.hasNext();){
String ky=it.next();
String val=attachments.get(ky);
if(val!=null){
StringMessageElement sme1=new StringMessageElement(ky,val,null);
msg.addMessageElement(null, sme1);
}
}
//System.out.println("~~~~~~~~~~~~OutgoingMessage.attachment:"+msg.toString());
}
//boolean msgsent=false;
//tries 5 times, maximum waits upto 400 //nano seconds
int numofTries=(omc!=null)?omc.numberOfTries:OutgoingMessageCallBack.PRIORITY_ZERO;
Date start=new Date();
for(int i=0;(i<numofTries && !this.messageSent);i++){
boolean taskvalided=true;
if(this.omc!=null && !this.omc.validateBeforeSend()){
taskvalided=false;
}
if(this.omc==null || taskvalided){
this.messageSent=outputPipe.send(msg);
}else{
i=numofTries;
//exit the loop;
}
log.debug("Msg:sent to client:getMessageElements:"+msg.getMessageElements().toString()+" this.messageSent:"+this.messageSent);
if(!this.messageSent && taskvalided){
try{
//log.error("Output pipe of "+this.destination+" is not responding waiting "+40*i+" ms" +" ~~Msg:"+getXML(this.smsg));
Thread.sleep(50);
}catch(Exception e){}
}
}
long diff=new Date().getTime()-start.getTime();
if(!this.messageSent && OutgoingMessage.maxDebugErrCounter<1000){
//display only 1000 errors, this will be reset on restarting the server/peer to avoid too many messsages in error log.
log.error("Message couldn't be sent to peer "+this.destination+" Tried:"+numofTries+"times Took:"+diff+"ms Msg:"+getXML(this.smsg));
OutgoingMessage.maxDebugErrCounter++;
}
if(this.messageSent && attachments!=null){
new CommunicationTrace(this.destination).outgoing(this.attachments);
}
//log.debug("Msg:"+getXML(this.smsg));
if(this.smsg!=null){
//new P2PPipeLog().logOutgoing(this.smsg,this.destination);
}
} catch (IOException e) {
e.printStackTrace();
//System.exit(-1);
//ClientErrorMgmt.reportError(e, "To Peer:"+ this.destination+" command:"+this.smsg.getCommand());
}finally{
if(this.omc!=null){this.omc.after(event);}
if(this.omc!=null && !this.messageSent){this.omc.onFail(event,this.smsg,this.destination);}
}
//msg=null;
//outputPipe=null;
}
private String getXML(MessageBean msg){
String rtn="<?xml version=\"1.0\"?><message>";
rtn+="<sender>"+msg.getSender()+"</sender>";
rtn+="<reply>"+msg.getReply()+"</reply>";
rtn+="<type>"+msg.getType()+"</type>";
rtn+="<command>"+msg.getCommand()+"</command>";
rtn+="</message>";
return rtn;
}
}
@@ -0,0 +1,69 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.listener;
import java.util.Map;
import net.jxta.pipe.OutputPipeEvent;
import com.fourelementscapital.scheduler.p2p.MessageBean;
import com.fourelementscapital.scheduler.p2p.msg.PostMessage;
public abstract class OutgoingMessageCallBack {
public static int PRIORITY_ZERO=1;
public static int PRIORITY_LOW=5;
public static int PRIORITY_NORMAL=10;
public static int PRIORITY_HIGH=50;
public static int PRIORITY_VERY_HIGH=100;
public static int PRIORITY_VERY_VERY_HIGH=1000;
protected String tuid=null;
private String destination=null;
private String scheduler_id;
private Map data=null;
private PostMessage postmessage=null;
public OutgoingMessageCallBack(){}
public OutgoingMessageCallBack(PostMessage pm){
this.postmessage=pm;
}
public OutgoingMessageCallBack(String tuid, Map data){this.tuid=tuid;this.data=data;}
protected static int PRIORITY_LOOP_FREQ=40;
protected int numberOfTries=PRIORITY_ZERO;
public void before(OutputPipeEvent pipe){}
public void after(OutputPipeEvent pipe){}
public void onFail(OutputPipeEvent pipe, MessageBean mbean, String destination){}
public boolean validateBeforeSend(){return true;}
public void setPriority(int priority){
this.numberOfTries=priority;
}
public String getTuid(){
return this.tuid;
}
public String getDestination(){
return this.destination;
}
protected void setDestination(String destination){
this.destination=destination;
}
protected Map getData(){
return this.data;
}
protected PostMessage getPostMessage(){
return this.postmessage;
}
}
@@ -0,0 +1,127 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.listener;
import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.fourelementscapital.scheduler.config.Config;
public class P2PPipeLog {
private static String nextLineChar="\r\n";
private Vector loggable=new Vector();
public P2PPipeLog() {
//loggable.add("\\bEXECUTETASK\\W+(?:\\w+\\W+){1,5}?CONFIRM\\b"); //client receives from server
//loggable.add("\\bEXECUTETASK\\W+(?:\\w+\\W+){1,6}?CONFIRM\\b"); //client receives from server
//loggable.add("\\bEXECUTETASK\\W+(?:\\w+\\W+){1,5}?TENDER\\b"); //client receives from server
//loggable.add("\\bEXECUTETASK\\W+(?:\\w+\\W+){1,4}?FINISHED\\b"); //server receives from client
//loggable.add("\\bEXECUTETASK\\W+(?:\\w+\\W+){1,4}?BID\\b"); //server receives from client
//loggable.add("^EXECUTEFAILED"); //server receives from client
//loggable.add("^RESTART_PEER"); //server receives from client
//loggable.add("^STATISTICS"); //server receives from client
//
//loggable.add("\\bEXECUTETASK\\W+(?:\\w+\\W+){1,4}?TENDER\\b"); //server receives from client
//loggable.add("^R_PACKAGES");
//loggable.add("^R_PACKAGES_DATA");
//loggable.add("^EXECUTESCRIPT");
}
//public void logIncoming(MessageBean mb) {
//if(validate(mb.getCommand())){
// String msg="From:"+mb.getSender()+" Comm:"+mb.getCommand();
//reportLog(msg);
//}
//}
//public void logOutgoing(MessageBean mb, String destination) {
//if(validate(mb.getCommand())){
// String msg="To:"+destination+" Comm:"+mb.getCommand();
// reportLog(msg);
///}
//}
private boolean validate(String s){
boolean rtn=false;
for(Iterator<String> it=this.loggable.iterator();(it.hasNext() && !rtn);){
Pattern p = Pattern.compile(it.next(), Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(s);
rtn= m.find();
}
return rtn;
}
public static void sendMsg(String msg, String toPeer) {
reportLog("To--->"+toPeer+" :"+msg);
}
public static void receiveMsg(String msg, String fromPeer) {
reportLog("<---------From "+fromPeer+" :"+msg);
}
private static void reportLog( String msg){
msg=(msg==null)?"":msg;
String root=Config.getString("log_error_folder");
Date d = new Date();
String folder =root+"p2p";
if (!new File(folder).isDirectory()) {
new File(folder).mkdirs();
}
String fname=root+"p2p"+File.separator+new SimpleDateFormat("dd_MM_yyyy").format(d)+".log";
File file=new File(fname);
try {
boolean append = true;
FileWriter fw = new FileWriter(file,append);
SimpleDateFormat sd=new SimpleDateFormat("HH:mm:ss SSS");
String logmessage=sd.format(new Date())+" "+msg;
if (!file.exists()) {
file.createNewFile();
}
fw.append(logmessage+nextLineChar);
fw.flush();
fw.close();
//String consoleoutput=Config.getString("log_error_to_console");
//if(consoleoutput!=null && consoleoutput.equalsIgnoreCase("yes")){
//System.out.println(logmessage);
//}
//
}
catch (Exception ex1) {
ex1.printStackTrace();
}
}
}
@@ -0,0 +1,22 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.listener;
public class P2PTransportMessage {
public static String COMMAND_STATUS="STATUS";
public static String COMMAND_STATISTICS="STATISTICS";
public static String COMMAND_R_PACKAGES="R_PACKAGES";
public static String COMMAND_R_PACKAGES_DATA="R_PACKAGES_DATA";
public static String COMMAND_PEER_QUEUE="PEER_QUEUE";
}
@@ -0,0 +1,115 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.scheduler.p2p.websocket.TomcatWSConsole;
public class CommunicationTrace {
private String peername=null;
public static ArrayList<String> PEERS=new ArrayList<String>();
public static ArrayList<String> IGNORE_CLASS=new ArrayList<String>();
private ArrayList ignoreprops=new ArrayList();
private static final int OUTGOING=1;
private static final int INCOMING=2;
private Logger log = LogManager.getLogger(CommunicationTrace.class.getName());
public CommunicationTrace(String p){
this.peername=p;
if(!IGNORE_CLASS.contains("PeerOnlineStatus")){
IGNORE_CLASS.add("PeerOnlineStatus");
}
ignoreprops.add("class");
ignoreprops.add("RendezVousPropagatejxta-NetGroup");
ignoreprops.add("JxtaWireHeader");
ignoreprops.add("msgCreator");
ignoreprops.add("msgRecipient");
ignoreprops.add(MessageNames.MESSAGE_BEAN_NAME);
ignoreprops.add(MessageNames.MESSAGE_TYPE_CALLBACK);
ignoreprops.add("next_trigger_time");
}
public void outgoing(Map attachment){
if(PEERS.contains(this.peername)){
produceOutPut(OUTGOING,attachment);
}
}
public void incoming(Map attachment){
if(PEERS.contains(this.peername)){
produceOutPut(INCOMING,attachment);
}
}
private void produceOutPut(int direction ,Map attachment){
String handlerclass=(String)attachment.get(MessageNames.MESSAGE_BEAN_NAME);
handlerclass=handlerclass.replaceAll("^(.*\\.)(\\S+)$", "$2");
SimpleDateFormat sdf=new SimpleDateFormat("HH:mm:ss S");
if(!IGNORE_CLASS.contains(handlerclass)){
String d="<span class='time'>"+sdf.format(new Date())+"</span>";
String line="";
String pcname=this.peername;
try{
pcname=pcname.toLowerCase().replaceAll("4ecap(pc|sv|lt|vm)sg(\\d+)" , "$1$2");
}catch(Exception e){log.error("error while parsing computer name:"+e.getMessage()); }
if(direction==OUTGOING) line+=d+" :<span class='hclass'>"+handlerclass+"</span>:<span class='p "+pcname+"'>"+this.peername+"</span><span class='out'>--&gt;</span>";
if(direction==INCOMING) line+=d+" :<span class='hclass'>"+handlerclass+"</span>:<span class='p "+pcname+"'>"+this.peername+"</span><span class='in'>&lt;--</span>";
for(Iterator<String> i=attachment.keySet().iterator();i.hasNext();){
String ky=i.next();
if(!ignoreprops.contains(ky) && attachment.get(ky)!=null){
//log.debug(""+this.peername+" class:"+handlerclass+" data:"+attachment);
if(ky.equals("scheduler_id")){
line+=ky+":<span class='sc_id'>"+attachment.get(ky)+"</span>, ";
}else{
line+=ky+":"+attachment.get(ky)+", ";
}
}
}
//out("\n");
out(line);
}
}
private void out(String s) {
//System.out.print(s);
//WSServer.consoleToAll(s);
TomcatWSConsole.consoleToAll(s);
}
}
@@ -0,0 +1,80 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg;
import java.lang.reflect.Constructor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.scheduler.exception.SchedulerException;
public abstract class ExceptionMessageHandler extends MessageHandler {
private Logger log = LogManager.getLogger(ExceptionMessageHandler.class.getName());
private String exceptionMessage=null;
private String exceptionClass=null;
private SchedulerException ex=null;
public void exception(SchedulerException se){
if(se!=null){
this.exceptionClass=se.getClass().getName();
this.exceptionMessage=se.getMessage();
}
}
public SchedulerException exception(){
//SchedulerException se=null;
if(this.ex==null && this.exceptionClass!=null){
try{
Class c=Class.forName(this.exceptionClass);
Constructor ct = c.getConstructor(String.class);
this.ex=(SchedulerException)ct.newInstance(this.exceptionMessage);
}catch(Exception e){
log.error("Exception class:"+this.exceptionClass+", error message:"+e.getMessage());
}
}
return this.ex;
}
public String getExceptionMessage() {
return exceptionMessage;
}
public void setExceptionMessage(String exceptionMessage) {
this.exceptionMessage = exceptionMessage;
}
public String getExceptionClass() {
return exceptionClass;
}
public void setExceptionClass(String exceptionClass) {
this.exceptionClass = exceptionClass;
}
}
@@ -0,0 +1,95 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.scheduler.p2p.listener.OutgoingMessageCallBack;
public abstract class MessageHandler {
//private Properties
//public MessageHandlerAbstract
private String msgCreator;
private String msgRecipient;
private String responseJSON;
public String getMsgCreator() {
return msgCreator;
}
public void setMsgCreator(String msgCreator) {
this.msgCreator = msgCreator;
}
public String getMsgRecipient() {
return msgRecipient;
}
public void setMsgRecipient(String msgRecipient) {
this.msgRecipient = msgRecipient;
}
public String getResponseJSON() {
return responseJSON;
}
public void setResponseJSON(String responseJSON) {
this.responseJSON = responseJSON;
}
public void setPriority(int priority) {
this.priority = priority;
}
//private String messageFrom=null;
private int priority=OutgoingMessageCallBack.PRIORITY_NORMAL;
//private Logger log = LogManager.getLogger(MessageHandler.class.getName());
//public abstract MessageHandlerAbstract getThisMessageHandler();
public abstract Map executeAtDestination();
public int getPriority() {
return this.priority ;
}
public abstract void onSendingFailed();
}
@@ -0,0 +1,18 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg;
public class MessageNames {
public static String MESSAGE_BEAN_NAME="__msgBeanName__";
public static String MESSAGE_TYPE_CALLBACK="__msgCallBack__";
public static String RSCRIPT="RScript";
public static String RSCRIPT_ENGINE="RScriptEngine";
}
@@ -0,0 +1,20 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg;
import java.util.Map;
public interface PostCallBack {
public static String IGNORE_CALLBACK="IGNORE_CALLBACK";
public void callBack(Map data);
public void onCallBackSendingFailed();
}
@@ -0,0 +1,160 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.scheduler.p2p.MessageBean;
import com.fourelementscapital.scheduler.p2p.P2PAdvertisement;
import com.fourelementscapital.scheduler.p2p.P2PService;
import com.fourelementscapital.scheduler.p2p.listener.OutgoingMessage;
import com.fourelementscapital.scheduler.p2p.listener.OutgoingMessageCallBack;
import net.jxta.peergroup.PeerGroup;
import net.jxta.pipe.OutputPipeEvent;
import net.jxta.pipe.PipeService;
import net.jxta.protocol.PipeAdvertisement;
public class PostMessage {
//private String sender;
//private String message;
protected MessageHandler mha;
protected String recipient=null;
protected Logger log = LogManager.getLogger(PostMessage.class.getName());
protected boolean callback=false;
protected OutgoingMessageCallBack omc=null;
public PostMessage(MessageHandler mha,String recipient){
this.mha=mha;
this.recipient=recipient;
this.omc=new OutgoingMessageCallBack(this){
@Override
public void onFail(OutputPipeEvent pipe, MessageBean mbean,String destination) {
if(getPostMessage().callback && getPostMessage().mha instanceof PostCallBack){
((PostCallBack)(getPostMessage().mha)).onCallBackSendingFailed();
}else{
getPostMessage().mha.onSendingFailed();
}
}
};
omc.setPriority(this.mha.getPriority());
}
public PostMessage(MessageHandler mha,String recipient,OutgoingMessageCallBack omc1){
this.mha=mha;
this.recipient=recipient;
this.omc=omc1;
}
public void setCallBack(){
this.callback=true;
}
protected boolean getHelperAdvertKey() {
return false;
}
public void send(){
try{
PeerGroup netPeerGroup = P2PService.getPeerGroup();
/*
PipeAdvertisement pipeAdv = null;
if(!getHelperAdvertKey()) {
pipeAdv= new P2PAdvertisement().getPipeAdvertisement(this.recipient,netPeerGroup);
}else{
log.debug("~~~~~~` Posting message: PeerHelper");
pipeAdv=new P2PAdvertisement(getHelperAdvertKey()).getPipeAdvertisement(this.recipient,netPeerGroup);
}
*/
PipeAdvertisement pipeAdv =new P2PAdvertisement().getPipeAdvertisement(this.recipient,netPeerGroup);
MessageBean response=new MessageBean();
response.setReply(MessageBean.REPLYBACK);
response.setType(MessageBean.TYPE_REQUEST);
//response.setCommand("NEWPROTOCOL:myTestId");
OutgoingMessage ogM=new OutgoingMessage(this.omc,response,this.recipient);
HashMap h=new HashMap();
this.mha.setMsgCreator(P2PService.getComputerName());
this.mha.setMsgRecipient(this.recipient);
Map data=BeanUtils.describe(this.mha);
if(this.callback){
data.put(MessageNames.MESSAGE_TYPE_CALLBACK, MessageNames.MESSAGE_TYPE_CALLBACK);
}
data.put(MessageNames.MESSAGE_BEAN_NAME,this.mha.getClass().getName());
//System.out.println("------->IncomingMessageParser:data:"+data);
HashMap debugd=new HashMap();
debugd.putAll(data);
debugd.remove("msgCreator");
debugd.remove("responseJSON");
debugd.remove("priority");
debugd.remove("class");
debugd.remove("__msgBeanName__");
debugd.remove("taskuid");
log.debug("~~~~~~ PostMessage:class:"+this.mha.getClass().getName()+" to:"+this.recipient+":data:"+debugd);
ogM.setAttachment(data);
//ogM.setAttachment(MessageNames.RSCRIPT,"asdf aghjasdfjasdfasd g;adfajsd gasl;sgjasd gjasdg lasdg jasdlgjasdg;l asdjglasd gjsdlagjsdgasdjg;sdagsdgasdg");
PipeService pipeService = P2PService.getPipeService();
try{
//System.out.println("------->IncomingMessageParser: Sending MSG TO:"+mbean.getSender()+":"+command.toString());
pipeService.createOutputPipe(pipeAdv,ogM);
}catch(Exception e){
e.printStackTrace();
PipeService pipeService1 = P2PService.getNewPipeService();
try{
pipeService1.createOutputPipe(pipeAdv,ogM);
}catch(Exception e1){
e1.printStackTrace();
}
pipeService1=null;
}
//cleaning up
netPeerGroup = null;
pipeAdv = null;
response=null;
omc=null;
ogM=null;
data=null;
pipeService = null;
}catch(Exception e){
log.error("Error:"+e.getMessage());
}
}
}
@@ -0,0 +1,127 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONObject;
public class ReceiveMessage {
private Map data;
private Logger log = LogManager.getLogger(ReceiveMessage.class.getName());
public ReceiveMessage(Map attachments){
this.data=attachments;
}
public void process(){
String classname=(String)this.data.get(MessageNames.MESSAGE_BEAN_NAME);
String loc="1";
if(classname!=null && !classname.equals("")){
try{
Class c=Class.forName(classname);
Constructor ct = c.getConstructor();
loc+=",2";
MessageHandler mha=(MessageHandler)ct.newInstance();
//this.data.remove("JxtaWireHeader"); //remove jxta msessage
//this.data.remove("RendezVousPropagatejxta-NetGroup");
loc+=",3";
BeanUtils.populate(mha, this.data);
//log.debug("msg recieved,mha.getResponseJSON():"+mha.getResponseJSON()+" mha getMsgCreator:"+mha.getMsgCreator()+ " receipient:"+mha.getMsgRecipient() );
Map rtn=null;
loc+=",4";
//log.debug("~~~~~~ executing at Destination: data:"+data.keySet());
if(mha!=null && mha.getMsgCreator()!=null){
new CommunicationTrace(mha.getMsgCreator()).incoming(this.data);
}
if(this.data!=null && this.data.get(MessageNames.MESSAGE_TYPE_CALLBACK)!=null){
//execute at source
//log.debug("~~~~~~ callback:"+this.data.get(MessageNames.MESSAGE_TYPE_CALLBACK));
loc+=",5";
if(mha instanceof PostCallBack){
HashMap h=new HashMap();
if(mha.getResponseJSON()!=null){
loc+=",6";
JSONObject json1=new JSONObject(mha.getResponseJSON());
loc+=",7";
//log.debug("~~~~~~ json1:"+json1);
for(Iterator it=json1.keys();it.hasNext();){
Object key=(Object)it.next();
//System.out.print("key:"+key+" value:"+json1.get((String)key));
h.put(key, json1.get(key+""));
}
}
//log.debug("callback data:"+h);
((PostCallBack)mha).callBack(h);
}
}else{
//destination
//log.debug("~~~~~~ executing at Destination: mha:"+data+mha);
loc+=",8";
rtn=mha.executeAtDestination();
loc+=",9";
//log.debug("~~~~~~ executed : rtn:"+rtn);
loc+=",10,rtn:"+rtn;
if(rtn!=null){
mha.setResponseJSON(new JSONObject(rtn).toString());
loc+=",10a";
}
loc+="10b";
}
//loc+=",data:"+this.data;
HashMap debugd=new HashMap();
debugd.putAll(this.data);
debugd.remove("RendezVousPropagatejxta-NetGroup");
debugd.remove("JxtaWireHeader");
//if(classname.contains("PeerOnlineStatus") || classname.contains("PeerOnlineStatus") ){
//}else{
log.debug("classname:"+classname+" data:"+debugd);
//}
if(mha instanceof PostCallBack && this.data.get(MessageNames.MESSAGE_TYPE_CALLBACK)==null && (rtn==null || (rtn!=null && rtn.get(PostCallBack.IGNORE_CALLBACK)==null))){
//PostClientTestMessage pctm=new PostClientTestMessage();
//pctm.setName("this name");
//pctm.setScript("this is my script");
//pctm.setTest("this is test");
loc+=",11";
PostMessage pm=new PostMessage(mha,mha.getMsgCreator());
pm.setCallBack();
loc+=",12";
pm.send();
//log.debug("callback message sent");
}
loc+=",mha:"+mha;
}catch(Exception e){
e.printStackTrace();
log.error("process() E:"+e.getMessage()+" classname:"+classname+" loc:"+loc);
}
}
}
}
@@ -0,0 +1,103 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg.helper;
import java.util.HashMap;
import java.util.Map;
import net.jxta.peergroup.PeerGroup;
import net.jxta.pipe.PipeService;
import net.jxta.protocol.PipeAdvertisement;
import org.apache.commons.beanutils.BeanUtils;
import com.fourelementscapital.scheduler.p2p.MessageBean;
import com.fourelementscapital.scheduler.p2p.P2PAdvertisement;
import com.fourelementscapital.scheduler.p2p.P2PService;
import com.fourelementscapital.scheduler.p2p.listener.OutgoingMessage;
import com.fourelementscapital.scheduler.p2p.listener.OutgoingMessageCallBack;
import com.fourelementscapital.scheduler.p2p.msg.MessageHandler;
import com.fourelementscapital.scheduler.p2p.msg.MessageNames;
import com.fourelementscapital.scheduler.p2p.msg.PostMessage;
public class HelperPostMessage extends PostMessage {
public static final String helper_prefix="_helper";
public HelperPostMessage(MessageHandler mha, String recipient) {
super(mha, recipient);
}
public HelperPostMessage(MessageHandler mha,String recipient,OutgoingMessageCallBack omc1){
super(mha,recipient,omc1);
}
public void send(){
try{
PeerGroup netPeerGroup = P2PService.getPeerGroup();
//PipeAdvertisement pipeAdv =new P2PAdvertisement().getPipeAdvertisement(super.recipient+P2PServiceServlet.helper_prefix,netPeerGroup);
PipeAdvertisement pipeAdv =new P2PAdvertisement().getPipeAdvertisement(super.recipient+helper_prefix,netPeerGroup);
MessageBean response=new MessageBean();
response.setReply(MessageBean.REPLYBACK);
response.setType(MessageBean.TYPE_REQUEST);
//response.setCommand("NEWPROTOCOL:myTestId");
OutgoingMessage ogM=new OutgoingMessage(super.omc,response,super.recipient);
HashMap h=new HashMap();
super.mha.setMsgCreator(P2PService.getComputerName());
super.mha.setMsgRecipient(super.recipient);
Map data=BeanUtils.describe(super.mha);
if(super.callback){
data.put(MessageNames.MESSAGE_TYPE_CALLBACK, MessageNames.MESSAGE_TYPE_CALLBACK);
}
data.put(MessageNames.MESSAGE_BEAN_NAME,super.mha.getClass().getName());
//System.out.println("------->IncomingMessageParser:data:"+data);
log.debug("~~~~~~` Posting message:to:"+super.recipient+":data:"+data);
ogM.setAttachment(data);
PipeService pipeService = P2PService.getPipeService();
try{
//System.out.println("------->IncomingMessageParser: Sending MSG TO:"+mbean.getSender()+":"+command.toString());
pipeService.createOutputPipe(pipeAdv,ogM);
}catch(Exception e){
e.printStackTrace();
PipeService pipeService1 = P2PService.getNewPipeService();
try{
pipeService1.createOutputPipe(pipeAdv,ogM);
}catch(Exception e1){
e1.printStackTrace();
}
pipeService1=null;
}
//cleaning up
netPeerGroup = null;
pipeAdv = null;
response=null;
omc=null;
ogM=null;
data=null;
pipeService = null;
}catch(Exception e){
log.error("Error:"+e.getMessage());
}
}
}
@@ -0,0 +1,231 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg.impl.helper;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.util.Map;
import java.util.StringTokenizer;
import org.apache.jcs.JCS;
import org.apache.jcs.engine.behavior.IElementAttributes;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.fileutils.RandomString;
import com.fourelementscapital.scheduler.p2p.msg.MessageHandler;
import com.fourelementscapital.scheduler.p2p.msg.PostCallBack;
import com.fourelementscapital.scheduler.p2p.msg.helper.HelperPostMessage;
public class SendCommand2Helper extends MessageHandler implements PostCallBack,Serializable {
//implements PostCallBack {
private Logger log = LogManager.getLogger(SendCommand2Helper.class.getName());
//private static final String STOP_CLIENT_QUEUE="yes";
//private String stopqueue=null;
private String command=null;
private String response=null;
public static final boolean WAIT_QUEUE_TO_FINISH=false;
private boolean wait=false;
private String cachekey=null;
public String getCachekey() {
return cachekey;
}
public void setCachekey(String cachekey) {
this.cachekey = cachekey;
}
public String getResponse() {
return response;
}
public void setWait(boolean flag) {
this.wait=flag;
}
public void setResponse(String response) {
this.response = response;
}
public String getCommand() {
return command;
}
public void setCommand(String command) {
this.command = command;
}
private static String currentCommand=null;
public Map executeAtDestination() {
try{
System.out.println("RequestPeerRestart: executeAtDestination() command:"+this.command);
StringTokenizer st=new StringTokenizer(command,"\n");
Runtime runtime = Runtime.getRuntime();
this.response="";
while(st.hasMoreTokens()){
String cl=st.nextToken();
Process process = runtime.exec(cl);
BufferedReader br2 = new BufferedReader(new InputStreamReader(process.getInputStream()));
//this.response+="---"+cl+"--->";
String line;
while ((line = br2.readLine()) != null) {
this.response+="\n"+line;
}
this.response+="\n";
//this.wait(2000);
Thread.sleep(2000);
}
System.out.println("RequestPeerRestart: executeAtDestination() response:"+this.response);
}catch(Exception e) {
e.printStackTrace();
log.error("Error while executing on destination:"+ e.getMessage());
}
return null;
}
/**
* this will be executed on client.
* @param data
*/
public void callBack(Map data) {
try{
IElementAttributes att= gCache().getDefaultElementAttributes();
att.setMaxLifeSeconds(30);
gCache().put(getCachekey(), getResponse(),att);
}catch(Exception e){
e.printStackTrace();
log.error("Error while callback e:"+e.getMessage());
}
//System.out.println("RequestPeerRestart: response:"+cachekey);
//System.out.println("RequestPeerRestart: response:"+response);
}
private static JCS cache=null;
private static JCS gCache() throws Exception {
if(cache==null){
cache=JCS.getInstance(SendCommand2Helper.class.getName());
}
return cache;
}
public static String sendCommand(String peername, String command) throws Exception {
String cachekey = RandomString.getString(10);
IElementAttributes att= gCache().getDefaultElementAttributes();
att.setMaxLifeSeconds(30);
gCache().put(cachekey, "", att);
SendCommand2Helper rpr=new SendCommand2Helper();
rpr.setCachekey(cachekey);
//rpr.setCommand("cmd.exe /c sc stop 4EPeer \n cmd.exe /c sc start 4EPeer");
//rpr.setCommand("cmd.exe /c sc "+command+" 4EPeer");
rpr.setCommand(command);
new HelperPostMessage(rpr, peername).send();
while(gCache().get(cachekey)!=null && ((String)gCache().get(cachekey)).equals("") ) {
Thread.sleep(100);
}
String rtn=null;
if(gCache().get(cachekey)!=null && !((String)gCache().get(cachekey)).equals("")){
//System.out.println("get the response::------------------------------------>");
//System.out.println(gCache().get(cachekey));
rtn=(String)gCache().get(cachekey);
}
gCache().remove(cachekey);
//System.out.println("end..");
return rtn;
}
public static String sendCommand(String peername, String command, int waitSecs) throws Exception {
String cachekey = RandomString.getString(10);
IElementAttributes att= gCache().getDefaultElementAttributes();
att.setMaxLifeSeconds(waitSecs);
gCache().put(cachekey, "", att);
SendCommand2Helper rpr=new SendCommand2Helper();
rpr.setCachekey(cachekey);
//rpr.setCommand("cmd.exe /c sc stop 4EPeer \n cmd.exe /c sc start 4EPeer");
//rpr.setCommand("cmd.exe /c sc "+command+" 4EPeer");
rpr.setCommand(command);
new HelperPostMessage(rpr, peername).send();
while(gCache().get(cachekey)!=null && ((String)gCache().get(cachekey)).equals("") ) {
Thread.sleep(100);
}
String rtn=null;
if(gCache().get(cachekey)!=null && !((String)gCache().get(cachekey)).equals("")){
//System.out.println("get the response::------------------------------------>");
//System.out.println(gCache().get(cachekey));
rtn=(String)gCache().get(cachekey);
}
gCache().remove(cachekey);
//System.out.println("end..");
return rtn;
}
@Override
public void onCallBackSendingFailed() {
// TODO Auto-generated method stub
}
@Override
public void onSendingFailed() {
// TODO Auto-generated method stub
}
}
@@ -0,0 +1,63 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg.scheduler;
import org.apache.jcs.JCS;
import org.apache.jcs.engine.behavior.IElementAttributes;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class PeerCacheLock {
private static synchronized void lockPeer(String peer, String taskuid) throws Exception{
try{
IElementAttributes att= getCache().getDefaultElementAttributes();
att.setMaxLifeSeconds(1);
getCache().put("peer_locked_"+peer+taskuid, "locked",att);
}catch(Exception e){}
}
public static synchronized boolean lockPeerIfFree(String peer, String taskuid) {
Logger log = LogManager.getLogger(PeerCacheLock.class.getName());
boolean rtn=true;
try{
if(getCache()!=null && getCache().get("peer_locked_"+peer+taskuid)!=null ){
rtn=false;
}else{
lockPeer(peer,taskuid);
}
}catch(Exception e){}
log.debug("locking the peer "+peer+" taskuid:"+taskuid);
return rtn;
}
public static synchronized void releasePeer(String peer,String taskuid) {
try{
if(getCache()!=null){
getCache().remove(peer);
}
}catch(Exception e){}
}
private static JCS cache=null;
private static JCS getCache() throws Exception {
if(cache==null){
cache=JCS.getInstance("PeerCacheLock");
}
return cache;
}
}
@@ -0,0 +1,59 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg.scheduler;
import com.fourelementscapital.scheduler.p2p.msg.ExceptionMessageHandler;
public abstract class TaskMessage extends ExceptionMessageHandler {
private String scheduler_id="";
private String trigger_time="";
private String next_trigger_time="";
private String taskuid="";
public String getScheduler_id() {
return scheduler_id;
}
public void setScheduler_id(String scheduelr_id) {
this.scheduler_id = scheduelr_id;
}
public String getTrigger_time() {
return trigger_time;
}
public void setTrigger_time(String trigger_time) {
this.trigger_time = trigger_time;
}
public String getNext_trigger_time() {
return next_trigger_time;
}
public void setNext_trigger_time(String next_trigger_time) {
this.next_trigger_time = next_trigger_time;
}
public String getTaskuid() {
return taskuid;
}
public void setTaskuid(String taskuid) {
this.taskuid = taskuid;
}
}
@@ -0,0 +1,83 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg.scheduler.rserve;
import java.util.Map;
import java.util.Properties;
import org.apache.jcs.JCS;
import org.apache.jcs.engine.behavior.IElementAttributes;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.scheduler.p2p.msg.MessageHandler;
import com.fourelementscapital.scheduler.p2p.msg.PostCallBack;
import com.fourelementscapital.scheduler.p2p.peer.PeerSpecificConfigurations;
public class PeerPropertiesGet extends MessageHandler implements PostCallBack {
private Logger log = LogManager.getLogger(PeerPropertiesGet.class.getName());
public Map executeAtDestination() {
Properties p=null;
try{
p=PeerSpecificConfigurations.getProperties();
}catch(Exception e){
log.error("Error:"+e.getMessage());
}
return p;
}
public void callBack(Map data) {
try{
IElementAttributes att= getCache().getDefaultElementAttributes();
att.setMaxLifeSeconds(20);
getCache().put("peer_"+this.getMsgCreator(),data,att);
}catch(Exception e){
log.error("Error:"+e.getMessage());
}
}
public static Map getPeerCachedProp(String peername) throws Exception {
Map data=(Map)getCache().get("peer_"+peername);
return data;
}
private static JCS cache=null;
private static JCS getCache() throws Exception {
if(cache==null){
cache=JCS.getInstance(PeerPropertiesGet.class.getName());
}
return cache;
}
@Override
public void onCallBackSendingFailed() {
// TODO Auto-generated method stub
}
@Override
public void onSendingFailed() {
// TODO Auto-generated method stub
}
}
@@ -0,0 +1,81 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.msg.scheduler.rserve;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.fourelementscapital.scheduler.p2p.msg.MessageHandler;
import com.fourelementscapital.scheduler.p2p.peer.PeerSpecificConfigurations;
public class PeerPropertiesSet extends MessageHandler {
private String peerConcurrentThread=null;
private String peerSessionExecutionMax=null;
private Logger log = LogManager.getLogger(PeerPropertiesSet.class.getName());
public Map executeAtDestination() {
// this log error is for production debugging purpose. remove when it's done. itask 8257.
log.error(">>>>> debug itask 8257 >>>>> PeerPropertiesSet.executeAtDestination() - start");
log.error(">>>>> debug itask 8257 >>>>> PeerPropertiesSet.getPeerConcurrentThread() : " + getPeerConcurrentThread());
log.error(">>>>> debug itask 8257 >>>>> PeerPropertiesSet.getPeerSessionExecutionMax() : " + getPeerSessionExecutionMax());
try{
Properties p=new Properties();
p.setProperty(PeerSpecificConfigurations.KEY_CONCURRENT_SESSION, getPeerConcurrentThread());
p.setProperty(PeerSpecificConfigurations.KEY_MAX_EXEC_SESSION, getPeerSessionExecutionMax());
PeerSpecificConfigurations.syncPartial(p);
}catch(Exception e){
log.error("Error:"+e.getMessage());
}
// this log error is for production debugging purpose. remove when it's done. itask 8257.
log.error(">>>>> debug itask 8257 >>>>> PeerPropertiesSet.executeAtDestination() - end");
return new HashMap();
///return null;
}
public String getPeerConcurrentThread() {
return peerConcurrentThread;
}
public void setPeerConcurrentThread(String peerConcurrentThread) {
this.peerConcurrentThread = peerConcurrentThread;
}
public String getPeerSessionExecutionMax() {
return peerSessionExecutionMax;
}
public void setPeerSessionExecutionMax(String peerSessionExecutionMax) {
this.peerSessionExecutionMax = peerSessionExecutionMax;
}
@Override
public void onSendingFailed() {
// TODO Auto-generated method stub
}
}
@@ -0,0 +1,113 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.peer;
import java.util.ArrayList;
import java.util.Date;
import java.util.StringTokenizer;
public class PeerMachine {
public PeerMachine(){}
public PeerMachine(String peer){this.peername=peer;}
private String executing=null;
private Date lastresponse=null;
private int num_tasks_running=0;
private String peername=null;
private String version="";
private String peerOS=""; // added by andy 2014-02-20
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getExecuting() {
return executing;
}
public void setExecuting(String executing) {
this.executing = executing;
}
public Date getLastresponse() {
return lastresponse;
}
public void setLastresponse(Date lastresponse) {
this.lastresponse = lastresponse;
}
public int getNum_tasks_running() {
return num_tasks_running;
}
public void setNum_tasks_running(int num_tasks_running) {
this.num_tasks_running = num_tasks_running;
}
public String getPeername() {
return peername;
}
public void setPeername(String peername) {
this.peername = peername;
}
public void setPeerOS(String peeros){ // added by andy 2014-02-20
this.peerOS = peeros;
}
public String getPeerOS(){ // added by andy 2014-02-20
return peerOS;
}
public String getBusyStatus(){
if(this.executing!=null && !this.executing.trim().equals("")){
return "BUSY";
}else{
return "NOBUSY";
}
}
public ArrayList getRunning(){
ArrayList rtn=new ArrayList();
if(this.executing!=null && !this.executing.trim().equals("")){
StringTokenizer st=new StringTokenizer(this.executing,",");
while(st.hasMoreTokens()){
String token=st.nextToken();
StringTokenizer st2=new StringTokenizer(token,"=");
if(st2.countTokens()>=2){
String scid=st2.nextToken();
String trigtime=st2.nextToken();
rtn.add(scid+"_"+trigtime);
}
}
}
return rtn;
}
public boolean equals(Object other){
boolean rtn=false;
if(other!=null && other instanceof PeerMachine){
PeerMachine other1=(PeerMachine)other;
if(other1.getPeername()!=null && this.peername!=null && other1.getPeername().equals(this.peername)){
rtn=true;
}
}
return rtn;
}
private static ArrayList<String> ver=new ArrayList();
public static String getLastVersion(){
ver.add("2.1"); //added on 13-june-2013
return ver.get(ver.size()-1);
}
}
@@ -0,0 +1,241 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.peer;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLSyntaxErrorException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class PeerManagerHSQL {
private Logger log = LogManager.getLogger(PeerManagerHSQL.class.getName());
private static Connection connection=null;
private static final Semaphore dblock=new Semaphore(1,true);
private static long TIMEOUT_MS=2000;
protected void acquireLock(){
try{
Date start=new Date();
PeerManagerHSQL.dblock.tryAcquire(TIMEOUT_MS, TimeUnit.MILLISECONDS);
Date end=new Date();
long diff=end.getTime()-start.getTime();
if(diff>0){
String caller=collectStack(Thread.getAllStackTraces().get(Thread.currentThread()));
//log.debug("!!!!!!!!!!!!!!!!!acquiring lock: thread:"+Thread.currentThread().getId()+" time took:"+diff+" ms");
log.debug(" Caller time:"+diff+" id:"+Thread.currentThread().getId() +"\n"+caller);
}
//LoadBalancingHSQLLayerDB.dblock.acquire();
}catch(Exception e){
log.error("Error:"+e.getMessage());
}
}
protected void releaseLock(){
try{
PeerManagerHSQL.dblock.release();
//log.debug("....releasing lock: thread:"+Thread.currentThread().getId());
}catch(Exception e){
log.error("Error:"+e.getMessage());
}
}
private static String nextLineChar="\r\n";
private static String collectStack(StackTraceElement[] stacks) throws Exception {
//StackTraceElement[] stacks=ex.getStackTrace();
String rtn="";
//if(msg!=null) rtn+=msg.trim()+nextLineChar;
//rtn+="ERROR MSG:"+ex.getMessage()+nextLineChar;
int startat=0;
for(int i=0;i<stacks.length;i++){
if(stacks[i].getClassName().startsWith("com.fe.")){
startat=i;
}
}
int numbefore=2;
startat=(startat>numbefore)?startat-numbefore:0;
int counter=1;
for(int i=startat;i<stacks.length;i++){
if((i>(startat+numbefore)) && !stacks[i].getClassName().startsWith("com.fe.")){
}else{
String space="";
for(int ab=0;ab<counter;ab++) space+=" "; counter++;
if(stacks[i].getClassName().startsWith("com.fe.")){
space+="->";
}
rtn+=space+""+stacks[i].getClassName()+"."+stacks[i].getMethodName()+"()"+nextLineChar;
}
}
return rtn;
}
private synchronized Connection getConnection(){
if(PeerManagerHSQL.connection==null){
//synchronized(PeerManagerHSQL.connection){
if(PeerManagerHSQL.connection==null){
//String driver="jdbc:hsqldb:mem:peers";
acquireLock();
try{
if(PeerManagerHSQL.connection==null){
log.debug("~~~~~~~~~getConnection(-------)~~~~~~~~~~~~~~");
Class.forName("org.hsqldb.jdbc.JDBCDriver" );
//String driver="jdbc:hsqldb:file:C:\\rnd\\hsqldb-2.2.9\\scheduler_peers\\peers";
String driver="jdbc:hsqldb:mem:peers";
this.connection = DriverManager.getConnection(driver, "SA", "SA");
String q=createSchemaQuery();
Statement st=this.connection.createStatement();
st.execute(q);
st.close();
}
}catch(SQLSyntaxErrorException sqle){
log.debug("Table already existing, e:"+sqle.getMessage());
}catch(Exception e){
e.printStackTrace();
}finally{
releaseLock();
}
}
//}
}
return PeerManagerHSQL.connection;
}
private String createSchemaQuery(){
String query="CREATE TABLE peers(";
query+=" id IDENTITY,";
query+=" peername VARCHAR(50),";
query+=" executing VARCHAR(250),";
query+=" lastresponse DATETIME,";
query+=" version VARCHAR(50),";
query+=" num_tasks_running INT ";
query+=")";
return query;
}
public List<PeerMachine> getOnlinePeers(int last_milli_sec){
//i guess no need to lock
//acquireLock();
ArrayList rtn=new ArrayList();
try{
String query="Select * from peers WHERE lastresponse>dateadd('ms',-"+last_milli_sec+",LOCALTIMESTAMP)";
PreparedStatement ps=getConnection().prepareStatement(query);
ResultSet rs=ps.executeQuery();
while(rs.next()){
PeerMachine pm=new PeerMachine();
pm.setExecuting(rs.getString("executing"));
pm.setPeername(rs.getString("peername"));
pm.setVersion(rs.getString("version"));
pm.setNum_tasks_running(rs.getInt("num_tasks_running"));
if(rs.getTimestamp("lastresponse")!=null){
Date d=new Date(rs.getTimestamp("lastresponse").getTime());
pm.setLastresponse(d);
}
rtn.add(pm);
}
rs.close();
ps.close();
}catch(Exception e){
log.error("getOnlinePeers:"+last_milli_sec);
e.printStackTrace();
}finally{
//releaseLock();
}
return rtn;
}
public void updatePeerResponse(String peername, Map executing,String version) {
acquireLock();
try{
String selq="Select * from peers where peername=?";
String strfy=null;
int num_running=0;
if(executing!=null){
num_running=executing.size();
for(Object sc_id: executing.keySet()){
strfy=(strfy==null)
?sc_id+"="+executing.get(sc_id)
:strfy+","+sc_id+"="+executing.get(sc_id);
}
}
PreparedStatement ps=this.getConnection().prepareStatement(selq);
ps.setString(1, peername);
ResultSet rs=ps.executeQuery();
String query="";
if(rs.next()){
query="UPDATE peers SET executing=?, lastresponse=?,num_tasks_running=?, version=? WHERE peername=?";
}else{
query="INSERT INTO peers(executing,lastresponse,num_tasks_running,version,peername) VALUES(?,?,?,?,?)";
}
rs.close();
ps.close();
PreparedStatement ps1=getConnection().prepareStatement(query);
ps1.setString(1,strfy);
//try catch block added because occasionally get the following error message.
//java.lang.IllegalArgumentException: YEAR
//at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2316)
try{
ps1.setTimestamp(2,new Timestamp(new Date().getTime()));
}catch(Exception e){;
log.error("error, e:"+e.getMessage());
ps1.setTimestamp(2,null);
}
ps1.setInt(3,num_running);
ps1.setString(4,version);
ps1.setString(5,peername);
ps1.executeUpdate();
ps1.close();
}catch(Exception e){
log.error("Executing:"+executing+" Error:"+e.getMessage());
//e.printStackTrace();
}finally{
releaseLock();
}
}
}
@@ -0,0 +1,72 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.peer;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
import org.jfree.util.Log;
public class PeerSpecificConfigurations {
private static String propertyfile="peer_specific.properties";
private static Properties defa=new Properties();
public static final String KEY_CONCURRENT_SESSION="rserve.concurrent.sessions";
public static final String KEY_MAX_EXEC_SESSION="rserve.max.executions.in.session";
public static Properties getDefaultProperties(){
defa.put(KEY_CONCURRENT_SESSION,"15");
defa.put(KEY_MAX_EXEC_SESSION,"10000");
return defa;
}
public static Properties getProperties() throws Exception {
Properties p=new Properties();
try{
FileInputStream fin=new FileInputStream(PeerSpecificConfigurations.propertyfile);
p.load(fin);
}catch(Exception e){
Log.error("No property file found, or error:"+e.getMessage());
}
Properties d=getDefaultProperties();
for(Object key:d.keySet()){
if(!p.containsKey(key)){
p.put(key, d.getProperty((String)key));
}
}
return p;
}
public static void syncPartial(Properties newp) throws Exception {
Properties oldp=getProperties();
for(Object key:newp.keySet()){
oldp.put(key, newp.getProperty((String)key));
}
FileOutputStream fos=new FileOutputStream(PeerSpecificConfigurations.propertyfile);
oldp.store(fos, null);
}
}
@@ -0,0 +1,94 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.websocket;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public abstract class CommandAbstract {
private Logger log = LogManager.getLogger(CommandAbstract.class.getName());
public Options getOptionsWithHelp(){
Options opt=getOptions();
opt.addOption("h", "help", false, "Show help of this command");
return opt;
}
public String showHelp() {
HelpFormatter h = new HelpFormatter();
StringWriter sw=new StringWriter();
String firstcommand=this.getClass().getSimpleName();
firstcommand=CommandMain.classToCommand(firstcommand);
//firstcommand=firstcommand.replaceFirst("Command", "");
h.printHelp(new PrintWriter(sw),200,firstcommand, getHeader(), getOptionsWithHelp(),0,5,getFooter(),true);
return sw.toString();
}
public String getCommand() {
String firstcommand=this.getClass().getSimpleName();
firstcommand=CommandMain.classToCommand(firstcommand);
return firstcommand;
}
public String executeCommand (String command) throws Exception {
String msg="";
try{
CommandLineParser parser = new PosixParser();
CommandLine cmd = parser.parse(getOptionsWithHelp(), command.split(" "));
if(cmd.hasOption('h')){
msg=showHelp();
}else{
log.debug("executeValidCommand()");
msg=executeValidCommand(cmd, command);
}
}catch(ParseException pe){
msg=showHelp();
}catch(Exception e){
msg=e.getMessage();
}
return msg;
}
public abstract String executeValidCommand(CommandLine cmd, String command);
public abstract Options getOptions();
public abstract String getHeader();
public abstract String getFooter();
}
@@ -0,0 +1,120 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.websocket;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class CommandMain {
private Logger log = LogManager.getLogger(CommandMain.class.getName());
private String command;
public CommandMain(String cmd){
this.command=cmd;
}
public String validate() {
String cmds[]=this.command.split(" ");
String msg="";
if(cmds.length>0){
//char[] stringArray = cmds[0].toCharArray();
//stringArray[0] = Character.toUpperCase(stringArray[0]);
//String commandclass = this.getClass().getPackage().getName()+".cmd."+ new String(stringArray);
String clss=command2Class(cmds[0]);
String commandclass = this.getClass().getPackage().getName()+".cmd."+ clss;
//System.out.println("CommandMain: his.getClass().getPackage():"+commandclass);
//ClassLoader myClassLoader = ClassLoader.getSystemClassLoader();
ClassLoader myClassLoader =this.getClass().getClassLoader();
log.debug("commandclass:"+commandclass);
try {
Class myClass = myClassLoader.loadClass(commandclass);
CommandAbstract cmdobj=(CommandAbstract)myClass.newInstance();
msg=cmdobj.executeCommand(this.command);
} catch (ClassNotFoundException e) {
msg="Invalid command";
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return msg;
}else{
msg="Invalid command";
}
return msg;
}
public static String command2Class(String command) {
try {
Pattern p1 = Pattern.compile("(\\_)([a-z]+?)",Pattern.DOTALL);
final Matcher matcher = p1.matcher(command);
final StringBuffer sb = new StringBuffer();
String grp="";
while(matcher.find()){
if( matcher.groupCount()>1){
matcher.appendReplacement(sb, matcher.group(2).toUpperCase());
}
}
matcher.appendTail(sb);
String cls=sb.toString();
char[] stringArray = cls.toCharArray();
stringArray[0] = Character.toUpperCase(stringArray[0]);
return new String(stringArray);
}catch(Exception e){
return "";
}
}
public static String classToCommand(String classname) {
try {
char[] stringArray = classname.toCharArray();
stringArray[0] = Character.toLowerCase(stringArray[0]);
classname= new String(stringArray);
Pattern p1 = Pattern.compile("([A-Z]+?)",Pattern.DOTALL);
final Matcher matcher = p1.matcher(classname);
final StringBuffer sb = new StringBuffer();
String grp="";
while(matcher.find()){
if( matcher.groupCount()>0){
matcher.appendReplacement(sb, "_"+matcher.group(1).toLowerCase());
}
}
matcher.appendTail(sb);
return sb.toString();
}catch(Exception e){
return "";
}
}
}
@@ -0,0 +1,112 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.websocket;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import javax.servlet.http.HttpServletRequest;
import org.apache.catalina.websocket.MessageInbound;
import org.apache.catalina.websocket.StreamInbound;
import org.apache.catalina.websocket.WebSocketServlet;
import org.apache.catalina.websocket.WsOutbound;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONException;
import org.json.JSONObject;
public class TomcatWSConsole extends WebSocketServlet {
private Logger log = LogManager.getLogger(TomcatWSConsole.class.getName());
private final static Set<ChatMessageInbound> connections = new CopyOnWriteArraySet<ChatMessageInbound>();
@Override
protected StreamInbound createWebSocketInbound(String subProtocol, HttpServletRequest request) {
//System.out.println("TomcatWSServer.createWebSocketInbound()");
return new ChatMessageInbound();
}
private final class ChatMessageInbound extends MessageInbound {
protected void onOpen(WsOutbound outbound) {
connections.add(this);
// System.out.println("TomcatWSServer.onOpen()");
log.debug("connected...");
}
@Override
protected void onClose(int status) {
connections.remove(this);
log.debug("closed...");
// System.out.println("TomcatWSServer.onClose()");
}
@Override
protected void onBinaryMessage(ByteBuffer message) throws IOException {
throw new UnsupportedOperationException(
"Binary message not supported.");
}
@Override
protected void onTextMessage(CharBuffer message) throws IOException {
// Never trust the client
//String filteredMessage = String.format("%s: %s", nickname, HTMLFilter.filter(message.toString()));
//broadcast(message.toString());
log.debug("msg received:"+message);
//this.getWsOutbound().writeTextMessage(message);
CommandMain cm=new CommandMain(message.toString());
String val=cm.validate();
JSONObject json=new JSONObject();
try{
json.put("rs", val);
this.getWsOutbound().writeTextMessage(CharBuffer.wrap(json.toString()));
//conn.send(json.toString());
}catch(Exception e){
log.error("Error onMessage:"+e.getMessage());
}
}
}
public static void consoleToAll(String msg){
for (ChatMessageInbound connection : connections) {
try {
JSONObject obj=new JSONObject();
try {
obj.put("c", msg);
} catch (JSONException e) { }
CharBuffer buffer = CharBuffer.wrap(obj.toString());
connection.getWsOutbound().writeTextMessage(buffer);
} catch (IOException ignore) {
// Ignore
}
}
}
}
@@ -0,0 +1,99 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p.websocket;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import javax.servlet.http.HttpServletRequest;
import org.apache.catalina.websocket.MessageInbound;
import org.apache.catalina.websocket.StreamInbound;
import org.apache.catalina.websocket.WebSocketServlet;
import org.apache.catalina.websocket.WsOutbound;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* Example web socket servlet for chat.
*/
public class TomcatWSServer extends WebSocketServlet {
private Logger log = LogManager.getLogger(TomcatWSServer.class.getName());
private final static Set<ChatMessageInbound> connections = new CopyOnWriteArraySet<ChatMessageInbound>();
@Override
protected StreamInbound createWebSocketInbound(String subProtocol, HttpServletRequest request) {
//System.out.println("TomcatWSServer.createWebSocketInbound()");
return new ChatMessageInbound();
}
private final class ChatMessageInbound extends MessageInbound {
protected void onOpen(WsOutbound outbound) {
connections.add(this);
// System.out.println("TomcatWSServer.onOpen()");
log.debug("connected...");
}
@Override
protected void onClose(int status) {
connections.remove(this);
log.debug("closed...");
// System.out.println("TomcatWSServer.onClose()");
}
@Override
protected void onBinaryMessage(ByteBuffer message) throws IOException {
throw new UnsupportedOperationException(
"Binary message not supported.");
}
@Override
protected void onTextMessage(CharBuffer message) throws IOException {
// Never trust the client
//String filteredMessage = String.format("%s: %s", nickname, HTMLFilter.filter(message.toString()));
//broadcast(message.toString());
log.debug("msg received:"+message);
this.getWsOutbound().writeTextMessage(message);
}
}
public static void broadcast(String message) {
for (ChatMessageInbound connection : connections) {
//Logger log=Logger.getLogger(TomcatWSServer.class);
//log.debug("# connections:"+connections.size());
//log.debug("# Msg:"+message);
try {
CharBuffer buffer = CharBuffer.wrap(message);
connection.getWsOutbound().writeTextMessage(buffer);
} catch (IOException ignore) {
// Ignore
}
}
}
}
@@ -0,0 +1,46 @@
/******************************************************************************
*
* Copyright: Intellectual Property of Four Elements Capital Pte Ltd, Singapore.
* All rights reserved.
*
******************************************************************************/
package com.fourelementscapital.scheduler.p2p;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for App
*/
public class AppTest extends TestCase {
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Empty Test
*/
public void testApp()
{
assertTrue( true );
}
}

Some files were not shown because too many files have changed in this diff Show More