tunnel client report arthas version. #1556

pull/1585/head^2
hengyunabc 4 years ago
parent 6a359ccff6
commit e53f355978

@ -9,6 +9,12 @@ import java.util.concurrent.CopyOnWriteArrayList;
/**
*
* <pre>
* * ClassFileTransformer
* * Enhancer
* </pre>
*
* @see com.taobao.arthas.core.advisor.Enhancer
* @author hengyunabc 2020-05-18
*
*/

@ -301,6 +301,7 @@ public class ArthasBootstrap {
tunnelClient = new TunnelClient();
tunnelClient.setId(configure.getAgentId());
tunnelClient.setTunnelServerUrl(configure.getTunnelServer());
tunnelClient.setVersion(ArthasBanner.version());
ChannelFuture channelFuture = tunnelClient.start();
channelFuture.await(10, TimeUnit.SECONDS);
if(channelFuture.isSuccess()) {

@ -55,6 +55,11 @@ public class TunnelClient {
// agent id, generated by tunnel server. if reconnect, reuse the id
volatile private String id;
/**
* arthas version
*/
private String version = "unknown";
public ChannelFuture start() throws IOException, InterruptedException, URISyntaxException {
return connect(false);
}
@ -62,6 +67,7 @@ public class TunnelClient {
public ChannelFuture connect(boolean reconnect) throws SSLException, URISyntaxException, InterruptedException {
QueryStringEncoder queryEncoder = new QueryStringEncoder(this.tunnelServerUrl);
queryEncoder.addParam(URIConstans.METHOD, MethodConstants.AGENT_REGISTER);
queryEncoder.addParam(URIConstans.ARTHAS_VERSION, this.version);
if (id != null) {
queryEncoder.addParam(URIConstans.ID, id);
}
@ -165,4 +171,11 @@ public class TunnelClient {
this.id = id;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}

@ -39,4 +39,6 @@ public class URIConstans {
* proxybase64
*/
public static final String PROXY_RESPONSE_DATA = "responseData";
public static final String ARTHAS_VERSION = "arthasVersion";
}

@ -15,6 +15,7 @@ public class AgentInfo {
private ChannelHandlerContext channelHandlerContext;
private String host;
private int port;
private String arthasVersion;
public ChannelHandlerContext getChannelHandlerContext() {
return channelHandlerContext;
@ -40,4 +41,12 @@ public class AgentInfo {
this.port = port;
}
public String getArthasVersion() {
return arthasVersion;
}
public void setArthasVersion(String arthasVersion) {
this.arthasVersion = arthasVersion;
}
}

@ -214,6 +214,12 @@ public class TunnelSocketFrameHandler extends SimpleChannelInboundHandler<WebSoc
id = idList.get(0);
}
String arthasVersion = null;
List<String> arthasVersionList = queryDecoder.parameters().get(URIConstans.ARTHAS_VERSION);
if (arthasVersionList != null && !arthasVersionList.isEmpty()) {
arthasVersion = arthasVersionList.get(0);
}
final String finalId = id;
// URI responseUri = new URI("response", null, "/", "method=" + MethodConstants.AGENT_REGISTER + "&id=" + id, null);
@ -229,6 +235,9 @@ public class TunnelSocketFrameHandler extends SimpleChannelInboundHandler<WebSoc
info.setPort(inetSocketAddress.getPort());
}
info.setChannelHandlerContext(ctx);
if (arthasVersion != null) {
info.setArthasVersion(arthasVersion);
}
tunnelServer.addAgent(id, info);
ctx.channel().closeFuture().addListener(new GenericFutureListener<Future<? super Void>>() {

Loading…
Cancel
Save