From 880e348a2698ea8edc02a45daa335c5270719faa Mon Sep 17 00:00:00 2001 From: Sumeet Chhetri Date: Sun, 27 Sep 2020 16:28:33 +0530 Subject: [PATCH 001/196] Added batched query support for postgres Added support for libpq async mode Added LRU support for memory cache Fixed issues with auto code generation in cases (deleted operator= and copy constructor) [skip_build][docker_push] --- .github/workflows/ci-docker-base-push.yml | 21 +- .github/workflows/ci-docker-tfb-benchmark.yml | 2 +- CMakeLists.txt | 4 + configure.ac | 1 + docker/build-docker-rust-base.sh | 19 - docker/build-te-images.sh | 31 +- .../install_ffead-cpp-framework-forsql.sh | 2 + .../ffead-cpp/install_ffead-cpp-framework.sh | 2 + docker/os-based/install_ffead-cpp-5.0.sh | 1 + .../techempower-config/benchmark_config.json | 28 +- .../ffead-cpp-apache.dockerfile | 2 +- .../ffead-cpp-base.dockerfile | 2 +- .../ffead-cpp-cinatra.dockerfile | 2 +- .../ffead-cpp-crystal-h2o.dockerfile | 2 +- .../ffead-cpp-crystal-http.dockerfile | 2 +- .../ffead-cpp-drogon.dockerfile | 2 +- .../ffead-cpp-go-fasthttp.dockerfile | 2 +- .../ffead-cpp-go-gnet.dockerfile | 2 +- .../ffead-cpp-java-base.dockerfile | 4 +- .../ffead-cpp-java-firenio.dockerfile | 2 +- .../ffead-cpp-java-rapidoid.dockerfile | 2 +- .../ffead-cpp-java-wizzardo-http.dockerfile | 2 +- .../ffead-cpp-libreactor.dockerfile | 2 +- .../ffead-cpp-lithium.dockerfile | 2 +- .../ffead-cpp-mongo-raw.dockerfile | 4 +- .../ffead-cpp-mysql.dockerfile | 2 +- .../ffead-cpp-nginx.dockerfile | 2 +- .../ffead-cpp-postgresql-raw-async.dockerfile | 7 + .../ffead-cpp-postgresql-raw.dockerfile | 4 +- .../ffead-cpp-postgresql.dockerfile | 2 +- .../ffead-cpp-rust-actix.dockerfile | 2 +- .../ffead-cpp-rust-base.dockerfile | 4 +- .../ffead-cpp-rust-hyper.dockerfile | 2 +- .../ffead-cpp-rust-rocket-base.dockerfile | 6 +- .../ffead-cpp-rust-rocket.dockerfile | 2 +- .../ffead-cpp-v-base.dockerfile | 4 +- .../ffead-cpp-v-picov.dockerfile | 2 +- .../ffead-cpp-v-vweb.dockerfile | 2 +- .../techempower-config/ffead-cpp.dockerfile | 2 +- .../install_ffead-cpp-framework.sh | 9 +- docker/techempower-config/run_ffead.sh | 55 +- docker/test/CMakeLists.txt | 4 + ...ile-UbuntuBionic-x64-ffead-cpp-5.0-fortest | 36 +- docker/test/install_ffead-cpp.sh | 44 +- docker/test/mongo-debug-orm.sh | 30 +- docker/test/mongo-debug-raw.sh | 32 +- docker/test/pipeline.lua | 12 + docker/test/server.sh | 33 + docker/test/sql-debug-orm.sh | 30 +- docker/test/sql-debug-raw-async.sh | 40 + docker/test/sql-debug-raw.sh | 36 +- docker/test/test.sh | 2 +- ...DockerFile-UbuntuBionic-x64-ffead-cpp-5.0} | 9 +- ...e-UbuntuBionic-x64-ffead-cpp-5.0_autoconf} | 9 +- src/framework/ConfigurationData.cpp | 25 +- src/framework/ConfigurationHandler.cpp | 55 +- src/framework/ConfigurationHandler.h | 1 + src/framework/ControllerHandler.cpp | 30 +- src/framework/ExtHandler.cpp | 8 +- src/framework/FilterHandler.cpp | 12 +- src/framework/FormHandler.cpp | 6 +- src/framework/Router.h | 2 +- src/framework/SecurityHandler.cpp | 4 +- src/framework/ServiceTask.cpp | 21 +- src/framework/ServiceTask.h | 1 + src/modules/cache/CacheManager.cpp | 59 +- src/modules/cache/CacheManager.h | 2 +- src/modules/cache/memory/MemoryCacheImpl.cpp | 172 ++-- src/modules/cache/memory/MemoryCacheImpl.h | 8 +- src/modules/common/CommonUtils.cpp | 14 + src/modules/common/CommonUtils.h | 10 + src/modules/http/HttpResponse.h | 4 +- src/modules/http/HttpServiceHandler.cpp | 5 +- src/modules/http/HttpServiceHandler.h | 2 +- src/modules/reflection/Reflection.cpp | 8 +- src/modules/sdorm/DataSourceManager.cpp | 34 +- src/modules/sdorm/DataSourceManager.h | 2 +- .../sdorm/sql/libpq/LibpqDataSourceImpl.cpp | 756 ++++++++++++++++-- .../sdorm/sql/libpq/LibpqDataSourceImpl.h | 74 +- .../server-util/RequestReaderHandler.cpp | 12 + .../server-util/RequestReaderHandler.h | 6 + src/modules/server-util/ServiceHandler.cpp | 2 +- src/modules/server-util/SocketInterface.cpp | 10 + src/modules/server-util/SocketInterface.h | 9 +- src/server/embedded/CHServer.cpp | 52 +- .../include/PeerServerController.h | 2 +- web/peer-server/src/PeerServerController.cpp | 27 +- web/te-benchmark-um-mgr/config/cache.xml | 13 - .../config/cachememory.xml | 7 + web/te-benchmark-um-mgr/include/TeBkUmMgr.h | 10 +- web/te-benchmark-um-mgr/src/TeBkUmMgr.cpp | 53 +- web/te-benchmark-um-pq-async/CMakeLists.txt | 10 + .../config/application.xml | 24 + .../config/cachememory.xml | 7 + web/te-benchmark-um-pq-async/config/sdorm.xml | 15 + .../include/TeBkUmLpqAsync.h | 145 ++++ .../src/TeBkUmLpqAsync.cpp | 507 ++++++++++++ .../src/autotools/Makefile.am | 17 + web/te-benchmark-um-pq-async/tpe/fortunes.tpe | 13 + web/te-benchmark-um-pq/config/cache.xml | 13 - web/te-benchmark-um-pq/config/cachememory.xml | 7 + web/te-benchmark-um-pq/config/sdorm.xml | 1 + web/te-benchmark-um-pq/include/TeBkUmLpq.h | 25 +- web/te-benchmark-um-pq/src/TeBkUmLpq.cpp | 228 ++++-- web/te-benchmark-um/config/cache.xml | 13 - web/te-benchmark-um/config/cachememory.xml | 7 + web/te-benchmark-um/include/TeBkUm.h | 8 +- web/te-benchmark-um/src/TeBkUm.cpp | 19 +- web/te-benchmark/config/cache.xml | 13 - web/te-benchmark/config/cachememory.xml | 7 + 110 files changed, 2574 insertions(+), 592 deletions(-) delete mode 100644 docker/build-docker-rust-base.sh create mode 100644 docker/techempower-config/ffead-cpp-postgresql-raw-async.dockerfile create mode 100644 docker/test/pipeline.lua create mode 100644 docker/test/server.sh create mode 100644 docker/test/sql-debug-raw-async.sh rename docker/webrtc-peerjs/{DockerFile-UbuntuBionic-x64-ffead-cpp-4.0 => DockerFile-UbuntuBionic-x64-ffead-cpp-5.0} (77%) rename docker/webrtc-peerjs/{DockerFile-UbuntuBionic-x64-ffead-cpp-4.0_autoconf => DockerFile-UbuntuBionic-x64-ffead-cpp-5.0_autoconf} (79%) delete mode 100644 web/te-benchmark-um-mgr/config/cache.xml create mode 100644 web/te-benchmark-um-mgr/config/cachememory.xml create mode 100644 web/te-benchmark-um-pq-async/CMakeLists.txt create mode 100644 web/te-benchmark-um-pq-async/config/application.xml create mode 100644 web/te-benchmark-um-pq-async/config/cachememory.xml create mode 100644 web/te-benchmark-um-pq-async/config/sdorm.xml create mode 100644 web/te-benchmark-um-pq-async/include/TeBkUmLpqAsync.h create mode 100644 web/te-benchmark-um-pq-async/src/TeBkUmLpqAsync.cpp create mode 100644 web/te-benchmark-um-pq-async/src/autotools/Makefile.am create mode 100644 web/te-benchmark-um-pq-async/tpe/fortunes.tpe delete mode 100644 web/te-benchmark-um-pq/config/cache.xml create mode 100644 web/te-benchmark-um-pq/config/cachememory.xml delete mode 100644 web/te-benchmark-um/config/cache.xml create mode 100644 web/te-benchmark-um/config/cachememory.xml delete mode 100644 web/te-benchmark/config/cache.xml create mode 100644 web/te-benchmark/config/cachememory.xml diff --git a/.github/workflows/ci-docker-base-push.yml b/.github/workflows/ci-docker-base-push.yml index 8693cf1f3..a098beed6 100644 --- a/.github/workflows/ci-docker-base-push.yml +++ b/.github/workflows/ci-docker-base-push.yml @@ -10,6 +10,7 @@ env: RUST_IMAGE_NAME: sumeetchhetri/ffead-cpp-5.0-rust-base RUST_RKT_IMAGE_NAME: sumeetchhetri/ffead-cpp-5.0-rust-rocket-base V_IMAGE_NAME: sumeetchhetri/ffead-cpp-5.0-v-base + IMG_VERSION: 5.1 jobs: push: runs-on: ubuntu-latest @@ -38,8 +39,8 @@ jobs: # Strip "v" prefix from tag name #[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - # Use Docker `latest` tag convention - [ "$VERSION" == "master" ] && VERSION=latest + # Use Docker `$IMG_VERSION` tag convention + [ "$VERSION" == "master" ] && VERSION=$IMG_VERSION echo IMAGE_ID=$IMAGE_ID echo VERSION=$VERSION @@ -68,8 +69,8 @@ jobs: # Strip "v" prefix from tag name #[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - # Use Docker `latest` tag convention - [ "$VERSION" == "master" ] && VERSION=latest + # Use Docker `$IMG_VERSION` tag convention + [ "$VERSION" == "master" ] && VERSION=$IMG_VERSION echo JAVA_IMAGE_ID=$JAVA_IMAGE_ID echo VERSION=$VERSION @@ -98,8 +99,8 @@ jobs: # Strip "v" prefix from tag name #[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - # Use Docker `latest` tag convention - [ "$VERSION" == "master" ] && VERSION=latest + # Use Docker `$IMG_VERSION` tag convention + [ "$VERSION" == "master" ] && VERSION=$IMG_VERSION echo RUST_IMAGE_ID=$RUST_IMAGE_ID echo VERSION=$VERSION @@ -128,8 +129,8 @@ jobs: # Strip "v" prefix from tag name #[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - # Use Docker `latest` tag convention - [ "$VERSION" == "master" ] && VERSION=latest + # Use Docker `$IMG_VERSION` tag convention + [ "$VERSION" == "master" ] && VERSION=$IMG_VERSION echo RUST_RKT_IMAGE_ID=$RUST_RKT_IMAGE_ID echo VERSION=$VERSION @@ -158,8 +159,8 @@ jobs: # Strip "v" prefix from tag name #[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - # Use Docker `latest` tag convention - [ "$VERSION" == "master" ] && VERSION=latest + # Use Docker `$IMG_VERSION` tag convention + [ "$VERSION" == "master" ] && VERSION=$IMG_VERSION echo V_IMAGE_ID=$V_IMAGE_ID echo VERSION=$VERSION diff --git a/.github/workflows/ci-docker-tfb-benchmark.yml b/.github/workflows/ci-docker-tfb-benchmark.yml index 9a6e65d63..0e0716786 100644 --- a/.github/workflows/ci-docker-tfb-benchmark.yml +++ b/.github/workflows/ci-docker-tfb-benchmark.yml @@ -18,4 +18,4 @@ jobs: cp -f docker/DockerFile-tfb-test FrameworkBenchmarks/frameworks/C++/ffead-cpp/ffead-cpp.dockerfile cp -f docker/techempower-config/* FrameworkBenchmarks/frameworks/C++/ffead-cpp/ cd FrameworkBenchmarks - ./tfb --mode benchmark --test ffead-cpp ffead-cpp-mongo-raw ffead-cpp-postgresql ffead-cpp-postgresql-raw + ./tfb --mode benchmark --test ffead-cpp-postgresql-raw ffead-cpp-postgresql-raw-async diff --git a/CMakeLists.txt b/CMakeLists.txt index dc0f467fa..176dc1bb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -493,6 +493,7 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/web/peer-server) add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark) add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um) add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um-pq) +add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um-pq-async) add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um-mgr) if(MOD_APACHE) @@ -595,6 +596,7 @@ if(CYGWIN OR MINGW) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark/libte_benchmark${CMAKE_SHARED_LIBRARY_SUFFIX}.a DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um/libte_benchmark_um${CMAKE_SHARED_LIBRARY_SUFFIX}.a DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-pq/libte_benchmark_um_pq${CMAKE_SHARED_LIBRARY_SUFFIX}.a DESTINATION ${PROJECT_NAME}-bin/lib) + install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-pq-async/libte_benchmark_um_pq_async${CMAKE_SHARED_LIBRARY_SUFFIX}.a DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-mgr/libte_benchmark_um_mgr${CMAKE_SHARED_LIBRARY_SUFFIX}.a DESTINATION ${PROJECT_NAME}-bin/lib) else() install(FILES ${PROJECT_BINARY_DIR}/src/modules/libffead-modules${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) @@ -607,6 +609,7 @@ if(CYGWIN OR MINGW) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark/libte_benchmark${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um/libte_benchmark_um${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-pq/libte_benchmark_um_pq${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) + install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-pq-async/libte_benchmark_um_pq_async${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-mgr/libte_benchmark_um_mgr${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) endif() install(FILES ${PROJECT_BINARY_DIR}/ffead-cpp.exe DESTINATION ${PROJECT_NAME}-bin/) @@ -621,6 +624,7 @@ else() install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark/libte_benchmark${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um/libte_benchmark_um${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-pq/libte_benchmark_um_pq${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) + install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-pq-async/libte_benchmark_um_pq_async${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-mgr/libte_benchmark_um_mgr${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/ffead-cpp DESTINATION ${PROJECT_NAME}-bin/) endif() diff --git a/configure.ac b/configure.ac index f676f7ac9..7e328d1ce 100644 --- a/configure.ac +++ b/configure.ac @@ -1201,6 +1201,7 @@ AC_CONFIG_FILES([web/default/src/autotools/Makefile web/te-benchmark/src/autotools/Makefile web/te-benchmark-um/src/autotools/Makefile web/te-benchmark-um-pq/src/autotools/Makefile + web/te-benchmark-um-pq-async/src/autotools/Makefile web/te-benchmark-um-mgr/src/autotools/Makefile]) AC_OUTPUT diff --git a/docker/build-docker-rust-base.sh b/docker/build-docker-rust-base.sh deleted file mode 100644 index b38b16ee6..000000000 --- a/docker/build-docker-rust-base.sh +++ /dev/null @@ -1,19 +0,0 @@ -docker rmi -f sumeetchhetri/ffead-cpp-5.0-base:1.0 -docker build -f ffead-cpp-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-base:1.0 . -docker push sumeetchhetri/ffead-cpp-5.0-base:1.0 - -docker rmi -f sumeetchhetri/ffead-cpp-5.0-rust-base:1.0 -docker build -f ffead-cpp-rust-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-rust-base:1.0 . -docker push sumeetchhetri/ffead-cpp-5.0-rust-base:1.0 - -docker rmi -f sumeetchhetri/ffead-cpp-5.0-v-base:1.0 -docker build -f ffead-cpp-v-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-v-base:1.0 . -docker push sumeetchhetri/ffead-cpp-5.0-v-base:1.0 - -docker rmi -f sumeetchhetri/ffead-cpp-5.0-java-base:1.0 -docker build -f ffead-cpp-java-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-java-base:1.0 . -docker push sumeetchhetri/ffead-cpp-5.0-java-base:1.0 - -docker rmi -f sumeetchhetri/ffead-cpp-5.0-rust-rocket-base:1.0 -docker build -f ffead-cpp-rust-rocket-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-rust-rocket-base:1.0 . -docker push sumeetchhetri/ffead-cpp-5.0-rust-rocket-base:1.0 diff --git a/docker/build-te-images.sh b/docker/build-te-images.sh index 76e09a429..7fc76fdcb 100644 --- a/docker/build-te-images.sh +++ b/docker/build-te-images.sh @@ -1,20 +1,19 @@ -docker rmi sumeetchhetri/ffead-cpp-5.0-base:latest -docker build -f ffead-cpp-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-base:latest . -docker push sumeetchhetri/ffead-cpp-5.0-base:latest +docker rmi -f sumeetchhetri/ffead-cpp-5.0-base:5.1 +docker build -f ffead-cpp-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-base:5.1 . +docker push sumeetchhetri/ffead-cpp-5.0-base:5.1 -docker rmi sumeetchhetri/ffead-cpp-5.0-rust-base:2.0 -docker build -f ffead-cpp-rust-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-rust-base:2.0 . -docker push sumeetchhetri/ffead-cpp-5.0-rust-base:2.0 +docker rmi -f sumeetchhetri/ffead-cpp-5.0-rust-base:5.1 +docker build -f ffead-cpp-rust-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-rust-base:5.1 . +docker push sumeetchhetri/ffead-cpp-5.0-rust-base:5.1 -docker rmi sumeetchhetri/ffead-cpp-5.0-v-base:2.0 -docker build -f ffead-cpp-v-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-v-base:2.0 . -docker push sumeetchhetri/ffead-cpp-5.0-v-base:2.0 +docker rmi -f sumeetchhetri/ffead-cpp-5.0-v-base:5.1 +docker build -f ffead-cpp-v-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-v-base:5.1 . +docker push sumeetchhetri/ffead-cpp-5.0-v-base:5.1 -docker rmi sumeetchhetri/ffead-cpp-5.0-java-base:2.0 -docker build -f ffead-cpp-java-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-java-base:2.0 . -docker push sumeetchhetri/ffead-cpp-5.0-java-base:2.0 - -docker rmi sumeetchhetri/ffead-cpp-5.0-rust-rocket-base:2.0 -docker build -f ffead-cpp-rust-rocket-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-rust-rocket-base:2.0 . -docker push sumeetchhetri/ffead-cpp-5.0-rust-rocket-base:2.0 +docker rmi -f sumeetchhetri/ffead-cpp-5.0-java-base:5.1 +docker build -f ffead-cpp-java-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-java-base:5.1 . +docker push sumeetchhetri/ffead-cpp-5.0-java-base:5.1 +docker rmi -f sumeetchhetri/ffead-cpp-5.0-rust-rocket-base:5.1 +docker build -f ffead-cpp-rust-rocket-base.dockerfile -t sumeetchhetri/ffead-cpp-5.0-rust-rocket-base:5.1 . +docker push sumeetchhetri/ffead-cpp-5.0-rust-rocket-base:5.1 diff --git a/docker/compose-techempower-tests/ffead-cpp/install_ffead-cpp-framework-forsql.sh b/docker/compose-techempower-tests/ffead-cpp/install_ffead-cpp-framework-forsql.sh index 1ba885522..bec3be9e4 100644 --- a/docker/compose-techempower-tests/ffead-cpp/install_ffead-cpp-framework-forsql.sh +++ b/docker/compose-techempower-tests/ffead-cpp/install_ffead-cpp-framework-forsql.sh @@ -42,7 +42,9 @@ sed -i 's|localhost|db|g' web/te-benchmark-um/config/sdorm.xml sed -i 's|localhost|db|g' web/te-benchmark-um/config/sdormmongo.xml sed -i 's|localhost|db|g' web/te-benchmark-um/config/sdormmysql.xml sed -i 's|localhost|db|g' web/te-benchmark-um/config/sdormpostgresql.xml +sed -i 's|localhost|db|g' web/te-benchmark-um-mgr/config/sdorm.xml sed -i 's|localhost|db|g' web/te-benchmark-um-pq/config/sdorm.xml +sed -i 's|localhost|db|g' web/te-benchmark-um-pq-async/config/sdorm.xml sed -i 's|127.0.0.1|db|g' resources/sample-odbcinst.ini sed -i 's|127.0.0.1|db|g' resources/sample-odbc.ini sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/default)||g' CMakeLists.txt diff --git a/docker/compose-techempower-tests/ffead-cpp/install_ffead-cpp-framework.sh b/docker/compose-techempower-tests/ffead-cpp/install_ffead-cpp-framework.sh index 291138cb4..9769b5b46 100644 --- a/docker/compose-techempower-tests/ffead-cpp/install_ffead-cpp-framework.sh +++ b/docker/compose-techempower-tests/ffead-cpp/install_ffead-cpp-framework.sh @@ -43,7 +43,9 @@ sed -i 's|localhost|db|g' web/te-benchmark-um/config/sdorm.xml sed -i 's|localhost|db|g' web/te-benchmark-um/config/sdormmongo.xml sed -i 's|localhost|db|g' web/te-benchmark-um/config/sdormmysql.xml sed -i 's|localhost|db|g' web/te-benchmark-um/config/sdormpostgresql.xml +sed -i 's|localhost|db|g' web/te-benchmark-um-mgr/config/sdorm.xml sed -i 's|localhost|db|g' web/te-benchmark-um-pq/config/sdorm.xml +sed -i 's|localhost|db|g' web/te-benchmark-um-pq-async/config/sdorm.xml sed -i 's|127.0.0.1|db|g' resources/sample-odbcinst.ini sed -i 's|127.0.0.1|db|g' resources/sample-odbc.ini sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/default)||g' CMakeLists.txt diff --git a/docker/os-based/install_ffead-cpp-5.0.sh b/docker/os-based/install_ffead-cpp-5.0.sh index 869fc82c6..2d70dcff0 100644 --- a/docker/os-based/install_ffead-cpp-5.0.sh +++ b/docker/os-based/install_ffead-cpp-5.0.sh @@ -11,6 +11,7 @@ sed -i'' -e "s|TeBkRestController.updateCache||g" /tmp/ffead-cpp-5. sed -i'' -e "s|TeBkUmRouter.updateCache||g" /tmp/ffead-cpp-5.0-bin/web/te-benchmark-um/config/cache.xml sed -i'' -e "s|TeBkUmLpqRouter.updateCache||g" /tmp/ffead-cpp-5.0-bin/web/te-benchmark-um-pq/config/cache.xml sed -i'' -e "s|TeBkUmMgrRouter.updateCache||g" /tmp/ffead-cpp-5.0-bin/web/te-benchmark-um-mgr/config/cache.xml +sed -i'' -e "s|TeBkUmLpqAsync.updateCache||g" /tmp/ffead-cpp-5.0-bin/web/te-benchmark-um-pq-async/config/cache.xml mv /tmp/ffead-cpp-5.0-bin /opt/ffead-cpp-5.0 chmod +x /opt/ffead-cpp-5.0/*.sh diff --git a/docker/techempower-config/benchmark_config.json b/docker/techempower-config/benchmark_config.json index fa817bc11..d448a9aa6 100644 --- a/docker/techempower-config/benchmark_config.json +++ b/docker/techempower-config/benchmark_config.json @@ -45,7 +45,7 @@ "os": "Linux", "database_os": "Linux", "display_name": "ffead-cpp-mongo-raw", - "notes": "mongodb raw redis", + "notes": "mongodb raw memory", "versus": "", "tags": [] }, @@ -439,7 +439,31 @@ "os": "Linux", "database_os": "Linux", "display_name": "ffead-cpp-postgresql-raw", - "notes": "", + "notes": "memory", + "versus": "", + "tags": [] + }, + "postgresql-raw-async": { + "json_url": "/te-benchmark-um-pq-async/json", + "plaintext_url": "/plaintext", + "db_url": "/te-benchmark-um-pq-async/db", + "query_url": "/te-benchmark-um-pq-async/queries?queries=", + "fortune_url": "/te-benchmark-um-pq-async/fortunes", + "update_url": "/te-benchmark-um-pq-async/updates?queries=", + "cached_query_url": "/te-benchmark-um-pq-async/cached-worlds?count=", + "port": 8080, + "approach": "Realistic", + "classification": "Fullstack", + "database": "postgres", + "framework": "ffead-cpp", + "language": "C++", + "orm": "Raw", + "platform": "None", + "webserver": "ffead-cpp", + "os": "Linux", + "database_os": "Linux", + "display_name": "ffead-cpp-postgresql-raw-async", + "notes": "async memory", "versus": "", "tags": [] }, diff --git a/docker/techempower-config/ffead-cpp-apache.dockerfile b/docker/techempower-config/ffead-cpp-apache.dockerfile index d64aadae1..c9abbcf6c 100644 --- a/docker/techempower-config/ffead-cpp-apache.dockerfile +++ b/docker/techempower-config/ffead-cpp-apache.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-base.dockerfile b/docker/techempower-config/ffead-cpp-base.dockerfile index 8dcb5eaa4..73b2aed01 100644 --- a/docker/techempower-config/ffead-cpp-base.dockerfile +++ b/docker/techempower-config/ffead-cpp-base.dockerfile @@ -1,6 +1,6 @@ FROM buildpack-deps:bionic LABEL maintainer="Sumeet Chhetri" -LABEL version="latest" +LABEL version="5.1" LABEL description="Base ffead-cpp docker image with commit id - master" ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-cinatra.dockerfile b/docker/techempower-config/ffead-cpp-cinatra.dockerfile index 2226d52d8..d35987967 100644 --- a/docker/techempower-config/ffead-cpp-cinatra.dockerfile +++ b/docker/techempower-config/ffead-cpp-cinatra.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-crystal-h2o.dockerfile b/docker/techempower-config/ffead-cpp-crystal-h2o.dockerfile index 1280e22cc..b2eb1b867 100644 --- a/docker/techempower-config/ffead-cpp-crystal-h2o.dockerfile +++ b/docker/techempower-config/ffead-cpp-crystal-h2o.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-crystal-http.dockerfile b/docker/techempower-config/ffead-cpp-crystal-http.dockerfile index 8f7260cbf..0699b796e 100644 --- a/docker/techempower-config/ffead-cpp-crystal-http.dockerfile +++ b/docker/techempower-config/ffead-cpp-crystal-http.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-drogon.dockerfile b/docker/techempower-config/ffead-cpp-drogon.dockerfile index f0bf97d62..f2cb51d9a 100644 --- a/docker/techempower-config/ffead-cpp-drogon.dockerfile +++ b/docker/techempower-config/ffead-cpp-drogon.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-go-fasthttp.dockerfile b/docker/techempower-config/ffead-cpp-go-fasthttp.dockerfile index 8672d5d6d..4a836ec52 100644 --- a/docker/techempower-config/ffead-cpp-go-fasthttp.dockerfile +++ b/docker/techempower-config/ffead-cpp-go-fasthttp.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-go-gnet.dockerfile b/docker/techempower-config/ffead-cpp-go-gnet.dockerfile index 193fc0fd1..fa74da112 100644 --- a/docker/techempower-config/ffead-cpp-go-gnet.dockerfile +++ b/docker/techempower-config/ffead-cpp-go-gnet.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-java-base.dockerfile b/docker/techempower-config/ffead-cpp-java-base.dockerfile index 600680287..ca41ed9e8 100644 --- a/docker/techempower-config/ffead-cpp-java-base.dockerfile +++ b/docker/techempower-config/ffead-cpp-java-base.dockerfile @@ -1,6 +1,6 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 LABEL maintainer="Sumeet Chhetri" -LABEL version="latest" +LABEL version="5.1" LABEL description="Base java docker image with master code" ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-java-firenio.dockerfile b/docker/techempower-config/ffead-cpp-java-firenio.dockerfile index a2a726cc0..db905ddee 100644 --- a/docker/techempower-config/ffead-cpp-java-firenio.dockerfile +++ b/docker/techempower-config/ffead-cpp-java-firenio.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-java-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-java-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-java-rapidoid.dockerfile b/docker/techempower-config/ffead-cpp-java-rapidoid.dockerfile index b5c6b7865..be27d8af6 100644 --- a/docker/techempower-config/ffead-cpp-java-rapidoid.dockerfile +++ b/docker/techempower-config/ffead-cpp-java-rapidoid.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-java-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-java-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-java-wizzardo-http.dockerfile b/docker/techempower-config/ffead-cpp-java-wizzardo-http.dockerfile index e5e841bf6..05f8c9ff5 100644 --- a/docker/techempower-config/ffead-cpp-java-wizzardo-http.dockerfile +++ b/docker/techempower-config/ffead-cpp-java-wizzardo-http.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-java-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-java-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-libreactor.dockerfile b/docker/techempower-config/ffead-cpp-libreactor.dockerfile index 07f08aed6..7c93bb840 100644 --- a/docker/techempower-config/ffead-cpp-libreactor.dockerfile +++ b/docker/techempower-config/ffead-cpp-libreactor.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-lithium.dockerfile b/docker/techempower-config/ffead-cpp-lithium.dockerfile index 3b4d17a60..2ff017c70 100644 --- a/docker/techempower-config/ffead-cpp-lithium.dockerfile +++ b/docker/techempower-config/ffead-cpp-lithium.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-mongo-raw.dockerfile b/docker/techempower-config/ffead-cpp-mongo-raw.dockerfile index fbe4094d9..acf925f49 100644 --- a/docker/techempower-config/ffead-cpp-mongo-raw.dockerfile +++ b/docker/techempower-config/ffead-cpp-mongo-raw.dockerfile @@ -1,7 +1,7 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs WORKDIR / -CMD ./run_ffead.sh ffead-cpp-5.0 emb mongo-raw redis +CMD ./run_ffead.sh ffead-cpp-5.0 emb mongo-raw memory diff --git a/docker/techempower-config/ffead-cpp-mysql.dockerfile b/docker/techempower-config/ffead-cpp-mysql.dockerfile index a07357ec8..aa736b0a3 100644 --- a/docker/techempower-config/ffead-cpp-mysql.dockerfile +++ b/docker/techempower-config/ffead-cpp-mysql.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-nginx.dockerfile b/docker/techempower-config/ffead-cpp-nginx.dockerfile index a8854bae8..9877378b5 100644 --- a/docker/techempower-config/ffead-cpp-nginx.dockerfile +++ b/docker/techempower-config/ffead-cpp-nginx.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-postgresql-raw-async.dockerfile b/docker/techempower-config/ffead-cpp-postgresql-raw-async.dockerfile new file mode 100644 index 000000000..b3fe9ea67 --- /dev/null +++ b/docker/techempower-config/ffead-cpp-postgresql-raw-async.dockerfile @@ -0,0 +1,7 @@ +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 + +ENV IROOT=/installs + +WORKDIR / + +CMD ./run_ffead.sh ffead-cpp-5.0-sql emb postgresql-raw-async memory diff --git a/docker/techempower-config/ffead-cpp-postgresql-raw.dockerfile b/docker/techempower-config/ffead-cpp-postgresql-raw.dockerfile index fa777de95..c3f074e62 100644 --- a/docker/techempower-config/ffead-cpp-postgresql-raw.dockerfile +++ b/docker/techempower-config/ffead-cpp-postgresql-raw.dockerfile @@ -1,7 +1,7 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs WORKDIR / -CMD ./run_ffead.sh ffead-cpp-5.0-sql emb postgresql-raw redis +CMD ./run_ffead.sh ffead-cpp-5.0-sql emb postgresql-raw memory diff --git a/docker/techempower-config/ffead-cpp-postgresql.dockerfile b/docker/techempower-config/ffead-cpp-postgresql.dockerfile index 2b19a0a85..6c508055e 100644 --- a/docker/techempower-config/ffead-cpp-postgresql.dockerfile +++ b/docker/techempower-config/ffead-cpp-postgresql.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-rust-actix.dockerfile b/docker/techempower-config/ffead-cpp-rust-actix.dockerfile index 6731336a0..4fa97b276 100644 --- a/docker/techempower-config/ffead-cpp-rust-actix.dockerfile +++ b/docker/techempower-config/ffead-cpp-rust-actix.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-rust-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-rust-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-rust-base.dockerfile b/docker/techempower-config/ffead-cpp-rust-base.dockerfile index dc178904b..351b0f355 100644 --- a/docker/techempower-config/ffead-cpp-rust-base.dockerfile +++ b/docker/techempower-config/ffead-cpp-rust-base.dockerfile @@ -1,6 +1,6 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 LABEL maintainer="Sumeet Chhetri" -LABEL version="latest" +LABEL version="5.1" LABEL description="Base rust docker image with ffead-cpp v4.0 - commit id - master" ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-rust-hyper.dockerfile b/docker/techempower-config/ffead-cpp-rust-hyper.dockerfile index 02a199883..d9053a891 100644 --- a/docker/techempower-config/ffead-cpp-rust-hyper.dockerfile +++ b/docker/techempower-config/ffead-cpp-rust-hyper.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-rust-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-rust-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-rust-rocket-base.dockerfile b/docker/techempower-config/ffead-cpp-rust-rocket-base.dockerfile index 71a2e80b0..48010dbec 100644 --- a/docker/techempower-config/ffead-cpp-rust-rocket-base.dockerfile +++ b/docker/techempower-config/ffead-cpp-rust-rocket-base.dockerfile @@ -1,7 +1,7 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 LABEL maintainer="Sumeet Chhetri" -LABEL version="2.0" -LABEL description="Base rust rocket docker image with ffead-cpp v4.0 - commit id - master" +LABEL version="5.1" +LABEL description="Base rust rocket docker image with ffead-cpp v5.0 - commit id - master" ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-rust-rocket.dockerfile b/docker/techempower-config/ffead-cpp-rust-rocket.dockerfile index 440113065..fb36da72c 100644 --- a/docker/techempower-config/ffead-cpp-rust-rocket.dockerfile +++ b/docker/techempower-config/ffead-cpp-rust-rocket.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-rust-rocket-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-rust-rocket-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-v-base.dockerfile b/docker/techempower-config/ffead-cpp-v-base.dockerfile index 0686806f0..f13317c76 100644 --- a/docker/techempower-config/ffead-cpp-v-base.dockerfile +++ b/docker/techempower-config/ffead-cpp-v-base.dockerfile @@ -1,6 +1,6 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 LABEL maintainer="Sumeet Chhetri" -LABEL version="latest" +LABEL version="5.1" LABEL description="Base v docker image with ffead-cpp v4.0 commit id - master" ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-v-picov.dockerfile b/docker/techempower-config/ffead-cpp-v-picov.dockerfile index b7698cd56..72acd5795 100644 --- a/docker/techempower-config/ffead-cpp-v-picov.dockerfile +++ b/docker/techempower-config/ffead-cpp-v-picov.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-v-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-v-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp-v-vweb.dockerfile b/docker/techempower-config/ffead-cpp-v-vweb.dockerfile index 3ba70801d..a95e903f0 100644 --- a/docker/techempower-config/ffead-cpp-v-vweb.dockerfile +++ b/docker/techempower-config/ffead-cpp-v-vweb.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-v-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-v-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/ffead-cpp.dockerfile b/docker/techempower-config/ffead-cpp.dockerfile index bb5a88ee9..ef4ab0330 100644 --- a/docker/techempower-config/ffead-cpp.dockerfile +++ b/docker/techempower-config/ffead-cpp.dockerfile @@ -1,4 +1,4 @@ -FROM sumeetchhetri/ffead-cpp-5.0-base:latest +FROM sumeetchhetri/ffead-cpp-5.0-base:5.1 ENV IROOT=/installs diff --git a/docker/techempower-config/install_ffead-cpp-framework.sh b/docker/techempower-config/install_ffead-cpp-framework.sh index affecad60..4b4c79b06 100644 --- a/docker/techempower-config/install_ffead-cpp-framework.sh +++ b/docker/techempower-config/install_ffead-cpp-framework.sh @@ -12,10 +12,12 @@ chmod 755 *.sh resources/*.sh rtdcf/autotools/*.sh #rm -rf web/te-benchmark-um #rm -rf web/te-benchmark-um-pq #rm -rf web/te-benchmark-um-mgr +#rm -rf web/te-benchmark-um-pq-async mv ${IROOT}/server.sh script/ #mv ${IROOT}/te-benchmark-um web/ #mv ${IROOT}/te-benchmark-um-pq web/ #mv ${IROOT}/te-benchmark-um-mgr web/ +#mv ${IROOT}/te-benchmark-um-pq-async web/ sed -i 's|THRD_PSIZ=6|THRD_PSIZ='${SERV_THREADS}'|g' resources/server.prop sed -i 's|W_THRD_PSIZ=2|W_THRD_PSIZ='${WRIT_THREADS}'|g' resources/server.prop sed -i 's|ENABLE_CRS=true|ENABLE_CRS=false|g' resources/server.prop @@ -42,6 +44,7 @@ sed -i 's|localhost|tfb-database|g' web/te-benchmark-um/config/sdormmysql.xml sed -i 's|localhost|tfb-database|g' web/te-benchmark-um/config/sdormpostgresql.xml sed -i 's|localhost|tfb-database|g' web/te-benchmark-um-pq/config/sdorm.xml sed -i 's|localhost|tfb-database|g' web/te-benchmark-um-mgr/config/sdorm.xml +sed -i 's|localhost|tfb-database|g' web/te-benchmark-um-pq-async/config/sdorm.xml sed -i 's|127.0.0.1|tfb-database|g' resources/sample-odbcinst.ini sed -i 's|127.0.0.1|tfb-database|g' resources/sample-odbc.ini sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/default)||g' CMakeLists.txt @@ -83,9 +86,6 @@ rm -f /usr/local/lib/libdinter.so cd ffead-cpp-5.0-bin #cache related dockerfiles will add the cache.xml accordingly whenever needed -rm -f web/te-benchmark-um/config/cache.xml -rm -f web/te-benchmark-um-pq/config/cache.xml -rm -f web/te-benchmark-um-mgr/config/cache.xml chmod 755 *.sh resources/*.sh rtdcf/autotools/*.sh ./server.sh & while [ ! -f lib/libinter.so ] @@ -120,9 +120,6 @@ make install -j${MAX_THREADS} cd ffead-cpp-5.0-bin #cache related dockerfiles will add the cache.xml accordingly whenever needed -rm -f web/te-benchmark-um/config/cache.xml -rm -f web/te-benchmark-um-pq/config/cache.xml -rm -f web/te-benchmark-um-mgr/config/cache.xml chmod 755 *.sh resources/*.sh rtdcf/autotools/*.sh ./server.sh & while [ ! -f lib/libinter.so ] diff --git a/docker/techempower-config/run_ffead.sh b/docker/techempower-config/run_ffead.sh index f1efcd8c9..0bfc02e6a 100644 --- a/docker/techempower-config/run_ffead.sh +++ b/docker/techempower-config/run_ffead.sh @@ -45,9 +45,14 @@ service apache2 stop service memcached stop rm -f /tmp/cache.lock -rm -f web/te-benchmark-um/config/cache.xml -rm -f web/te-benchmark-um-pq/config/cache.xml -rm -f web/te-benchmark-um-mgr/config/cache.xml + +if [ "$4" = "memory" ] +then + cp -f web/te-benchmark-um/config/cachememory.xml web/te-benchmark-um/config/cache.xml + cp -f web/te-benchmark-um-pq/config/cachememory.xml web/te-benchmark-um-pq/config/cache.xml + cp -f web/te-benchmark-um-mgr/config/cachememory.xml web/te-benchmark-um-mgr/config/cache.xml + cp -f web/te-benchmark-um-pq-async/config/cachememory.xml web/te-benchmark-um-pq/config/cache.xml +fi if [ "$4" = "redis" ] then @@ -69,6 +74,7 @@ if [ "$3" = "mongo" ] then rm -f web/te-benchmark-um-pq/config/cache.xml rm -f web/te-benchmark-um-mgr/config/cache.xml + rm -f web/te-benchmark-um-pq-async/config/cache.xml cp -f web/te-benchmark-um/config/sdormmongo.xml web/te-benchmark-um/config/sdorm.xml fi @@ -76,12 +82,14 @@ if [ "$3" = "mongo-raw" ] then rm -f web/te-benchmark-um-pq/config/cache.xml rm -f web/te-benchmark-um/config/cache.xml + rm -f web/te-benchmark-um-pq-async/config/cache.xml fi if [ "$3" = "mysql" ] then rm -f web/te-benchmark-um-pq/config/cache.xml rm -f web/te-benchmark-um-mgr/config/cache.xml + rm -f web/te-benchmark-um-pq-async/config/cache.xml cp -f web/te-benchmark-um/config/sdormmysql.xml web/te-benchmark-um/config/sdorm.xml fi @@ -89,13 +97,24 @@ if [ "$3" = "postgresql" ] then rm -f web/te-benchmark-um-pq/config/cache.xml rm -f web/te-benchmark-um-mgr/config/cache.xml + rm -f web/te-benchmark-um-pq-async/config/cache.xml cp -f web/te-benchmark-um/config/sdormpostgresql.xml web/te-benchmark-um/config/sdorm.xml fi if [ "$3" = "postgresql-raw" ] then rm -f web/te-benchmark-um/config/cache.xml + rm -f web/te-benchmark-um-pq/config/cache.xml + rm -f web/te-benchmark-um-mgr/config/cache.xml + sed -i 's|true|false|g' web/te-benchmark-um-pq/config/sdorm.xml +fi + +if [ "$3" = "postgresql-raw-async" ] +then + rm -f web/te-benchmark-um/config/cache.xml + rm -f web/te-benchmark-um-pq/config/cache.xml rm -f web/te-benchmark-um-mgr/config/cache.xml + sed -i 's|false|true|g' web/te-benchmark-um-pq-async/config/sdorm.xml fi rm -f rtdcf/*.d rtdcf/*.o @@ -111,7 +130,7 @@ chmod 700 rtdcf/* if [ "$2" = "emb" ] then - sed -i 's|EVH_SINGLE=false|EVH_SINGLE=true|g' $FFEAD_CPP_PATH/resources/server.prop + sed -i 's|EVH_SINGLE=false|EVH_SINGLE=true|g' resources/server.prop for i in $(seq 0 $(($(nproc --all)-1))); do taskset -c $i ./ffead-cpp $FFEAD_CPP_PATH & done @@ -139,24 +158,28 @@ then sed -i 's|/installs/ffead-cpp-5.0|'/installs/ffead-cpp-5.0-sql'|g' /etc/apache2/apache2.conf sed -i 's|/installs/ffead-cpp-5.0|'/installs/ffead-cpp-5.0-sql'|g' /etc/apache2/sites-enabled/000-default.conf /etc/apache2/sites-enabled/ffead-site.conf fi - sed -i 's|30|3|g' $FFEAD_CPP_PATH/web/te-benchmark-um/config/sdorm.xml - sed -i 's|10|2|g' $FFEAD_CPP_PATH/web/te-benchmark-um/config/cache.xml - sed -i 's|30|3|g' $FFEAD_CPP_PATH/web/te-benchmark-um-pq/config/sdorm.xml - sed -i 's|10|2|g' $FFEAD_CPP_PATH/web/te-benchmark-um-pq/config/cache.xml - sed -i 's|30|3|g' $FFEAD_CPP_PATH/web/te-benchmark-um-mgr/config/sdorm.xml - sed -i 's|10|2|g' $FFEAD_CPP_PATH/web/te-benchmark-um-mgr/config/cache.xml + sed -i 's|30|3|g' web/te-benchmark-um/config/sdorm.xml + sed -i 's|10|2|g' web/te-benchmark-um/config/cache.xml + sed -i 's|30|3|g' web/te-benchmark-um-pq/config/sdorm.xml + sed -i 's|10|2|g' web/te-benchmark-um-pq/config/cache.xml + sed -i 's|30|3|g' web/te-benchmark-um-mgr/config/sdorm.xml + sed -i 's|10|2|g' web/te-benchmark-um-mgr/config/cache.xml + sed -i 's|30|3|g' web/te-benchmark-um-pq-async/config/sdorm.xml + sed -i 's|10|2|g' web/te-benchmark-um-pq-async/config/cache.xml apachectl -D FOREGROUND fi if [ "$2" = "nginx" ] then mkdir -p ${IROOT}/nginxfc/logs - sed -i 's|30|3|g' $FFEAD_CPP_PATH/web/te-benchmark-um/config/sdorm.xml - sed -i 's|10|2|g' $FFEAD_CPP_PATH/web/te-benchmark-um/config/cache.xml - sed -i 's|30|3|g' $FFEAD_CPP_PATH/web/te-benchmark-um-pq/config/sdorm.xml - sed -i 's|10|2|g' $FFEAD_CPP_PATH/web/te-benchmark-um-pq/config/cache.xml - sed -i 's|30|3|g' $FFEAD_CPP_PATH/web/te-benchmark-um-mgr/config/sdorm.xml - sed -i 's|10|2|g' $FFEAD_CPP_PATH/web/te-benchmark-um-mgr/config/cache.xml + sed -i 's|30|3|g' web/te-benchmark-um/config/sdorm.xml + sed -i 's|10|2|g' web/te-benchmark-um/config/cache.xml + sed -i 's|30|3|g' web/te-benchmark-um-pq/config/sdorm.xml + sed -i 's|10|2|g' web/te-benchmark-um-pq/config/cache.xml + sed -i 's|30|3|g' web/te-benchmark-um-mgr/config/sdorm.xml + sed -i 's|10|2|g' web/te-benchmark-um-mgr/config/cache.xml + sed -i 's|30|3|g' web/te-benchmark-um-pq-async/config/sdorm.xml + sed -i 's|10|2|g' web/te-benchmark-um-pq-async/config/cache.xml if [ "$3" = "mysql" ] || [ "$3" = "postgresql" ] then nginx -g 'daemon off;' -c ${IROOT}/nginx-ffead-sql/conf/nginx.conf diff --git a/docker/test/CMakeLists.txt b/docker/test/CMakeLists.txt index dc0f467fa..176dc1bb2 100644 --- a/docker/test/CMakeLists.txt +++ b/docker/test/CMakeLists.txt @@ -493,6 +493,7 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/web/peer-server) add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark) add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um) add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um-pq) +add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um-pq-async) add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um-mgr) if(MOD_APACHE) @@ -595,6 +596,7 @@ if(CYGWIN OR MINGW) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark/libte_benchmark${CMAKE_SHARED_LIBRARY_SUFFIX}.a DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um/libte_benchmark_um${CMAKE_SHARED_LIBRARY_SUFFIX}.a DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-pq/libte_benchmark_um_pq${CMAKE_SHARED_LIBRARY_SUFFIX}.a DESTINATION ${PROJECT_NAME}-bin/lib) + install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-pq-async/libte_benchmark_um_pq_async${CMAKE_SHARED_LIBRARY_SUFFIX}.a DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-mgr/libte_benchmark_um_mgr${CMAKE_SHARED_LIBRARY_SUFFIX}.a DESTINATION ${PROJECT_NAME}-bin/lib) else() install(FILES ${PROJECT_BINARY_DIR}/src/modules/libffead-modules${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) @@ -607,6 +609,7 @@ if(CYGWIN OR MINGW) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark/libte_benchmark${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um/libte_benchmark_um${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-pq/libte_benchmark_um_pq${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) + install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-pq-async/libte_benchmark_um_pq_async${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-mgr/libte_benchmark_um_mgr${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) endif() install(FILES ${PROJECT_BINARY_DIR}/ffead-cpp.exe DESTINATION ${PROJECT_NAME}-bin/) @@ -621,6 +624,7 @@ else() install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark/libte_benchmark${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um/libte_benchmark_um${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-pq/libte_benchmark_um_pq${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) + install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-pq-async/libte_benchmark_um_pq_async${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/web/te-benchmark-um-mgr/libte_benchmark_um_mgr${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib) install(FILES ${PROJECT_BINARY_DIR}/ffead-cpp DESTINATION ${PROJECT_NAME}-bin/) endif() diff --git a/docker/test/DockerFile-UbuntuBionic-x64-ffead-cpp-5.0-fortest b/docker/test/DockerFile-UbuntuBionic-x64-ffead-cpp-5.0-fortest index 04b2dcd1c..a9814394a 100644 --- a/docker/test/DockerFile-UbuntuBionic-x64-ffead-cpp-5.0-fortest +++ b/docker/test/DockerFile-UbuntuBionic-x64-ffead-cpp-5.0-fortest @@ -174,53 +174,63 @@ RUN mkdir build WORKDIR /tmp/ffead-cpp-src/build RUN cmake -GNinja -DSRV_EMB=on -DMOD_MEMCACHED=on -DMOD_REDIS=on -DMOD_SDORM_MONGO=on -DDEBUG=on .. RUN ninja install && \ - mv /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-mgr/config/cacheredis.xml /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-mgr/config/cache.xml && \ + cp -f /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-mgr/config/cacheredis.xml /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-mgr/config/cache.xml && \ rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um && \ rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-pq && \ + rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-pq-async && \ mv /tmp/ffead-cpp-src/ffead-cpp-5.0-bin /tmp/ffead-cpp-mongo-raw WORKDIR /tmp/ffead-cpp-src/build RUN ninja install && \ - mv /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/sdormmongo.xml /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/sdorm.xml && \ - mv /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/cacheredis.xml /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/cache.xml && \ + cp -f /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/sdormmongo.xml /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/sdorm.xml && \ + cp -f /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/cacheredis.xml /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/cache.xml && \ rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-pq && \ + rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-pq-async && \ rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-mgr && \ mv /tmp/ffead-cpp-src/ffead-cpp-5.0-bin /tmp/ffead-cpp-mongo-orm WORKDIR /tmp/ffead-cpp-src/build RUN ninja install && \ - mv /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-pq/config/cacheredis.xml /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-pq/config/cache.xml && \ + cp -f /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-pq/config/cacheredis.xml /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-pq/config/cache.xml && \ rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um && \ rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-mgr && \ + rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-pq-async && \ mv /tmp/ffead-cpp-src/ffead-cpp-5.0-bin /tmp/ffead-cpp-sql-raw WORKDIR /tmp/ffead-cpp-src/build RUN cp -f /tmp/ffead-cpp-src/web/te-benchmark-um/sql-src/TeBkUmWorldsql.h /tmp/ffead-cpp-src/web/te-benchmark-um/include/TeBkUmWorld.h && \ cp -f /tmp/ffead-cpp-src/web/te-benchmark-um/sql-src/TeBkUmWorldsql.cpp /tmp/ffead-cpp-src/web/te-benchmark-um/src/TeBkUmWorld.cpp && \ ninja install && \ - mv /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/sdormpostgresql.xml /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/sdorm.xml && \ - mv /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/cacheredis.xml /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/cache.xml && \ + cp -f /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/sdormpostgresql.xml /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/sdorm.xml && \ + cp -f /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/cacheredis.xml /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um/config/cache.xml && \ cp /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/resources/sample-odbcinst.ini /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/resources/odbcinst.ini && \ cp /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/resources/sample-odbc.ini /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/resources/odbc.ini && \ rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-pq && \ + rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-pq-async && \ rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-mgr && \ mv /tmp/ffead-cpp-src/ffead-cpp-5.0-bin /tmp/ffead-cpp-sql-orm -COPY *.sh / +WORKDIR /tmp/ffead-cpp-src/build +RUN ninja install && \ + rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um && \ + rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-pq && \ + rm -rf /tmp/ffead-cpp-src/ffead-cpp-5.0-bin/web/te-benchmark-um-mgr && \ + mv /tmp/ffead-cpp-src/ffead-cpp-5.0-bin /tmp/ffead-cpp-sql-raw-async -WORKDIR / +COPY *.sh pipeline.lua / -RUN rm -rf /tmp/ffead-cpp-src && chmod +x *.sh && ./install_ffead-cpp.sh +WORKDIR / RUN chown -Rf root:root /ssd && chown -Rf postgres:postgres /ssd/postgresql && chown -Rf mysql:mysql /ssd/mysql && chmod 777 pipeline.lua concurrency.sh pipeline.sh query.sh -#RUN echo "/opt/run.sh" >> /root/.bashrc +EXPOSE 9781 9782 9783 9784 9785 + +RUN rm -rf /tmp/ffead-cpp-src && chmod +x *.sh && ./install_ffead-cpp.sh RUN sed -i 's|PORT_NO=8080|PORT_NO=9781|g' /tmp/ffead-cpp-mongo-raw/resources/server.prop && \ sed -i 's|PORT_NO=8080|PORT_NO=9782|g' /tmp/ffead-cpp-mongo-orm/resources/server.prop && \ sed -i 's|PORT_NO=8080|PORT_NO=9783|g' /tmp/ffead-cpp-sql-raw/resources/server.prop && \ - sed -i 's|PORT_NO=8080|PORT_NO=9784|g' /tmp/ffead-cpp-sql-orm/resources/server.prop - -EXPOSE 9781 9782 9783 9784 + sed -i 's|PORT_NO=8080|PORT_NO=9784|g' /tmp/ffead-cpp-sql-orm/resources/server.prop && \ + sed -i 's|PORT_NO=8080|PORT_NO=9785|g' /tmp/ffead-cpp-sql-raw-async/resources/server.prop CMD /bin/bash \ No newline at end of file diff --git a/docker/test/install_ffead-cpp.sh b/docker/test/install_ffead-cpp.sh index 2f17ce0bc..19b954ee9 100644 --- a/docker/test/install_ffead-cpp.sh +++ b/docker/test/install_ffead-cpp.sh @@ -14,13 +14,19 @@ sed -i 's|W_THRD_PSIZ=2|W_THRD_PSIZ='${WRIT_THREADS}'|g' /tmp/ffead-cpp-mongo-or sed -i 's|THRD_PSIZ=6|THRD_PSIZ='${SERV_THREADS}'|g' /tmp/ffead-cpp-sql-raw/resources/server.prop sed -i 's|W_THRD_PSIZ=2|W_THRD_PSIZ='${WRIT_THREADS}'|g' /tmp/ffead-cpp-sql-raw/resources/server.prop -sed -i 's|THRD_PSIZ=6|THRD_PSIZ='${SERV_THREADS}'|g' /tmp/ffead-cpp-mongo-orm/resources/server.prop -sed -i 's|W_THRD_PSIZ=2|W_THRD_PSIZ='${WRIT_THREADS}'|g' /tmp/ffead-cpp-mongo-orm/resources/server.prop +sed -i 's|THRD_PSIZ=6|THRD_PSIZ='${SERV_THREADS}'|g' /tmp/ffead-cpp-sql-orm/resources/server.prop +sed -i 's|W_THRD_PSIZ=2|W_THRD_PSIZ='${WRIT_THREADS}'|g' /tmp/ffead-cpp-sql-orm/resources/server.prop + +sed -i 's|THRD_PSIZ=6|THRD_PSIZ='${SERV_THREADS}'|g' /tmp/ffead-cpp-sql-raw-async/resources/server.prop +sed -i 's|W_THRD_PSIZ=2|W_THRD_PSIZ='${WRIT_THREADS}'|g' /tmp/ffead-cpp-sql-raw-async/resources/server.prop chmod +x /tmp/ffead-cpp-mongo-raw/*.sh chmod +x /tmp/ffead-cpp-mongo-orm/*.sh chmod +x /tmp/ffead-cpp-sql-raw/*.sh chmod +x /tmp/ffead-cpp-sql-orm/*.sh +chmod +x /tmp/ffead-cpp-sql-raw-async/*.sh + +cp /tmp/ffead-cpp-mongo-raw/server.sh /server_orig.sh cd /tmp/ffead-cpp-mongo-raw nohup bash -c "./server.sh > ffead.log &" @@ -158,4 +164,38 @@ echo "normal shutdown" rm -f serv.ctrl pkill ffead-cpp +cd /tmp/ffead-cpp-sql-raw-async +nohup bash -c "./server.sh > ffead.log &" +echo "Waiting for ffead-cpp to launch on port 8080..." +COUNTER=0 +while [ ! -f lib/libinter.so ] +do + sleep 1 + COUNTER=$((COUNTER+1)) + if [ "$COUNTER" = 600 ] + then + cat ffead.log + cat logs/jobs.log + echo "exiting...." + exit 1 + fi +done +COUNTER=0 +while [ ! -f lib/libdinter.so ] +do + sleep 1 + COUNTER=$((COUNTER+1)) + if [ "$COUNTER" = 120 ] + then + cat ffead.log + cat logs/jobs.log + echo "exiting....dlib" + exit 1 + fi +done +echo "ffead-cpp with sql-raw-async-postgres support launched" +echo "normal shutdown" +rm -f serv.ctrl +pkill ffead-cpp + exit 0 \ No newline at end of file diff --git a/docker/test/mongo-debug-orm.sh b/docker/test/mongo-debug-orm.sh index cc0da1d46..123a0c12f 100644 --- a/docker/test/mongo-debug-orm.sh +++ b/docker/test/mongo-debug-orm.sh @@ -1,24 +1,40 @@ +if ! nc -z localhost 5432 ; then + /run.sh +fi + +ulimit -c unlimited export FFEAD_CPP_PATH=/tmp/ffead-cpp-mongo-orm/ export ODBCINI=$FFEAD_CPP_PATH/resources/odbc.ini export ODBCSYSINI=$FFEAD_CPP_PATH/resources export LD_LIBRARY_PATH=$FFEAD_CPP_PATH/lib:/usr/local/lib:$LD_LIBRARY_PATH export PATH=$FFEAD_CPP_PATH/lib:$PATH cd /tmp/ffead-cpp-mongo-orm +cp -f web/te-benchmark-um/config/cachememory.xml web/te-benchmark-um/config/cache.xml if [ $# -eq 0 ]; then + cp /server_orig.sh server.sh nohup bash -c "./server.sh > ffead.log &" sleep 10 echo "ffead-cpp with mongo-orm support launched" - wrk -t1 -c1 -d5s http://localhost:9782/te-benchmark-um/json - wrk -t1 -c1 -d5s http://localhost:9782/te-benchmark-um/plaintext - wrk -t1 -c1 -d5s http://localhost:9782/te-benchmark-um/fortunes + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9782/te-benchmark-um/json" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 2 "http://localhost:9782/te-benchmark-um/plaintext" -s /pipeline.lua -- 16 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 2 "http://localhost:9782/te-benchmark-um/fortunes" mongo admin --eval 'var stats = db.runCommand( { serverStatus: 1});print(stats["opcounters"]["query"])' - wrk -t1 -c1 -d5s http://localhost:9782/te-benchmark-um/db + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9782/te-benchmark-um/db" mongo admin --eval 'var stats = db.runCommand( { serverStatus: 1});print(stats["opcounters"]["query"])' - wrk -t1 -c1 -d5s http://localhost:9782/te-benchmark-um/queries?queries=1 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9782/te-benchmark-um/queries?queries=20" mongo admin --eval 'var stats = db.runCommand( { serverStatus: 1});print(stats["opcounters"]["query"])' - wrk -t1 -c1 -d5s http://localhost:9782/te-benchmark-um/updates?queries=1 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9782/te-benchmark-um/updates?queries=20" mongo admin --eval 'var stats = db.runCommand( { serverStatus: 1});print(stats["opcounters"]["update"])' - wrk -t1 -c1 -d5s http://localhost:9782/te-benchmark-um/cached-worlds?queries=1 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9782/te-benchmark-um/cached-worlds?count=100" + sleep 10 + pkill ffead-cpp fi if [ "$1" == "g" ]; then gdb ffead-cpp diff --git a/docker/test/mongo-debug-raw.sh b/docker/test/mongo-debug-raw.sh index 874d6c175..c508c4997 100644 --- a/docker/test/mongo-debug-raw.sh +++ b/docker/test/mongo-debug-raw.sh @@ -1,25 +1,43 @@ +if ! nc -z localhost 5432 ; then + /run.sh +fi + +ulimit -c unlimited export FFEAD_CPP_PATH=/tmp/ffead-cpp-mongo-raw/ export ODBCINI=$FFEAD_CPP_PATH/resources/odbc.ini export ODBCSYSINI=$FFEAD_CPP_PATH/resources export LD_LIBRARY_PATH=$FFEAD_CPP_PATH/lib:/usr/local/lib:$LD_LIBRARY_PATH export PATH=$FFEAD_CPP_PATH/lib:$PATH cd /tmp/ffead-cpp-mongo-raw +cp -f web/te-benchmark-um-mgr/config/cachememory.xml web/te-benchmark-um-mgr/config/cache.xml +sed -i 's|EVH_SINGLE=false|EVH_SINGLE=true|g' resources/server.prop if [ $# -eq 0 ]; then + cp /server_orig.sh server.sh nohup bash -c "./server.sh > ffead.log &" sleep 10 echo "ffead-cpp with mongo-raw support launched" - wrk -t1 -c1 -d5s http://localhost:9781/te-benchmark-um-mgr/json - wrk -t1 -c1 -d5s http://localhost:9781/te-benchmark-um-mgr/plaintext - wrk -t1 -c1 -d5s http://localhost:9781/te-benchmark-um-mgr/fortunes + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9781/te-benchmark-um-mgr/json" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 2 "http://localhost:9781/te-benchmark-um-mgr/plaintext" -s /pipeline.lua -- 16 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 2 "http://localhost:9781/te-benchmark-um-mgr/fortunes" mongo admin --eval 'var stats = db.runCommand( { serverStatus: 1});print(stats["opcounters"]["query"])' - wrk -t1 -c1 -d5s http://localhost:9781/te-benchmark-um-mgr/db + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9781/te-benchmark-um-mgr/db" mongo admin --eval 'var stats = db.runCommand( { serverStatus: 1});print(stats["opcounters"]["query"])' - wrk -t1 -c1 -d5s http://localhost:9781/te-benchmark-um-mgr/queries?queries=1 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9781/te-benchmark-um-mgr/queries?queries=20" mongo admin --eval 'var stats = db.runCommand( { serverStatus: 1});print(stats["opcounters"]["query"])' - wrk -t1 -c1 -d5s http://localhost:9781/te-benchmark-um-mgr/updates?queries=1 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9781/te-benchmark-um-mgr/updates?queries=20" mongo admin --eval 'var stats = db.runCommand( { serverStatus: 1});print(stats["opcounters"]["update"])' - wrk -t1 -c1 -d5s http://localhost:9781/te-benchmark-um-mgr/cached-worlds?queries=1 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9781/te-benchmark-um-mgr/cached-worlds?count=100" + sleep 10 + pkill ffead-cpp fi if [ "$1" == "g" ]; then + cp /server.sh . gdb ffead-cpp fi \ No newline at end of file diff --git a/docker/test/pipeline.lua b/docker/test/pipeline.lua new file mode 100644 index 000000000..850e5a717 --- /dev/null +++ b/docker/test/pipeline.lua @@ -0,0 +1,12 @@ +init = function(args) + local r = {} + local depth = tonumber(args[1]) or 1 + for i=1,depth do + r[i] = wrk.format() + end + req = table.concat(r) +end + +request = function() + return req +end \ No newline at end of file diff --git a/docker/test/server.sh b/docker/test/server.sh new file mode 100644 index 000000000..0c02f982f --- /dev/null +++ b/docker/test/server.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +export MALLOC_CHECK_=0 +IS_OS_DARWIN=`uname|tr '[A-Z]' '[a-z]'|awk 'index($0,"darwin") != 0 {print "darwin"}'` +if [ "$IS_OS_DARWIN" != "" ]; then + export FFEAD_CPP_PATH=`cd "$(dirname server.sh)" && ABSPATH=$(pwd) && cd -` +else + export FFEAD_CPP_PATH=`echo $(dirname $(readlink -f $0))` +fi + +export ODBCINI=$FFEAD_CPP_PATH/resources/odbc.ini +export ODBCSYSINI=$FFEAD_CPP_PATH/resources +echo $FFEAD_CPP_PATH +export LD_LIBRARY_PATH=$FFEAD_CPP_PATH/lib:/usr/local/lib:$LD_LIBRARY_PATH +echo $LD_LIBRARY_PATH +export DYLD_FALLBACK_LIBRARY_PATH=$LD_LIBRARY_PATH +echo $DYLD_FALLBACK_LIBRARY_PATH +export PATH=$FFEAD_CPP_PATH/lib:$PATH +echo $PATH +rm -f $FFEAD_CPP_PATH/rtdcf/*.d $FFEAD_CPP_PATH/rtdcf/*.o +rm -f $FFEAD_CPP_PATH/*.cntrl +rm -f $FFEAD_CPP_PATH/tmp/*.sess +if [ ! -d tmp ]; then +mkdir tmp +fi +chmod 700 $FFEAD_CPP_PATH/ffead-cpp +chmod 700 $FFEAD_CPP_PATH/resources/*.sh +chmod 700 $FFEAD_CPP_PATH/tests/* +chmod 700 $FFEAD_CPP_PATH/rtdcf/* +chmod 700 $FFEAD_CPP_PATH/rtdcf/autotools/* +#/usr/sbin/setenforce 0 + +./ffead-cpp $FFEAD_CPP_PATH > ffead.log 2>&1 diff --git a/docker/test/sql-debug-orm.sh b/docker/test/sql-debug-orm.sh index d4a2dc656..9aa15d6b7 100644 --- a/docker/test/sql-debug-orm.sh +++ b/docker/test/sql-debug-orm.sh @@ -1,20 +1,36 @@ +if ! nc -z localhost 5432 ; then + /run.sh +fi + +ulimit -c unlimited export FFEAD_CPP_PATH=/tmp/ffead-cpp-sql-orm/ export ODBCINI=$FFEAD_CPP_PATH/resources/odbc.ini export ODBCSYSINI=$FFEAD_CPP_PATH/resources export LD_LIBRARY_PATH=$FFEAD_CPP_PATH/lib:/usr/local/lib:$LD_LIBRARY_PATH export PATH=$FFEAD_CPP_PATH/lib:$PATH cd /tmp/ffead-cpp-sql-orm +cp -f web/te-benchmark-um/config/cachememory.xml web/te-benchmark-um/config/cache.xml if [ $# -eq 0 ]; then + cp /server_orig.sh server.sh nohup bash -c "./server.sh > ffead.log &" sleep 10 echo "ffead-cpp with sql-orm support launched" - wrk -t1 -c1 -d5s http://localhost:9784/te-benchmark-um/json - wrk -t1 -c1 -d5s http://localhost:9784/te-benchmark-um/plaintext - wrk -t1 -c1 -d5s http://localhost:9784/te-benchmark-um/fortunes - wrk -t1 -c1 -d5s http://localhost:9784/te-benchmark-um/db - wrk -t1 -c1 -d5s http://localhost:9784/te-benchmark-um/queries?queries=1 - wrk -t1 -c1 -d5s http://localhost:9784/te-benchmark-um/updates?queries=1 - wrk -t1 -c1 -d5s http://localhost:9784/te-benchmark-um/cached-worlds?queries=1 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9784/te-benchmark-um/json" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 2 "http://localhost:9784/te-benchmark-um/plaintext" -s /pipeline.lua -- 16 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 2 "http://localhost:9784/te-benchmark-um/fortunes" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9784/te-benchmark-um/db" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9784/te-benchmark-um/queries?queries=20" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9784/te-benchmark-um/updates?queries=20" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9784/te-benchmark-um/cached-worlds?count=100" + sleep 10 + pkill ffead-cpp fi if [ "$1" == "g" ]; then gdb ffead-cpp diff --git a/docker/test/sql-debug-raw-async.sh b/docker/test/sql-debug-raw-async.sh new file mode 100644 index 000000000..0e00e3921 --- /dev/null +++ b/docker/test/sql-debug-raw-async.sh @@ -0,0 +1,40 @@ +if ! nc -z localhost 5432 ; then + /run.sh +fi + +ulimit -c unlimited +export FFEAD_CPP_PATH=/tmp/ffead-cpp-sql-raw-async/ +export ODBCINI=$FFEAD_CPP_PATH/resources/odbc.ini +export ODBCSYSINI=$FFEAD_CPP_PATH/resources +export LD_LIBRARY_PATH=$FFEAD_CPP_PATH/lib:/usr/local/lib:$LD_LIBRARY_PATH +export PATH=$FFEAD_CPP_PATH/lib:$PATH +cd /tmp/ffead-cpp-sql-raw-async +cp -f web/te-benchmark-um-pq-async/config/cachememory.xml web/te-benchmark-um-pq-async/config/cache.xml +sed -i 's|EVH_SINGLE=false|EVH_SINGLE=true|g' resources/server.prop +if [ $# -eq 0 ]; then + cp /server_orig.sh server.sh + nohup bash -c "./server.sh > ffead.log &" + sleep 10 + echo "ffead-cpp with sql-raw-async support launched" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9785/te-benchmark-um-pq-async/json" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 2 "http://localhost:9785/te-benchmark-um-pq-async/plaintext" -s /pipeline.lua -- 16 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 2 "http://localhost:9785/te-benchmark-um-pq-async/fortunes" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9785/te-benchmark-um-pq-async/db" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9785/te-benchmark-um-pq-async/queries?queries=20" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9785/te-benchmark-um-pq-async/updates?queries=20" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9785/te-benchmark-um-pq-async/cached-worlds?count=100" + sleep 10 + pkill ffead-cpp +fi +if [ "$1" == "g" ]; then + + cp /server.sh . + gdb ffead-cpp +fi \ No newline at end of file diff --git a/docker/test/sql-debug-raw.sh b/docker/test/sql-debug-raw.sh index cab8aff79..4b348c4ac 100644 --- a/docker/test/sql-debug-raw.sh +++ b/docker/test/sql-debug-raw.sh @@ -1,21 +1,43 @@ +if ! nc -z localhost 5432 ; then + /run.sh +fi + +ulimit -c unlimited export FFEAD_CPP_PATH=/tmp/ffead-cpp-sql-raw/ export ODBCINI=$FFEAD_CPP_PATH/resources/odbc.ini export ODBCSYSINI=$FFEAD_CPP_PATH/resources export LD_LIBRARY_PATH=$FFEAD_CPP_PATH/lib:/usr/local/lib:$LD_LIBRARY_PATH export PATH=$FFEAD_CPP_PATH/lib:$PATH cd /tmp/ffead-cpp-sql-raw +cp -f web/te-benchmark-um-pq/config/cachememory.xml web/te-benchmark-um-pq/config/cache.xml +sed -i 's|EVH_SINGLE=false|EVH_SINGLE=true|g' resources/server.prop if [ $# -eq 0 ]; then + cp /server_orig.sh server.sh nohup bash -c "./server.sh > ffead.log &" sleep 10 echo "ffead-cpp with sql-raw support launched" - wrk -t1 -c1 -d5s http://localhost:9783/te-benchmark-um-pq/json - wrk -t1 -c1 -d5s http://localhost:9783/te-benchmark-um-pq/plaintext - wrk -t1 -c1 -d5s http://localhost:9783/te-benchmark-um-pq/fortunes - wrk -t1 -c1 -d5s http://localhost:9783/te-benchmark-um-pq/db - wrk -t1 -c1 -d5s http://localhost:9783/te-benchmark-um-pq/queries?queries=1 - wrk -t1 -c1 -d5s http://localhost:9783/te-benchmark-um-pq/updates?queries=1 - wrk -t1 -c1 -d5s http://localhost:9783/te-benchmark-um-pq/cached-worlds?queries=1 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9783/te-benchmark-um-pq/json" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 2 "http://localhost:9783/te-benchmark-um-pq/plaintext" -s /pipeline.lua -- 16 + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 256 --timeout 8 -t 2 "http://localhost:9783/te-benchmark-um-pq/fortunes" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9783/te-benchmark-um-pq/db" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9783/te-benchmark-um-pq/queries?queries=20" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9783/te-benchmark-um-pq/queriesm?queries=20" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9783/te-benchmark-um-pq/updates?queries=20" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9783/te-benchmark-um-pq/updatesm?queries=20" + wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' \ +-H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 2 "http://localhost:9783/te-benchmark-um-pq/cached-worlds?count=100" + sleep 10 + pkill ffead-cpp fi if [ "$1" == "g" ]; then + cp /server.sh . gdb ffead-cpp fi \ No newline at end of file diff --git a/docker/test/test.sh b/docker/test/test.sh index 0d54bbd48..db2eaacc8 100644 --- a/docker/test/test.sh +++ b/docker/test/test.sh @@ -1 +1 @@ -docker run --rm -it --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -p 9781:9781 -p 9782:9782 -p 9783:9783 -p 9784:9784 ffeadcpptest:1.0 \ No newline at end of file +docker run --rm -it --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -p 9781:9781 -p 9782:9782 -p 9783:9783 -p 9784:9784 -p 9785:9785 ffeadcpptest:1.0 \ No newline at end of file diff --git a/docker/webrtc-peerjs/DockerFile-UbuntuBionic-x64-ffead-cpp-4.0 b/docker/webrtc-peerjs/DockerFile-UbuntuBionic-x64-ffead-cpp-5.0 similarity index 77% rename from docker/webrtc-peerjs/DockerFile-UbuntuBionic-x64-ffead-cpp-4.0 rename to docker/webrtc-peerjs/DockerFile-UbuntuBionic-x64-ffead-cpp-5.0 index ec832bd64..a99c90916 100644 --- a/docker/webrtc-peerjs/DockerFile-UbuntuBionic-x64-ffead-cpp-4.0 +++ b/docker/webrtc-peerjs/DockerFile-UbuntuBionic-x64-ffead-cpp-5.0 @@ -21,27 +21,34 @@ RUN mv ffead-cpp-master ffead-cpp-src RUN rm -f master.zip WORKDIR /tmp/ffead-cpp-src -RUN rm -rf web/default web/oauthApp web/flexApp web/markers web/te-benchmark web/te-benchmark-um +RUN rm -rf web/default web/oauthApp web/flexApp web/markers web/te-benchmark web/te-benchmark-um web/te-benchmark-um-mgr web/te-benchmark-um-pq web/te-benchmark-um-pq-async RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/default)||g' CMakeLists.txt RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/flexApp)||g' CMakeLists.txt RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/oauthApp)||g' CMakeLists.txt RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/markers)||g' CMakeLists.txt RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark)||g' CMakeLists.txt RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um)||g' CMakeLists.txt +RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um-mgr)||g' CMakeLists.txt +RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um-pq)||g' CMakeLists.txt +RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um-pq-async)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/default/libdefault${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/flexApp/libflexApp${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/oauthApp/liboauthApp${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/markers/libmarkers${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/te-benchmark/libte_benchmark${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/te-benchmark-um/libte_benchmark_um${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt +RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/te-benchmark-um-mgr/libte_benchmark_um_mgr${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/te-benchmark-um-pq/libte_benchmark_um_pq${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt +RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/te-benchmark-um-pq-async/libte_benchmark_um_pq_async${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|web/default/src/autotools/Makefile||g' configure.ac RUN sed -i 's|web/flexApp/src/autotools/Makefile||g' configure.ac RUN sed -i 's|web/oauthApp/src/autotools/Makefile||g' configure.ac RUN sed -i 's|web/markers/src/autotools/Makefile||g' configure.ac RUN sed -i 's|web/te-benchmark/src/autotools/Makefile||g' configure.ac RUN sed -i 's|web/te-benchmark-um/src/autotools/Makefile||g' configure.ac +RUN sed -i 's|web/te-benchmark-um-mgr/src/autotools/Makefile||g' configure.ac RUN sed -i 's|web/te-benchmark-um-pq/src/autotools/Makefile||g' configure.ac +RUN sed -i 's|web/te-benchmark-um-pq-async/src/autotools/Makefile||g' configure.ac RUN cmake -DSRV_EMB=on -DMOD_REDIS=on -DMOD_SDORM_MONGO=on . RUN make install -j4 diff --git a/docker/webrtc-peerjs/DockerFile-UbuntuBionic-x64-ffead-cpp-4.0_autoconf b/docker/webrtc-peerjs/DockerFile-UbuntuBionic-x64-ffead-cpp-5.0_autoconf similarity index 79% rename from docker/webrtc-peerjs/DockerFile-UbuntuBionic-x64-ffead-cpp-4.0_autoconf rename to docker/webrtc-peerjs/DockerFile-UbuntuBionic-x64-ffead-cpp-5.0_autoconf index c433d492e..a70e93b4c 100644 --- a/docker/webrtc-peerjs/DockerFile-UbuntuBionic-x64-ffead-cpp-4.0_autoconf +++ b/docker/webrtc-peerjs/DockerFile-UbuntuBionic-x64-ffead-cpp-5.0_autoconf @@ -21,27 +21,34 @@ RUN mv ffead-cpp-master ffead-cpp-src RUN rm -f master.zip WORKDIR /tmp/ffead-cpp-src -RUN rm -rf web/default web/oauthApp web/flexApp web/markers web/te-benchmark web/te-benchmark-um +RUN rm -rf web/default web/oauthApp web/flexApp web/markers web/te-benchmark web/te-benchmark-um web/te-benchmark-um-mgr web/te-benchmark-um-pq web/te-benchmark-um-pq-async RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/default)||g' CMakeLists.txt RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/flexApp)||g' CMakeLists.txt RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/oauthApp)||g' CMakeLists.txt RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/markers)||g' CMakeLists.txt RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark)||g' CMakeLists.txt RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um)||g' CMakeLists.txt +RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um-mgr)||g' CMakeLists.txt +RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um-pq)||g' CMakeLists.txt +RUN sed -i 's|add_subdirectory(${PROJECT_SOURCE_DIR}/web/te-benchmark-um-pq-async)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/default/libdefault${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/flexApp/libflexApp${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/oauthApp/liboauthApp${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/markers/libmarkers${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/te-benchmark/libte_benchmark${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/te-benchmark-um/libte_benchmark_um${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt +RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/te-benchmark-um-mgr/libte_benchmark_um_mgr${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/te-benchmark-um-pq/libte_benchmark_um_pq${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt +RUN sed -i 's|install(FILES ${PROJECT_SOURCE_DIR}/web/te-benchmark-um-pq-async/libte_benchmark_um_pq_async${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${PROJECT_NAME}-bin/lib)||g' CMakeLists.txt RUN sed -i 's|web/default/src/autotools/Makefile||g' configure.ac RUN sed -i 's|web/flexApp/src/autotools/Makefile||g' configure.ac RUN sed -i 's|web/oauthApp/src/autotools/Makefile||g' configure.ac RUN sed -i 's|web/markers/src/autotools/Makefile||g' configure.ac RUN sed -i 's|web/te-benchmark/src/autotools/Makefile||g' configure.ac RUN sed -i 's|web/te-benchmark-um/src/autotools/Makefile||g' configure.ac +RUN sed -i 's|web/te-benchmark-um-mgr/src/autotools/Makefile||g' configure.ac RUN sed -i 's|web/te-benchmark-um-pq/src/autotools/Makefile||g' configure.ac +RUN sed -i 's|web/te-benchmark-um-pq-async/src/autotools/Makefile||g' configure.ac RUN chmod +x autogen.sh RUN ./autogen.sh diff --git a/src/framework/ConfigurationData.cpp b/src/framework/ConfigurationData.cpp index 1e32963fb..18d21bcb1 100644 --- a/src/framework/ConfigurationData.cpp +++ b/src/framework/ConfigurationData.cpp @@ -122,20 +122,33 @@ void ConfigurationData::initializeAllSingletonBeans() { std::cout << "Could not load dynamic Library" << std::endl; exit(0); } - getInstance()->ffeadContext.initializeAllSingletonBeans(getInstance()->servingContexts, &(getInstance()->reflector)); std::map >::iterator it = ConfigurationData::getInstance()->servingContextRouterNames.begin(); for(;it!=ConfigurationData::getInstance()->servingContextRouterNames.end();++it) { std::string rt = it->second; std::vector prts = StringUtil::splitAndReturn >(rt, ";"); std::string scappName = ConfigurationData::getInstance()->servingContextAppNames[prts[1]]; + + Bean bean(prts[0],"",prts[0],"singleton",false,false,scappName); + ConfigurationData::getInstance()->ffeadContext.addBean(bean); + } + + getInstance()->ffeadContext.initializeAllSingletonBeans(getInstance()->servingContexts, &(getInstance()->reflector)); + + it = ConfigurationData::getInstance()->servingContextRouterNames.begin(); + for(;it!=ConfigurationData::getInstance()->servingContextRouterNames.end();++it) { + std::string rt = it->second; + std::vector prts = StringUtil::splitAndReturn >(rt, ";"); + std::string scappName = ConfigurationData::getInstance()->servingContextAppNames[prts[1]]; + CommonUtils::setAppName(scappName); + ClassInfo* rtcls = getInstance()->reflector.getClassInfo(prts[0], scappName); - args argus; - Constructor ctor = rtcls->getConstructor(argus); - vals values; - Router* router = (Router*)getInstance()->reflector.newInstanceGVP(ctor, values); - ConfigurationData::getInstance()->servingContextRouters[prts[1]] = router; + if(rtcls->getClassName()!="") { + void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean(prts[0], scappName); + Router* router = (Router*)_temp; + ConfigurationData::getInstance()->servingContextRouters[prts[1]] = router; + } } SerializeBase::init(ConfigurationData::getInstance()->dlib); diff --git a/src/framework/ConfigurationHandler.cpp b/src/framework/ConfigurationHandler.cpp index 8b34bdf1f..c761e0f79 100644 --- a/src/framework/ConfigurationHandler.cpp +++ b/src/framework/ConfigurationHandler.cpp @@ -310,7 +310,7 @@ void ConfigurationHandler::handle(strVec webdirs, const strVec& webdirs1, const if(root.getAttribute("router")!="" && StringUtil::trimCopy(root.getAttribute("router"))!="") { std::string router = StringUtil::trimCopy(root.getAttribute("router")); ConfigurationData::getInstance()->servingContextRouterNames[name] = router+";"+name; - //Bean bean1("router_"+router,"",router,"singleton",false,true,name); + //Bean bean1(router,"",router,"singleton",false,true,name); //ConfigurationData::getInstance()->ffeadContext.addBean(bean1); logger << ("Adding Router for " + name + " :: " + router) << std::endl; } @@ -318,7 +318,7 @@ void ConfigurationHandler::handle(strVec webdirs, const strVec& webdirs1, const std::string properties = StringUtil::trimCopy(root.getAttribute("properties")); propMap srprps = pread.getProperties(defpath+"config/"+properties); ConfigurationData::getInstance()->appPropertiesMap[scappName] = srprps; - //Bean bean1("router_"+router,"",router,"singleton",false,true,name); + //Bean bean1(router,"",router,"singleton",false,true,name); //ConfigurationData::getInstance()->ffeadContext.addBean(bean1); logger << ("Adding Properties for " + name + " :: " + properties) << std::endl; } @@ -339,7 +339,7 @@ void ConfigurationHandler::handle(strVec webdirs, const strVec& webdirs1, const if(url!="" && clas!="") { normalizeUrl(name, url); - Bean bean("controller_"+clas,"",clas,scope,false,true,name); + Bean bean(clas,"",clas,scope,false,true,name); ConfigurationData::getInstance()->ffeadContext.addBean(bean); ConfigurationData::getInstance()->controllerObjectMap[name][url] = clas; logger << ("Adding Controller for " + url + " :: " + clas) << std::endl; @@ -419,7 +419,7 @@ void ConfigurationHandler::handle(strVec webdirs, const strVec& webdirs1, const if(provider!="" && provider.find("class:")!=std::string::npos) { std::string clas = provider.substr(provider.find(":")+1); - Bean bean("authhandler_"+name+clas,"",clas,scope,false,name); + Bean bean(name+clas,"",clas,scope,false,name); ConfigurationData::getInstance()->ffeadContext.addBean(bean); } logger << ("Adding Authhandler for " + (name + url) + " :: " + provider) << std::endl; @@ -449,7 +449,7 @@ void ConfigurationHandler::handle(strVec webdirs, const strVec& webdirs1, const ConfigurationData::getInstance()->filterObjectMap[name][url+type].push_back(clas); if(clas!="") { - Bean bean("filter_"+clas,"",clas,scope,false,false,name); + Bean bean(clas,"",clas,scope,false,false,name); ConfigurationData::getInstance()->ffeadContext.addBean(bean); } logger << ("Adding Filter for " + (name + url + type) + " :: " + clas) << std::endl; @@ -481,7 +481,7 @@ void ConfigurationHandler::handle(strVec webdirs, const strVec& webdirs1, const std::string scope = tmplts.at(tmpn).getAttribute("scope"); if(clas!="") { - Bean bean("template_"+clas,"",clas,scope,false,false,name); + Bean bean(clas,"",clas,scope,false,false,name); ConfigurationData::getInstance()->ffeadContext.addBean(bean); } logger << ("Adding Template for " + (url) + " :: " + clas) << std::endl; @@ -543,7 +543,7 @@ void ConfigurationHandler::handle(strVec webdirs, const strVec& webdirs1, const std::string scope = tmplts.at(tmpn).getAttribute("scope"); if(clas!="") { - Bean bean("websocketclass_"+clas,"",clas,scope,false,false,name); + Bean bean(clas,"",clas,scope,false,false,name); ConfigurationData::getInstance()->ffeadContext.addBean(bean); } logger << ("Adding WebSocketHandler for " + (url) + " :: " + clas) << std::endl; @@ -570,7 +570,7 @@ void ConfigurationHandler::handle(strVec webdirs, const strVec& webdirs1, const std::string scope = dvs.at(dn).getAttribute("scope"); if(clas!="") { - Bean bean("dview_"+clas,"",clas,scope,false,false,name); + Bean bean(clas,"",clas,scope,false,false,name); ConfigurationData::getInstance()->ffeadContext.addBean(bean); } logger << ("Adding Dynamic View for " + (name+url) + " :: " + clas) << std::endl; @@ -752,7 +752,7 @@ void ConfigurationHandler::handle(strVec webdirs, const strVec& webdirs1, const } if(clas!="") { - Bean bean("restcontroller_"+clas,"",clas,scope,false,true,name); + Bean bean(clas,"",clas,scope,false,true,name); ConfigurationData::getInstance()->ffeadContext.addBean(bean); } logger << ("Rest: Adding rest-controller => " + urlmpp + " , class => " + clas) << std::endl; @@ -814,7 +814,7 @@ void ConfigurationHandler::handle(strVec webdirs, const strVec& webdirs1, const if(provider!="" && provider.find("class:")!=std::string::npos) { std::string clas = provider.substr(provider.find(":")+1); - Bean bean("login-handler_"+clas,"",clas,scope,false,false,name); + Bean bean(clas,"",clas,scope,false,false,name); ConfigurationData::getInstance()->ffeadContext.addBean(bean); } logger << ("Security: Adding Login Handler => " + url + " , provider => " + provider) << std::endl; @@ -1001,7 +1001,7 @@ void ConfigurationHandler::handle(strVec webdirs, const strVec& webdirs1, const std::string scope = elese.at(appse).getAttribute("scope"); if(clas!="") { - Bean bean("form_"+clas,"",clas,scope,false,false,name); + Bean bean(clas,"",clas,scope,false,false,name); ConfigurationData::getInstance()->ffeadContext.addBean(bean); } elese.at(appse).copy(&(ConfigurationData::getInstance()->fviewFormMap[name][elese.at(appse).getAttribute("name")])); @@ -1677,7 +1677,7 @@ void ConfigurationHandler::handleMarkerConfigurations(std::mapsecurityObjectMap[appName][provName] = securityObject; - Bean bean("login-handler_"+clas,"",clas,scope,false,false,appName); + Bean bean(clas,"",clas,scope,false,false,appName); ConfigurationData::getInstance()->ffeadContext.addBean(bean); logger << ("Security: Adding Security Provider => " + url + " , provider => " + provider) << std::endl; } @@ -1785,7 +1785,7 @@ void ConfigurationHandler::handleMarkerConfigurations(std::mapcontrollerObjectMap[appName][url] = clas; - Bean bean("controller_"+clas,"",clas,scope,false,true,appName); + Bean bean(clas,"",clas,scope,false,true,appName); ConfigurationData::getInstance()->ffeadContext.addBean(bean); } logger << ("Adding Controller for " + (appName + url) + " :: " + clas) << std::endl; @@ -1879,7 +1879,7 @@ void ConfigurationHandler::handleMarkerConfigurations(std::mapfilterObjectMap[appName][url+type].push_back(clas); - Bean bean("filter_"+clas,"",clas,scope,false,false,appName); + Bean bean(clas,"",clas,scope,false,false,appName); ConfigurationData::getInstance()->ffeadContext.addBean(bean); } logger << ("Adding Filter for " + (appName + url + type) + " :: " + clas) << std::endl; @@ -1912,7 +1912,7 @@ void ConfigurationHandler::handleMarkerConfigurations(std::mapffeadContext.addBean(bean); } logger << ("Adding Template for " + (url) + " :: " + clas) << std::endl; @@ -1941,7 +1941,7 @@ void ConfigurationHandler::handleMarkerConfigurations(std::mapffeadContext.addBean(bean); } logger << ("Adding WebSocketHandler for " + (url) + " :: " + clas) << std::endl; @@ -1969,7 +1969,7 @@ void ConfigurationHandler::handleMarkerConfigurations(std::mapffeadContext.addBean(bean); } logger << ("Adding Dynamic View for " + (appName+url) + " :: " + clas) << std::endl; @@ -2521,7 +2521,7 @@ void ConfigurationHandler::handleRestControllerMarker(ClassStructure& cs, const restfunction.path = urlmpp; ConfigurationData::getInstance()->rstCntMap[appName][restfunction.meth+urlmpp].push_back(restfunction); } - Bean bean("restcontroller_"+clas,"",clas,scope,false,true,appName); + Bean bean(clas,"",clas,scope,false,true,appName); ConfigurationData::getInstance()->ffeadContext.addBean(bean); if(!isClasSecure && cs.pubms.at(var).markers.find("@Secure")!=cs.pubms.at(var).markers.end()) { @@ -2587,12 +2587,27 @@ void ConfigurationHandler::initializeDataSources() std::map > allMapps = sdormEntityMappings[mit->first]; for (it=allProps.begin();it!=allProps.end();++it) { logger << "ds is " << it->first << std::endl; - DataSourceManager::initDSN(allProps[it->first], allMapps[it->first]); + DataSourceManager::initDSN(allProps[it->first], allMapps[it->first], &ConfigurationHandler::populateClassBeanInstanceCb); } } } } +void ConfigurationHandler::populateClassBeanInstanceCb(std::string& clsn, std::string appn, ClassBeanIns* cbi) { + cbi->clas = ConfigurationData::getReflector()->getClassInfo(clsn, appn); + if(cbi->clas->getClassName()!="") { + void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean(clsn, appn); + if(_temp!=NULL) { + cbi->instance = _temp; + return; + } + args argus; + vals valus; + const Constructor& ctor = cbi->clas->getConstructor(argus); + cbi->instance = ConfigurationData::getReflector()->newInstanceGVP(ctor); + } +} + void ConfigurationHandler::initializeCaches() { bool isSinglEVH = StringUtil::toLowerCopy(ConfigurationData::getInstance()->coreServerProperties.sprops["EVH_SINGLE"])=="true"; @@ -2606,7 +2621,7 @@ void ConfigurationHandler::initializeCaches() std::map > allProps = cacheConnProperties[mit->first]; std::map::iterator it; for (it=allProps.begin();it!=allProps.end();++it) { - CacheManager::initCache(allProps[it->first], mit->first); + CacheManager::initCache(allProps[it->first], mit->first, &ConfigurationHandler::populateClassBeanInstanceCb); } } } diff --git a/src/framework/ConfigurationHandler.h b/src/framework/ConfigurationHandler.h index bed7c3b91..e2823e28c 100644 --- a/src/framework/ConfigurationHandler.h +++ b/src/framework/ConfigurationHandler.h @@ -73,6 +73,7 @@ class ConfigurationHandler { static void initializeDataSources(); static void initializeCaches(); static void initializeWsdls(); + static void populateClassBeanInstanceCb(std::string& clsn, std::string appn, ClassBeanIns* cbi); }; #endif /* CONFIGURATIONHANDLER_H_ */ diff --git a/src/framework/ControllerHandler.cpp b/src/framework/ControllerHandler.cpp index b649d694d..6794ee62d 100644 --- a/src/framework/ControllerHandler.cpp +++ b/src/framework/ControllerHandler.cpp @@ -88,7 +88,7 @@ bool ControllerExtensionHandler::handle(HttpRequest* req, HttpResponse* res, con { //Timer t; //t.start(); - void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean("controller_"+controller, req->getCntxt_name()); + void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean(controller, req->getCntxt_name()); args argus; argus.push_back("HttpRequest*"); argus.push_back("HttpResponse*"); @@ -112,7 +112,7 @@ bool ControllerExtensionHandler::handle(HttpRequest* req, HttpResponse* res, con res->setHTTPResponseStatus(HTTPResponseStatus::InternalServerError); isContrl = true; } - ConfigurationData::getInstance()->ffeadContext.release(_temp, "controller_"+controller, req->getCntxt_name()); + ConfigurationData::getInstance()->ffeadContext.release(_temp, controller, req->getCntxt_name()); //t.end(); //CommonUtils::tsContExec += t.timerNanoSeconds(); } @@ -255,14 +255,14 @@ bool ControllerHandler::handle(HttpRequest* req, HttpResponse* res, const std::s if(flag) { //t.start(); - ClassInfo* srv = ConfigurationData::getInstance()->ffeadContext.contInsMap["restcontroller_"+rft->clas+rft->appName]; + ClassInfo* srv = ConfigurationData::getInstance()->ffeadContext.contInsMap[rft->clas+rft->appName]; //t.end(); //CommonUtils::tsContRstCsiLkp += t.timerNanoSeconds(); //t.start(); void *_temp = srv->getSI(); if(_temp==NULL) { - _temp = ConfigurationData::getInstance()->ffeadContext.getBean("restcontroller_"+rft->clas, rft->appName); + _temp = ConfigurationData::getInstance()->ffeadContext.getBean(rft->clas, rft->appName); if(_temp==NULL) { //logger << "Rest Controller Not Found" << std::endl; res->setHTTPResponseStatus(HTTPResponseStatus::InternalServerError); @@ -275,7 +275,7 @@ bool ControllerHandler::handle(HttpRequest* req, HttpResponse* res, const std::s { res->setHTTPResponseStatus(HTTPResponseStatus::UnsupportedMedia); res->setDone(true); - if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, "restcontroller_"+rft->clas, rft->appName); + if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, rft->clas, rft->appName); return true; } req->addHeader(HttpRequest::ContentType, rft->icontentType); @@ -342,7 +342,7 @@ bool ControllerHandler::handle(HttpRequest* req, HttpResponse* res, const std::s //logger << "File can only be mapped to ifstream" << std::endl; res->setHTTPResponseStatus(HTTPResponseStatus::InternalServerError); res->setDone(true); - if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, "restcontroller_"+rft->clas, rft->appName); + if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, rft->clas, rft->appName); return true; } } @@ -356,7 +356,7 @@ bool ControllerHandler::handle(HttpRequest* req, HttpResponse* res, const std::s //logger << "Invalid mapping specified in config, no multipart content found with name " + rft->params.at(var).name << std::endl; res->setHTTPResponseStatus(HTTPResponseStatus::InternalServerError); res->setDone(true); - if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, "restcontroller_"+rft->clas, rft->appName); + if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, rft->clas, rft->appName); return true; } } @@ -367,7 +367,7 @@ bool ControllerHandler::handle(HttpRequest* req, HttpResponse* res, const std::s //logger << "Request Body cannot be mapped to more than one argument..." << std::endl; res->setHTTPResponseStatus(HTTPResponseStatus::BadRequest); res->setDone(true); - if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, "restcontroller_"+rft->clas, rft->appName); + if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, rft->clas, rft->appName); return true; } pmvalue = req->getContent(); @@ -393,7 +393,7 @@ bool ControllerHandler::handle(HttpRequest* req, HttpResponse* res, const std::s { res->setHTTPResponseStatus(HTTPResponseStatus::BadRequest); res->setDone(true); - if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, "restcontroller_"+rft->clas, rft->appName); + if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, rft->clas, rft->appName); for(int i=0;i<(int)valus.size();++i) { if(valus.at(i)!=NULL) { reflector.destroy(valus.at(i), argus.at(i)); @@ -473,7 +473,7 @@ bool ControllerHandler::handle(HttpRequest* req, HttpResponse* res, const std::s { res->setHTTPResponseStatus(HTTPResponseStatus::BadRequest); res->setDone(true); - if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, "restcontroller_"+rft->clas, rft->appName); + if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, rft->clas, rft->appName); for(int i=0;i<(int)valus.size();++i) { if(valus.at(i)!=NULL) { reflector.destroy(valus.at(i), argus.at(i)); @@ -517,7 +517,7 @@ bool ControllerHandler::handle(HttpRequest* req, HttpResponse* res, const std::s invValue= true; res->setHTTPResponseStatus(HTTPResponseStatus::BadRequest); res->setDone(true); - if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, "restcontroller_"+rft->clas, rft->appName); + if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, rft->clas, rft->appName); for(int i=0;i<(int)valus.size();++i) { if(valus.at(i)!=NULL) { reflector.destroy(valus.at(i), argus.at(i)); @@ -545,7 +545,7 @@ bool ControllerHandler::handle(HttpRequest* req, HttpResponse* res, const std::s if(rft->unmapped) { res->addHeader(HttpResponse::ContentType, rft->ocontentType); res->setHTTPResponseStatus(HTTPResponseStatus::getStatusByCode(rft->statusCode)); - if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, "restcontroller_"+rft->clas, rft->appName); + if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, rft->clas, rft->appName); } else { int serOpt = rft->serOpt>=2000?-3:(rft->serOpt>=1000?-2:rft->serOpt); switch(serOpt) { @@ -627,7 +627,7 @@ bool ControllerHandler::handle(HttpRequest* req, HttpResponse* res, const std::s it->second->clear(); } mpvecstreams.clear(); - if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, "restcontroller_"+rft->clas, rft->appName); + if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, rft->clas, rft->appName); } //t.end(); @@ -638,14 +638,14 @@ bool ControllerHandler::handle(HttpRequest* req, HttpResponse* res, const std::s res->setHTTPResponseStatus(HTTPResponseStatus::NotFound); //res->addHeader(HttpResponse::ContentType, ContentTypes::CONTENT_TYPE_TEXT_PLAIN); //logger << "Rest Controller Method Not Found" << std::endl; - if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, "restcontroller_"+rft->clas, rft->appName); + if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, rft->clas, rft->appName); } } catch(const std::exception& e) { //logger << "Restcontroller exception occurred" << std::endl; invValue= true; res->setHTTPResponseStatus(HTTPResponseStatus::InternalServerError); res->setDone(true); - if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, "restcontroller_"+rft->clas, rft->appName); + if(srv->getSI()==NULL)ConfigurationData::getInstance()->ffeadContext.release(_temp, rft->clas, rft->appName); return true; } } diff --git a/src/framework/ExtHandler.cpp b/src/framework/ExtHandler.cpp index b58332b87..3c1922831 100644 --- a/src/framework/ExtHandler.cpp +++ b/src/framework/ExtHandler.cpp @@ -37,7 +37,7 @@ bool ExtHandler::handle(HttpRequest* req, HttpResponse* res, void* dlib, void* d std::string tpefilename = tmplMap->find(req->getCurl())->second.substr(tmplMap->find(req->getCurl())->second.find(";")+1); std::string tpeclasname = tmplMap->find(req->getCurl())->second.substr(0, tmplMap->find(req->getCurl())->second.find(";")); cntrlit = true; - void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean("template_"+tpeclasname, req->getCntxt_name()); + void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean(tpeclasname, req->getCntxt_name()); if(_temp!=NULL) { try { @@ -76,7 +76,7 @@ bool ExtHandler::handle(HttpRequest* req, HttpResponse* res, void* dlib, void* d //logger << "Template exception occurred" << std::endl; res->setHTTPResponseStatus(HTTPResponseStatus::InternalServerError); } - ConfigurationData::getInstance()->ffeadContext.release(_temp, "template_"+tpeclasname, req->getCntxt_name()); + ConfigurationData::getInstance()->ffeadContext.release(_temp, tpeclasname, req->getCntxt_name()); } if(content.length()>0) { @@ -224,7 +224,7 @@ bool ExtHandler::handle(HttpRequest* req, HttpResponse* res, void* dlib, void* d #ifdef INC_DVIEW else if(ext==".view" && vwMap->find(req->getCurl())!=vwMap->end()) { - void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean("dview_"+vwMap->find(req->getCurl())->second, req->getCntxt_name()); + void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean(vwMap->find(req->getCurl())->second, req->getCntxt_name()); if(_temp!=NULL) { cntrlit = true; @@ -252,7 +252,7 @@ bool ExtHandler::handle(HttpRequest* req, HttpResponse* res, void* dlib, void* d //logger << "Dview exception occurred" << std::endl; res->setHTTPResponseStatus(HTTPResponseStatus::InternalServerError); } - ConfigurationData::getInstance()->ffeadContext.release(_temp, "dview_"+vwMap->find(req->getCurl())->second, req->getCntxt_name()); + ConfigurationData::getInstance()->ffeadContext.release(_temp, vwMap->find(req->getCurl())->second, req->getCntxt_name()); } else { diff --git a/src/framework/FilterHandler.cpp b/src/framework/FilterHandler.cpp index e4ab67c5d..5993c9a9c 100644 --- a/src/framework/FilterHandler.cpp +++ b/src/framework/FilterHandler.cpp @@ -51,7 +51,7 @@ void FilterHandler::handleIn(HttpRequest* req, const std::string& ext, Reflector for (int var = 0; var < (int)filters.size(); ++var) { std::string claz = filters.at(var); - void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean("filter_"+claz, req->getCntxt_name()); + void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean(claz, req->getCntxt_name()); args argus; argus.push_back("HttpRequest*"); vals valus; @@ -62,7 +62,7 @@ void FilterHandler::handleIn(HttpRequest* req, const std::string& ext, Reflector valus.push_back(req); reflector.invokeMethodGVP(_temp,meth,valus); } - ConfigurationData::getInstance()->ffeadContext.release(_temp, "filter_"+claz, req->getCntxt_name()); + ConfigurationData::getInstance()->ffeadContext.release(_temp, claz, req->getCntxt_name()); } } } @@ -77,7 +77,7 @@ bool FilterHandler::handle(HttpRequest* req, HttpResponse* res, const std::strin for (int var = 0; var < (int)filters.size(); ++var) { std::string claz = filters.at(var); - void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean("filter_"+claz, req->getCntxt_name()); + void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean(claz, req->getCntxt_name()); args argus; argus.push_back("HttpRequest*"); argus.push_back("HttpResponse*"); @@ -90,7 +90,7 @@ bool FilterHandler::handle(HttpRequest* req, HttpResponse* res, const std::strin valus.push_back(res); reflector.invokeMethod(&continue_proc_request,_temp,meth,valus); } - ConfigurationData::getInstance()->ffeadContext.release(_temp, "filter_"+claz, req->getCntxt_name()); + ConfigurationData::getInstance()->ffeadContext.release(_temp, claz, req->getCntxt_name()); } } return continue_proc_request; @@ -104,7 +104,7 @@ void FilterHandler::handleOut(HttpRequest* req, HttpResponse* res, const std::st for (int var = 0; var < (int)filters.size(); ++var) { std::string claz = filters.at(var); - void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean("filter_"+claz, req->getCntxt_name()); + void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean(claz, req->getCntxt_name()); args argus; argus.push_back("HttpResponse*"); vals valus; @@ -115,7 +115,7 @@ void FilterHandler::handleOut(HttpRequest* req, HttpResponse* res, const std::st valus.push_back(res); reflector.invokeMethodGVP(_temp,meth,valus); } - ConfigurationData::getInstance()->ffeadContext.release(_temp, "filter_"+claz, req->getCntxt_name()); + ConfigurationData::getInstance()->ffeadContext.release(_temp, claz, req->getCntxt_name()); } } } diff --git a/src/framework/FormHandler.cpp b/src/framework/FormHandler.cpp index 16c0fc813..3f1ef1d15 100644 --- a/src/framework/FormHandler.cpp +++ b/src/framework/FormHandler.cpp @@ -74,7 +74,7 @@ bool FormHandler::handle(HttpRequest* req, HttpResponse* res, Reflector& reflect json += "}"; //logger << json << std::endl; - void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean("form_"+ele->getAttribute("controller"), req->getCntxt_name()); + void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean(ele->getAttribute("controller"), req->getCntxt_name()); args argus; argus.push_back("void*"); argus.push_back("HttpResponse*"); @@ -91,9 +91,9 @@ bool FormHandler::handle(HttpRequest* req, HttpResponse* res, Reflector& reflect reflector.invokeMethodGVP(_temp,meth,valus,false); reflector.destroy(_beaninst, ele->getAttribute("bean")); //logger << "Successfully called Formcontroller" << std::endl; - ConfigurationData::getInstance()->ffeadContext.release(_temp, "form_"+ele->getAttribute("controller"), req->getCntxt_name()); + ConfigurationData::getInstance()->ffeadContext.release(_temp, ele->getAttribute("controller"), req->getCntxt_name()); return true; } - ConfigurationData::getInstance()->ffeadContext.release(_temp, "form_"+ele->getAttribute("controller"), req->getCntxt_name()); + ConfigurationData::getInstance()->ffeadContext.release(_temp, ele->getAttribute("controller"), req->getCntxt_name()); return false; } diff --git a/src/framework/Router.h b/src/framework/Router.h index 3272ffa5d..0a2d3f4d5 100644 --- a/src/framework/Router.h +++ b/src/framework/Router.h @@ -29,7 +29,7 @@ class Router { public: - virtual void route(HttpRequest* req, HttpResponse* res, void* dlib, void* ddlib)=0; + virtual bool route(HttpRequest* req, HttpResponse* res, void* dlib, void* ddlib, SocketInterface* sif)=0; virtual ~Router(){} }; diff --git a/src/framework/SecurityHandler.cpp b/src/framework/SecurityHandler.cpp index 8b6fb900e..1deca2ebe 100644 --- a/src/framework/SecurityHandler.cpp +++ b/src/framework/SecurityHandler.cpp @@ -208,7 +208,7 @@ bool SecurityHandler::handle(HttpRequest* req, HttpResponse* res, const long& se args argusi, argusa, argusg; vals valusi, valusa, valusg; - void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean("login-handler_"+claz, req->getCntxt_name()); + void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean(claz, req->getCntxt_name()); ClassInfo* srv = ConfigurationData::getClassInfo(claz, req->getCntxt_name()); Method methIsInitialized = srv->getMethod("isInitialized", argusi); @@ -252,7 +252,7 @@ bool SecurityHandler::handle(HttpRequest* req, HttpResponse* res, const long& se { logger << "AuthController not initialized" << std::endl; } - ConfigurationData::getInstance()->ffeadContext.release(_temp, "login-handler_"+claz, req->getCntxt_name()); + ConfigurationData::getInstance()->ffeadContext.release(_temp, claz, req->getCntxt_name()); } if(validUser && (aspect.role==userRole || securityObject.isLoginPage(req->getCntxt_name(), req->getCurl()))) { diff --git a/src/framework/ServiceTask.cpp b/src/framework/ServiceTask.cpp index 08e5947cb..c8f41f4e3 100644 --- a/src/framework/ServiceTask.cpp +++ b/src/framework/ServiceTask.cpp @@ -444,7 +444,7 @@ WebSockHandler* ServiceTask::handleWebsockOpen(WebSocketData* req, WebSocketResp { if(it->second!="") { - void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean("websocketclass_"+it->second, req->getCntxt_name()); + void *_temp = ConfigurationData::getInstance()->ffeadContext.getBean(it->second, req->getCntxt_name()); WebSockHandler* h = (WebSockHandler*)_temp; h->sif = sif; if(h->onOpen(req, res, sif->getAddress(), hreq)) @@ -457,7 +457,11 @@ WebSockHandler* ServiceTask::handleWebsockOpen(WebSocketData* req, WebSocketResp return NULL; } -void ServiceTask::handle(HttpRequest* req, HttpResponse* res) +void ServiceTask::handle(HttpRequest* req, HttpResponse* res) { + handle(req, res, NULL); +} + +bool ServiceTask::handle(HttpRequest* req, HttpResponse* res, SocketInterface* sif) { //Timer t1; //t1.start(); @@ -472,7 +476,7 @@ void ServiceTask::handle(HttpRequest* req, HttpResponse* res) { res->setHTTPResponseStatus(*req->getRequestParseStatus()); res->addHeader(HttpResponse::Connection, "close"); - return; + return true; } if(ConfigurationData::getInstance()->enableStaticResponses && ConfigurationData::getInstance()->staticResponsesMap.find(req->getPath())!= @@ -482,7 +486,7 @@ void ServiceTask::handle(HttpRequest* req, HttpResponse* res) res->setContentType(sr.t); res->setHTTPResponseStatus(HTTPResponseStatus::Ok); res->setDone(true); - return; + return true; } if(req->getCntxt_name().length()==0) { @@ -497,10 +501,9 @@ void ServiceTask::handle(HttpRequest* req, HttpResponse* res) Router* router = ConfigurationData::getInstance()->servingContextRouters.find(req->getCntxt_name())->second; if(router!=NULL) { req->setCntxt_root(ConfigurationData::getInstance()->servingContextAppRoots.find(req->getCntxt_name())->second); - router->route(req, res, ConfigurationData::getInstance()->dlib, ConfigurationData::getInstance()->ddlib); + return router->route(req, res, ConfigurationData::getInstance()->dlib, ConfigurationData::getInstance()->ddlib, sif); //t1.end(); //CommonUtils::tsServicePre += t1.timerNanoSeconds(); - return; } } else { if(ConfigurationData::getInstance()->servingContextRouters.find(HttpRequest::DEFAULT_CTX)!= @@ -510,10 +513,9 @@ void ServiceTask::handle(HttpRequest* req, HttpResponse* res) Router* router = ConfigurationData::getInstance()->servingContextRouters.find(req->getCntxt_name())->second; if(router!=NULL) { req->setCntxt_root(ConfigurationData::getInstance()->servingContextAppRoots.find(req->getCntxt_name())->second); - router->route(req, res, ConfigurationData::getInstance()->dlib, ConfigurationData::getInstance()->ddlib); + return router->route(req, res, ConfigurationData::getInstance()->dlib, ConfigurationData::getInstance()->ddlib, sif); //t1.end(); //CommonUtils::tsServicePre += t1.timerNanoSeconds(); - return; } } } @@ -524,7 +526,7 @@ void ServiceTask::handle(HttpRequest* req, HttpResponse* res) if(ConfigurationData::getInstance()->servingContexts.find(req->getCntxt_name())==ConfigurationData::getInstance()->servingContexts.end()) { res->addHeader(HttpResponse::Connection, "close"); - return; + return true; } } @@ -724,6 +726,7 @@ void ServiceTask::handle(HttpRequest* req, HttpResponse* res) { //logger << "Standard exception occurred while processing ServiceTask request " << std::endl; } + return true; } void ServiceTask::handleWebSocket(HttpRequest* req, void* dlib, void* ddlib, SocketInterface* sockUtil) diff --git a/src/framework/ServiceTask.h b/src/framework/ServiceTask.h index efa56a76d..9a10d9128 100644 --- a/src/framework/ServiceTask.h +++ b/src/framework/ServiceTask.h @@ -76,6 +76,7 @@ class ServiceTask : public HttpServiceTask std::string getCntEncoding(); WebSockHandler* handleWebsockOpen(WebSocketData* request, WebSocketRespponseData* response, SocketInterface* sif, HttpRequest* hreq); void handle(HttpRequest* req, HttpResponse* res); + bool handle(HttpRequest* req, HttpResponse* res, SocketInterface* sif); }; #endif /* SERVICETASK_H_ */ diff --git a/src/modules/cache/CacheManager.cpp b/src/modules/cache/CacheManager.cpp index 558f2d025..edd349acc 100644 --- a/src/modules/cache/CacheManager.cpp +++ b/src/modules/cache/CacheManager.cpp @@ -31,7 +31,7 @@ void CacheManager::init(bool issevh) { isSinglEVH = issevh; } -void CacheManager::initCache(const ConnectionProperties& props, const std::string& appNameN) { +void CacheManager::initCache(const ConnectionProperties& props, const std::string& appNameN, GetClassBeanIns f) { Logger logger = LoggerFactory::getLogger("CacheManager"); std::string name = StringUtil::trimCopy(props.getName()); if(name=="") @@ -42,19 +42,22 @@ void CacheManager::initCache(const ConnectionProperties& props, const std::strin StringUtil::replaceAll(appName, "-", "_"); RegexUtil::replace(appName, "[^a-zA-Z0-9_]+", ""); name = appName + name; - if(caches.find(name)!=caches.end()) - { - throw std::runtime_error("Cache Already exists"); - } - if(props.getProperty("_isdefault_")=="true") { - defDsnNames[appName] = StringUtil::trimCopy(props.getName()); - } - try { - CacheManager* mgr = new CacheManager(props); - caches[name] = mgr; - } catch (const std::exception& e) { - logger.info("Error initializing Cache " + appNameN + "@" + props.getName() + " " + std::string(e.what())); + if(StringUtil::toLowerCopy(props.getType()) != "custom") { + if(caches.find(name)!=caches.end()) + { + throw std::runtime_error("Cache Already exists"); + } + if(props.getProperty("_isdefault_")=="true") { + defDsnNames[appName] = StringUtil::trimCopy(props.getName()); + } + + try { + CacheManager* mgr = new CacheManager(props); + caches[name] = mgr; + } catch (const std::exception& e) { + logger.info("Error initializing Cache " + appNameN + "@" + props.getName() + " " + std::string(e.what())); + } } Reflector* ref = GenericObject::getReflector(); @@ -64,25 +67,23 @@ void CacheManager::initCache(const ConnectionProperties& props, const std::strin StringUtil::split(v, meth, "."); if(v.size()==2) { CommonUtils::setAppName(appName); - ClassInfo* clas = ref->getClassInfo(v.at(0), appName); - if(clas->getClassName()!="") { - args argus; - vals valus; - const Constructor& ctor = clas->getConstructor(argus); - void* _temp = ref->newInstanceGVP(ctor); - try { - if(_temp!=NULL) { - const Method& meth = clas->getMethod(v.at(1), argus); - if(meth.getMethodName()!="") - { - ref->invokeMethodGVP(_temp, meth, valus); - } + ClassBeanIns cbi; + f(v.at(0), appName, &cbi); + void* _temp = cbi.instance; + try { + if(_temp!=NULL) { + args argus; + vals valus; + const Method& meth = cbi.clas->getMethod(v.at(1), argus); + if(meth.getMethodName()!="") + { + ref->invokeMethodGVP(_temp, meth, valus); } - } catch(const std::exception& e) { - logger.info("Error during init call for Cache " + appNameN + "@" + props.getName() + " " + std::string(e.what())); } - ref->destroy(_temp, v.at(0), appName); + } catch(const std::exception& e) { + logger.info("Error during init call for Cache " + appNameN + "@" + props.getName() + " " + std::string(e.what())); } + ref->destroy(_temp, v.at(0), appName); } } } diff --git a/src/modules/cache/CacheManager.h b/src/modules/cache/CacheManager.h index 4cd59e399..2ee3aedd7 100644 --- a/src/modules/cache/CacheManager.h +++ b/src/modules/cache/CacheManager.h @@ -40,7 +40,7 @@ class CacheManager { ConnectionProperties props; ConnectionPooler* pool; Reflector* reflector; - static void initCache(const ConnectionProperties& props, const std::string& appName); + static void initCache(const ConnectionProperties& props, const std::string& appName, GetClassBeanIns f); static void destroy(); CacheManager(const ConnectionProperties& props); friend class ConfigurationHandler; diff --git a/src/modules/cache/memory/MemoryCacheImpl.cpp b/src/modules/cache/memory/MemoryCacheImpl.cpp index 397abad72..f83266fe2 100644 --- a/src/modules/cache/memory/MemoryCacheImpl.cpp +++ b/src/modules/cache/memory/MemoryCacheImpl.cpp @@ -38,91 +38,164 @@ MemoryCacheImpl::~MemoryCacheImpl() { } bool MemoryCacheImpl::remove(const std::string& key) { - ((MemoryCacheConnectionPool*)pool)->internalMap.erase(key); + MemoryCacheConnectionPool* p = (MemoryCacheConnectionPool*)pool; + p->lock.lock(); + auto it = p->internalMap.find(key); + bool exists = it!=p->internalMap.end(); + if(exists) { + p->lrul.erase(it->second); + p->internalMap.erase(it); + } + p->lock.unlock(); return true; } long long MemoryCacheImpl::increment(const std::string& key, const int& number) { long long val = -1; - ((MemoryCacheConnectionPool*)pool)->lock.lock(); - if(((MemoryCacheConnectionPool*)pool)->internalMap.find(key)!=((MemoryCacheConnectionPool*)pool)->internalMap.end()) { - val = CastUtil::toLonglong(((MemoryCacheConnectionPool*)pool)->internalMap[key]) + number; - ((MemoryCacheConnectionPool*)pool)->internalMap[key] = CastUtil::fromNumber(val); + MemoryCacheConnectionPool* p = (MemoryCacheConnectionPool*)pool; + + p->lock.lock(); + auto it = p->internalMap.find(key); + bool exists = it!=p->internalMap.end(); + if(exists) { + p->lrul.splice(p->lrul.begin(), p->lrul, it->second); + std::string rval = it->second->second; + + p->lrul.erase(it->second); + p->internalMap.erase(it); + + val = CastUtil::toLongdouble(rval) + number; + p->lrul.push_front(make_pair(key, CastUtil::fromNumber(val))); + p->internalMap.insert(make_pair(key, p->lrul.begin())); + clean(); } - ((MemoryCacheConnectionPool*)pool)->lock.unlock(); + p->lock.unlock(); return val; } long long MemoryCacheImpl::decrement(const std::string& key, const int& number) { long long val = -1; - ((MemoryCacheConnectionPool*)pool)->lock.lock(); - if(((MemoryCacheConnectionPool*)pool)->internalMap.find(key)!=((MemoryCacheConnectionPool*)pool)->internalMap.end()) { - val = CastUtil::toLonglong(((MemoryCacheConnectionPool*)pool)->internalMap[key]) - number; - ((MemoryCacheConnectionPool*)pool)->internalMap[key] = CastUtil::fromNumber(val); + MemoryCacheConnectionPool* p = (MemoryCacheConnectionPool*)pool; + + p->lock.lock(); + auto it = p->internalMap.find(key); + bool exists = it!=p->internalMap.end(); + if(exists) { + p->lrul.splice(p->lrul.begin(), p->lrul, it->second); + std::string rval = it->second->second; + + p->lrul.erase(it->second); + p->internalMap.erase(it); + + val = CastUtil::toLongdouble(rval) - number; + p->lrul.push_front(make_pair(key, CastUtil::fromNumber(val))); + p->internalMap.insert(make_pair(key, p->lrul.begin())); + clean(); } - ((MemoryCacheConnectionPool*)pool)->lock.unlock(); + p->lock.unlock(); return val; } long double MemoryCacheImpl::incrementFloat(const std::string& key, const double& number) { long double val = -1.0; - ((MemoryCacheConnectionPool*)pool)->lock.lock(); - if(((MemoryCacheConnectionPool*)pool)->internalMap.find(key)!=((MemoryCacheConnectionPool*)pool)->internalMap.end()) { - val = CastUtil::toLongdouble(((MemoryCacheConnectionPool*)pool)->internalMap[key]) + number; - ((MemoryCacheConnectionPool*)pool)->internalMap[key] = CastUtil::fromNumber(val); + MemoryCacheConnectionPool* p = (MemoryCacheConnectionPool*)pool; + + p->lock.lock(); + auto it = p->internalMap.find(key); + bool exists = it!=p->internalMap.end(); + if(exists) { + p->lrul.splice(p->lrul.begin(), p->lrul, it->second); + std::string rval = it->second->second; + + p->lrul.erase(it->second); + p->internalMap.erase(it); + + val = CastUtil::toLongdouble(rval) + number; + p->lrul.push_front(make_pair(key, CastUtil::fromNumber(val))); + p->internalMap.insert(make_pair(key, p->lrul.begin())); + clean(); } - ((MemoryCacheConnectionPool*)pool)->lock.unlock(); + p->lock.unlock(); return val; } long double MemoryCacheImpl::decrementFloat(const std::string& key, const double& number) { long double val = -1.0; - ((MemoryCacheConnectionPool*)pool)->lock.lock(); - if(((MemoryCacheConnectionPool*)pool)->internalMap.find(key)!=((MemoryCacheConnectionPool*)pool)->internalMap.end()) { - val = CastUtil::toLongdouble(((MemoryCacheConnectionPool*)pool)->internalMap[key]) - number; - ((MemoryCacheConnectionPool*)pool)->internalMap[key] = CastUtil::fromNumber(val); + MemoryCacheConnectionPool* p = (MemoryCacheConnectionPool*)pool; + + p->lock.lock(); + auto it = p->internalMap.find(key); + bool exists = it!=p->internalMap.end(); + if(exists) { + p->lrul.splice(p->lrul.begin(), p->lrul, it->second); + std::string rval = it->second->second; + + p->lrul.erase(it->second); + p->internalMap.erase(it); + + val = CastUtil::toLongdouble(rval) - number; + p->lrul.push_front(make_pair(key, CastUtil::fromNumber(val))); + p->internalMap.insert(make_pair(key, p->lrul.begin())); + clean(); } - ((MemoryCacheConnectionPool*)pool)->lock.unlock(); + p->lock.unlock(); return val; } std::map MemoryCacheImpl::statistics() { - return ((MemoryCacheConnectionPool*)pool)->internalMap; + std::map m; + return m; } bool MemoryCacheImpl::flushAll() { return true; } -bool MemoryCacheImpl::setInternal(const std::string& key, const std::string& value, const int& expireSeconds, const int& setOrAddOrRep) { - if(setOrAddOrRep==1) - { - ((MemoryCacheConnectionPool*)pool)->lock.lock(); - ((MemoryCacheConnectionPool*)pool)->internalMap[key] = value; - ((MemoryCacheConnectionPool*)pool)->lock.unlock(); - return true; +void MemoryCacheImpl::clean() { + MemoryCacheConnectionPool* p = (MemoryCacheConnectionPool*)pool; + while(p->internalMap.size()>p->size) { + auto last_it = p->lrul.end(); last_it --; + p->internalMap.erase(last_it->first); + p->lrul.pop_back(); } - else if(setOrAddOrRep==2 && ((MemoryCacheConnectionPool*)pool)->internalMap.find(key)==((MemoryCacheConnectionPool*)pool)->internalMap.end()) - { - ((MemoryCacheConnectionPool*)pool)->lock.lock(); - ((MemoryCacheConnectionPool*)pool)->internalMap[key] = value; - ((MemoryCacheConnectionPool*)pool)->lock.unlock(); - return true; +} + +bool MemoryCacheImpl::setInternal(const std::string& key, const std::string& value, const int& expireSeconds, const int& setOrAddOrRep) { + MemoryCacheConnectionPool* p = (MemoryCacheConnectionPool*)pool; + + if(setOrAddOrRep<1 && setOrAddOrRep>3) return false; + + p->lock.lock(); + auto it = p->internalMap.find(key); + bool exists = it!=p->internalMap.end(); + if(exists) { + p->lrul.erase(it->second); + p->internalMap.erase(it); } - else if(setOrAddOrRep==3 && ((MemoryCacheConnectionPool*)pool)->internalMap.find(key)!=((MemoryCacheConnectionPool*)pool)->internalMap.end()) + + bool flag = false; + if(setOrAddOrRep==1 || (setOrAddOrRep==2 && !exists) || (setOrAddOrRep==3 && exists)) { - ((MemoryCacheConnectionPool*)pool)->lock.lock(); - ((MemoryCacheConnectionPool*)pool)->internalMap[key] = value; - ((MemoryCacheConnectionPool*)pool)->lock.unlock(); - return true; + p->lrul.push_front(make_pair(key, value)); + p->internalMap.insert(make_pair(key, p->lrul.begin())); + clean(); + flag = true; } - return false; + + p->lock.unlock(); + return flag; } std::string MemoryCacheImpl::getValue(const std::string& key) { - ((MemoryCacheConnectionPool*)pool)->lock.lock(); - std::string rval = ((MemoryCacheConnectionPool*)pool)->internalMap[key]; - ((MemoryCacheConnectionPool*)pool)->lock.unlock(); + MemoryCacheConnectionPool* p = (MemoryCacheConnectionPool*)pool; + std::string rval; + p->lock.lock(); + if(p->internalMap.count(key)>0) { + auto it = p->internalMap.find(key); + p->lrul.splice(p->lrul.begin(), p->lrul, it->second); + rval = it->second->second; + } + p->lock.unlock(); return rval; } @@ -134,9 +207,7 @@ std::vector MemoryCacheImpl::getValues(const std::vector& keys, std::vector& values) { for(int i=0;i<(int)keys.size();++i) { - ((MemoryCacheConnectionPool*)pool)->lock.lock(); - values.push_back(((MemoryCacheConnectionPool*)pool)->internalMap[keys.at(i)]); - ((MemoryCacheConnectionPool*)pool)->lock.unlock(); + values.push_back(getValue(keys.at(i))); } } @@ -204,6 +275,13 @@ void MemoryCacheImpl::init() { } MemoryCacheConnectionPool::MemoryCacheConnectionPool(const ConnectionProperties& props) { + size = 10000; + if(props.getProperty("size")!="") { + try { + size = CastUtil::toInt(props.getProperty("size")); + } catch(const std::exception& e) { + } + } } MemoryCacheConnectionPool::~MemoryCacheConnectionPool() { diff --git a/src/modules/cache/memory/MemoryCacheImpl.h b/src/modules/cache/memory/MemoryCacheImpl.h index da69b1db1..ff7b1079c 100644 --- a/src/modules/cache/memory/MemoryCacheImpl.h +++ b/src/modules/cache/memory/MemoryCacheImpl.h @@ -26,11 +26,16 @@ #include "ConnectionPooler.h" #include "Mutex.h" #include +#include +#include +#include class MemoryCacheConnectionPool: public ConnectionPooler { Logger logger; Mutex lock; - std::map internalMap; + int size; + std::list> lrul; + std::unordered_map internalMap; Mutex qlock; std::map> internalQMap; void initEnv(); @@ -46,6 +51,7 @@ class MemoryCacheConnectionPool: public ConnectionPooler { class MemoryCacheImpl : public CacheInterface { ConnectionProperties properties; bool setInternal(const std::string& key, const std::string& value, const int& expireSeconds, const int& setOrAddOrRep); + void clean(); public: MemoryCacheImpl(ConnectionPooler* pool); ~MemoryCacheImpl(); diff --git a/src/modules/common/CommonUtils.cpp b/src/modules/common/CommonUtils.cpp index e6f8c87c0..75d15f550 100644 --- a/src/modules/common/CommonUtils.cpp +++ b/src/modules/common/CommonUtils.cpp @@ -419,3 +419,17 @@ void CommonUtils::printStats() { logger.info(g); } } + +std::string CommonUtils::normalizeAppName(const std::string& appName) { + std::string scappName = appName; + StringUtil::replaceAll(scappName, "-", "_"); + RegexUtil::replace(scappName, "[^a-zA-Z0-9_]+", ""); + return scappName; +} + +std::string CommonUtils::getTpeFnName(const std::string& tpe, const std::string& appName) { + std::string stpe = appName + tpe; + RegexUtil::replace(stpe,"[/]+","/"); + RegexUtil::replace(stpe,"[^a-zA-Z0-9_]+",""); + return "_" + stpe + "emittTemplateHTML"; +} diff --git a/src/modules/common/CommonUtils.h b/src/modules/common/CommonUtils.h index 9389eaf29..7d8edb27f 100644 --- a/src/modules/common/CommonUtils.h +++ b/src/modules/common/CommonUtils.h @@ -52,6 +52,14 @@ #include "LoggerFactory.h" #include "HTTPResponseStatus.h" #include "SocketInterface.h" +#include "ClassInfo.h" + +struct ClassBeanIns { + ClassInfo* clas; + void* instance; +}; + +typedef void (*GetClassBeanIns) (std::string& clsn, std::string appn, ClassBeanIns* cbi); class CommonUtils { CommonUtils(); @@ -125,6 +133,8 @@ class CommonUtils { static CommonUtils* getInstance(); virtual ~CommonUtils(); static void printStats(); + static std::string normalizeAppName(const std::string& appName); + static std::string getTpeFnName(const std::string& tpe, const std::string& appName); }; #endif /* COMMONUTILS_H_ */ diff --git a/src/modules/http/HttpResponse.h b/src/modules/http/HttpResponse.h index 513a4489f..ecd197947 100644 --- a/src/modules/http/HttpResponse.h +++ b/src/modules/http/HttpResponse.h @@ -81,6 +81,8 @@ class HttpResponse { void setUrl(const std::string& url); const std::string& getUrl(); void addHeader(std::string header, const std::string& value); + void generateHeadResponse(std::string& resp); + void update(HttpRequest* req); private: static RiMap HDRS_SW_CODES; static const std::string HDR_SRV, HDR_SEP, HDR_SEPT, HDR_END, HDR_CORS_ALW, HDR_FIN; @@ -106,8 +108,6 @@ class HttpResponse { int tecurrpart; bool hasContent; void setCompressed(const bool& compressed); - void update(HttpRequest* req); - void generateHeadResponse(std::string& resp); void generateOptionsResponse(std::string& data); void generateTraceResponse(HttpRequest* req, std::string& data); bool updateContent(HttpRequest* req, const uint32_t& techunkSiz); diff --git a/src/modules/http/HttpServiceHandler.cpp b/src/modules/http/HttpServiceHandler.cpp index d599e3f80..22898a77a 100644 --- a/src/modules/http/HttpServiceHandler.cpp +++ b/src/modules/http/HttpServiceHandler.cpp @@ -251,7 +251,10 @@ void HttpServiceTask::run() { res->setDone(true); } } else { - handle(req, res); + if(!handle(req, res, handlerRequest.getSif())) { + //handlerRequest.getSif()->endRequest(handlerRequest.reqPos); + return; + } } } else diff --git a/src/modules/http/HttpServiceHandler.h b/src/modules/http/HttpServiceHandler.h index cfd9538d4..e78bb619b 100644 --- a/src/modules/http/HttpServiceHandler.h +++ b/src/modules/http/HttpServiceHandler.h @@ -43,7 +43,7 @@ class HttpServiceTask : public Task { HttpServiceTask(); virtual std::string getCntEncoding(); HttpServiceTask(ReusableInstanceHolder* h); - virtual void handle(HttpRequest* request, HttpResponse* response)=0; + virtual bool handle(HttpRequest* request, HttpResponse* response, SocketInterface* sif)=0; virtual WebSockHandler* handleWebsockOpen(WebSocketData* request, WebSocketRespponseData* response, SocketInterface* sif, HttpRequest* hreq)=0; }; diff --git a/src/modules/reflection/Reflection.cpp b/src/modules/reflection/Reflection.cpp index b2aa5fcc4..eedf888ab 100644 --- a/src/modules/reflection/Reflection.cpp +++ b/src/modules/reflection/Reflection.cpp @@ -1387,7 +1387,7 @@ std::string Reflection::generateClassDefinition(std::map")!=std::string::npos || meth.find("operator<=")!=std::string::npos + if(meth.find("operator=")!=std::string::npos || meth.find("operator<")!=std::string::npos || meth.find("operator>")!=std::string::npos || meth.find("operator<=")!=std::string::npos || meth.find("operator>=")!=std::string::npos || meth.find("operator==")!=std::string::npos || meth.find("operator!=")!=std::string::npos || meth.find("operator!")!=std::string::npos || meth.find("operator<<")!=std::string::npos || meth.find("operator>>")!=std::string::npos || meth.find("operator+")!=std::string::npos || meth.find("operator-")!=std::string::npos || meth.find("operator*")!=std::string::npos || meth.find("operator/")!=std::string::npos || meth.find("operator[]")!=std::string::npos || meth.find("operator()")!=std::string::npos @@ -2668,7 +2668,7 @@ std::string Reflection::generateAllSerDefinition(std::map")!=std::string::npos || meth.find("operator<=")!=std::string::npos + if(meth.find("operator=")!=std::string::npos || meth.find("operator<")!=std::string::npos || meth.find("operator>")!=std::string::npos || meth.find("operator<=")!=std::string::npos || meth.find("operator>=")!=std::string::npos || meth.find("operator==")!=std::string::npos || meth.find("operator!=")!=std::string::npos || meth.find("operator!")!=std::string::npos || meth.find("operator<<")!=std::string::npos || meth.find("operator>>")!=std::string::npos || meth.find("operator+")!=std::string::npos || meth.find("operator-")!=std::string::npos || meth.find("operator*")!=std::string::npos || meth.find("operator/")!=std::string::npos || meth.find("operator[]")!=std::string::npos || meth.find("operator()")!=std::string::npos @@ -3019,7 +3019,7 @@ std::string Reflection::generateAllSerDefinition(std::map")!=std::string::npos || meth.find("operator<=")!=std::string::npos + if(meth.find("operator=")!=std::string::npos || meth.find("operator<")!=std::string::npos || meth.find("operator>")!=std::string::npos || meth.find("operator<=")!=std::string::npos || meth.find("operator>=")!=std::string::npos || meth.find("operator==")!=std::string::npos || meth.find("operator!=")!=std::string::npos || meth.find("operator!")!=std::string::npos || meth.find("operator<<")!=std::string::npos || meth.find("operator>>")!=std::string::npos || meth.find("operator+")!=std::string::npos || meth.find("operator-")!=std::string::npos || meth.find("operator*")!=std::string::npos || meth.find("operator/")!=std::string::npos || meth.find("operator[]")!=std::string::npos || meth.find("operator()")!=std::string::npos @@ -3764,7 +3764,7 @@ std::string Reflection::getXSDDefinitions(std::map")!=std::string::npos || meth.find("operator<=")!=std::string::npos + if(meth.find("operator=")!=std::string::npos || meth.find("operator<")!=std::string::npos || meth.find("operator>")!=std::string::npos || meth.find("operator<=")!=std::string::npos || meth.find("operator>=")!=std::string::npos || meth.find("operator==")!=std::string::npos || meth.find("operator!=")!=std::string::npos || meth.find("operator!")!=std::string::npos || meth.find("operator<<")!=std::string::npos || meth.find("operator>>")!=std::string::npos || meth.find("operator+")!=std::string::npos || meth.find("operator-")!=std::string::npos || meth.find("operator*")!=std::string::npos || meth.find("operator/")!=std::string::npos || meth.find("operator[]")!=std::string::npos || meth.find("operator()")!=std::string::npos diff --git a/src/modules/sdorm/DataSourceManager.cpp b/src/modules/sdorm/DataSourceManager.cpp index b23b94f8e..b46b3936e 100644 --- a/src/modules/sdorm/DataSourceManager.cpp +++ b/src/modules/sdorm/DataSourceManager.cpp @@ -32,7 +32,7 @@ void DataSourceManager::init(bool issevh) { isSingleEVH = issevh; } -void DataSourceManager::initDSN(const ConnectionProperties& props, const Mapping& mapping) +void DataSourceManager::initDSN(const ConnectionProperties& props, const Mapping& mapping, GetClassBeanIns f) { Logger logger = LoggerFactory::getLogger("DataSourceManager"); std::string name = StringUtil::trimCopy(props.getName()); @@ -67,25 +67,23 @@ void DataSourceManager::initDSN(const ConnectionProperties& props, const Mapping StringUtil::split(v, meth, "."); if(v.size()==2) { CommonUtils::setAppName(appName); - ClassInfo* clas = ref->getClassInfo(v.at(0), appName); - if(clas->getClassName()!="") { - args argus; - vals valus; - const Constructor& ctor = clas->getConstructor(argus); - void* _temp = ref->newInstanceGVP(ctor); - try { - if(_temp!=NULL) { - const Method& meth = clas->getMethod(v.at(1), argus); - if(meth.getMethodName()!="") - { - ref->invokeMethodGVP(_temp, meth, valus); - } + ClassBeanIns cbi; + f(v.at(0), appName, &cbi); + void* _temp = cbi.instance; + try { + if(_temp!=NULL) { + args argus; + vals valus; + const Method& meth = cbi.clas->getMethod(v.at(1), argus); + if(meth.getMethodName()!="") + { + ref->invokeMethodGVP(_temp, meth, valus); } - } catch(const std::exception& e) { - logger.info("Error during init call for Datasource " + mapping.getAppName() + "@" + props.getName() + " " + std::string(e.what())); } - ref->destroy(_temp, v.at(0), appName); + } catch(const std::exception& e) { + logger.info("Error during init call for Datasource " + mapping.getAppName() + "@" + props.getName() + " " + std::string(e.what())); } + ref->destroy(_temp, v.at(0), appName); } } } @@ -164,7 +162,7 @@ void* DataSourceManager::getRawImpl(std::string name, std::string appName) { if(StringUtil::toLowerCopy(dsnMgr->props.getType())=="sql-raw-pq") { #if defined(INC_SDORM_SQL) && defined(HAVE_LIBPQ) - t = new LibpqDataSourceImpl(dsnMgr->props.getNodes().at(0).getBaseUrl()); + t = new LibpqDataSourceImpl(dsnMgr->props.getNodes().at(0).getBaseUrl(), dsnMgr->props.getProperty("async")=="true"); ((LibpqDataSourceImpl*)t)->init(); #endif } diff --git a/src/modules/sdorm/DataSourceManager.h b/src/modules/sdorm/DataSourceManager.h index 74e61de1d..6e432ca84 100644 --- a/src/modules/sdorm/DataSourceManager.h +++ b/src/modules/sdorm/DataSourceManager.h @@ -47,7 +47,7 @@ class DataSourceManager { ConnectionProperties props; Mapping mapping; ConnectionPooler* pool; - static void initDSN(const ConnectionProperties& props, const Mapping& mapping); + static void initDSN(const ConnectionProperties& props, const Mapping& mapping, GetClassBeanIns f); DataSourceManager(const ConnectionProperties& props, const Mapping& mapping); static void destroy(); friend class ConfigurationHandler; diff --git a/src/modules/sdorm/sql/libpq/LibpqDataSourceImpl.cpp b/src/modules/sdorm/sql/libpq/LibpqDataSourceImpl.cpp index 92f59ea1d..1fbb54e43 100644 --- a/src/modules/sdorm/sql/libpq/LibpqDataSourceImpl.cpp +++ b/src/modules/sdorm/sql/libpq/LibpqDataSourceImpl.cpp @@ -15,20 +15,26 @@ */ #include "LibpqDataSourceImpl.h" +std::atomic LibpqDataSourceImpl::done = false; + DSType LibpqDataSourceImpl::getType() { return SD_RAW_SQLPG; } -LibpqDataSourceImpl::LibpqDataSourceImpl(const std::string& url) { +LibpqDataSourceImpl::LibpqDataSourceImpl(const std::string& url, bool isAsync) { this->url = url; #ifdef HAVE_LIBPQ conn = NULL; #endif trx = false; + this->isAsync = isAsync; + fd = -1; } LibpqDataSourceImpl::~LibpqDataSourceImpl() { #ifdef HAVE_LIBPQ + done = true; + Thread::sSleep(3); if(conn!=NULL) { PQfinish(conn); } @@ -45,12 +51,59 @@ bool LibpqDataSourceImpl::init() { conn = NULL; return false; } + fd = PQsocket(conn); + if(isAsync) { + PQsetnonblocking(conn, 1); + if(RequestReaderHandler::getInstance()!=NULL) { + rdTsk = new PgReadTask(this); + RequestReaderHandler::getInstance()->addSf(this); + } else { + Thread* pthread = new Thread(&handle, this); + pthread->execute(); + } + } #endif return true; } +void* LibpqDataSourceImpl::beginAsync(void* vitem) { + if(isAsync) { + int status = -1; + std::vector pvals; + __AsyncReq* areq = NULL; + executeQueryInt("BEGIN", pvals, true, status, NULL, NULL, NULL, vitem, false, &areq); + return areq; + } + return NULL; +} + +void* LibpqDataSourceImpl::commitAsync(void* vitem) { + if(isAsync) { + int status = -1; + std::vector pvals; + __AsyncReq* areq = NULL; + executeQueryInt("COMMIT", pvals, true, status, NULL, NULL, NULL, vitem, false, &areq); + return areq; + } + return NULL; +} + +void* LibpqDataSourceImpl::rollbackAsync(void* vitem) { + if(isAsync) { + int status = -1; + std::vector pvals; + __AsyncReq* areq = NULL; + executeQueryInt("ROLLBACK", pvals, true, status, NULL, NULL, NULL, vitem, false, &areq); + return areq; + } + return NULL; +} + bool LibpqDataSourceImpl::begin() { #ifdef HAVE_LIBPQ + if(isAsync) { + throw std::runtime_error("Please call beginAsync"); + } PGresult *res = PQexec(conn, "BEGIN"); if (PQresultStatus(res) != PGRES_COMMAND_OK) { printf("BEGIN command failed\n"); @@ -66,6 +119,9 @@ bool LibpqDataSourceImpl::begin() { bool LibpqDataSourceImpl::commit() { #ifdef HAVE_LIBPQ + if(isAsync) { + throw std::runtime_error("Please call commitAsync"); + } PGresult *res = PQexec(conn, "COMMIT"); if (PQresultStatus(res) != PGRES_COMMAND_OK) { printf("COMMIT command failed\n"); @@ -81,6 +137,9 @@ bool LibpqDataSourceImpl::commit() { bool LibpqDataSourceImpl::rollback() { #ifdef HAVE_LIBPQ + if(isAsync) { + throw std::runtime_error("Please call rollbackAsync"); + } PGresult *res = PQexec(conn, "ROLLBACK"); if (PQresultStatus(res) != PGRES_COMMAND_OK) { printf("ROLLBACK command failed\n"); @@ -114,48 +173,624 @@ void LibpqDataSourceImpl::ADD_BIN(std::vector& pvals, const char *i, pvals.push_back({.p = i, .s = 0, .i = 0, .li = 0, .l = (size_t)len, .t = 5, .b = 1}); } +__AsyncReq* LibpqDataSourceImpl::getNext() { + __AsyncReq* ar = NULL; + if(rdTsk==NULL)c_mutex.lock(); + if(Q.size()>0) { + ar = Q.front(); + Q.pop(); + } + if(rdTsk==NULL)c_mutex.unlock(); + return ar; +} + +void* LibpqDataSourceImpl::handle(void* inp) { + LibpqDataSourceImpl* ths = (LibpqDataSourceImpl*)inp; +#ifdef HAVE_LIBPQ + struct timeval tv; + tv.tv_sec = 2; + tv.tv_usec = 0; -void LibpqDataSourceImpl::executeQuery(const std::string &query, const std::vector& pvals, void* ctx, LipqResFunc cb, bool isPrepared) { - int psize = (int)pvals.size(); - const char *paramValues[psize]; - int paramLengths[psize]; - int paramBinary[psize]; - for (int var = 0; var < psize; ++var) { - if(pvals.at(var).t==1) {//short - paramValues[var] = (char *)&pvals.at(var).s; - paramLengths[var] = pvals.at(var).l; - } else if(pvals.at(var).t==2) {//int - paramValues[var] = (char *)&pvals.at(var).i; - paramLengths[var] = pvals.at(var).l; - } else if(pvals.at(var).t==3) {//long - paramValues[var] = (char *)&pvals.at(var).li; - paramLengths[var] = pvals.at(var).l; - } else { - paramValues[var] = pvals.at(var).p; - paramLengths[var] = pvals.at(var).l; + while(!done) { + ths->c_mutex.lock(); + while (!ths->cvar) + ths->c_mutex.conditionalWait(); + ths->c_mutex.unlock(); + + ths->cvar = false; + + __AsyncReq* item = NULL; + while((item = ths->getNext())!=NULL && !done) { + int counter = -1; + while(item->q.size()>0) { + counter ++; + __AsynQuery* q = item->q.front(); + item->q.pop(); + + int psize = (int)q->pvals.size(); + const char *paramValues[psize]; + int paramLengths[psize]; + int paramBinary[psize]; + for (int var = 0; var < psize; ++var) { + if(q->pvals.at(var).t==1) {//short + paramValues[var] = (char *)&q->pvals.at(var).s; + paramLengths[var] = q->pvals.at(var).l; + } else if(q->pvals.at(var).t==2) {//int + paramValues[var] = (char *)&q->pvals.at(var).i; + paramLengths[var] = q->pvals.at(var).l; + } else if(q->pvals.at(var).t==3) {//long + paramValues[var] = (char *)&q->pvals.at(var).li; + paramLengths[var] = q->pvals.at(var).l; + } else { + paramValues[var] = q->pvals.at(var).p; + paramLengths[var] = q->pvals.at(var).l; + } + paramBinary[var] = q->pvals.at(var).b?1:0; + } + + std::string stmtName; + if(q->isPrepared) { + if(ths->prepStmtMap.find(q->query)==ths->prepStmtMap.end()) { + stmtName = CastUtil::fromNumber(ths->prepStmtMap.size()+1); + ths->prepStmtMap[q->query] = stmtName; + PGresult* res = PQprepare(ths->conn, stmtName.c_str(), q->query.c_str(), psize, NULL); + if (PQresultStatus(res) != PGRES_COMMAND_OK) { + fprintf(stderr, "PREPARE failed: %s", PQerrorMessage(ths->conn)); + PQclear(res); + if(q->cmcb!=NULL) { + q->cmcb(q->ctx, false, q->query, counter); + } else if(item->cmcb!=NULL) { + item->cmcb(item->ctx, false, q->query, counter); + } + delete q; + while(item->q.size()>0) { + __AsynQuery* qr = item->q.front(); + item->q.pop(); + delete qr; + } + break; + } + } else { + stmtName = ths->prepStmtMap[q->query]; + } + } + + int qs = -1; + if(q->isPrepared) { + qs = PQsendQueryPrepared(ths->conn, stmtName.c_str(), psize, paramValues, paramLengths, paramBinary, 1); + } else { + qs = PQsendQueryParams(ths->conn, q->query.c_str(), psize, NULL, paramValues, paramLengths, paramBinary, 1); + } + + if (!qs) { + fprintf(stderr, "Failed to send query %s\n", PQerrorMessage(ths->conn)); + if(q->cmcb!=NULL) { + q->cmcb(q->ctx, false, q->query, counter); + } else if(item->cmcb!=NULL) { + item->cmcb(item->ctx, false, q->query, counter); + } + delete q; + while(item->q.size()>0) { + __AsynQuery* qr = item->q.front(); + item->q.pop(); + delete qr; + } + break; + } + + bool resDone = false; + while(!resDone) { + fd_set read_fds; + FD_ZERO(&read_fds); + FD_SET(ths->fd, &read_fds); + + int retval = select(ths->fd + 1, &read_fds, NULL, NULL, &tv); + switch (retval) { + case -1: + perror("select() failed"); + resDone = true; + break; + case 0: + break; + default: + if (FD_ISSET(ths->fd, &read_fds)) { + if (!PQconsumeInput(ths->conn)) { + fprintf(stderr, "Failed to consume pg input: %s\n", PQerrorMessage(ths->conn)); + throw std::runtime_error("Invalid connection state"); + } + if(PQisBusy(ths->conn)==1) { + continue; + } + + PGresult* res = NULL; + bool itemDone = false; + while ((res = PQgetResult(ths->conn))!=NULL && !done) { + if(itemDone) { + PQclear(res); + continue; + } + if(q->isSelect) { + if (PQresultStatus(res) != PGRES_TUPLES_OK) { + if(q->cmcb!=NULL) { + q->cmcb(q->ctx, false, q->query, counter); + } else if(item->cmcb!=NULL) { + item->cmcb(item->ctx, false, q->query, counter); + } + fprintf(stderr, "SELECT failed: %s", PQerrorMessage(ths->conn)); + PQclear(res); + } else if(q->cb!=NULL) { + int cols = PQnfields(res); + int rows = PQntuples(res); + std::vector row; + for(int i=0; icb(q->ctx, i, row); + } + } + } else { + if (PQresultStatus(res) != PGRES_COMMAND_OK) { + if(q->cmcb!=NULL) { + q->cmcb(q->ctx, false, q->query, counter); + } else if(item->cmcb!=NULL) { + item->cmcb(item->ctx, false, q->query, counter); + } + fprintf(stderr, "UPDATE failed: %s", PQerrorMessage(ths->conn)); + PQclear(res); + } + } + + if(item->cnt--==-1) { + if(q->cmcb!=NULL) { + q->cmcb(q->ctx, true, q->query, counter); + } else if(item->cmcb!=NULL) { + item->cmcb(item->ctx, false, q->query, counter); + } + itemDone = true; + } + PQclear(res); + } + resDone = true; + } + } + } + delete q; + } + delete item; } - paramBinary[var] = pvals.at(var).b?1:0; } -#ifdef HAVE_LIBPQ - PGresult *res = NULL; - if(isPrepared) { - std::string stmtName; - if(prepStmtMap.find(query)==prepStmtMap.end()) { - stmtName = CastUtil::fromNumber(prepStmtMap.size()+1); - prepStmtMap[query] = stmtName; - res = PQprepare(conn, stmtName.c_str(), query.c_str(), psize, NULL); +#endif + return NULL; +} + +void PgReadTask::run() { + LibpqDataSourceImpl* ths = (LibpqDataSourceImpl*)sif; + if (!PQconsumeInput(ths->conn)) { + fprintf(stderr, "Failed to consume pg input: %s\n", PQerrorMessage(ths->conn)); + throw std::runtime_error("Invalid connection state"); + } + //if(PQisBusy(ths->conn)==1) { + // continue; + //} + + PGresult* res = NULL; + bool ritemDone = false; + while ((res = PQgetResult(ths->conn))!=NULL) { + if(ritemDone) { + PQclear(res); + continue; + } + if(hasPrepare) { if (PQresultStatus(res) != PGRES_COMMAND_OK) { - fprintf(stderr, "PREPARE failed: %s", PQerrorMessage(conn)); + fprintf(stderr, "PREPARE failed: %s", PQerrorMessage(ths->conn)); PQclear(res); - return; + if(q->cmcb!=NULL) { + q->cmcb(q->ctx, false, q->query, counter); + } else if(ritem->cmcb!=NULL) { + ritem->cmcb(ritem->ctx, false, q->query, counter); + } + while(ritem->q.size()>0) { + __AsynQuery* qr = ritem->q.front(); + ritem->q.pop(); + delete qr; + } + delete q; + q = NULL; + ritemDone = true; + } else { + //fprintf(stdout, "PREPARE response....\n");fflush(stdout); } + } else if(q->isSelect) { + if (PQresultStatus(res) != PGRES_TUPLES_OK) { + if(q->cmcb!=NULL) { + q->cmcb(q->ctx, false, q->query, counter); + } else if(ritem->cmcb!=NULL) { + ritem->cmcb(ritem->ctx, false, q->query, counter); + } + fprintf(stderr, "SELECT failed: %s", PQerrorMessage(ths->conn)); + PQclear(res); + while(ritem->q.size()>0) { + __AsynQuery* qr = ritem->q.front(); + ritem->q.pop(); + delete qr; + } + ritemDone = true; + } else if(q->cb!=NULL) { + //fprintf(stdout, "SELECT response\n");fflush(stdout); + int cols = PQnfields(res); + int rows = PQntuples(res); + std::vector row; + for(int i=0; icb(q->ctx, i, row); + } + if(ritem->cnt--==-1) { + if(q->cmcb!=NULL) { + q->cmcb(q->ctx, true, q->query, counter); + } else if(ritem->cmcb!=NULL) { + ritem->cmcb(ritem->ctx, false, q->query, counter); + } + ritemDone = true; + } + } + delete q; + q = NULL; } else { - stmtName = prepStmtMap[query]; + if (PQresultStatus(res) != PGRES_COMMAND_OK) { + if(q->cmcb!=NULL) { + q->cmcb(q->ctx, false, q->query, counter); + } else if(ritem->cmcb!=NULL) { + ritem->cmcb(ritem->ctx, false, q->query, counter); + } + fprintf(stderr, "UPDATE failed: %s", PQerrorMessage(ths->conn)); + PQclear(res); + while(ritem->q.size()>0) { + __AsynQuery* qr = ritem->q.front(); + ritem->q.pop(); + delete qr; + } + ritemDone = true; + } else { + //fprintf(stdout, "UPDATE response\n");fflush(stdout); + } + if(ritem->cnt--==-1) { + if(q->cmcb!=NULL) { + q->cmcb(q->ctx, true, q->query, counter); + } else if(ritem->cmcb!=NULL) { + ritem->cmcb(ritem->ctx, false, q->query, counter); + } + ritemDone = true; + } + delete q; + q = NULL; + } + PQclear(res); + } + flux = false; + submit(NULL); + if(hasPrepare) hasPrepare = false; +} + +void PgReadTask::submit(__AsyncReq* nitem) { + LibpqDataSourceImpl* ths = (LibpqDataSourceImpl*)sif; + + if(flux && nitem!=NULL) { + ths->Q.push(nitem); + //fprintf(stdout, "Add query to Q....\n");fflush(stdout); + return; + } + + if(ritem!=NULL && ritem->cnt==-2 && !hasPrepare) { + delete ritem; + ritem = NULL; + counter = -1; + //fprintf(stdout, "Clear query....\n");fflush(stdout); + } + + if(nitem==NULL && ritem==NULL) { + ritem = ths->getNext(); + //fprintf(stdout, "New query from Q....\n");fflush(stdout); + } else if(ritem==NULL && nitem!=NULL) { + ritem = nitem; + //fprintf(stdout, "New query....\n");fflush(stdout); + } + + if(ritem!=NULL) { + if((hasPrepare && q!=NULL) || ritem->q.size()>0) { + if(!hasPrepare) { + counter ++; + q = ritem->q.front(); + ritem->q.pop(); + } + + int psize = (int)q->pvals.size(); + + if(q->isPrepared) { + if(ths->prepStmtMap.find(q->query)==ths->prepStmtMap.end()) { + //fprintf(stdout, "Prepare query....\n");fflush(stdout); + hasPrepare = true; + q->stmtName = CastUtil::fromNumber(ths->prepStmtMap.size()+1); + ths->prepStmtMap[q->query] = q->stmtName; + int qs = PQsendPrepare(ths->conn, q->stmtName.c_str(), q->query.c_str(), psize, NULL); + + if (!qs) { + fprintf(stderr, "Failed to prepare query %s\n", PQerrorMessage(ths->conn)); + if(q->cmcb!=NULL) { + q->cmcb(q->ctx, false, q->query, counter); + } else if(ritem->cmcb!=NULL) { + ritem->cmcb(ritem->ctx, false, q->query, counter); + } + delete q; + while(ritem->q.size()>0) { + __AsynQuery* qr = ritem->q.front(); + ritem->q.pop(); + delete qr; + } + delete ritem; + ritem = NULL; + } else { + flux = true; + PQflush(ths->conn); + } + return; + } else { + q->stmtName = ths->prepStmtMap[q->query]; + } + } + + const char *paramValues[psize]; + int paramLengths[psize]; + int paramBinary[psize]; + for (int var = 0; var < psize; ++var) { + if(q->pvals.at(var).t==1) {//short + paramValues[var] = (char *)&q->pvals.at(var).s; + paramLengths[var] = q->pvals.at(var).l; + } else if(q->pvals.at(var).t==2) {//int + paramValues[var] = (char *)&q->pvals.at(var).i; + paramLengths[var] = q->pvals.at(var).l; + } else if(q->pvals.at(var).t==3) {//long + paramValues[var] = (char *)&q->pvals.at(var).li; + paramLengths[var] = q->pvals.at(var).l; + } else { + paramValues[var] = q->pvals.at(var).p; + paramLengths[var] = q->pvals.at(var).l; + } + paramBinary[var] = q->pvals.at(var).b?1:0; + } + + int qs = -1; + if(q->isPrepared) { + qs = PQsendQueryPrepared(ths->conn, q->stmtName.c_str(), psize, paramValues, paramLengths, paramBinary, 1); + } else { + qs = PQsendQueryParams(ths->conn, q->query.c_str(), psize, NULL, paramValues, paramLengths, paramBinary, 1); + } + //fprintf(stdout, "Send query....\n");fflush(stdout); + + if (!qs) { + fprintf(stderr, "Failed to send query %s\n", PQerrorMessage(ths->conn)); + if(q->cmcb!=NULL) { + q->cmcb(q->ctx, false, q->query, counter); + } else if(ritem->cmcb!=NULL) { + ritem->cmcb(ritem->ctx, false, q->query, counter); + } + delete q; + while(ritem->q.size()>0) { + __AsynQuery* qr = ritem->q.front(); + ritem->q.pop(); + delete qr; + } + delete ritem; + ritem = NULL; + } else { + flux = true; + PQflush(ths->conn); + } } - res = PQexecPrepared(conn, stmtName.c_str(), psize, paramValues, paramLengths, paramBinary, 1); + } else if(nitem!=NULL) { + //ths->c_mutex.lock(); + ths->Q.push(nitem); + //ths->c_mutex.unlock(); + //fprintf(stdout, "Add query to Q....\n");fflush(stdout); + } +} + +void LibpqDataSourceImpl::completeAsync(void* vitem, void* ctx, LipqComplFunc cmcb) { + __AsyncReq* item = (__AsyncReq*)vitem; + if(item!=NULL) { + item->cmcb = cmcb; + item->ctx = ctx; + + if(rdTsk!=NULL) { + ((PgReadTask*)rdTsk)->submit(item); + return; + } + + c_mutex.lock(); + Q.push(item); + cvar = true; + c_mutex.conditionalNotifyOne(); + c_mutex.unlock(); + } +} + +PGresult* LibpqDataSourceImpl::executeQueryInt(const std::string &query, const std::vector& pvals, bool isPrepared, int& status, + void* ctx, LipqResFunc cb, LipqComplFunc cmcb, void* vitem, bool isSelect, __AsyncReq** areq) { + if(isAsync) { + status = 1; + __AsyncReq* item = vitem!=NULL?(__AsyncReq*)vitem:new __AsyncReq; + if(vitem==NULL) { + item->cnt = -1; + } else { + item->cnt++; + } + + __AsynQuery* q = new __AsynQuery; + q->query = query; + q->isPrepared = isPrepared; + q->pvals = pvals; + q->ctx = ctx; + q->cb = cb; + q->cmcb = cmcb; + q->isSelect = isSelect; + item->q.push(q); + + *areq = item; + + return NULL; } else { - res = PQexecParams(conn, query.c_str(), psize, NULL, paramValues, paramLengths, paramBinary, 1); + int psize = (int)pvals.size(); + const char *paramValues[psize]; + int paramLengths[psize]; + int paramBinary[psize]; + for (int var = 0; var < psize; ++var) { + if(pvals.at(var).t==1) {//short + paramValues[var] = (char *)&pvals.at(var).s; + paramLengths[var] = pvals.at(var).l; + } else if(pvals.at(var).t==2) {//int + paramValues[var] = (char *)&pvals.at(var).i; + paramLengths[var] = pvals.at(var).l; + } else if(pvals.at(var).t==3) {//long + paramValues[var] = (char *)&pvals.at(var).li; + paramLengths[var] = pvals.at(var).l; + } else { + paramValues[var] = pvals.at(var).p; + paramLengths[var] = pvals.at(var).l; + } + paramBinary[var] = pvals.at(var).b?1:0; + } + #ifdef HAVE_LIBPQ + std::string stmtName; + if(isPrepared) { + if(prepStmtMap.find(query)==prepStmtMap.end()) { + stmtName = CastUtil::fromNumber(prepStmtMap.size()+1); + prepStmtMap[query] = stmtName; + PGresult* res = PQprepare(conn, stmtName.c_str(), query.c_str(), psize, NULL); + if (PQresultStatus(res) != PGRES_COMMAND_OK) { + fprintf(stderr, "PREPARE failed: %s", PQerrorMessage(conn)); + PQclear(res); + return NULL; + } + } else { + stmtName = prepStmtMap[query]; + } + } + if(isPrepared) { + return PQexecPrepared(conn, stmtName.c_str(), psize, paramValues, paramLengths, paramBinary, 1); + } else if (psize>0) { + return PQexecParams(conn, query.c_str(), psize, NULL, paramValues, paramLengths, paramBinary, 1); + } else { + int qs = PQsendQuery(conn, query.c_str()); + if (!qs) { + fprintf(stderr, "Failed to send query %s\n", PQerrorMessage(conn)); + } + return NULL; + } + } +#endif + return NULL; +} + +void* LibpqDataSourceImpl::executeUpdateQueryAsync(const std::string &query, const std::vector& pvals, void* ctx, LipqComplFunc cmcb, void* vitem, bool isPrepared) { + int status = -1; + __AsyncReq* areq = NULL; + executeQueryInt(query, pvals, true, status, ctx, NULL, cmcb, vitem, false, &areq); + return areq; +} + +void* LibpqDataSourceImpl::executeQueryAsync(const std::string &query, const std::vector& pvals, void* ctx, LipqResFunc cb, LipqComplFunc cmcb, void* vitem, bool isPrepared) { + int status = -1; + __AsyncReq* areq = NULL; + executeQueryInt(query, pvals, true, status, ctx, cb, cmcb, vitem, true, &areq); + return areq; +} + +void LibpqDataSourceImpl::executeMultiQuery(const std::string &query, void* ctx, LipqResFunc cb, LipqComplFunc cmcb) { + if(isAsync) { + throw std::runtime_error("Please call executeQueryAsync"); + } +#ifdef HAVE_LIBPQ + int status = -1; + __AsyncReq* areq = NULL; + std::vector pvals; + executeQueryInt(query, pvals, false, status, NULL, NULL, NULL, NULL, true, &areq); + PGresult* res = NULL; + bool stat = true; + int counter = -1; + while((res = PQgetResult(conn))!=NULL) { + counter++; + if (PQresultStatus(res) != PGRES_TUPLES_OK) { + fprintf(stderr, "SELECT failed: %s", PQerrorMessage(conn)); + if(cmcb!=NULL) { + cmcb(ctx, false, query, counter); + } + stat = false; + } else { + int cols = PQnfields(res); + int rows = PQntuples(res); + std::vector row; + for(int i=0; i pvals; + executeQueryInt(query, pvals, false, status, NULL, NULL, NULL, NULL, true, &areq); + PGresult* res = NULL; + int counter = -1; + bool stat = true; + while((res = PQgetResult(conn))!=NULL) { + counter++; + if (PQresultStatus(res) != PGRES_COMMAND_OK) { + fprintf(stderr, "UPDATE failed: %s", PQerrorMessage(conn)); + PQclear(res); + stat = false; + if(cmcb!=NULL) { + cmcb(ctx, false, query, counter); + } + } + PQclear(res); } + if(stat) { + if(cmcb!=NULL) { + cmcb(ctx, stat, query, counter); + } + } +#endif +} + +void LibpqDataSourceImpl::executeQuery(const std::string &query, const std::vector& pvals, void* ctx, LipqResFunc cb, bool isPrepared) { + if(isAsync) { + throw std::runtime_error("Please call executeQueryAsync"); + } +#ifdef HAVE_LIBPQ + int status = -1; + __AsyncReq* areq = NULL; + PGresult *res = executeQueryInt(query, pvals, true, status, NULL, NULL, NULL, NULL, true, &areq); if (PQresultStatus(res) != PGRES_TUPLES_OK) { fprintf(stderr, "SELECT failed: %s", PQerrorMessage(conn)); PQclear(res); @@ -177,46 +812,13 @@ void LibpqDataSourceImpl::executeQuery(const std::string &query, const std::vect } bool LibpqDataSourceImpl::executeUpdateQuery(const std::string &query, const std::vector& pvals, bool isPrepared) { - int psize = (int)pvals.size(); - const char *paramValues[psize]; - int paramLengths[psize]; - int paramBinary[psize]; - for (int var = 0; var < psize; ++var) { - if(pvals.at(var).t==1) {//short - paramValues[var] = (char *)&pvals.at(var).s; - paramLengths[var] = pvals.at(var).l; - } else if(pvals.at(var).t==2) {//int - paramValues[var] = (char *)&pvals.at(var).i; - paramLengths[var] = pvals.at(var).l; - } else if(pvals.at(var).t==3) {//long - paramValues[var] = (char *)&pvals.at(var).li; - paramLengths[var] = pvals.at(var).l; - } else { - paramValues[var] = pvals.at(var).p; - paramLengths[var] = pvals.at(var).l; - } - paramBinary[var] = pvals.at(var).b?1:0; + if(isAsync) { + throw std::runtime_error("Please call executeUpdateQueryAsync"); } #ifdef HAVE_LIBPQ - PGresult *res = NULL; - if(isPrepared) { - std::string stmtName; - if(prepStmtMap.find(query)==prepStmtMap.end()) { - stmtName = CastUtil::fromNumber(prepStmtMap.size()+1); - prepStmtMap[query] = stmtName; - res = PQprepare(conn, stmtName.c_str(), query.c_str(), psize, NULL); - if (PQresultStatus(res) != PGRES_COMMAND_OK) { - fprintf(stderr, "PREPARE failed: %s", PQerrorMessage(conn)); - PQclear(res); - return false; - } - } else { - stmtName = prepStmtMap[query]; - } - res = PQexecPrepared(conn, stmtName.c_str(), psize, paramValues, paramLengths, paramBinary, 1); - } else { - res = PQexecParams(conn, query.c_str(), psize, NULL, paramValues, paramLengths, paramBinary, 1); - } + int status = -1; + __AsyncReq* areq = NULL; + PGresult *res = executeQueryInt(query, pvals, false, status, NULL, NULL, NULL, NULL, false, &areq); if (PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "UPDATE failed: %s", PQerrorMessage(conn)); PQclear(res); @@ -226,3 +828,15 @@ bool LibpqDataSourceImpl::executeUpdateQuery(const std::string &query, const std #endif return true; } + +PgReadTask::~PgReadTask() { +} + +PgReadTask::PgReadTask(SocketInterface* sif) { + this->sif = sif; + ritem = NULL; + counter = -1; + hasPrepare = false; + q = NULL; + flux = false; +} diff --git a/src/modules/sdorm/sql/libpq/LibpqDataSourceImpl.h b/src/modules/sdorm/sql/libpq/LibpqDataSourceImpl.h index 1d6ff5f8f..69087bb76 100644 --- a/src/modules/sdorm/sql/libpq/LibpqDataSourceImpl.h +++ b/src/modules/sdorm/sql/libpq/LibpqDataSourceImpl.h @@ -30,6 +30,9 @@ #endif #include "DataSourceInterface.h" #include "DialectHelper.h" +#include "Thread.h" +#include "SocketInterface.h" +#include "RequestReaderHandler.h" struct LibpqParam { const char* p; @@ -47,20 +50,74 @@ struct LibpqRes { int l; }; +typedef void (*LipqComplFunc) (void* ctx, bool, std::string, int); typedef void (*LipqResFunc) (void* ctx, int, std::vector&); -class LibpqDataSourceImpl : public DataSourceType { +struct __AsynQuery { + std::string query; + std::string stmtName; + std::vector pvals; + bool isPrepared; + bool isSelect; + void* ctx; + LipqResFunc cb; + LipqComplFunc cmcb; +}; + +struct __AsyncReq { + void* ctx; + LipqComplFunc cmcb; + int cnt; + std::queue<__AsynQuery*> q; +}; + +class PgReadTask : public Task { + __AsyncReq* ritem; + int counter = 0; + __AsynQuery* q; + bool hasPrepare; + SocketInterface* sif; + bool flux; + void run(); + void submit(__AsyncReq* item); + friend class LibpqDataSourceImpl; +public: + virtual ~PgReadTask(); + PgReadTask(SocketInterface* sif); +}; + +class LibpqDataSourceImpl : public DataSourceType, public SocketInterface { std::map prepStmtMap; Logger logger; std::string url; bool trx; + bool isAsync; #ifdef HAVE_LIBPQ PGconn* conn; //statement + std::queue<__AsyncReq*> Q; + static std::atomic done; + ConditionMutex c_mutex; + std::atomic cvar; #endif + PGresult* executeQueryInt(const std::string &query, const std::vector& pvals, bool isPrepared, int& status, + void* ctx, LipqResFunc cb, LipqComplFunc cmcb, void* vitem, bool isSelect, __AsyncReq**); + static void* handle(void* inp); + __AsyncReq* getNext(); + friend class PgReadTask; public: DSType getType(); - LibpqDataSourceImpl(const std::string&); - ~LibpqDataSourceImpl(); + LibpqDataSourceImpl(const std::string&, bool isAsync); + virtual ~LibpqDataSourceImpl(); + + std::string getProtocol(void* context){return "pgsql";} + int getType(void* context){return 1;} + int getTimeout(){return -1;} + bool readRequest(void* request, void*& context, int& pending, int& reqPos){return true;} + bool writeResponse(void* req, void* res, void* context, std::string& data, int reqPos){return true;} + void onOpen(){} + void onClose(){} + void addHandler(SocketInterface* handler){} + bool isEmbedded(){return false;} bool init(); @@ -68,6 +125,12 @@ class LibpqDataSourceImpl : public DataSourceType { bool commit(); bool rollback(); + void completeAsync(void* vitem, void* ctx = NULL, LipqComplFunc cmcb = NULL); + + void* beginAsync(void* vitem = NULL); + void* commitAsync(void* vitem = NULL); + void* rollbackAsync(void* vitem = NULL); + static void ADD_INT2(std::vector& pvals, unsigned short i, bool isH = true); static void ADD_INT4(std::vector& pvals, unsigned int i, bool isH = true); static void ADD_INT8(std::vector& pvals, long long i); @@ -75,7 +138,12 @@ class LibpqDataSourceImpl : public DataSourceType { static void ADD_BIN(std::vector& pvals, const char* i, int len); void executeQuery(const std::string &query, const std::vector& pvals, void* ctx, LipqResFunc cb, bool isPrepared = true); + void executeMultiQuery(const std::string &query, void* ctx, LipqResFunc cb, LipqComplFunc cmcb); bool executeUpdateQuery(const std::string &query, const std::vector& pvals, bool isPrepared = true); + void executeUpdateMultiQuery(const std::string &query, void* ctx, LipqComplFunc cmcb); + + void* executeQueryAsync(const std::string &query, const std::vector& pvals, void* ctx, LipqResFunc cb, LipqComplFunc cmcb, void* item, bool isPrepared = true); + void* executeUpdateQueryAsync(const std::string &query, const std::vector& pvals, void* ctx, LipqComplFunc cmcb, void* item, bool isPrepared = true); }; #endif /* LibpqDataSourceIMPL_H_ */ diff --git a/src/modules/server-util/RequestReaderHandler.cpp b/src/modules/server-util/RequestReaderHandler.cpp index d297b68c7..e1ae65c71 100644 --- a/src/modules/server-util/RequestReaderHandler.cpp +++ b/src/modules/server-util/RequestReaderHandler.cpp @@ -22,6 +22,8 @@ #include "RequestReaderHandler.h" +RequestReaderHandler* RequestReaderHandler::_i = NULL; + RequestReaderHandler::RequestReaderHandler(ServiceHandler* shi, const bool& isMain, bool isSinglEVH, const SOCKET& listenerSock) { this->shi = shi; this->listenerSock = listenerSock; @@ -34,6 +36,16 @@ RequestReaderHandler::RequestReaderHandler(ServiceHandler* shi, const bool& isMa this->isSinglEVH = isSinglEVH; } +void RequestReaderHandler::setInstance(RequestReaderHandler* ins) { + if(_i==NULL) { + _i = ins; + } +} + +RequestReaderHandler* RequestReaderHandler::getInstance() { + return _i; +} + void RequestReaderHandler::start(unsigned int cid) { if(run) { return; diff --git a/src/modules/server-util/RequestReaderHandler.h b/src/modules/server-util/RequestReaderHandler.h index 3ee5a8ec2..564bd540b 100644 --- a/src/modules/server-util/RequestReaderHandler.h +++ b/src/modules/server-util/RequestReaderHandler.h @@ -39,6 +39,8 @@ typedef SocketInterface* (*SocketInterfaceFactory) (SOCKET); +class RequestReaderHandler; + class RequestReaderHandler { SelEpolKqEvPrt selector; std::atomic run; @@ -54,7 +56,11 @@ class RequestReaderHandler { bool isActive(); void addSf(SocketInterface* sf); static void* handle(void* inp); + static RequestReaderHandler* _i; + friend class LibpqDataSourceImpl; public: + static void setInstance(RequestReaderHandler*); + static RequestReaderHandler* getInstance(); void start(unsigned int cid); void stop(std::string, int, bool); RequestReaderHandler(ServiceHandler* shi, const bool& isMain, bool isSinglEVH, const SOCKET& listenerSock = INVALID_SOCKET); diff --git a/src/modules/server-util/ServiceHandler.cpp b/src/modules/server-util/ServiceHandler.cpp index e9ddc6ade..bef345a3f 100644 --- a/src/modules/server-util/ServiceHandler.cpp +++ b/src/modules/server-util/ServiceHandler.cpp @@ -47,7 +47,7 @@ void* ServiceHandler::closeConnections(void *arg) { } for(it=addrs.begin();it!=addrs.end();) { long long t = Timer::getTimestamp(); - if(t-it->second>=15) { + if(t-it->second>=15 && sifMap[it->first]->useCounter==0) { delete sifMap[it->first]; sifMap.erase(it->first); addrs.erase(it++); diff --git a/src/modules/server-util/SocketInterface.cpp b/src/modules/server-util/SocketInterface.cpp index 94d774688..072accfc9 100644 --- a/src/modules/server-util/SocketInterface.cpp +++ b/src/modules/server-util/SocketInterface.cpp @@ -38,6 +38,7 @@ SocketInterface::SocketInterface() { rdTsk = NULL; wrTsk = NULL; srvTsk = NULL; + useCounter = 0; } SocketInterface::SocketInterface(const SOCKET& fd, SSL* ssl, BIO* io) { @@ -56,6 +57,15 @@ SocketInterface::SocketInterface(const SOCKET& fd, SSL* ssl, BIO* io) { rdTsk = NULL; wrTsk = NULL; srvTsk = NULL; + useCounter = 0; +} + +void SocketInterface::use() { + useCounter++; +} + +void SocketInterface::unUse() { + useCounter--; } bool SocketInterface::init(const SOCKET& fd, SSL*& ssl, BIO*& io, Logger& logger) { diff --git a/src/modules/server-util/SocketInterface.h b/src/modules/server-util/SocketInterface.h index c63b31e0f..7aedc2ff3 100644 --- a/src/modules/server-util/SocketInterface.h +++ b/src/modules/server-util/SocketInterface.h @@ -48,12 +48,9 @@ class SocketInterface; class ResponseData { +public: std::string _b; int oft; - friend class SocketInterface; - friend class HttpServiceTask; - friend class WebSockHandler; -public: ResponseData(); virtual ~ResponseData(); }; @@ -80,6 +77,7 @@ class SocketInterface { Logger logger; std::string buffer; std::atomic tid; + std::atomic useCounter; //Mutex m; //Mutex wm; std::map wtl; @@ -103,6 +101,7 @@ class SocketInterface { friend class CommonUtils; friend class DummySocketInterface; friend class HttpServiceHandler; + friend class LibpqDataSourceImpl; public: int completeWrite(); int pushResponse(void* request, void* response, void* context, int reqPos); @@ -136,6 +135,8 @@ class SocketInterface { virtual void onClose()=0; virtual void addHandler(SocketInterface* handler)=0; virtual bool isEmbedded()=0; + void use(); + void unUse(); }; #endif /* SOCKETINTERFACE_H_ */ diff --git a/src/server/embedded/CHServer.cpp b/src/server/embedded/CHServer.cpp index d002fd09d..a10290d0d 100644 --- a/src/server/embedded/CHServer.cpp +++ b/src/server/embedded/CHServer.cpp @@ -1194,6 +1194,24 @@ void CHServer::serve(std::string port, std::string ipaddr, int thrdpsiz, std::st return; } + std::string cntEnc = StringUtil::toLowerCopy(ConfigurationData::getInstance()->coreServerProperties.sprops["CONTENT_ENCODING"]); + try { + techunkSiz = CastUtil::toInt(ConfigurationData::getInstance()->coreServerProperties.sprops["TRANSFER_ENCODING_CHUNK_SIZE"]); + } catch(const std::exception& e) { + } + try { + connKeepAlive = CastUtil::toInt(ConfigurationData::getInstance()->coreServerProperties.sprops["KEEP_ALIVE_SECONDS"]); + } catch(const std::exception& e) { + } + try { + maxReqHdrCnt = CastUtil::toInt(ConfigurationData::getInstance()->coreServerProperties.sprops["MAX_REQUEST_HEADERS_COUNT"]); + } catch(const std::exception& e) { + } + try { + maxEntitySize = CastUtil::toInt(ConfigurationData::getInstance()->coreServerProperties.sprops["MAX_REQUEST_ENTITY_SIZE"]); + } catch(const std::exception& e) { + } + //Load all the FFEADContext beans so that the same copy is shared by all process //We need singleton beans so only initialize singletons(controllers,authhandlers,formhandlers..) logger << ("Initializing ffeadContext....") << std::endl; @@ -1205,6 +1223,14 @@ void CHServer::serve(std::string port, std::string ipaddr, int thrdpsiz, std::st ConfigurationHandler::initializeWsdls(); logger << ("Initializing WSDL files done....") << std::endl; + unsigned int nthreads = hardware_concurrency(); + ServiceHandler* handler = new HttpServiceHandler(cntEnc, &httpServiceFactoryMethod, nthreads, isSinglEVH, &httpReadFactoryMethod); + RequestReaderHandler reader(handler, true, isSinglEVH, sockfd); + RequestReaderHandler::setInstance(&reader); + handler->start(); + reader.registerSocketInterfaceFactory(&CHServer::createSocketInterface); + reader.start(-1); + #ifdef INC_SDORM logger << ("Initializing DataSources....") << std::endl; ConfigurationHandler::initializeDataSources(); @@ -1246,23 +1272,6 @@ void CHServer::serve(std::string port, std::string ipaddr, int thrdpsiz, std::st //Thread* pthread = new Thread(&gracefullShutdown_monitor, &ipport); //pthread->execute(); - std::string cntEnc = StringUtil::toLowerCopy(ConfigurationData::getInstance()->coreServerProperties.sprops["CONTENT_ENCODING"]); - try { - techunkSiz = CastUtil::toInt(ConfigurationData::getInstance()->coreServerProperties.sprops["TRANSFER_ENCODING_CHUNK_SIZE"]); - } catch(const std::exception& e) { - } - try { - connKeepAlive = CastUtil::toInt(ConfigurationData::getInstance()->coreServerProperties.sprops["KEEP_ALIVE_SECONDS"]); - } catch(const std::exception& e) { - } - try { - maxReqHdrCnt = CastUtil::toInt(ConfigurationData::getInstance()->coreServerProperties.sprops["MAX_REQUEST_HEADERS_COUNT"]); - } catch(const std::exception& e) { - } - try { - maxEntitySize = CastUtil::toInt(ConfigurationData::getInstance()->coreServerProperties.sprops["MAX_REQUEST_ENTITY_SIZE"]); - } catch(const std::exception& e) { - } HTTPResponseStatus::init(); @@ -1272,15 +1281,6 @@ void CHServer::serve(std::string port, std::string ipaddr, int thrdpsiz, std::st MultipartContent::init(); - unsigned int nthreads = hardware_concurrency(); - - ServiceHandler* handler = new HttpServiceHandler(cntEnc, &httpServiceFactoryMethod, nthreads, isSinglEVH, &httpReadFactoryMethod); - handler->start(); - - RequestReaderHandler reader(handler, true, isSinglEVH, sockfd); - reader.registerSocketInterfaceFactory(&CHServer::createSocketInterface); - reader.start(-1); - //int counter = 0; struct stat buffer; while(stat (serverCntrlFileNm.c_str(), &buffer) == 0) diff --git a/web/peer-server/include/PeerServerController.h b/web/peer-server/include/PeerServerController.h index 532d07ceb..7c6025cae 100644 --- a/web/peer-server/include/PeerServerController.h +++ b/web/peer-server/include/PeerServerController.h @@ -54,7 +54,7 @@ class PeerServerRouter : public Router { bool isAuthorizedKey(const std::string &key, HttpResponse* res); bool isValidUser(const std::string& id, const std::string& token, HttpResponse* res); public: - void route(HttpRequest* req, HttpResponse* res, void* dlib, void* ddlib); + bool route(HttpRequest* req, HttpResponse* res, void* dlib, void* ddlib, SocketInterface* sif); PeerServerRouter(); virtual ~PeerServerRouter(); }; diff --git a/web/peer-server/src/PeerServerController.cpp b/web/peer-server/src/PeerServerController.cpp index e498e1f5e..40044e761 100644 --- a/web/peer-server/src/PeerServerController.cpp +++ b/web/peer-server/src/PeerServerController.cpp @@ -349,7 +349,7 @@ bool PeerServerRouter::isValidUser(const std::string &id, const std::string &tok } } -void PeerServerRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, void* ddlib) { +bool PeerServerRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, void* ddlib, SocketInterface* sif) { req->normalizeUrl(); res->setDone(true); std::string_view path = req->getPath(); @@ -365,7 +365,7 @@ void PeerServerRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, vo std::string id, token, key, type, dstId; if(auth(path, res, key, id, token)) { res->setHTTPResponseStatus(HTTPResponseStatus::Unauthorized); - return; + return true; } JSONElement el; JSONUtil::getDocument(req->getContent(), el); @@ -373,14 +373,14 @@ void PeerServerRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, vo if(tmp!=NULL && (type = StringUtil::trimCopy(tmp->getValue()))!=""){}; if(type!="OFFER") { res->setHTTPResponseStatus(HTTPResponseStatus::Unauthorized); - return; + return true; } tmp = el.getNodeP("dst"); if(tmp!=NULL && (dstId = StringUtil::trimCopy(tmp->getValue()))!=""){}; if(dstId=="") { res->setHTTPResponseStatus(HTTPResponseStatus::Unauthorized); - return; + return true; } el.add("src", id); @@ -396,7 +396,7 @@ void PeerServerRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, vo std::string id, token, key, type, dstId; if(auth(path, res, key, id, token)) { res->setHTTPResponseStatus(HTTPResponseStatus::Unauthorized); - return; + return true; } JSONElement el; JSONUtil::getDocument(req->getContent(), el); @@ -404,14 +404,14 @@ void PeerServerRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, vo if(tmp!=NULL && (type = StringUtil::trimCopy(tmp->getValue()))!=""){}; if(type!="CANDIDATE") { res->setHTTPResponseStatus(HTTPResponseStatus::Unauthorized); - return; + return true; } tmp = el.getNodeP("dst"); if(tmp!=NULL && (dstId = StringUtil::trimCopy(tmp->getValue()))!=""){}; if(dstId=="") { res->setHTTPResponseStatus(HTTPResponseStatus::Unauthorized); - return; + return true; } el.add("src", id); @@ -427,7 +427,7 @@ void PeerServerRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, vo std::string id, token, key, type, dstId; if(auth(path, res, key, id, token)) { res->setHTTPResponseStatus(HTTPResponseStatus::Unauthorized); - return; + return true; } JSONElement el; JSONUtil::getDocument(req->getContent(), el); @@ -435,14 +435,14 @@ void PeerServerRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, vo if(tmp!=NULL && (type = StringUtil::trimCopy(tmp->getValue()))!=""){}; if(type!="ANSWER") { res->setHTTPResponseStatus(HTTPResponseStatus::Unauthorized); - return; + return true; } tmp = el.getNodeP("dst"); if(tmp!=NULL && (dstId = StringUtil::trimCopy(tmp->getValue()))!=""){}; if(dstId=="") { res->setHTTPResponseStatus(HTTPResponseStatus::Unauthorized); - return; + return true; } el.add("src", id); @@ -458,7 +458,7 @@ void PeerServerRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, vo std::string id, token, key, type; if(auth(path, res, key, id, token)) { res->setHTTPResponseStatus(HTTPResponseStatus::Unauthorized); - return; + return true; } CacheInterface* cchi = CacheManager::getImpl(); @@ -475,7 +475,7 @@ void PeerServerRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, vo std::string id, token, key, type; if(auth(path, res, key, id, token)) { res->setHTTPResponseStatus(HTTPResponseStatus::Unauthorized); - return; + return true; } CacheInterface* cchi = CacheManager::getImpl(); @@ -540,7 +540,7 @@ void PeerServerRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, vo } if(!isAuthorizedKey(key, res)) { - return; + return true; } if(id=="") { @@ -592,6 +592,7 @@ void PeerServerRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, vo } else { res->setHTTPResponseStatus(HTTPResponseStatus::NotFound); } + return true; } PeerServerRouter::PeerServerRouter() { diff --git a/web/te-benchmark-um-mgr/config/cache.xml b/web/te-benchmark-um-mgr/config/cache.xml deleted file mode 100644 index a06b17de6..000000000 --- a/web/te-benchmark-um-mgr/config/cache.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - sumeet - sumeet - - - TeBkUmMgrRouter.updateCache - Memory-Cached - memory - - \ No newline at end of file diff --git a/web/te-benchmark-um-mgr/config/cachememory.xml b/web/te-benchmark-um-mgr/config/cachememory.xml new file mode 100644 index 000000000..688c653ef --- /dev/null +++ b/web/te-benchmark-um-mgr/config/cachememory.xml @@ -0,0 +1,7 @@ + + + TeBkUmMgrRouter.updateCache + Memory-Cached + memory + + \ No newline at end of file diff --git a/web/te-benchmark-um-mgr/include/TeBkUmMgr.h b/web/te-benchmark-um-mgr/include/TeBkUmMgr.h index a4ec27270..61b2487e1 100644 --- a/web/te-benchmark-um-mgr/include/TeBkUmMgr.h +++ b/web/te-benchmark-um-mgr/include/TeBkUmMgr.h @@ -82,6 +82,10 @@ class TeBkUmMgrRouter : public Router { static const std::string HELLO_WORLD; static std::string WORLD; static std::string FORTUNE; + + static std::string APP_NAME; + static std::string TPE_FN_NAME; + bool strToNum(const char* str, int len, int& ret); void db(TeBkUmMgrWorld&); @@ -100,10 +104,14 @@ class TeBkUmMgrRouter : public Router { void getContext(HttpRequest* request, Context* context); #ifdef INC_SDORM_MONGO static void getContextUtil(void* ctx, int rn, std::vector& data); + MongoDBRawDataSourceImpl* sqli; + MongoDBRawDataSourceImpl* getDb(); #endif public: + TeBkUmMgrRouter(); + virtual ~TeBkUmMgrRouter(); void updateCache(); - void route(HttpRequest* req, HttpResponse* res, void* dlib, void* ddlib); + bool route(HttpRequest* req, HttpResponse* res, void* dlib, void* ddlib, SocketInterface* sif); }; #endif /* WEB_TE_BENCHMARK_UM_INCLUDE_TeBkUmMgr_H_ */ diff --git a/web/te-benchmark-um-mgr/src/TeBkUmMgr.cpp b/web/te-benchmark-um-mgr/src/TeBkUmMgr.cpp index 464c9a927..1192a36aa 100644 --- a/web/te-benchmark-um-mgr/src/TeBkUmMgr.cpp +++ b/web/te-benchmark-um-mgr/src/TeBkUmMgr.cpp @@ -89,7 +89,7 @@ std::string TeBkUmMgrRouter::FORTUNE = "fortune"; void TeBkUmMgrRouter::db(TeBkUmMgrWorld& w) { #ifdef INC_SDORM_MONGO - MongoDBRawDataSourceImpl* sqli = static_cast(DataSourceManager::getRawImpl()); + MongoDBRawDataSourceImpl* sqli = getDb(); int rid = rand() % 10000 + 1; try { bson_t q = BSON_INITIALIZER; @@ -98,9 +98,7 @@ void TeBkUmMgrRouter::db(TeBkUmMgrWorld& w) { sqli->executeQuery(&q, &w, &TeBkUmMgrRouter::dbUtil); sqli->end(); bson_destroy(&q); - DataSourceManager::cleanRawImpl(sqli); } catch(const std::exception& e) { - DataSourceManager::cleanRawImpl(sqli); throw e; } #endif @@ -131,7 +129,7 @@ void TeBkUmMgrRouter::queries(const char* q, int ql, std::vector if(queryCount<1)queryCount=1; else if(queryCount>500)queryCount=500; #ifdef INC_SDORM_MONGO - MongoDBRawDataSourceImpl* sqli = static_cast(DataSourceManager::getRawImpl()); + MongoDBRawDataSourceImpl* sqli = getDb(); try { TeBkUmMgrWorld w; @@ -145,9 +143,7 @@ void TeBkUmMgrRouter::queries(const char* q, int ql, std::vector wlst.push_back(w); } sqli->end(); - DataSourceManager::cleanRawImpl(sqli); } catch(const std::exception& e) { - DataSourceManager::cleanRawImpl(sqli); throw e; } #endif @@ -159,7 +155,7 @@ void TeBkUmMgrRouter::updates(const char* q, int ql, std::vector if(queryCount<1)queryCount=1; else if(queryCount>500)queryCount=500; #ifdef INC_SDORM_MONGO - MongoDBRawDataSourceImpl* sqli = static_cast(DataSourceManager::getRawImpl()); + MongoDBRawDataSourceImpl* sqli = getDb(); try { sqli->startBulk(WORLD); @@ -194,18 +190,16 @@ void TeBkUmMgrRouter::updates(const char* q, int ql, std::vector wlst.push_back(w); } sqli->endBulk(); - DataSourceManager::cleanRawImpl(sqli); } catch(const std::exception& e) { - DataSourceManager::cleanRawImpl(sqli); throw e; } #endif } void TeBkUmMgrRouter::updateCache() { - CacheInterface* cchi = CacheManager::getImpl(); #ifdef INC_SDORM_MONGO - MongoDBRawDataSourceImpl* sqli = static_cast(DataSourceManager::getRawImpl()); + CacheInterface* cchi = CacheManager::getImpl(); + MongoDBRawDataSourceImpl* sqli = getDb(); try { std::vector wlist; @@ -219,10 +213,8 @@ void TeBkUmMgrRouter::updateCache() { sprintf(str, "%d;%d", w.getId(), w.getRandomNumber()); cchi->setRaw(CastUtil::fromNumber(w.getId()), str); } - DataSourceManager::cleanRawImpl(sqli); CacheManager::cleanImpl(cchi); } catch(const std::exception& e) { - DataSourceManager::cleanRawImpl(sqli); CacheManager::cleanImpl(cchi); throw e; } @@ -288,7 +280,7 @@ void TeBkUmMgrRouter::cachedWorlds(const char* q, int ql, std::vector(DataSourceManager::getRawImpl()); + MongoDBRawDataSourceImpl* sqli = getDb(); try { std::vector* flst = new std::vector; @@ -303,9 +295,7 @@ void TeBkUmMgrRouter::getContext(HttpRequest* request, Context* context) { std::sort (flst->begin(), flst->end()); context->insert(std::pair("fortunes", flst)); - DataSourceManager::cleanRawImpl(sqli); } catch(...) { - DataSourceManager::cleanRawImpl(sqli); throw; } #endif @@ -342,7 +332,7 @@ bool TeBkUmMgrRouter::strToNum(const char* str, int len, int& ret) { return true; } -void TeBkUmMgrRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, void* ddlib) { +bool TeBkUmMgrRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, void* ddlib, SocketInterface* sif) { //Timer t; //t.start(); std::string_view path = req->getPath(); @@ -400,8 +390,7 @@ void TeBkUmMgrRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, voi Context ctx; getContext(req, &ctx); - std::string fname = "_tebenchmarkummgrtpefortunestpeemittTemplateHTML"; - void* mkr = dlsym(ddlib, fname.c_str()); + void* mkr = dlsym(ddlib, TPE_FN_NAME.c_str()); if(mkr!=NULL) { TeBkUmMgrTemplatePtr f = (TeBkUmMgrTemplatePtr)mkr; @@ -447,4 +436,30 @@ void TeBkUmMgrRouter::route(HttpRequest* req, HttpResponse* res, void* dlib, voi res->setHTTPResponseStatus(HTTPResponseStatus::NotFound); } res->setDone(true); + return true; +} + +std::string TeBkUmMgrRouter::APP_NAME = ""; +std::string TeBkUmMgrRouter::TPE_FN_NAME = ""; + +TeBkUmMgrRouter::TeBkUmMgrRouter() { +#ifdef INC_SDORM_MONGO + sqli = NULL; +#endif + if(APP_NAME=="") { + APP_NAME = CommonUtils::normalizeAppName("te-benchmark-um-mgr"); + TPE_FN_NAME = CommonUtils::getTpeFnName("tpe/fortunes.tpe", "te-benchmark-um-mgr"); + } } + +TeBkUmMgrRouter::~TeBkUmMgrRouter() { +} + +#ifdef INC_SDORM_MONGO +MongoDBRawDataSourceImpl* TeBkUmMgrRouter::getDb() { + if(sqli==NULL) { + sqli = static_cast(DataSourceManager::getRawImpl("MongoDB-DSN", "te-benchmark-um-mgr")); + } + return sqli; +} +#endif diff --git a/web/te-benchmark-um-pq-async/CMakeLists.txt b/web/te-benchmark-um-pq-async/CMakeLists.txt new file mode 100644 index 000000000..a03ca88f1 --- /dev/null +++ b/web/te-benchmark-um-pq-async/CMakeLists.txt @@ -0,0 +1,10 @@ + +file(GLOB sources + "include/*.h" + "src/*.cpp" +) + +include_directories("${CMAKE_SOURCE_DIR}/web/te-benchmark-um-pq-async/include") +add_library(te_benchmark_um_pq_async SHARED ${sources}) +set_property(TARGET te_benchmark_um_pq_async PROPERTY POSITION_INDEPENDENT_CODE ON) +target_link_libraries(te_benchmark_um_pq_async ffead-modules ffead-framework ${HAVE_PQLIB} ${HAVE_CURLLIB} ${HAVE_SSLLIB} ${HAVE_MEMCACHEDLIB} ${HAVE_ODBCLIB} ${HAVE_MONGOCLIB} ${HAVE_BSONLIB} ${HAVE_ZLIB} ${HAVE_CRYPTOLIB}) diff --git a/web/te-benchmark-um-pq-async/config/application.xml b/web/te-benchmark-um-pq-async/config/application.xml new file mode 100644 index 000000000..1c084b4d9 --- /dev/null +++ b/web/te-benchmark-um-pq-async/config/application.xml @@ -0,0 +1,24 @@ + + + * + GET, POST, HEAD, PUT, DELETE + content-type, origin + content-type, origin + true + 1023 + + + + + + + + + +