Code Monkey home page Code Monkey logo

andy_doc-back's Introduction

JDWP and JDI

JVM TI - Java VM Tool Interface Defines the debugging services a JVM provides. JDWP - Java Debug Wire Protocol Defines the communication between debuggee and debugger processes. JDI - Java Debug Interface Defines a high-level Java language interface which tool developers can easily use to write remote debugger applications.

the modern JDWP agent was embeded in JVM since 1999, java 1.2.2, nearly twenty years ago, with minor changes to support languange features in each java versions, it is developed using c++ languange and it supports transporting data using sockets and shared memories. It has nearly 90 commands each of them is designed to fullfill a very simple task, for example: get the thread name for a specifed thread id. JDI is a serries of interfaces and JDK has also a standard implementation of it, eclipse has also another implementation of it, using JDI, you are free of constructing JDWP requests and decoding JDWP reponses. You might not know that the JDWP agent is single threaded with a request buffer and a repsonse buffer, both the JDI implementations are using sync mode because async is not invented by the the time, that means each JDWP command will need to wait for the response of previous request even when there is no depenceny between them. Sync mode and fragmented request/response make the major latency issue of java remote debugging over the internet.


                /    |--------------|
               /     |     JVM      |
 target   ----(      |--------------|  <------- JVM TI - Java JVM Tool Interface
               \     |   back-end   |
                \    |--------------|
                /           |
 comm channel -(            |  <--------------- JDWP - Java Debug Wire Protocol
                \           |
                     |--------------|
                     | front-end    |
                     |--------------|  <------- JDI - Java Debug Interface
                     |      UI      |
                     |--------------|
J2SE 1.2.2 Cricket 蟋蟀 1999-07-08
J2SE 1.3 Kestrel 美洲红隼 2000-05-08
J2SE 1.3.1 Ladybird 瓢虫 2001-05-17
J2SE 1.4.0 Merlin 灰背隼 2002-02-13
J2SE 1.4.1 grasshopper 蚱蜢 2002-09-16
J2SE 1.4.2 Mantis 螳螂 2003-06-26
J2SE 5.0 (1.5.0) Tiger 老虎 2004-10
J2SE 6.0 (Beta) Mustang 野马 2006-04

On the contrary, the node.js and c# debug protocol has polished the debug protocol for remote debugging, and we have proven vscode protocol is more efficient to fullfill debug needs. Let me give a comparasion of these two protocols using a typical spring boot application on four typical scenarios.

Case 1: set on breakpoint

name count request size response size total size
linetable 2 76 146 222
set 3 164 45 209
methodswithgeneric 1 30 97 127
classesbysignature 1 49 28 77
capabilitiesnew 1 22 43 65
sourcedebugextension 1 30 11 41
total 9 371 370 741
vscode 1(11.11 %) 252(67.92 %) 158(42.70 %) 410(55.33 %)

Case 2: threads

name count request size response size total size
thread::name 22 660 804 1464
iscollected 22 660 264 924
allthreads 1 22 191 213
set 2 56 30 86
total 47 1398 1289 2687
vscode 1(2.13 %) 46(3.29 %) 1203(93.33 %) 1249(46.48 %)

Case 3: get stack trace

name count request size response size total size
methodswithgeneric 36 1080 59189 60269
linetable 18 684 5130 5814
frames 1 38 2226 2264
signature 12 360 796 1156
sourcefile 12 360 486 846
sourcedebugextension 11 330 121 451
allthreads 1 22 191 213
framecount 1 30 15 45
iscollected 1 30 12 42
total 93 2934 68166 71100
vscode 1(1.08 %) 104(3.54 %) 8769(12.86 %) 8873(12.48 %)

Case 4: evaluation on 'this.hashCode()'

name count request size response size total size
frames 4 152 6726 6878
fieldswithgeneric 5 150 1839 1989
sourcedebugextension 25 750 275 1025
methodswithgeneric 1 30 585 615
superclass 6 180 114 294
interfaces 5 150 83 233
variabletablewithgeneric 1 38 134 172
referencetype 2 60 40 100
parent 2 60 38 98
thread::status 2 60 38 98
object::invokemethod 1 62 25 87
object::getvalues 1 42 17 59
thisobject 1 38 20 58
threadgroup 1 30 19 49
threadgroup::name 1 30 19 49
classloader 1 30 19 49
total 59 1862 9991 11853
vscode 1(1.69 %) 123(6.61 %) 169(1.69 %) 292(2.46 %)

As a conclusion, the overall JDWP request/response numbers is over 50 times as vscode, the overall JDWP request/response body is 3 times as vsocde, producing overy 40 times of lentency of each operation. The solution is to replace the JDWP protocol over the internet with vscode protocol. In order to archive this, we make a minior change on the archecture diagram, we move the debug core module which is to comunicate with JVM from local to the remote container or vm where the JVM runs at, we call it debug agent server, we also use a agent client at local to communicate with debug agent server using vscode debug protocol.

Now let me demo the debug experience using debug agent. I have setup a spring boot application, set a breakpoint, now let me start the debug session, we can see that the breakpoint is hit, step over and over, we can see that the operation can be completed in less than 1 seconds.

Problems

  1. We need to brand new a debug server supporting this archetecture. Because one vscode debug operation like set breakpoint also needs to interact with JDT language server and local project file by debug provider described before, it is hard to have one debug server which supports both local debug and agent debug.
  2. We cannot easily implement evaluation and HCR, because the evaluation/hcr provider needs the project support to generate java bytecode instructions, so it cannot be moved to remote together with debug core, it requires us to extends vscode protocol for transport java bytecode instructions. All reasons above will result in a huge change to our code, then why we cannot move the entire debug server to remote? That is because the debug server depends on JDT language server for project support, if we move all debug server to remote, we also need to setup the project remote the same as the local ones, which means your project in remote must have the exact same path as your local machine, and you cannot move/rename your local project, the jdk version and location must be same too and the third-party librairies.
operation jdwp requests jdwp packet size vscode requests vscode packet size
list threads 47 2687 1(2.13 %) 1249 (46.48 %)
set a breakpoint 9 741 1(11.11 %) 410 (55.33 %)
get stackTrace 93 71100 1(1.08 %) 8873 (12.48 %)
evalution 59 11853 1(1.69 %) 292 (2.46 %)

andy_doc-back's People

Contributors

andxu avatar

Watchers

 avatar  avatar

andy_doc-back's Issues

Bugbash doc

  1. download the latest azure cli(version 2.0.42): https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest, if you have already installed the azure cli, please upgrade the version to latest version.

  2. Create an azure kubernetes cluster with default default parameter and a specified group name and kubernetes cluster name and dns name, these names will be used later.
    alt text

  3. in console , run az login and az account set --subscritpion=XXXXXXX to switch to the subscription where the kubernetes cluster created.

  4. if you previously installed azure dev-spaces cli, please uninstall it.

  5. in terminal run az aks use-dev-spaces -g g -n n, and install latest azure dev-spaces cli with the hint in console

  6. When An Azure Dev Spaces Controller will be created that targets resource 'n' in resource group 'g'. Continue? (y/N): hint appear, input 'N' since the group name and cluster name in the command line is wrong on purpose.

  7. Remove all the files and folder under C:\Program Files\Microsoft SDKs\Azure\Azure Dev Spaces CLI (Preview), copy all the files in \\devdivcn\Shared\Personal\andxu\bugbash\AzdsCli-PrivateBuild to this folder.

  8. Open a new terminal: run azds --version,make sure the following version is print:
    Z:\Personal\andxu\bugbash\AzdsCli-PrivateBuild>azds --version Azure Dev Spaces CLI (Preview) 0.1.0.07191646-stephpr

  9. Install the latest vscode, install extension: "Language support for Java", in vscode settings by ctrl + comma, add the following settings
    "extensions.autoUpdate": false

  10. install the vscode extension by the vsix in \\devdivcn\Shared\Personal\andxu\bugbash\azds-0.1.1.vsix

  11. install the vscode extension by the vsix in \\devdivcn\Shared\Personal\andxu\bugbash\vscode-java-debugger-azds-0.1.0.vsix

  12. add system environment variable: AZDS_ENVIRONMENT=dev
    image

  13. Start a new terminal, run azds controller create -g <your resouce group name> -n <your kubernetes cluster name> -tg <your resouce group name> -tn <your kubernetes cluster name>. When this terminal finishes, run azds controller select -g <your resouce group name> -n <your kubernetes cluster name> and then run azds space select and input 1 for the default space name.

  14. clone the git to a directory: https://github.com/stepro/dev-spaces and open the folder samples\java\getting-started\webfrontend in vscode

  15. In vscode, run the command by ctrl+shift+p: Azure Dev Spaces: prepare configuration files ...

  16. Set a breakpoint at samples\java\getting-started\webfrontend\src\main\java\com\ms\sample\webfrontend\Application.java#line 19, press F5, wait the breakpoint to be hit.

if step 15-17, if it passes, you can try any kind of maven projects(only single pom.xml is now supported).

Issue list 0.2.0

  • more telemetry on the duration of azds up
  • args and vmArgs should allow array

S177

  • One Deploy API (Intellij&Maven)
  • Spring Cloud maven plugin refactor(Maven)
  • Code Navigation in Azure Log (Intellij)
  • Azure File Explorer for Webapp/Functions (Intellij)
  • Create Function new UI creation wizard (Intellij)
  • AAD java sample (service integration)
  • Azure toolkit bugs: (Token expiration, no subscription through device login)
  • Enable app logs/ssh/log streaming by default when create from tooling
  • Enable Flight Recorder (Intellij)
  • BI

azds java debugger 0.1.3 Endgame

Build

Test

Tutorial && Document

Release

  • 9/29 - Release tag 0.1.3 docker hub - @andxu
  • 9/30 - Add 0.1.3 tag for vscode-java-debug-azds - @andxu
  • 9/30 - Add 0.1.3 tag for java debug agent - @andxu
  • 9/30 - Release to marketplace - @andxu

VS Code Java Debugger for Azure Dev Spaces End Game 0.1.0

Preparation:

  1. set env variable: AZDS_ENVIRONMENT=staging
  2. install staging azds-cli:
    CLI: Azure Dev Spaces CLI.exe
    OSX Setup: https://mindarostage.blob.core.windows.net/azdssetup/LKS/azds-osx-setup.sh
    Linux Setup: https://mindarostage.blob.core.windows.net/azdssetup/LKS/azds-linux-setup.sh
  3. install vscode plugin at https://mindarostage.blob.core.windows.net/azdssetup/LKS/azds-0.1.1.vsix
  4. install vscode plugin at https://vscjavaci.cloudapp.net/job/vscode-java-debug-azds.vsix-withSign/27/Azure/processDownloadRequest/signedartifacts/27/vscode-java-debugger-azds-0.1.0.vsix
  5. create azure kubernetes cluster and install dev-spaces using az aks use-dev-spaces -g <your resouce group name> -n <your kubernetes cluster name>
  6. open the java project in vscode: https://github.com/Azure/dev-spaces/tree/master/samples/java/getting-started/webfrontend
  7. In vscode, run the command by ctrl+shift+p: Azure Dev Spaces: prepare configuration files ...
  8. Set a breakpoint at samples\java\getting-started\webfrontend\src\main\java\com\ms\sample\webfrontend\Application.java#line 19, press F5, wait the breakpoint to be hit.

IDEA vs STS4

Tables

Operations STS(4.0) IDEA
Scaffolding
  • spring initializr
  • spring initializr
Module management
  • update modules
Navigation
  • Quick navigate @beans@url-mappings@annotations
Live Information Filtering
  • urls
Configuration
  • Properties Editor (hove information/validation/completion)
  • Convert to yaml
Dependency Graph
  • Beans
  • Application Context
  • Runtime Beans
Editing
  • Smart code completions special to Spring
No additional support
Run Locally
  • Live load
  • JMX
  • Live load
  • JMX
Deploy
  • Pivotal cloud
Debug
  • Local Debug
  • Local Debug
Cloud Monitoring
Cloud Diagnose
Cloud Debug

track2 migration

Migration to track2 progress

WebApp

  • WebApp Maven plugin (1.14.0, Apr 29)
  • Azure Toolkits for Intellij (3.52.0, Apr 29)
  • WebApp Gradle plugin (to be released in this month: 1.0.0)
  • Azure Toolkits for Eclipse

Azure Functions

  • Functions Maven plugin (1.12.0, May 27)
  • Azure Toolkits for Intellij (3.54.0, Jun 28)

Azure Spring Cloud

  • Azure Spring Cloud Maven plugin (1.6.0, May 26)
  • Azure Toolkits for Intellij (3.53.0, May 27)
  • Functions VSCode plugin (0.1.0, Jan 8)

Azure Application Insights

  • Functions Maven plugin (1.12.0, May 27)
  • Azure Toolkits for Intellij
  • Azure Toolkits for Eclipse

MySql Server for Azure

  • Azure Toolkits for Intellij (3.54.0, Jun 28)

Azure SqlServer

  • Azure Toolkits for Intellij (3.53.0, May 27)

Virtual Machine

  • Azure Toolkits for Intellij
  • Azure Toolkits for Eclipse

Azure Storage

  • Azure Toolkits for Intellij
  • Azure Toolkits for Eclipse

Redis

  • Azure Toolkits for Intellij
  • Azure Toolkits for Eclipse

Azure Container Registry

  • Azure Toolkits for Intellij
  • Azure Toolkits for Eclipse

ARM template/Resource group

  • Azure Toolkits for Intellij
  • Azure Toolkits for Eclipse

HDInsight

  • Azure Toolkits for Intellij
  • Azure Toolkits for Eclipse

Proxy

  • login - oauth/device code
  • login - azure cli
  • login - sp
  • azure explorer - list/refresh/create/start/stop/delete/open in portal/file explorer
  • webapp - create
  • webapp - deploy
  • webapp - ssh
  • webapp - open log stream
  • reference book
  • spring cloud - deploy
  • spring cloud - add dependencies (need maven config for proxy)
  • spring cloud - open log stream (not yet tested)
  • function - deploy
  • function - create with application insight
  • function - list triggers
  • function - local run (blocked by function core tools)
  • function - open log stream (not yet tested)

End game 0.2.0

Build

Test

Tutorial && Document

Release

  • 1/14 - Release tag 0.2.0 docker hub - @andxu
  • 1/14 - Add 0.2.0 tag for vscode-java-debug-azds - @andxu
  • 1/14 - Add 0.2.0 tag for java debug agent - @andxu
  • 1/14 - Release to marketplace - @andxu

azds 0.1.4 S144

  • Remove JVM mismatch warning if major version matches
  • Use zulu enterprise jdk for java debug agent
  • Produce a run-able example.
  • Fix restart issue
  • Fix message box of connect failure
  • Fix message text of lower version between plugin and debug agent
  • Fix code: this.server = undefined two times

AZDS Java Endgame 0.1.4

Build

Test

Tutorial && Document

Release

  • 11/7 - Release tag 0.1.4 docker hub - @andxu
  • 11/7 - Add 0.1.4 tag for vscode-java-debug-azds - @andxu
  • 11/7 - Add 0.1.4 tag for java debug agent - @andxu
  • 11/7 - Release to marketplace - @andxu

Test

Login

az login
az account show

Prepare mysql database

export SUBSCRIPTION=$(az account show --query id --output tsv)
export RESOURCE_GROUP=migrate-javaee-app
export WEBAPP=migrate-petstore-andxu
export REGION=eastus

export DATABASE_SERVER=migrate-petstore-andxu
export DATABASE_ADMIN=andxu
export DATABASE_ADMIN_PASSWORD=secret


export MYSQL_SERVER_NAME=mysql-${DATABASE_SERVER}
export MYSQL_SERVER_ADMIN_LOGIN_NAME=${DATABASE_ADMIN}
export MYSQL_SERVER_ADMIN_PASSWORD=${DATABASE_ADMIN_PASSWORD}
export MYSQL_DATABASE_NAME=petstore

export MYSQL_SERVER_FULL_NAME=${MYSQL_SERVER_NAME}.mysql.database.azure.com
export MYSQL_CONNECTION_URL=jdbc:mysql://${MYSQL_SERVER_FULL_NAME}:3306/${MYSQL_DATABASE_NAME}?ssl=true\&useLegacyDatetimeCode=false\&serverTimezone=GMT
export MYSQL_SERVER_ADMIN_FULL_NAME=${MYSQL_SERVER_ADMIN_LOGIN_NAME}\@${MYSQL_SERVER_NAME}

export DEVBOX_IP_ADDRESS=167.220.255.76
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home

az mysql server create --resource-group ${RESOURCE_GROUP} \
    --name ${MYSQL_SERVER_NAME}  --location ${REGION} \
    --admin-user ${MYSQL_SERVER_ADMIN_LOGIN_NAME} \
    --admin-password ${MYSQL_SERVER_ADMIN_PASSWORD} \
    --sku-name GP_Gen5_32 \
    --ssl-enforcement Disabled \
    --version 5.7

az mysql server firewall-rule create --name allAzureIPs \
    --server ${MYSQL_SERVER_NAME} \
    --resource-group ${RESOURCE_GROUP} \
    --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0

az mysql server firewall-rule create --name myDevBox \
    --server ${MYSQL_SERVER_NAME} \
    --resource-group ${RESOURCE_GROUP} \
    --start-ip-address ${DEVBOX_IP_ADDRESS} --end-ip-address ${DEVBOX_IP_ADDRESS}

az mysql server configuration set --name wait_timeout \
    --resource-group ${RESOURCE_GROUP} \
    --server ${MYSQL_SERVER_NAME} --value 2147483

mysql -u ${MYSQL_SERVER_ADMIN_FULL_NAME}  -h ${MYSQL_SERVER_FULL_NAME} -P 3306 -p

Azds Java End Game 0.1.2

Preparation:

  1. verify there is no env variable: AZDS_ENVIRONMENT
C:\Users\andxu>echo %AZDS_ENVIRONMENT%
%AZDS_ENVIRONMENT%
  1. install latest azure cli, uninstall Azure AZDS cli if you installed.
  2. install latest azds vscode plugin
  3. install azds java debugger plugin at https://vscjavaci.cloudapp.net/job/vscode-java-debug-azds.vsix-withSign for the version 0.1.2
  4. create azure kubernetes cluster and install dev-spaces using az aks use-dev-spaces -g <your resouce group name> -n <your kubernetes cluster name>
  5. Run test plan at https://github.com/andxu/andy_doc/issues/3

Java Docs CheckPoints

  • Azure Hosting(AAD)
  • Daily Job load data from Kusto to Sql Server
  • PV - 30days
  • UV - 30days
  • Rating - 30days
  • CSAT - 30days
  • Query(google/bing) - 30days
  • Comment Count
  • PV Chart(30 days) progressing
  • Comment Text
  • Time Range Config-able other than 30days
  • Better UI for Document Metadata/Metric

Container cannot be reached

Configuration

azds version: 0.1.20190228.12
azds vscode extension: 0.1.120190228
JDK: 11

Steps

  1. Open project 'dev-spaces-master\samples\java\getting-started\webfrontend'
  2. Using "AZDS: Prepare xxxx" to generate launch.json and select open jdk
  3. Click F5

Result

Report error as below:
image

> Executing task: C:\Program Files\Microsoft SDKs\Azure\Azure Dev Spaces CLI (Preview)\azds.exe up --port=51452:7000 --detach --keep-alive --command /javadebug/start.sh <

Synchronizing files...2s
Using dev space 'default' with target 'sally37'
Installing Helm chart...1s
Waiting for container image build...4s
Building container image...
Step 1/8 : FROM maven:3.5-jdk-11-slim
Step 2/8 : EXPOSE 8080
Step 3/8 : WORKDIR /usr/src/app
Step 4/8 : COPY pom.xml ./
Step 5/8 : RUN /usr/local/bin/mvn-entrypoint.sh     mvn package -Dmaven.test.skip=true -Dcheckstyle.skip=true -Dmaven.javadoc.skip=true --fail-never
Step 6/8 : COPY . .
Step 7/8 : RUN mvn package -Dmaven.test.skip=true -Dcheckstyle.skip=true -Dmaven.javadoc.skip=true
Step 8/8 : ENTRYPOINT ["java","-jar","target/webfrontend-0.1.0.jar"]
Built container image in 1m 18s
Waiting for container...5s
Service 'webfrontend' port 80 (http) is available at http://localhost:59163
Container cannot be reached.
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

20190523

Progress

  • Create Java web app - Azure App Service | Microsoft Docs
  • Create your first function in Azure with Java and Maven | Microsoft Docs
  • Create Java web app on Linux - Azure App Service | Microsoft Docs
  • Deploy a Spring Boot JAR file app to the cloud with Maven and Azure | Microsoft Docs
  • Develop with Java on Kubernetes using Azure Dev Spaces - Azure Dev Spaces | Microsoft Docs
  • Install the Azure Toolkit for Eclipse | Microsoft Docs
  • Deploy a Spring Boot App on Kubernetes in Azure Kubernetes Service | Microsoft Docs
  • Create an Azure function with Java and IntelliJ | Microsoft Docs
  • Deploy a Spring Boot Web App on Azure App Service for Container | Microsoft Docs (wait for a bug to be fixed in cloud shell)
  • Installing the Azure Toolkit for IntelliJ | Microsoft Docs
  • Create an Azure function app with Java and Eclipse | Microsoft Docs
  • Sign In Instructions for the Azure Toolkit for Eclipse | Microsoft Docs
  • How to use the Maven Plugin for Azure Web Apps to deploy a containerized Spring Boot app to Azure

Call two times effective pom request when prepare azds files

Environment:

  • Operating System: Win10/Mac OS

  • JDK version: 1.8.0_191

  • Visual Studio Code version: 1.30.2

  • Azure cli: 2.0.54

  • Azure Dev Spaces CLI (Preview): 0.1.20190102.6

  • Build: 61

Repro steps:

  1. Open one test project

  2. F1 and select "AZDS: Prepare xxxx"

Result:
After selecting the base image for the first time, after a while, it will will let you choose again
image

Issue list 0.1.1

  • If connect to agent timeout, there is no way of starting a new debug session
  • Sometimes module name may end with 'pom.xml' or not like 'module1' or 'module1/pom.xml'
  • Special handling for path contains space
  • Telemetry wrapper and don't record too many telemetries like resolveSourceName
  • Breakpoint hits two times for some cases
  • classpath is duplicate and missing runtime scope classpath
  • license

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.