From 59e87ba12fb4065582ea3e07fd4821d6de93da8d Mon Sep 17 00:00:00 2001 From: Ilia Krustev Date: Mon, 27 Apr 2020 13:46:24 +0300 Subject: [PATCH 01/23] Chart: change web port names as an attempt to switch Istio to use h2c. --- charts/calling-service/Chart.yaml | 2 +- charts/calling-service/templates/history-service.yaml | 2 +- charts/calling-service/templates/service.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/calling-service/Chart.yaml b/charts/calling-service/Chart.yaml index c162c8d1..1f668de3 100644 --- a/charts/calling-service/Chart.yaml +++ b/charts/calling-service/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v1 appVersion: "1.0" description: Calling service Helm chart name: calling-service -version: 0.2.15 +version: 0.2.16 diff --git a/charts/calling-service/templates/history-service.yaml b/charts/calling-service/templates/history-service.yaml index 4e0b79fa..f7861b8e 100644 --- a/charts/calling-service/templates/history-service.yaml +++ b/charts/calling-service/templates/history-service.yaml @@ -20,4 +20,4 @@ spec: - protocol: TCP port: 41714 targetPort: 41714 - name: web-history + name: h2c-history diff --git a/charts/calling-service/templates/service.yaml b/charts/calling-service/templates/service.yaml index e42e9d75..061524b4 100644 --- a/charts/calling-service/templates/service.yaml +++ b/charts/calling-service/templates/service.yaml @@ -20,4 +20,4 @@ spec: - protocol: TCP port: 41514 targetPort: 41514 - name: http-focus + name: h2c-focus -- GitLab From 71f43286c278699d0765a09ce91e830c34ef96ca Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Wed, 29 Apr 2020 13:26:30 +0300 Subject: [PATCH 02/23] Updated chart to annotate h2c connections --- charts/calling-service/Chart.yaml | 2 +- charts/calling-service/templates/history-service.yaml | 2 ++ charts/calling-service/templates/service.yaml | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/charts/calling-service/Chart.yaml b/charts/calling-service/Chart.yaml index 1f668de3..7349ec83 100644 --- a/charts/calling-service/Chart.yaml +++ b/charts/calling-service/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v1 appVersion: "1.0" description: Calling service Helm chart name: calling-service -version: 0.2.16 +version: 0.2.17 diff --git a/charts/calling-service/templates/history-service.yaml b/charts/calling-service/templates/history-service.yaml index f7861b8e..155e7593 100644 --- a/charts/calling-service/templates/history-service.yaml +++ b/charts/calling-service/templates/history-service.yaml @@ -1,6 +1,8 @@ kind: Service apiVersion: v1 metadata: + annotations: + cloud.google.com/app-protocols: '{"h2c-history":"HTTP2"}' name: {{ template "calling-service.fullname" . }}-history labels: app: {{ template "calling-service.name" . }}-history diff --git a/charts/calling-service/templates/service.yaml b/charts/calling-service/templates/service.yaml index 061524b4..3e21d92d 100644 --- a/charts/calling-service/templates/service.yaml +++ b/charts/calling-service/templates/service.yaml @@ -1,6 +1,9 @@ kind: Service apiVersion: v1 metadata: + annotations: + cloud.google.com/app-protocols: '{"h2c-focus":"HTTP2"}' + name: {{ template "calling-service.fullname" . }} labels: app: {{ template "calling-service.name" . }} -- GitLab From a1cddb12204f4090a41d7de6886e0d3683fbf102 Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Wed, 29 Apr 2020 17:15:41 +0300 Subject: [PATCH 03/23] Chart: added upgrade to h2 --- charts/calling-service/Chart.yaml | 2 +- charts/calling-service/templates/destinationrule.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/charts/calling-service/Chart.yaml b/charts/calling-service/Chart.yaml index 7349ec83..5fa2a3d8 100644 --- a/charts/calling-service/Chart.yaml +++ b/charts/calling-service/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v1 appVersion: "1.0" description: Calling service Helm chart name: calling-service -version: 0.2.17 +version: 0.2.18 diff --git a/charts/calling-service/templates/destinationrule.yaml b/charts/calling-service/templates/destinationrule.yaml index 14ab3bc3..c0de141b 100644 --- a/charts/calling-service/templates/destinationrule.yaml +++ b/charts/calling-service/templates/destinationrule.yaml @@ -13,6 +13,7 @@ spec: connectionPool: http: http2MaxRequests: 30000 + h2UpgradePolicy: UPGRADE --- apiVersion: networking.istio.io/v1alpha3 kind: DestinationRule @@ -29,3 +30,4 @@ spec: connectionPool: http: http2MaxRequests: 30000 + h2UpgradePolicy: UPGRADE -- GitLab From a7ddbe1337763672ded4942728ded02a6ebc9c53 Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 11:15:51 +0300 Subject: [PATCH 04/23] Updated jitsi version to 1132 --- components/jitsi-backend/jvb/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index 363530e3..1a88c5c8 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -2,7 +2,7 @@ FROM debian:stretch MAINTAINER Jarle Aase -ENV VIDEOBRIDGE_BUILDNUM="1124" +ENV VIDEOBRIDGE_BUILDNUM="1132" ENV STUN=stun.stunprotocol.org BRIDGE_IP=127.0.0.1 REST_IP=8080 BRIDGE_TCP_PORT=4443 BRIDGE_UDP_PORT=10000 @@ -14,7 +14,7 @@ RUN apt-get update && apt-get -y install \ default-jre-headless RUN wget https://download.jitsi.org/jitsi-videobridge/linux/jitsi-videobridge-linux-x64-${VIDEOBRIDGE_BUILDNUM}.zip RUN unzip jitsi-videobridge-linux-x64-${VIDEOBRIDGE_BUILDNUM}.zip && rm jitsi-videobridge-linux-x64-${VIDEOBRIDGE_BUILDNUM}.zip -RUN wget -N https://github.com/angel-popov/status/releases/download/tmp1/jitsi-videobridge.jar -P jitsi-videobridge-linux-x64-${VIDEOBRIDGE_BUILDNUM} +# RUN wget -N https://github.com/angel-popov/status/releases/download/tmp1/jitsi-videobridge.jar -P jitsi-videobridge-linux-x64-${VIDEOBRIDGE_BUILDNUM} #ADD conf/logging.properties /logging.properties #RUN cp -f /logging.properties /jitsi-videobridge-linux-x64-${VIDEOBRIDGE_BUILDNUM}/lib -- GitLab From a93ed8645d1e99534610c43fdb1bd77f3e5a4893 Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 13:48:23 +0300 Subject: [PATCH 05/23] Dockerfile for JVB 2 --- components/jitsi-backend/jvb/Dockerfile | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index 1a88c5c8..65e70157 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -2,8 +2,6 @@ FROM debian:stretch MAINTAINER Jarle Aase -ENV VIDEOBRIDGE_BUILDNUM="1132" - ENV STUN=stun.stunprotocol.org BRIDGE_IP=127.0.0.1 REST_IP=8080 BRIDGE_TCP_PORT=4443 BRIDGE_UDP_PORT=10000 # Install videobridge and dependencies @@ -12,12 +10,8 @@ RUN apt-get update && apt-get -y install \ wget \ unzip curl \ default-jre-headless -RUN wget https://download.jitsi.org/jitsi-videobridge/linux/jitsi-videobridge-linux-x64-${VIDEOBRIDGE_BUILDNUM}.zip -RUN unzip jitsi-videobridge-linux-x64-${VIDEOBRIDGE_BUILDNUM}.zip && rm jitsi-videobridge-linux-x64-${VIDEOBRIDGE_BUILDNUM}.zip -# RUN wget -N https://github.com/angel-popov/status/releases/download/tmp1/jitsi-videobridge.jar -P jitsi-videobridge-linux-x64-${VIDEOBRIDGE_BUILDNUM} - -#ADD conf/logging.properties /logging.properties -#RUN cp -f /logging.properties /jitsi-videobridge-linux-x64-${VIDEOBRIDGE_BUILDNUM}/lib +RUN wget https://download.jitsi.org/stable/jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb +RUN apt install ./jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb # Create videobridge user RUN mkdir --parents /jvb/.sip-communicator && \ -- GitLab From 68226d2adeadf12f62fcf800c77612caf94f07b7 Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 14:02:45 +0300 Subject: [PATCH 06/23] Jvb docker updated --- components/jitsi-backend/jvb/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index 65e70157..756bc990 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get update && apt-get -y install \ unzip curl \ default-jre-headless RUN wget https://download.jitsi.org/stable/jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb -RUN apt install ./jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb +RUN apt install -y ./jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb # Create videobridge user RUN mkdir --parents /jvb/.sip-communicator && \ -- GitLab From 8790b8f20c8bff05c88b6d01f161119526f517c7 Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 14:17:01 +0300 Subject: [PATCH 07/23] JVB Docker, jvb user already created --- components/jitsi-backend/jvb/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index 756bc990..10db568a 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -15,8 +15,8 @@ RUN apt install -y ./jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb # Create videobridge user RUN mkdir --parents /jvb/.sip-communicator && \ - groupadd -r jvb && \ - useradd -r -g jvb -d /jvb -s /sbin/nologin -c "Jitsi Videobridge User" jvb + groupadd -r jvb +# - user already created && useradd -r -g jvb -d /jvb -s /sbin/nologin -c "Jitsi Videobridge User" jvb # Configure and run #USER jvb -- GitLab From 6b0f2f91488bafdf3d926c095f0e36ed271ea609 Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 14:49:43 +0300 Subject: [PATCH 08/23] Jvb WIP --- components/jitsi-backend/jvb/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index 10db568a..19b05c43 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -19,7 +19,7 @@ RUN mkdir --parents /jvb/.sip-communicator && \ # - user already created && useradd -r -g jvb -d /jvb -s /sbin/nologin -c "Jitsi Videobridge User" jvb # Configure and run -#USER jvb +USER jvb ADD conf/sip-communicator.properties /jvb/.sip-communicator/sip-communicator.properties ADD conf/logging.properties /jvb/.sip-communicator/logging.properties @@ -30,4 +30,4 @@ USER jvb EXPOSE $REST_IP $BRIDGE_UDP_PORT/udp $BRIDGE_TCP_PORT -CMD ["/jvb/run.sh"] +CMD ["sleep 2d;/jvb/run.sh"] -- GitLab From af54043bba97e50320ba7c95c2a58650f66866b0 Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 14:57:04 +0300 Subject: [PATCH 09/23] Jvb docker WIP --- components/jitsi-backend/jvb/Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index 19b05c43..d88b1038 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -25,9 +25,6 @@ ADD conf/sip-communicator.properties /jvb/.sip-communicator/sip-communicator.pro ADD conf/logging.properties /jvb/.sip-communicator/logging.properties ADD scripts/run.sh /jvb/run.sh -RUN chown -R jvb:jvb /jvb -USER jvb - EXPOSE $REST_IP $BRIDGE_UDP_PORT/udp $BRIDGE_TCP_PORT CMD ["sleep 2d;/jvb/run.sh"] -- GitLab From 2627182e343da683884137be341e989024742e0a Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 15:16:59 +0300 Subject: [PATCH 10/23] Jvb docker WIP --- components/jitsi-backend/jvb/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index d88b1038..7bfe9ed8 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -27,4 +27,4 @@ ADD scripts/run.sh /jvb/run.sh EXPOSE $REST_IP $BRIDGE_UDP_PORT/udp $BRIDGE_TCP_PORT -CMD ["sleep 2d;/jvb/run.sh"] +CMD ["sleep 2d"] -- GitLab From 7f467a2a6531acb38211b781667fb776d65d3a05 Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 15:36:37 +0300 Subject: [PATCH 11/23] Jvb docker WIP --- components/jitsi-backend/jvb/scripts/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/jitsi-backend/jvb/scripts/run.sh b/components/jitsi-backend/jvb/scripts/run.sh index 683f0a22..b326c8a5 100755 --- a/components/jitsi-backend/jvb/scripts/run.sh +++ b/components/jitsi-backend/jvb/scripts/run.sh @@ -7,6 +7,6 @@ export LOCAL_IP=`ip addr show eth0 | grep inet\ | tr -s \ | cut -f3 -d\ | cut - for VARIABLE in `env | cut -f1 -d=`; do sed -i "s={{ $VARIABLE }}=${!VARIABLE}=g" /jvb/.sip-communicator/sip-communicator.properties done - +sleep 100d exec jitsi-videobridge-linux-x64-$VIDEOBRIDGE_BUILDNUM/jvb.sh \ --apis=rest -- GitLab From aedeaf888645430152ca9f26ec956a6cb0820b5f Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 17:10:33 +0300 Subject: [PATCH 12/23] JVB Docker: Updated paths to jvb2 --- components/jitsi-backend/jvb/Dockerfile | 11 ++++------- components/jitsi-backend/jvb/scripts/run.sh | 8 ++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index 7bfe9ed8..fe983620 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -7,22 +7,19 @@ ENV STUN=stun.stunprotocol.org BRIDGE_IP=127.0.0.1 REST_IP=8080 BRIDGE_TCP_PORT= # Install videobridge and dependencies USER root RUN apt-get update && apt-get -y install \ - wget \ - unzip curl \ - default-jre-headless + wget nzip curl default-jre-headless RUN wget https://download.jitsi.org/stable/jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb RUN apt install -y ./jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb # Create videobridge user -RUN mkdir --parents /jvb/.sip-communicator && \ - groupadd -r jvb +# RUN mkdir --parents /jvb/.sip-communicator && groupadd -r jvb # - user already created && useradd -r -g jvb -d /jvb -s /sbin/nologin -c "Jitsi Videobridge User" jvb # Configure and run USER jvb -ADD conf/sip-communicator.properties /jvb/.sip-communicator/sip-communicator.properties -ADD conf/logging.properties /jvb/.sip-communicator/logging.properties +ADD conf/sip-communicator.properties /etc/jitsi/videobridge/sip-communicator.properties +ADD conf/logging.properties /etc/jitsi/videobridge/logging.properties ADD scripts/run.sh /jvb/run.sh EXPOSE $REST_IP $BRIDGE_UDP_PORT/udp $BRIDGE_TCP_PORT diff --git a/components/jitsi-backend/jvb/scripts/run.sh b/components/jitsi-backend/jvb/scripts/run.sh index b326c8a5..208fd337 100755 --- a/components/jitsi-backend/jvb/scripts/run.sh +++ b/components/jitsi-backend/jvb/scripts/run.sh @@ -5,8 +5,8 @@ export LOCAL_IP=`ip addr show eth0 | grep inet\ | tr -s \ | cut -f3 -d\ | cut -f1 -d/` for VARIABLE in `env | cut -f1 -d=`; do - sed -i "s={{ $VARIABLE }}=${!VARIABLE}=g" /jvb/.sip-communicator/sip-communicator.properties + sed -i "s={{ $VARIABLE }}=${!VARIABLE}=g" /etc/jitsi/videobridge/sip-communicator.properties done -sleep 100d -exec jitsi-videobridge-linux-x64-$VIDEOBRIDGE_BUILDNUM/jvb.sh \ - --apis=rest + +export JVB_OPTS="--apis=rest" +/etc/init.d/jitsi-videobridge2 start -- GitLab From 86fa046a2580ae446964aee8626538141de5ba7c Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 17:41:18 +0300 Subject: [PATCH 13/23] Jvb docker update --- components/jitsi-backend/jvb/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index fe983620..81176ff1 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -6,8 +6,7 @@ ENV STUN=stun.stunprotocol.org BRIDGE_IP=127.0.0.1 REST_IP=8080 BRIDGE_TCP_PORT= # Install videobridge and dependencies USER root -RUN apt-get update && apt-get -y install \ - wget nzip curl default-jre-headless +RUN apt-get update && apt install -y wget nzip curl default-jre-headless RUN wget https://download.jitsi.org/stable/jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb RUN apt install -y ./jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb -- GitLab From 2cded9621fc072c5a1e98c8e01f7d33daf971190 Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 17:44:43 +0300 Subject: [PATCH 14/23] Jvb docker file --- components/jitsi-backend/jvb/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index 81176ff1..05421a0d 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -6,7 +6,7 @@ ENV STUN=stun.stunprotocol.org BRIDGE_IP=127.0.0.1 REST_IP=8080 BRIDGE_TCP_PORT= # Install videobridge and dependencies USER root -RUN apt-get update && apt install -y wget nzip curl default-jre-headless +RUN apt update && apt install -y wget unzip curl default-jre-headless RUN wget https://download.jitsi.org/stable/jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb RUN apt install -y ./jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb -- GitLab From eec6c6eadbe95d328c37584341636f76ac28bce8 Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 20:12:41 +0300 Subject: [PATCH 15/23] Jvb docker as root --- components/jitsi-backend/jvb/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index 05421a0d..f48d2695 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -15,7 +15,7 @@ RUN apt install -y ./jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb # - user already created && useradd -r -g jvb -d /jvb -s /sbin/nologin -c "Jitsi Videobridge User" jvb # Configure and run -USER jvb +# USER jvb ADD conf/sip-communicator.properties /etc/jitsi/videobridge/sip-communicator.properties ADD conf/logging.properties /etc/jitsi/videobridge/logging.properties -- GitLab From 44fd61a04ebdce15b1028ce0b9d84ac661738e4f Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Mon, 4 May 2020 20:43:39 +0300 Subject: [PATCH 16/23] Jvb WIP --- components/jitsi-backend/jvb/scripts/run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/components/jitsi-backend/jvb/scripts/run.sh b/components/jitsi-backend/jvb/scripts/run.sh index 208fd337..6a0758a2 100755 --- a/components/jitsi-backend/jvb/scripts/run.sh +++ b/components/jitsi-backend/jvb/scripts/run.sh @@ -10,3 +10,4 @@ done export JVB_OPTS="--apis=rest" /etc/init.d/jitsi-videobridge2 start +sleep 2d -- GitLab From 2bbd15903579b660cece8ceadff655923bbc2471 Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Tue, 5 May 2020 16:17:52 +0300 Subject: [PATCH 17/23] Jvb do not run as root --- components/jitsi-backend/jvb/Dockerfile | 15 ++++----------- components/jitsi-backend/jvb/scripts/run.sh | 6 ++---- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index f48d2695..b8107a58 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -10,17 +10,10 @@ RUN apt update && apt install -y wget unzip curl default-jre-headless RUN wget https://download.jitsi.org/stable/jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb RUN apt install -y ./jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb -# Create videobridge user -# RUN mkdir --parents /jvb/.sip-communicator && groupadd -r jvb -# - user already created && useradd -r -g jvb -d /jvb -s /sbin/nologin -c "Jitsi Videobridge User" jvb - # Configure and run -# USER jvb - -ADD conf/sip-communicator.properties /etc/jitsi/videobridge/sip-communicator.properties -ADD conf/logging.properties /etc/jitsi/videobridge/logging.properties +USER jvb +RUN mkdir --parents /jvb/.sip-communicator +ADD conf/sip-communicator.properties /jvb/.sip-communicator/sip-communicator.properties +ADD conf/logging.properties /jvb/.sip-communicator/logging.properties ADD scripts/run.sh /jvb/run.sh - EXPOSE $REST_IP $BRIDGE_UDP_PORT/udp $BRIDGE_TCP_PORT - -CMD ["sleep 2d"] diff --git a/components/jitsi-backend/jvb/scripts/run.sh b/components/jitsi-backend/jvb/scripts/run.sh index 6a0758a2..2584a30b 100755 --- a/components/jitsi-backend/jvb/scripts/run.sh +++ b/components/jitsi-backend/jvb/scripts/run.sh @@ -5,9 +5,7 @@ export LOCAL_IP=`ip addr show eth0 | grep inet\ | tr -s \ | cut -f3 -d\ | cut -f1 -d/` for VARIABLE in `env | cut -f1 -d=`; do - sed -i "s={{ $VARIABLE }}=${!VARIABLE}=g" /etc/jitsi/videobridge/sip-communicator.properties + sed -i "s={{ $VARIABLE }}=${!VARIABLE}=g" /jvb/.sip-communicator/sip-communicator.properties done -export JVB_OPTS="--apis=rest" -/etc/init.d/jitsi-videobridge2 start -sleep 2d +exec /usr/share/jitsi-videobridge/jvb.sh --apis=rest -- GitLab From 5d0d392855e388e61ab27941592a04e972f7d06c Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Tue, 5 May 2020 16:23:55 +0300 Subject: [PATCH 18/23] Jvb docker --- components/jitsi-backend/jvb/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index b8107a58..a35c49e6 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -12,7 +12,7 @@ RUN apt install -y ./jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb # Configure and run USER jvb -RUN mkdir --parents /jvb/.sip-communicator + ADD conf/sip-communicator.properties /jvb/.sip-communicator/sip-communicator.properties ADD conf/logging.properties /jvb/.sip-communicator/logging.properties ADD scripts/run.sh /jvb/run.sh -- GitLab From d893f017cf1b367fafece9997d359bd998d0cb72 Mon Sep 17 00:00:00 2001 From: "A.Popov" Date: Tue, 5 May 2020 17:29:42 +0300 Subject: [PATCH 19/23] Jvb2 docker --- components/jitsi-backend/jvb/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/jitsi-backend/jvb/Dockerfile b/components/jitsi-backend/jvb/Dockerfile index a35c49e6..9e21bc36 100644 --- a/components/jitsi-backend/jvb/Dockerfile +++ b/components/jitsi-backend/jvb/Dockerfile @@ -11,9 +11,10 @@ RUN wget https://download.jitsi.org/stable/jitsi-videobridge2_2.1-163-g63d2f9da- RUN apt install -y ./jitsi-videobridge2_2.1-163-g63d2f9da-1_all.deb # Configure and run -USER jvb ADD conf/sip-communicator.properties /jvb/.sip-communicator/sip-communicator.properties ADD conf/logging.properties /jvb/.sip-communicator/logging.properties ADD scripts/run.sh /jvb/run.sh +RUN chown -R jvb /jvb EXPOSE $REST_IP $BRIDGE_UDP_PORT/udp $BRIDGE_TCP_PORT +USER jvb -- GitLab From df8636287eb4fcb37dbd4a7cf8781bf30586a3a1 Mon Sep 17 00:00:00 2001 From: Ilia Krustev Date: Tue, 5 May 2020 17:35:46 +0300 Subject: [PATCH 20/23] Move ChatRoomClient and BubbleSender away from the deprecated RestClientBase. The latest replacement has better logging. --- .../com/nynjacoin/nccs/call/service/Call.java | 15 +--- .../nccs/restclient/bubble/BubbleSender.java | 80 ++++++++++++------- .../restclient/bubble/NoopBubbleSender.java | 13 ++- .../restclient/chatroom/ChatRoomClient.java | 77 ++++++++++-------- .../bubble/BubbleSenderManualTest.java | 68 ++++++++++++++++ .../chatroom/ChatRoomClientManualTest.java | 20 ++--- gradle.properties | 2 +- 7 files changed, 184 insertions(+), 91 deletions(-) create mode 100644 focus/src/test/java/com/nynjacoin/nccs/restclient/bubble/BubbleSenderManualTest.java diff --git a/focus/src/main/java/com/nynjacoin/nccs/call/service/Call.java b/focus/src/main/java/com/nynjacoin/nccs/call/service/Call.java index 644929d2..fb7438c3 100644 --- a/focus/src/main/java/com/nynjacoin/nccs/call/service/Call.java +++ b/focus/src/main/java/com/nynjacoin/nccs/call/service/Call.java @@ -58,7 +58,7 @@ public class Call { private static final Long CONFIRM_TIMEOUT = 30000L; private static final Long ACCEPT_TIMEOUT = 30000L; private static final Long DESTROY_TIMEOUT = 10000L; - static final Long MISSING_PARTY_TIMEOUT = 30000L; + private static final Long MISSING_PARTY_TIMEOUT = 30000L; private static final int MAX_PUSH_OFFER_SIZE = 3 * 1024; private static final String OFFER_TRUNCATED = "OFFER_TRUNCATED"; @@ -721,16 +721,9 @@ public class Call { String from = callInfo.getFrom().getValue(); String to = callInfo.getTo().getValue(); - String feedId; - if (from.compareTo(to) < 0) { - feedId = composeFeedId(from, to); - } else { - feedId = composeFeedId(to, from); - } - parent.getBubbleSender().sendForP2P( from, - feedId, + to, callInfo.getId(), (int)(getDuration() / 1000), getStartTime().getTime(), @@ -754,10 +747,6 @@ public class Call { return ContentType.UNKNOWN; } - private String composeFeedId(String left, String right) { - return left + '/' + right; - } - private String getToAccountId() { Address address = callInfo.getTo(); assert address.getType() == Type.ACCOUNT; diff --git a/focus/src/main/java/com/nynjacoin/nccs/restclient/bubble/BubbleSender.java b/focus/src/main/java/com/nynjacoin/nccs/restclient/bubble/BubbleSender.java index 8f19b6b3..2e075e92 100644 --- a/focus/src/main/java/com/nynjacoin/nccs/restclient/bubble/BubbleSender.java +++ b/focus/src/main/java/com/nynjacoin/nccs/restclient/bubble/BubbleSender.java @@ -2,10 +2,10 @@ package com.nynjacoin.nccs.restclient.bubble; import com.nynjacoin.nccs.focus.config.FocusConfigKey; import com.nynjacoin.nccs.lib.vertx.restclient.AuthenticationHandler; -import com.nynjacoin.nccs.lib.vertx.restclient.RestClientBase; -import com.nynjacoin.nccs.lib.vertx.restclient.RetryExecutor; +import com.nynjacoin.nccs.lib.vertx.restclient.JsonRetryExecutor; import com.nynjacoin.nccs.lib.vertx.restclient.WebClientFactory; import com.nynjacoin.nccs.protocol.def.CallEndedBy; +import io.vertx.core.Future; import io.vertx.core.Vertx; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; @@ -15,7 +15,7 @@ import java.util.Objects; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public class BubbleSender extends RestClientBase { +public class BubbleSender { public enum AnswerStatus { ANSWERED("answered"), @@ -51,8 +51,16 @@ public class BubbleSender extends RestClientBase { } } + private static final int DEFAULT_MAX_RETRIES = 3; + private static final long DEFAULT_RETRY_MILLISECONDS = 100L; + private static final Logger LOGGER = LogManager.getLogger(BubbleSender.class); + private final WebClient webClient; + private final AuthenticationHandler authenticationHandler; + private final JsonRetryExecutor retryExecutor; + private final String rootUrl; + public static BubbleSender create(Vertx vertx, JsonObject config) { int poolSize = config.getInteger(FocusConfigKey.BUBBLE_PER_REQUEST_POOL_SIZE.key(), 32); WebClient webClient = WebClientFactory.create(vertx, poolSize); @@ -60,12 +68,11 @@ public class BubbleSender extends RestClientBase { String auth = config.getString(FocusConfigKey.BUBBLE_KEY.key()); AuthenticationHandler authenticationHandler = AuthenticationHandler.create(auth); - RetryExecutor retryExecutor = RetryExecutor.newBuilder(vertx) - .setOrDefaultMaxRetries(config.getInteger( - FocusConfigKey.BUBBLE_MAX_RETRIES.key())) - .setOrDefaultRetryMilliseconds(config.getLong( - FocusConfigKey.BUBBLE_RETRY_AFTER_MILLISECONDS.key())) - .build(); + JsonRetryExecutor retryExecutor = new JsonRetryExecutor( + vertx, + config.getInteger(FocusConfigKey.BUBBLE_MAX_RETRIES.key(), DEFAULT_MAX_RETRIES), + config.getLong( + FocusConfigKey.BUBBLE_RETRY_AFTER_MILLISECONDS.key(), DEFAULT_RETRY_MILLISECONDS)); String rootUrl = config.getString(FocusConfigKey.BUBBLE_URL.key()); Objects.requireNonNull(rootUrl); @@ -76,13 +83,16 @@ public class BubbleSender extends RestClientBase { BubbleSender( WebClient webClient, AuthenticationHandler authenticationHandler , - RetryExecutor retryExecutor, + JsonRetryExecutor retryExecutor, String rootUrl) { - super(webClient, authenticationHandler, retryExecutor, rootUrl); + this.webClient = webClient; + this.authenticationHandler = authenticationHandler; + this.retryExecutor = retryExecutor; + this.rootUrl = rootUrl; } - public void sendForConference( + public Future sendForConference( String senderAccountId, String feedId, String callId, @@ -104,7 +114,7 @@ public class BubbleSender extends RestClientBase { .put("count", membersCount) .put("recipients", to); - send( + return send( senderAccountId, body, feedId, @@ -116,9 +126,9 @@ public class BubbleSender extends RestClientBase { endedBy); } - public void sendForP2P( + public Future sendForP2P( String senderAccountId, - String feedId, + String to, String callId, int duration, long startTime, @@ -126,11 +136,18 @@ public class BubbleSender extends RestClientBase { ContentType contentType, CallEndedBy endedBy) { + String feedId; + if (senderAccountId.compareTo(to) < 0) { + feedId = composeFeedId(senderAccountId, to); + } else { + feedId = composeFeedId(to, senderAccountId); + } + JsonObject body = new JsonObject() .put("type", "p2p"); - send( + return send( senderAccountId, body, feedId, @@ -142,7 +159,11 @@ public class BubbleSender extends RestClientBase { endedBy); } - private void send( + private String composeFeedId(String left, String right) { + return left + '/' + right; + } + + private Future send( String senderAccountId, JsonObject body, String feedId, @@ -153,10 +174,10 @@ public class BubbleSender extends RestClientBase { ContentType contentType, CallEndedBy endedBy) { - var request = getWebClient() - .postAbs(getRootUrl()) + var request = webClient + .postAbs(rootUrl) .putHeader("PhoneId", senderAccountId); - request = getAuthenticationHandler().apply(request); + request = authenticationHandler.apply(request); body .put("feed_id", feedId) @@ -168,14 +189,15 @@ public class BubbleSender extends RestClientBase { .put("ended_by", endedBy.name().toLowerCase()) ; - getRetryExecutor().execute(request, body).setHandler( - event -> { - if (event.succeeded()) { - LOGGER.debug("Bubble {} for {} SENT", callId, feedId); - } else { - LOGGER.error("Bubble {} for {} FAILED {}", callId, feedId, event.cause()); - } - } - ); + return retryExecutor.execute(request, body) + .recover(cause -> { + LOGGER.error("Bubble {} for {} FAILED {}", callId, feedId, cause); + return Future.failedFuture(cause); + }) + .map(res -> { + LOGGER.debug("Bubble {} for {} SENT", callId, feedId); + return null; + }) + ; } } diff --git a/focus/src/main/java/com/nynjacoin/nccs/restclient/bubble/NoopBubbleSender.java b/focus/src/main/java/com/nynjacoin/nccs/restclient/bubble/NoopBubbleSender.java index 27965bb0..507cb02e 100644 --- a/focus/src/main/java/com/nynjacoin/nccs/restclient/bubble/NoopBubbleSender.java +++ b/focus/src/main/java/com/nynjacoin/nccs/restclient/bubble/NoopBubbleSender.java @@ -1,6 +1,7 @@ package com.nynjacoin.nccs.restclient.bubble; import com.nynjacoin.nccs.protocol.def.CallEndedBy; +import io.vertx.core.Future; import java.util.List; public class NoopBubbleSender extends BubbleSender { @@ -10,7 +11,7 @@ public class NoopBubbleSender extends BubbleSender { } @Override - public void sendForConference( + public Future sendForConference( String senderAccountId, String feedId, String callId, @@ -21,10 +22,12 @@ public class NoopBubbleSender extends BubbleSender { CallEndedBy endedBy, int membersCount, List recipients) - {} + { + return Future.succeededFuture(); + } @Override - public void sendForP2P( + public Future sendForP2P( String senderAccountId, String feedId, String callId, @@ -33,5 +36,7 @@ public class NoopBubbleSender extends BubbleSender { AnswerStatus answerStatus, ContentType contentType, CallEndedBy endedBy) - {} + { + return Future.succeededFuture(); + } } diff --git a/focus/src/main/java/com/nynjacoin/nccs/restclient/chatroom/ChatRoomClient.java b/focus/src/main/java/com/nynjacoin/nccs/restclient/chatroom/ChatRoomClient.java index b301e297..b94ff509 100644 --- a/focus/src/main/java/com/nynjacoin/nccs/restclient/chatroom/ChatRoomClient.java +++ b/focus/src/main/java/com/nynjacoin/nccs/restclient/chatroom/ChatRoomClient.java @@ -2,10 +2,9 @@ package com.nynjacoin.nccs.restclient.chatroom; import com.nynjacoin.nccs.focus.config.FocusConfigKey; import com.nynjacoin.nccs.lib.vertx.restclient.AuthenticationHandler; -import com.nynjacoin.nccs.lib.vertx.restclient.RestClientBase; +import com.nynjacoin.nccs.lib.vertx.restclient.JsonRetryExecutor; import com.nynjacoin.nccs.lib.vertx.restclient.ValidatingJsonArray; import com.nynjacoin.nccs.lib.vertx.restclient.ValidatingJsonObject; -import com.nynjacoin.nccs.lib.vertx.restclient.RetryExecutor; import com.nynjacoin.nccs.lib.vertx.restclient.WebClientFactory; import com.nynjacoin.nccs.protocol.def.Void; import com.nynjacoin.nccs.lib.grpc.protocol.error.NccsError; @@ -20,7 +19,10 @@ import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public class ChatRoomClient extends RestClientBase { +public class ChatRoomClient { + static final int DEFAULT_MAX_RETRIES = 3; + static final long DEFAULT_RETRY_MILLISECONDS = 100L; + private static final Logger LOGGER = LogManager.getLogger(ChatRoomClient.class); private static final String HEADER_ACCOUNT_ID = "PhoneId"; @@ -37,6 +39,11 @@ public class ChatRoomClient extends RestClientBase { private static final String FIELD_IS_JOINING = "join"; private static final String FIELD_ACCOUNT_IDS = QUERY_PARAM_ACCOUNT_IDS; + private final WebClient webClient; + private final AuthenticationHandler authenticationHandler; + private final JsonRetryExecutor retryExecutor; + private final String rootUrl; + public static ChatRoomClient create(Vertx vertx, JsonObject config) { int poolSize = config.getInteger(FocusConfigKey.CHAT_ROOM_PER_REQUEST_POOL_SIZE.key(), 32); WebClient webClient = WebClientFactory.create(vertx, poolSize); @@ -44,12 +51,11 @@ public class ChatRoomClient extends RestClientBase { String auth = config.getString(FocusConfigKey.CHAT_ROOM_KEY.key()); AuthenticationHandler authenticationHandler = AuthenticationHandler.create(auth); - RetryExecutor retryExecutor = RetryExecutor.newBuilder(vertx) - .setOrDefaultMaxRetries(config.getInteger( - FocusConfigKey.CHAT_ROOM_MAX_RETRIES.key())) - .setOrDefaultRetryMilliseconds(config.getLong( - FocusConfigKey.CHAT_ROOM_RETRY_AFTER_MILLISECONDS.key())) - .build(); + JsonRetryExecutor retryExecutor = new JsonRetryExecutor( + vertx, + config.getInteger(FocusConfigKey.CHAT_ROOM_MAX_RETRIES.key(), DEFAULT_MAX_RETRIES), + config.getLong(FocusConfigKey.CHAT_ROOM_RETRY_AFTER_MILLISECONDS.key(), + DEFAULT_RETRY_MILLISECONDS)); String rootUrl = config.getString(FocusConfigKey.CHAT_ROOM_URL.key()); Objects.requireNonNull(rootUrl); @@ -62,20 +68,23 @@ public class ChatRoomClient extends RestClientBase { ChatRoomClient( WebClient webClient, AuthenticationHandler authenticationHandler , - RetryExecutor retryExecutor, + JsonRetryExecutor retryExecutor, String rootUrl) { - super(webClient, authenticationHandler, retryExecutor, rootUrl); - membersPath = getRootUrl() + "/members"; + this.webClient = webClient; + this.authenticationHandler = authenticationHandler; + this.retryExecutor = retryExecutor; + this.rootUrl = rootUrl; + membersPath = rootUrl + "/members"; } public Future createRoom(String ownerAccountId) { - var request = getWebClient() - .postAbs(getRootUrl()) - .putHeader(HEADER_ACCOUNT_ID, ownerAccountId) - ; - request = getAuthenticationHandler().apply(request); - var response = getRetryExecutor().execute(request); + var request = webClient + .postAbs(rootUrl) + .putHeader(HEADER_ACCOUNT_ID, ownerAccountId); + + request =authenticationHandler.apply(request); + var response = retryExecutor.execute(request); Future result = Future.future(); response.compose(rawBody -> { ValidatingJsonObject body = wrapAndCheck(rawBody); @@ -91,14 +100,14 @@ public class ChatRoomClient extends RestClientBase { } public Future areAllMembers(String ownerAccountId, String roomId, List accountIds) { - var request = getWebClient() + var request = webClient .getAbs(membersPath) .putHeader(HEADER_ACCOUNT_ID, ownerAccountId) .addQueryParam(QUERY_PARAM_ROOM_ID, roomId) .addQueryParam(QUERY_PARAM_ACCOUNT_IDS, StringUtils.join(accountIds, ',')) ; - request = getAuthenticationHandler().apply(request); - var response = getRetryExecutor().execute(request); + request =authenticationHandler.apply(request); + var response = retryExecutor.execute(request); Future result = Future.future(); response.compose( rawBody-> { @@ -132,11 +141,11 @@ public class ChatRoomClient extends RestClientBase { String roomId, List accountIdsToAdd) { - var request = getWebClient() + var request = webClient .postAbs(membersPath) .putHeader(HEADER_ACCOUNT_ID, ownerAccountId) ; - request = getAuthenticationHandler().apply(request); + request =authenticationHandler.apply(request); var body = new JsonObject() .put(FIELD_ROOM_ID, roomId) @@ -144,54 +153,54 @@ public class ChatRoomClient extends RestClientBase { .put(FIELD_ACCOUNT_IDS, new JsonArray(accountIdsToAdd)) ; - var response = getRetryExecutor().execute(request, body); + var response = retryExecutor.execute(request, body); Future result = Future.future(); response.compose(rawBody -> result.complete(), result); return result; } public Future joinMember(String accountId, String roomId) { - var request = getWebClient() + var request = webClient .postAbs(membersPath) .putHeader(HEADER_ACCOUNT_ID, accountId) ; - request = getAuthenticationHandler().apply(request); + request =authenticationHandler.apply(request); var body = new JsonObject() .put(FIELD_ROOM_ID, roomId) .put(FIELD_IS_JOINING, true) ; - var response = getRetryExecutor().execute(request, body); + var response = retryExecutor.execute(request, body); Future result = Future.future(); response.compose(rawBody -> result.complete(), result); return result; } public Future removeMember(String ownerAccountId, String roomId, String accountId) { - var request = getWebClient() + var request = webClient .deleteAbs(membersPath) .putHeader(HEADER_ACCOUNT_ID, ownerAccountId) .addQueryParam(QUERY_PARAM_ROOM_ID, roomId) .addQueryParam(QUERY_PARAM_ACCOUNT_IDS, accountId) ; - request = getAuthenticationHandler().apply(request); + request =authenticationHandler.apply(request); - var response = getRetryExecutor().execute(request); + var response = retryExecutor.execute(request); Future result = Future.future(); response.compose(rawBody -> result.complete(), result); return result; } public Future tryDeleteRoom(String ownerAccountId, String roomId, boolean flag) { - var request = getWebClient() - .deleteAbs(getRootUrl()) + var request = webClient + .deleteAbs(rootUrl) .putHeader(HEADER_ACCOUNT_ID, ownerAccountId) .addQueryParam(QUERY_PARAM_ROOM_ID, roomId) .addQueryParam(QUERY_PARAM_DELETE, String.valueOf(flag)) ; - request = getAuthenticationHandler().apply(request); - var response = getRetryExecutor().execute(request); + request =authenticationHandler.apply(request); + var response = retryExecutor.execute(request); Future result = Future.future(); response.compose( rawBody -> { diff --git a/focus/src/test/java/com/nynjacoin/nccs/restclient/bubble/BubbleSenderManualTest.java b/focus/src/test/java/com/nynjacoin/nccs/restclient/bubble/BubbleSenderManualTest.java new file mode 100644 index 00000000..e05bc42b --- /dev/null +++ b/focus/src/test/java/com/nynjacoin/nccs/restclient/bubble/BubbleSenderManualTest.java @@ -0,0 +1,68 @@ +package com.nynjacoin.nccs.restclient.bubble; + +import com.nynjacoin.nccs.focus.config.FocusConfigKey; +import com.nynjacoin.nccs.protocol.def.CallEndedBy; +import com.nynjacoin.nccs.restclient.bubble.BubbleSender.AnswerStatus; +import com.nynjacoin.nccs.restclient.bubble.BubbleSender.ContentType; +import io.vertx.core.Vertx; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.unit.TestContext; +import io.vertx.ext.unit.junit.RunTestOnContext; +import io.vertx.ext.unit.junit.VertxUnitRunner; +import java.util.List; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(VertxUnitRunner.class) +@Ignore +public class BubbleSenderManualTest { + + private BubbleSender bubbleSender; + + @ClassRule + public static RunTestOnContext rule = new RunTestOnContext(); + + @Before + public void setUp() { + Vertx vertx = rule.vertx(); + JsonObject config = new JsonObject(); + config + .put(FocusConfigKey.BUBBLE_KEY.key(), "nynja:nynjaTS") + .put(FocusConfigKey.BUBBLE_URL.key(), "http://localhost:8888/cri/bubbles") + ; + bubbleSender = BubbleSender.create(vertx, config); + } + + @Test + public void sendForConference(TestContext context) { + bubbleSender.sendForConference( + "37936e07-1930-4317-8719-aadac2524184_2806", + "d57061b1-3313-43bb-b745-7612677d3195", + "dummy-call-id", + 10, + System.currentTimeMillis(), + AnswerStatus.ANSWERED, + ContentType.AUDIO_CALL, + CallEndedBy.CALLEE, + 3, + List.of("37936e07-1930-4317-8719-aadac2524184_2806") + ).setHandler(context.asyncAssertSuccess()); + } + + @Test + public void sendForP2P(TestContext context) { + bubbleSender.sendForP2P( + "37936e07-1930-4317-8719-aadac2524184_2806", + "5ef289e7-3c9b-44e2-9dce-637e30f3f02a_2807", + "dummy-call-id", + 10, + System.currentTimeMillis(), + AnswerStatus.ANSWERED, + ContentType.AUDIO_CALL, + CallEndedBy.CALLEE + ).setHandler(context.asyncAssertSuccess()); + } +} diff --git a/focus/src/test/java/com/nynjacoin/nccs/restclient/chatroom/ChatRoomClientManualTest.java b/focus/src/test/java/com/nynjacoin/nccs/restclient/chatroom/ChatRoomClientManualTest.java index ee23f427..a98839d4 100644 --- a/focus/src/test/java/com/nynjacoin/nccs/restclient/chatroom/ChatRoomClientManualTest.java +++ b/focus/src/test/java/com/nynjacoin/nccs/restclient/chatroom/ChatRoomClientManualTest.java @@ -1,7 +1,7 @@ package com.nynjacoin.nccs.restclient.chatroom; import com.nynjacoin.nccs.lib.vertx.restclient.AuthenticationHandler; -import com.nynjacoin.nccs.lib.vertx.restclient.RetryExecutor; +import com.nynjacoin.nccs.lib.vertx.restclient.JsonRetryExecutor; import com.nynjacoin.nccs.protocol.def.Void; import io.vertx.core.Future; import io.vertx.core.Vertx; @@ -35,17 +35,19 @@ public class ChatRoomClientManualTest { // AuthenticationHandler authenticationHandler = AuthenticationHandler.create("nynja:nynjaTS"); AuthenticationHandler authenticationHandler = AuthenticationHandler.create("nynja:nynjaTS"); - RetryExecutor retryExecutor = RetryExecutor.newBuilder(vertx).build(); + JsonRetryExecutor retryExecutor = new JsonRetryExecutor( + vertx, ChatRoomClient.DEFAULT_MAX_RETRIES, ChatRoomClient.DEFAULT_RETRY_MILLISECONDS); // String rootUrl = "http://csdk.ci.nynja.net:8888/cri/rooms"; - String rootUrl = "https://im.dev.nynja.net/cri/rooms"; +// String rootUrl = "https://im.dev.nynja.net/cri/rooms"; + String rootUrl = "http://localhost:8888/cri/rooms"; chatRoomClient = new ChatRoomClient(webClient, authenticationHandler, retryExecutor, rootUrl); } @Test public void createRoom(TestContext context) { - Future result = chatRoomClient.createRoom("359999111101_166"); + Future result = chatRoomClient.createRoom("37936e07-1930-4317-8719-aadac2524184_2806"); result.setHandler(context.asyncAssertSuccess(roomId -> { context.assertNotNull(roomId); context.assertNotEquals(roomId, ""); @@ -60,9 +62,8 @@ public class ChatRoomClientManualTest { "359999111101_166", "conference_1547131523640_206", accounts); - result.setHandler(context.asyncAssertSuccess(allMembers -> { - System.out.println("Am I member: " + allMembers); - })); + result.setHandler(context.asyncAssertSuccess(allMembers -> + System.out.println("Am I member: " + allMembers))); } /* @@ -88,9 +89,8 @@ public class ChatRoomClientManualTest { "359999131313_76", "692D4F79-E63F-4A41-B17E-A8CEEC2139F7_359898773312_20_153935357591482_7DE313F6-B206-4205-ADCB-7432D8928A81", accounts); - result.setHandler(context.asyncAssertSuccess(allMembers -> { - System.out.println("ALL ARE MEMBERS: " + allMembers); - })); + result.setHandler(context.asyncAssertSuccess(allMembers -> + System.out.println("ALL ARE MEMBERS: " + allMembers))); } @Test diff --git a/gradle.properties b/gradle.properties index 77e0346a..49c50bf5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,4 +7,4 @@ rxjava2Version = 2.1.13 prometheusVersion = 0.5.0 cassandraDriverVersion = 3.6.0 junitVersion = 4.12 -nccsLibsVersion = 0.20.0 +nccsLibsVersion = 0.21.0-SNAPSHOT -- GitLab From 101009751c9715e257d0467b9adb0f93f8885b7b Mon Sep 17 00:00:00 2001 From: Ilia Krustev Date: Tue, 5 May 2020 17:52:31 +0300 Subject: [PATCH 21/23] Work-around: latest erlang server insist to have content type even for POST requests without any content. --- .../nynjacoin/nccs/restclient/chatroom/ChatRoomClient.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/focus/src/main/java/com/nynjacoin/nccs/restclient/chatroom/ChatRoomClient.java b/focus/src/main/java/com/nynjacoin/nccs/restclient/chatroom/ChatRoomClient.java index b94ff509..5fc45f83 100644 --- a/focus/src/main/java/com/nynjacoin/nccs/restclient/chatroom/ChatRoomClient.java +++ b/focus/src/main/java/com/nynjacoin/nccs/restclient/chatroom/ChatRoomClient.java @@ -26,6 +26,7 @@ public class ChatRoomClient { private static final Logger LOGGER = LogManager.getLogger(ChatRoomClient.class); private static final String HEADER_ACCOUNT_ID = "PhoneId"; + private static final String HEADER_CONTENT_TYPE = "Content-Type"; private static final String QUERY_PARAM_ROOM_ID = "room_id"; private static final String QUERY_PARAM_ACCOUNT_IDS = "phone_ids"; @@ -81,7 +82,8 @@ public class ChatRoomClient { public Future createRoom(String ownerAccountId) { var request = webClient .postAbs(rootUrl) - .putHeader(HEADER_ACCOUNT_ID, ownerAccountId); + .putHeader(HEADER_ACCOUNT_ID, ownerAccountId) + .putHeader(HEADER_CONTENT_TYPE, "application/json"); request =authenticationHandler.apply(request); var response = retryExecutor.execute(request); -- GitLab From da7c008e3f78a2615724b73a8fce646b14ec3abd Mon Sep 17 00:00:00 2001 From: Ilia Krustev Date: Thu, 7 May 2020 13:09:14 +0300 Subject: [PATCH 22/23] Move PushNotificationsSender and RoomLinkClient away from the deprecated RestClientBase. The latest replacement has better logging. --- .../push/PushNotificationSender.java | 35 ++++++++++------- .../restclient/roomlink/RoomLinkClient.java | 38 +++++++++++-------- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/focus/src/main/java/com/nynjacoin/nccs/restclient/push/PushNotificationSender.java b/focus/src/main/java/com/nynjacoin/nccs/restclient/push/PushNotificationSender.java index 48b8a48e..f5b4d2b6 100644 --- a/focus/src/main/java/com/nynjacoin/nccs/restclient/push/PushNotificationSender.java +++ b/focus/src/main/java/com/nynjacoin/nccs/restclient/push/PushNotificationSender.java @@ -2,8 +2,7 @@ package com.nynjacoin.nccs.restclient.push; import com.nynjacoin.nccs.focus.config.FocusConfigKey; import com.nynjacoin.nccs.lib.vertx.restclient.AuthenticationHandler; -import com.nynjacoin.nccs.lib.vertx.restclient.RestClientBase; -import com.nynjacoin.nccs.lib.vertx.restclient.RetryExecutor; +import com.nynjacoin.nccs.lib.vertx.restclient.JsonRetryExecutor; import com.nynjacoin.nccs.lib.vertx.restclient.WebClientFactory; import io.vertx.core.Vertx; import io.vertx.core.json.JsonArray; @@ -15,10 +14,16 @@ import org.apache.logging.log4j.Logger; import java.util.List; -public class PushNotificationSender extends RestClientBase { +public class PushNotificationSender { private static final Logger LOGGER = LogManager.getLogger(PushNotificationSender.class); + private static final int DEFAULT_MAX_RETRIES = 3; + private static final long DEFAULT_RETRY_MILLISECONDS = 100L; + private final WebClient webClient; + private final AuthenticationHandler authenticationHandler; + private final JsonRetryExecutor retryExecutor; + private final String rootUrl; private final Integer pushTtl; public static PushNotificationSender create(Vertx vertx, final JsonObject config) { @@ -28,12 +33,11 @@ public class PushNotificationSender extends RestClientBase { String auth = config.getString(FocusConfigKey.PUSH_KEY.key()); AuthenticationHandler authenticationHandler = AuthenticationHandler.create(auth); - RetryExecutor retryExecutor = RetryExecutor.newBuilder(vertx) - .setOrDefaultMaxRetries(config.getInteger( - FocusConfigKey.PUSH_MAX_RETRIES.key())) - .setOrDefaultRetryMilliseconds(config.getLong( - FocusConfigKey.PUSH_RETRY_AFTER_MILLISECONDS.key())) - .build(); + var retryExecutor = new JsonRetryExecutor( + vertx, + config.getInteger(FocusConfigKey.PUSH_MAX_RETRIES.key(), DEFAULT_MAX_RETRIES), + config.getLong( + FocusConfigKey.PUSH_RETRY_AFTER_MILLISECONDS.key(), DEFAULT_RETRY_MILLISECONDS)); String rootUrl = config.getString(FocusConfigKey.PUSH_URL.key()); if (Objects.isNull(rootUrl)) { @@ -59,11 +63,14 @@ public class PushNotificationSender extends RestClientBase { PushNotificationSender( WebClient webClient, AuthenticationHandler authenticationHandler , - RetryExecutor retryExecutor, + JsonRetryExecutor retryExecutor, String rootUrl, Integer pushTtl) { - super(webClient, authenticationHandler, retryExecutor, rootUrl); + this.webClient = webClient; + this.authenticationHandler = authenticationHandler; + this.retryExecutor = retryExecutor; + this.rootUrl = rootUrl; this.pushTtl = pushTtl; } @@ -71,8 +78,8 @@ public class PushNotificationSender extends RestClientBase { // Fire and forget. public void sendNotification(String id, List recipients, String module, String payload) { - var request = getWebClient().postAbs(getRootUrl()); - request = getAuthenticationHandler().apply(request); + var request = webClient.postAbs(rootUrl); + request = authenticationHandler.apply(request); JsonArray to = new JsonArray(); for (String r : recipients) { @@ -87,7 +94,7 @@ public class PushNotificationSender extends RestClientBase { .put("ttl", pushTtl) .put("payload", payload); - getRetryExecutor().execute(request, body).setHandler( + retryExecutor.execute(request, body).setHandler( event -> { if (event.succeeded()) { LOGGER.debug("Push notification {} to {} SENT", id, to); diff --git a/focus/src/main/java/com/nynjacoin/nccs/restclient/roomlink/RoomLinkClient.java b/focus/src/main/java/com/nynjacoin/nccs/restclient/roomlink/RoomLinkClient.java index dc67bcef..4d3820d3 100644 --- a/focus/src/main/java/com/nynjacoin/nccs/restclient/roomlink/RoomLinkClient.java +++ b/focus/src/main/java/com/nynjacoin/nccs/restclient/roomlink/RoomLinkClient.java @@ -3,8 +3,7 @@ package com.nynjacoin.nccs.restclient.roomlink; import com.nynjacoin.nccs.focus.config.FocusConfigKey; import com.nynjacoin.nccs.lib.vertx.restclient.AuthenticationHandler; import com.nynjacoin.nccs.lib.vertx.restclient.JsonHttpException; -import com.nynjacoin.nccs.lib.vertx.restclient.RestClientBase; -import com.nynjacoin.nccs.lib.vertx.restclient.RetryExecutor; +import com.nynjacoin.nccs.lib.vertx.restclient.JsonRetryExecutor; import com.nynjacoin.nccs.lib.vertx.restclient.ValidatingJsonObject; import com.nynjacoin.nccs.lib.vertx.restclient.WebClientFactory; import com.nynjacoin.nccs.lib.grpc.protocol.error.NccsError; @@ -14,10 +13,17 @@ import io.vertx.core.json.JsonObject; import io.vertx.ext.web.client.WebClient; import java.util.Objects; -public class RoomLinkClient extends RestClientBase { +public class RoomLinkClient { private static final String FIELD_ROOM_ID = "room_id"; private static final String FIELD_ROOM_NAME = "room_name"; + private static final int DEFAULT_MAX_RETRIES = 3; + private static final long DEFAULT_RETRY_MILLISECONDS = 100L; + + private final WebClient webClient; + private final AuthenticationHandler authenticationHandler; + private final JsonRetryExecutor retryExecutor; + private final String rootUrl; public static RoomLinkClient create(Vertx vertx, JsonObject config) { int poolSize = config.getInteger(FocusConfigKey.ROOM_LINK_PER_REQUEST_POOL_SIZE.key(), 32); @@ -26,12 +32,11 @@ public class RoomLinkClient extends RestClientBase { String auth = config.getString(FocusConfigKey.ROOM_LINK_KEY.key()); AuthenticationHandler authenticationHandler = AuthenticationHandler.create(auth); - RetryExecutor retryExecutor = RetryExecutor.newBuilder(vertx) - .setOrDefaultMaxRetries(config.getInteger( - FocusConfigKey.ROOM_LINK_MAX_RETRIES.key())) - .setOrDefaultRetryMilliseconds(config.getLong( - FocusConfigKey.ROOM_LINK_RETRY_AFTER_MILLISECONDS.key())) - .build(); + var retryExecutor = new JsonRetryExecutor( + vertx, + config.getInteger(FocusConfigKey.ROOM_LINK_MAX_RETRIES.key(), DEFAULT_MAX_RETRIES), + config.getLong( + FocusConfigKey.ROOM_LINK_RETRY_AFTER_MILLISECONDS.key(), DEFAULT_RETRY_MILLISECONDS)); String rootUrl = config.getString(FocusConfigKey.ROOM_LINK_URL.key()); Objects.requireNonNull(rootUrl); @@ -41,16 +46,19 @@ public class RoomLinkClient extends RestClientBase { private RoomLinkClient(WebClient webClient, AuthenticationHandler authenticationHandler, - RetryExecutor retryExecutor, + JsonRetryExecutor retryExecutor, String rootUrl) { - super(webClient, authenticationHandler, retryExecutor, rootUrl); + this.webClient = webClient; + this.authenticationHandler = authenticationHandler; + this.retryExecutor = retryExecutor; + this.rootUrl = rootUrl; } public Future getRoomInfo(String linkId) { - var request = getWebClient().getAbs(getRoomUrl(linkId)); - request = getAuthenticationHandler().apply(request); - var response = getRetryExecutor().execute(request); + var request = webClient.getAbs(getRoomUrl(linkId)); + request = authenticationHandler.apply(request); + var response = retryExecutor.execute(request); return response .map(rawBody -> { ValidatingJsonObject body = ValidatingJsonObject.wrap(rawBody); @@ -78,6 +86,6 @@ public class RoomLinkClient extends RestClientBase { } private String getRoomUrl(String linkId) { - return getRootUrl() + '/' + linkId + "/room_id"; + return rootUrl + '/' + linkId + "/room_id"; } } -- GitLab From 2d06ae3e3cd5da7e86354d57e256ae82aae3313b Mon Sep 17 00:00:00 2001 From: Ilia Krustev Date: Thu, 7 May 2020 15:55:19 +0300 Subject: [PATCH 23/23] Lock nccs-libs to 0.21.0. --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 49c50bf5..ffe1f234 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,4 +7,4 @@ rxjava2Version = 2.1.13 prometheusVersion = 0.5.0 cassandraDriverVersion = 3.6.0 junitVersion = 4.12 -nccsLibsVersion = 0.21.0-SNAPSHOT +nccsLibsVersion = 0.21.0 -- GitLab