Skip to content

Commit

Permalink
Merge branch 'alibaba:master' into NewOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoGuorui666 authored Sep 29, 2024
2 parents 461dc62 + 925cf17 commit 4671334
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 79 deletions.
32 changes: 16 additions & 16 deletions boot/src/main/java/com/taobao/arthas/boot/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,14 @@ public static void main(String[] args) throws ParserConfigurationException, SAXE
+ File.separator + bootstrap.getUseVersion() + File.separator + "arthas");
if (!specialVersionDir.exists()) {
// try to download arthas from remote server.
DownloadUtils.downArthasPackaging(bootstrap.getRepoMirror(), bootstrap.isuseHttp(),
DownloadUtils.downArthasPackaging(bootstrap.getRepoMirror(), bootstrap.isUseHttp(),
bootstrap.getUseVersion(), ARTHAS_LIB_DIR.getAbsolutePath());
}
verifyArthasHome(specialVersionDir.getAbsolutePath());
arthasHomeDir = specialVersionDir;
}

// Try set the directory where arthas-boot.jar is located to arhtas home
// Try set the directory where arthas-boot.jar is located to arthas home
if (arthasHomeDir == null) {
CodeSource codeSource = Bootstrap.class.getProtectionDomain().getCodeSource();
if (codeSource != null) {
Expand Down Expand Up @@ -470,16 +470,16 @@ public static void main(String[] args) throws ParserConfigurationException, SAXE
List<String> versionList = listNames(ARTHAS_LIB_DIR);
Collections.sort(versionList);

String localLastestVersion = null;
String localLatestVersion = null;
if (!versionList.isEmpty()) {
localLastestVersion = versionList.get(versionList.size() - 1);
localLatestVersion = versionList.get(versionList.size() - 1);
}

String remoteLastestVersion = DownloadUtils.readLatestReleaseVersion();
String remoteLatestVersion = DownloadUtils.readLatestReleaseVersion();

boolean needDownload = false;
if (localLastestVersion == null) {
if (remoteLastestVersion == null) {
if (localLatestVersion == null) {
if (remoteLatestVersion == null) {
// exit
AnsiLog.error("Can not find Arthas under local: {} and remote repo mirror: {}", ARTHAS_LIB_DIR,
bootstrap.getRepoMirror());
Expand All @@ -490,23 +490,23 @@ public static void main(String[] args) throws ParserConfigurationException, SAXE
needDownload = true;
}
} else {
if (remoteLastestVersion != null) {
if (localLastestVersion.compareTo(remoteLastestVersion) < 0) {
AnsiLog.info("local lastest version: {}, remote lastest version: {}, try to download from remote.",
localLastestVersion, remoteLastestVersion);
if (remoteLatestVersion != null) {
if (localLatestVersion.compareTo(remoteLatestVersion) < 0) {
AnsiLog.info("local latest version: {}, remote latest version: {}, try to download from remote.",
localLatestVersion, remoteLatestVersion);
needDownload = true;
}
}
}
if (needDownload) {
// try to download arthas from remote server.
DownloadUtils.downArthasPackaging(bootstrap.getRepoMirror(), bootstrap.isuseHttp(),
remoteLastestVersion, ARTHAS_LIB_DIR.getAbsolutePath());
localLastestVersion = remoteLastestVersion;
DownloadUtils.downArthasPackaging(bootstrap.getRepoMirror(), bootstrap.isUseHttp(),
remoteLatestVersion, ARTHAS_LIB_DIR.getAbsolutePath());
localLatestVersion = remoteLatestVersion;
}

// get the latest version
arthasHomeDir = new File(ARTHAS_LIB_DIR, localLastestVersion + File.separator + "arthas");
arthasHomeDir = new File(ARTHAS_LIB_DIR, localLatestVersion + File.separator + "arthas");
}

verifyArthasHome(arthasHomeDir.getAbsolutePath());
Expand Down Expand Up @@ -785,7 +785,7 @@ public String getRepoMirror() {
return repoMirror;
}

public boolean isuseHttp() {
public boolean isUseHttp() {
return useHttp;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void setClear(boolean clear) {
}

@Argument(index = 0, argName = "n", required = false)
@Description("how many history commnads to display")
@Description("how many history commands to display")
public void setNumber(int n) {
this.n = n;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public void process(CommandProcess process) {
try {
r.setDestination(Paths.get(getFilename()));
} catch (IOException e) {
process.end(-1, "Failed to stop" + r.getName() + ". Could not set destination for " + filename + "to file" + e.getMessage());
process.end(-1, "Failed to stop " + r.getName() + ". Could not set destination for " + filename + "to file" + e.getMessage());
}

r.stop();
Expand Down Expand Up @@ -353,7 +353,7 @@ public long parseSize(String s) throws Exception {
try {
return Long.parseLong(s);
} catch (Exception e) {
throw new NumberFormatException("'" + s + "' is not a valid size. Shoule be numeric value followed by a unit, i.e. 20M. Valid units k, M, G");
throw new NumberFormatException("'" + s + "' is not a valid size. Should be numeric value followed by a unit, i.e. 20M. Valid units k, M, G");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,15 @@ public static DefaultFullHttpResponse directView(File dir, String path, FullHttp
} finally {
IOUtils.close(fileInputStream);
}
ctx.write(fullResp);
ChannelFuture future = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
future.addListener(ChannelFutureListener.CLOSE);
ChannelFuture channelFuture = ctx.writeAndFlush(fullResp);
channelFuture.addListener((ChannelFutureListener) future -> {
if (future.isSuccess()) {
ChannelFuture lastContentFuture = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
lastContentFuture.addListener(ChannelFutureListener.CLOSE);
} else {
future.channel().close();
}
});
return fullResp;
}
logger.info("file {} size bigger than {}, send by future.",file.getName(), MIN_NETTY_DIRECT_SEND_SIZE);
Expand Down
17 changes: 3 additions & 14 deletions core/src/main/java/one/profiler/AsyncProfiler.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/*
* Copyright 2018 Andrei Pangin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright The async-profiler authors
* SPDX-License-Identifier: Apache-2.0
*/

package one.profiler;
Expand Down Expand Up @@ -283,4 +272,4 @@ private void filterThread(Thread thread, boolean enable) {
private native String execute0(String command) throws IllegalArgumentException, IllegalStateException, IOException;

private native void filterThread0(Thread thread, boolean enable);
}
}
17 changes: 3 additions & 14 deletions core/src/main/java/one/profiler/AsyncProfilerMXBean.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/*
* Copyright 2018 Andrei Pangin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright The async-profiler authors
* SPDX-License-Identifier: Apache-2.0
*/

package one.profiler;
Expand Down Expand Up @@ -40,4 +29,4 @@ public interface AsyncProfilerMXBean {
String dumpCollapsed(Counter counter);
String dumpTraces(int maxTraces);
String dumpFlat(int maxMethods);
}
}
17 changes: 3 additions & 14 deletions core/src/main/java/one/profiler/Counter.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/*
* Copyright 2018 Andrei Pangin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright The async-profiler authors
* SPDX-License-Identifier: Apache-2.0
*/

package one.profiler;
Expand All @@ -22,4 +11,4 @@
public enum Counter {
SAMPLES,
TOTAL
}
}
18 changes: 4 additions & 14 deletions core/src/main/java/one/profiler/Events.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/*
* Copyright 2018 Andrei Pangin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright The async-profiler authors
* SPDX-License-Identifier: Apache-2.0
*/

package one.profiler;
Expand All @@ -24,5 +13,6 @@ public class Events {
public static final String ALLOC = "alloc";
public static final String LOCK = "lock";
public static final String WALL = "wall";
public static final String CTIMER = "ctimer";
public static final String ITIMER = "itimer";
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<maven-invoker-plugin.version>3.0.0</maven-invoker-plugin.version>
<project.build.outputTimestamp>2020-09-27T15:10:43Z</project.build.outputTimestamp>
<lifecycle-mapping.version>1.0.0</lifecycle-mapping.version>
<netty.version>4.1.112.Final</netty.version>
<netty.version>4.1.113.Final</netty.version>
</properties>

<dependencyManagement>
Expand Down

0 comments on commit 4671334

Please sign in to comment.