From 351e7bfa3d7ac5a1955354be889e2d9aec319603 Mon Sep 17 00:00:00 2001 From: "Xinxin (Cissie) Mei" Date: Mon, 16 Sep 2024 19:00:01 +0000 Subject: [PATCH] Rerun pybind notebooks with new version no --- .../example_ControlPlane.ipynb | 61 ++--- .../pybind11_examples/example_DataPlane.ipynb | 2 +- .../pybind11_examples/example_EjfatURI.ipynb | 251 +++++++++++++++--- .../pybind11_examples/example_Headers.ipynb | 79 +++++- 4 files changed, 308 insertions(+), 85 deletions(-) diff --git a/scripts/notebooks/pybind11_examples/example_ControlPlane.ipynb b/scripts/notebooks/pybind11_examples/example_ControlPlane.ipynb index 1b0689a..6eb45ba 100644 --- a/scripts/notebooks/pybind11_examples/example_ControlPlane.ipynb +++ b/scripts/notebooks/pybind11_examples/example_ControlPlane.ipynb @@ -20,7 +20,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "0.1.0\n" + "0.1.1\n" ] } ], @@ -72,7 +72,7 @@ "Defaulting to user installation because normal site-packages is not writeable\n", "Requirement already satisfied: protobuf in /home/ubuntu/.local/lib/python3.10/site-packages (5.28.1)\n", "Note: you may need to restart the kernel to use updated packages.\n", - "Timestamp: seconds = 1726507802, nanos = 990104000\n" + "Timestamp: seconds = 1726512856, nanos = 809628000\n" ] } ], @@ -120,8 +120,8 @@ "Worker control signal: 0.8999999761581421\n", "Worker slots assigned: 10\n", "Worker last_updated (following 2 lines):\n", - "seconds: 1726507802\n", - "nanos: 990104000\n", + "seconds: 1726512856\n", + "nanos: 809628000\n", "\n" ] } @@ -327,7 +327,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Instance token: 037cd85578669e455f5801f2eeb7b5ce3cbdd2025d2153d28a2e5c64884e9a1f\n" + "Instance token: 9b0a986e06d5983e79e71904a6dba3fdb3aef7065d4b81e639c7ea66fedc2b45\n" ] } ], @@ -398,7 +398,7 @@ "output_type": "stream", "text": [ "Sync IPv4 addr is: 192.168.0.3\n", - "LB id is: 2\n" + "LB id is: 16\n" ] } ], @@ -554,7 +554,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "LB ID is: 3\n" + "LB ID is: 17\n" ] } ], @@ -677,8 +677,8 @@ "\n", "Send state succeeded\n", "\n", - "Session id is: 1\n", - "Session token is: 7f4cfb2438e461784dcff9be6ab3abb07462fb4ec507e273b2e2b5dffbf79f55\n", + "Session id is: 9\n", + "Session token is: 53d47321eecfc42cdb7999649c9bc9bd197d39e3b32830e5a3028bc83cfba473\n", "\n", "Deregister worker succeeded\n" ] @@ -795,7 +795,7 @@ "\n", "Send state for 25 times\n", "\n", - "Get LB status succeeded: \n" + "Get LB status succeeded: \n" ] } ], @@ -857,14 +857,14 @@ "name": "stdout", "output_type": "stream", "text": [ - "Timestamp: seconds: 1726507806\n", - "nanos: 689280748\n", + "Timestamp: seconds: 1726512860\n", + "nanos: 102211657\n", "\n", - "expiresAt: seconds: 1726511404\n", + "expiresAt: seconds: 1726516457\n", "\n", "currentEpoch: 3\n", "currentPredictedEventNumber: 9223372036854775808\n", - "workers: []\n" + "workers: []\n" ] } ], @@ -925,16 +925,16 @@ "Create LBManager obj succeeded: 0\n", "Register worker succeeded\n", "\n", - "Session id is: 3\n", - "Session token is: 071eec5b399e563de181c8e452d3f2973628d0c422e8083afa29d33c2b657529\n", + "Session id is: 11\n", + "Session token is: 07589d480e99cdb41bf26b263e236eae381f0ba33feec5054c62a38a3c41f811\n", "\n", "Send state for 25 times\n", "Add senders succeeded.\n", "\n", - "Get LB status succeeded: \n", + "Get LB status succeeded: \n", "Remove senders succeeded.\n", "\n", - "Get LB status succeeded: \n", + "Get LB status succeeded: \n", "\n", "Deregister worker succeeded\n", "Free LB succeeded!\n" @@ -1076,7 +1076,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 39, "metadata": {}, "outputs": [ { @@ -1086,25 +1086,26 @@ "Create LBManager obj succeeded: 0\n", "Register worker succeeded\n", "\n", - "Session id is: 4\n", - "Session token is: 33298a5893b6b5d9808f96ac351d0671886d1d7ad5693d9676f0401e1289fa14\n", + "Session id is: 14\n", + "Session token is: 24409feb705a6ae6a6ef7dce008a7c726fa6134bba00e19e47ca6d342d81d162\n", "\n", "Send state for 25 times\n", "\n", - "Get LB status succeeded: \n", + "Get LB status succeeded: \n", "Sender addresses: ['192.168.20.1', '192.168.20.2']\n", - "Current Epoch: 3\n", + "Current Epoch: 2\n", "Current predicted Event No: 9223372036854775808\n", - "Workers: []\n", - "Timestamp: seconds: 1726507812\n", - "nanos: 130294396\n", + "Workers: []\n", + "Timestamp: seconds: 1726512975\n", + "nanos: 658369981\n", "\n", - "expiresAt: seconds: 1726511409\n", + "expiresAt: seconds: 1726516573\n", "\n", "\n", "Send state for 25 times\n", "\n", - "LB id: 7\n" + "LB id: 23\n", + "1\n" ] } ], @@ -1203,12 +1204,12 @@ "print(\"LB id: \", res[0].lb_id)\n", "assert(res[0].name == \"mylb\")\n", "assert(res[0].lb_status.senderAddresses == ip_list)\n", - "# print(res[0].lb_status.workers, dir(res[0].lb_status.workers))" + "print(len(res[0].lb_status.workers))" ] }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 40, "metadata": {}, "outputs": [ { diff --git a/scripts/notebooks/pybind11_examples/example_DataPlane.ipynb b/scripts/notebooks/pybind11_examples/example_DataPlane.ipynb index 1aa8666..79b135a 100644 --- a/scripts/notebooks/pybind11_examples/example_DataPlane.ipynb +++ b/scripts/notebooks/pybind11_examples/example_DataPlane.ipynb @@ -1045,7 +1045,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/scripts/notebooks/pybind11_examples/example_EjfatURI.ipynb b/scripts/notebooks/pybind11_examples/example_EjfatURI.ipynb index 8065f05..2e51157 100644 --- a/scripts/notebooks/pybind11_examples/example_EjfatURI.ipynb +++ b/scripts/notebooks/pybind11_examples/example_EjfatURI.ipynb @@ -11,9 +11,17 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.1.1\n" + ] + } + ], "source": [ "import sys\n", "\n", @@ -47,9 +55,19 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The IP address is 192.168.1.3\n", + "The IP address is of IPv4: True\n", + "The IP address is of IPv6: False\n" + ] + } + ], "source": [ "ip_instance = e2sar_py.IPAddress.from_string(\"192.168.1.3\")\n", "print(f\"The IP address is {ip_instance}\")\n", @@ -82,9 +100,17 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Created EjfatURI object successfully: ejfat://token@192.188.29.6:18020/lb/36?sync=192.188.29.6:10920&data=192.188.29.20\n" + ] + } + ], "source": [ "CP_IPV4 = \"192.188.29.6\"\n", "CP_PORT = \"18020\"\n", @@ -103,9 +129,18 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " ejfat://token@192.188.29.6:18020/lb/36?sync=192.188.29.6:10920&data=192.188.29.20\n", + " ejfat://token@192.188.29.6:18020/lb/36?sync=192.188.29.6:10920&data=192.188.29.20\n" + ] + } + ], "source": [ "# Print the EjfatURI object as a normal string\n", "print(type(uri), uri)\n", @@ -121,9 +156,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The created ejfatURI object instance:\n", + " useTls: False\n", + " lb_id: 36\n", + " lb_name: UNSET\n", + " session_id: UNSET\n" + ] + } + ], "source": [ "print(\"The created ejfatURI object instance:\")\n", "print(f\" useTls: {uri.get_useTls()}\")\n", @@ -144,9 +191,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Object's LB name not set!\n", + "Set LB name as py_lb\n", + "Object's LB name: py_lb\n" + ] + } + ], "source": [ "LB_NAME = \"py_lb\"\n", "\n", @@ -171,9 +229,21 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The EjfatURI instance:\n", + " has data plane address: True\n", + " has sync plane address: True\n", + " has data plane IPv4 address: True\n", + " has data plane IPv6 address: False\n" + ] + } + ], "source": [ "# Set syncAddr\n", "sync_addr = (e2sar_py.IPAddress.from_string(\"192.168.1.1\"), 8080)\n", @@ -202,9 +272,18 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Instance Token: token123\n" + ] + } + ], "source": [ "print(uri.get_instance_token()) # the return type is an object\n", "\n", @@ -225,9 +304,29 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "get_cp_address return type is \n", + " tuple[0] is of type: \n", + " tuple[1] is of type: \n" + ] + }, + { + "data": { + "text/plain": [ + "('192.188.29.6', 18020)" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "\n", "# Get control plane address\n", @@ -250,9 +349,30 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "C++ get_dp_address_v4 return type is \n", + " tuple[0] is of type: \n", + " tuple[1] is of type: \n", + "Data plane IPV4 address: 10.0.0.1\n", + "Data plane port: 19522\n", + "\n", + "get_dp_address_v6 error: \n", + "Try get data plane IPV6 address: ('', -1)\n", + "\n", + "C++ get_sync_address return type is \n", + " tuple[0] is of type: \n", + " tuple[1] is of type: \n", + "Sync IPV4 address: 192.168.1.1\n", + "Sync port: 8080\n" + ] + } + ], "source": [ "# Redo the above with a Python decorator of C++ return type result>\n", "def result_tuple2_handler(get_func):\n", @@ -299,9 +419,19 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "get_cp_hostname error: \n", + "Control plane hostname: \n", + "Control plane port: UNSET\n" + ] + } + ], "source": [ "# The decorator applies to C++ return type of result>\n", "@result_tuple2_handler\n", @@ -330,9 +460,28 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "get_cp_address return type is \n", + " tuple[0] is of type: \n", + " tuple[1] is of type: \n", + "Control plane (address, port) : ('2001:4860:0:2001::68', 18020)\n", + "C++ get_dp_address_v6 return type is \n", + " tuple[0] is of type: \n", + " tuple[1] is of type: \n", + "Data plane (address, port) : ('2001:4860:0:2021::68', 19522)\n", + "C++ get_sync_address return type is \n", + " tuple[0] is of type: \n", + " tuple[1] is of type: \n", + "Sync (address, port) : ('2001:4860:0:2031::68', 19020)\n" + ] + } + ], "source": [ "DEMO_IPV6 = \"ejfat://[2001:4860:0:2001::68]:18020/lb/36?data=[2001:4860:0:2021::68]&sync=[2001:4860:0:2031::68]:19020\"\n", "\n", @@ -477,9 +626,17 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "An error occured: Caught an unknown exception!\n" + ] + } + ], "source": [ "DEMO_WRONG_URI = \"ejfact://token@192.188.29.6:18020/lb/36?sync=192.188.29.6:19020&data=192.188.29.20\"\n", "\n", @@ -522,9 +679,17 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Environment variable EJFAT_URI not defined.\n" + ] + } + ], "source": [ "# Delete env var EJFAT_URI\n", "if 'EJFAT_URI' in os.environ:\n", @@ -662,7 +827,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/scripts/notebooks/pybind11_examples/example_Headers.ipynb b/scripts/notebooks/pybind11_examples/example_Headers.ipynb index 03a143b..f91a901 100644 --- a/scripts/notebooks/pybind11_examples/example_Headers.ipynb +++ b/scripts/notebooks/pybind11_examples/example_Headers.ipynb @@ -11,9 +11,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.1.1\n" + ] + } + ], "source": [ "import sys\n", "\n", @@ -29,9 +37,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Default data plane port: 19522\n", + "Default Reassembler Header version: 1\n", + "Default Reassembler Header nibble: 16\n", + "Default Load Balancer Header version: 2\n", + "Default Sync Header version: 1\n" + ] + } + ], "source": [ "# Print the constant atrributes\n", "print(f\"Default data plane port: {e2sar_py._dp_port}\")\n", @@ -43,9 +63,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "IP header length: 20\n", + "UDP header length: 8\n", + "Total header length: 64\n", + "LB + RE header length: 36\n" + ] + } + ], "source": [ "\n", "# The Hdr lengths\n", @@ -66,9 +97,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Before setting fields: (0, 0, 0, 0)\n", + "After setting fields: (1, 2, 4, 8)\n", + " data_id=1\n", + " buff_off=2\n", + " buff_len=4\n", + " event_num=8\n" + ] + } + ], "source": [ "# Setting the Reaasembler header fields\n", "rehdr = e2sar_py.REHdr()\n", @@ -96,9 +140,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Before (2, 1, 0, 0)\n", + "2\n", + "1\n", + "0\n", + "0\n", + "After (2, 1, 200, 50)\n" + ] + } + ], "source": [ "# Load balancer header\n", "lbhdr = e2sar_py.LBHdr()\n", @@ -149,7 +206,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.10.12" } }, "nbformat": 4,