[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Fix remote connection issue
From: |
vladimir . mezentsev |
Subject: |
[PATCH] Fix remote connection issue |
Date: |
Wed, 13 Nov 2024 23:19:30 -0800 |
From: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
gprofng-gui uses ssh for remote connection.
Java hangs when ssh needs to ask for a password or passphrase.
See Orabug #36991667 - Cannot run /usr/bin/ssh in Runtime.getRuntime().exec
To remove any dialog with ssh, I run ssh with PasswordAuthentication=no,
UserKnownHostsFile=/dev/null, StrictHostKeyChecking=no.
ChangeLog
2024-11-13 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
gprofng-gui.sh: Add option --verbose
org/gprofng/analyzer/AnMain.java: Likewise.
org/gprofng/mpmt/persistence/UserPref.java: Likewise.
org/gprofng/mpmt/Analyzer.java: Clean up code.
org/gprofng/mpmt/remote/ConnectionDialog.java: Add arguments to ssh.
---
gprofng-gui.sh | 49 ++++++++-----
org/gprofng/analyzer/AnMain.java | 7 ++
org/gprofng/mpmt/Analyzer.java | 73 ++++++++-----------
org/gprofng/mpmt/persistence/UserPref.java | 13 ++--
org/gprofng/mpmt/remote/ConnectionDialog.java | 26 ++++---
5 files changed, 90 insertions(+), 78 deletions(-)
diff --git a/gprofng-gui.sh b/gprofng-gui.sh
index d0c7c6e..016c05a 100644
--- a/gprofng-gui.sh
+++ b/gprofng-gui.sh
@@ -83,6 +83,20 @@ Usage()
Message 7 # "\nAll other options and arguments are passed to gprofng
GUI.\nSee documentations for details.\n"
}
+ShowLogs()
+{
+ if [ -s "$1" ]; then
+ echo "===== /bin/cat -- $1: ======"
+ /bin/cat -- "$1"
+ echo ""
+ fi
+ if [ -s $1.err ]; then
+ echo "===== /bin/cat -- $1.err: ======"
+ /bin/cat -- "$1".err
+ echo ""
+ fi
+}
+
###########################################################################
# main program starts here
@@ -174,7 +188,10 @@ while [ $# -gt 0 ] ; do
jdkhome=$1; # jdk home
;;
-J*) jopt=`expr $1 : '-J\(.*\)'`; jargs="$jargs \"$jopt\"";;
- -v|--verbose) verbose="true";;
+ -v|--verbose)
+ args="$args --verbose"
+ verbose="true"
+ ;;
-V|--version) echo GNU `basename $PRG`: "REPLACE_ME_WITH_VERSION"; exit
0;;
-\?|-h|--help) Usage; exit 0;;
-f|--fontsize)
@@ -291,27 +308,23 @@ export SP_COLLECTOR_FROM_GUI
PID=$$
LOG="${USER_DIR}/an.${PID}.log"
-/bin/rm -f -- "${LOG}"
+/bin/rm -f -- "${LOG}" "${LOG}.err"
gprofng_jar="${GPROFNG_datadir}/gprofng-gui/gprofng-analyzer.jar"
-if [ $verbose = "true" ] ; then
- echo "Run java:"
- echo "'$jdkhome/bin/java' $jargs -jar ${gprofng_jar} $args > ${LOG} 2>&1"
+if [ $verbose = "true" ]; then
+ echo "% '$jdkhome/bin/java' $jargs -jar '${gprofng_jar}' $args >${LOG}
2>${LOG}.err"
# eval "/usr/bin/strace -v -f -t -o ${USER_DIR}/truss.log
'$jdkhome/bin/java'" $jargs -jar ${gprofng_jar} $args
# exit
fi
+eval "'$jdkhome/bin/java'" $jargs -jar "'${gprofng_jar}'" $args >"${LOG}"
2>"${LOG}.err"
+res=$?
-if [ x"${GPROFNG_DEBUG}" == "x" ]; then
- eval "'$jdkhome/bin/java'" $jargs -jar ${gprofng_jar} $args > "${LOG}" 2>&1
- res=$?
-else
- eval "'$jdkhome/bin/java'" $jargs -jar ${gprofng_jar} $args
- res=$?
+if [ $verbose = "true" ]; then
+ ShowLogs "${LOG}"
fi
if [ ${res} -eq 0 ]; then
- /bin/cat -- "${LOG}"
- /bin/rm -f -- "${LOG}"
+ /bin/rm -f -- "${LOG}" "${LOG}.err"
exit ${res}
fi
@@ -324,20 +337,22 @@ if [ ${err} -eq 0 ]; then
err=`/bin/cat -- "${LOG}" | /bin/grep ClassFormatError | wc -l`
if [ ${err} -eq 0 ]; then
# unknown error
- /bin/cat -- "${LOG}"
- /bin/rm -f -- "${LOG}"
+ if [ $verbose != "true" ]; then
+ ShowLogs "${LOG}"
+ fi
+ /bin/rm -f -- "${LOG}" "${LOG}.err"
exit ${res}
fi
Message 27 "$jdkhome/bin/java"
else
Message 22 "$jdkhome/bin/java"
fi
-else
+ else
Message 23 "$jdkhome/bin/java"
fi
Message 24
Message 25
Message 26
-/bin/rm -f -- "${LOG}"
+/bin/rm -f -- "${LOG}" "${LOG}.err"
exit ${res}
diff --git a/org/gprofng/analyzer/AnMain.java b/org/gprofng/analyzer/AnMain.java
index 00a5f52..ec01016 100644
--- a/org/gprofng/analyzer/AnMain.java
+++ b/org/gprofng/analyzer/AnMain.java
@@ -83,6 +83,8 @@ public final class AnMain {
UserPref.dataDirFromCommandLine =
argvOrig.substring(argvOrig.indexOf("=") + 1);
} else if (argvOrig.startsWith("--gprofngdir=")) {
UserPref.gprofngdir = argvOrig.substring(argvOrig.indexOf("=") + 1);
+ } else if (argvOrig.equals("--verbose")) {
+ UserPref.verbose = true;
} else {
argsExp.add(argvOrig);
// This argument is an experiment name, or a name of a binary to
profile
@@ -93,6 +95,11 @@ public final class AnMain {
break;
}
}
+ if (UserPref.verbose) {
+ for (int i = 0; i < args.length; i++) {
+ AnLog.log(String.format("%2d %s", i, args[i]));
+ }
+ }
return argsExp.toArray(new String[argsExp.size()]);
}
diff --git a/org/gprofng/mpmt/Analyzer.java b/org/gprofng/mpmt/Analyzer.java
index 526b698..dcc7ab4 100644
--- a/org/gprofng/mpmt/Analyzer.java
+++ b/org/gprofng/mpmt/Analyzer.java
@@ -151,7 +151,7 @@ public final class Analyzer {
private static String IPC_PROTOCOL = IPCProtocol.IPC_PROTOCOL_STR;
private final String ipc_protocol = IPC_PROTOCOL;
- private static final String DisplayAppName = "gp-display-text";
+ public static final String DisplayAppName = "gp-display-text";
private static final String CollectAppName = "gp-collect-app";
private static final String KernelAppName = "gp-collect-kernel";
@@ -420,6 +420,7 @@ public final class Analyzer {
* @param host
* @param name
* @param p
+ * @param connectCommand
* @param path
*/
public String createNewIPC(
@@ -430,6 +431,12 @@ public final class Analyzer {
String connectCommand,
String path) {
kernelProfilingEnabled = false;
+ AnLog.log("host: " + host);
+ AnLog.log("name: " + name);
+ AnLog.log("p: " + (p == null ? "NULL" : String.valueOf(p)));
+ AnLog.log("connectCommand: " + connectCommand);
+ AnLog.log("path: " + path);
+
fireConnectionStatus(AnChangeEvent.Type.REMOTE_CONNECTION_CHANGING);
stopConnectionManager();
// Destroy old IPC session
@@ -437,7 +444,6 @@ public final class Analyzer {
IPC new_IPC_session = IPC_session;
IPC_session = old_IPC_session;
setIPCStarted(old_IPC_status);
- // win.QUIT();
old_IPC_session.destroyIPCProc();
IPC_session = new_IPC_session;
}
@@ -445,31 +451,31 @@ public final class Analyzer {
old_IPC_session = IPC_session;
old_IPC_status = IPC_started;
IPC newIPC = new IPC(this);
- String str_gp_display_text = "gp-display-text";
- String path_to_er_print = str_gp_display_text;
+ String path_to_er_print = DisplayAppName;
String l_fdhome = emptyString;
if (null != path) {
l_fdhome = path.trim();
if (l_fdhome.length() > 0) {
if (!l_fdhome.equals(path_to_er_print)) {
- if (l_fdhome.endsWith("/" + str_gp_display_text)) {
+ if (l_fdhome.endsWith("/" + DisplayAppName)) {
path_to_er_print = l_fdhome;
+ } else if (l_fdhome.endsWith("/bin/")) {
+ path_to_er_print = l_fdhome + DisplayAppName;
+ } else if (l_fdhome.endsWith("/bin")) {
+ path_to_er_print = l_fdhome + "/" + DisplayAppName;
+ } else if (l_fdhome.endsWith("/")) {
+ path_to_er_print = l_fdhome + "bin/" + DisplayAppName;
} else {
- if (l_fdhome.endsWith("/bin") || l_fdhome.endsWith("/bin/")) {
- path_to_er_print = l_fdhome + "/" + str_gp_display_text;
- } else {
- path_to_er_print = l_fdhome + "/bin/" + str_gp_display_text;
- }
+ path_to_er_print = l_fdhome + "/bin/" + DisplayAppName;
}
}
}
- System.out.println("path: " + path);
+ AnLog.log("path: " + path);
}
- System.out.println("l_fdhome: " + l_fdhome);
- System.out.println("str_gp_display_text: " + str_gp_display_text);
- String str_collect = "gp-collect-app";
- int i = path_to_er_print.lastIndexOf(str_gp_display_text);
- String path_to_collect = path_to_er_print.substring(0, i) + str_collect;
+ AnLog.log("l_fdhome: " + l_fdhome);
+ AnLog.log("str_gp_display_text: " + DisplayAppName);
+ int i = path_to_er_print.lastIndexOf(DisplayAppName);
+ String path_to_collect = path_to_er_print.substring(0, i) + CollectAppName;
String er_printCmd = path_to_er_print;
String rc = null;
String emsg = null;
@@ -512,7 +518,7 @@ public final class Analyzer {
}
// Initialize new IPC connection - start gp-display-text
try {
- System.out.println("Start connection:\n" + er_printCmd);
+ AnLog.log("Start connection:\n" + er_printCmd);
newIPC.init(er_printCmd, false);
sendP(newIPC, p, cc);
er_print = path_to_er_print;
@@ -523,7 +529,6 @@ public final class Analyzer {
}
newIPC.getIPCReader().runThread(); // TEMPORARY FOR DEBUG
- AnWindow win = AnWindow.getInstance();
if (IPC_started) { // see newinit()
// AnFrame if fully initialized
try {
@@ -545,7 +550,6 @@ public final class Analyzer {
// Could not establish new connection
IPC_session = old_IPC_session;
setIPCStarted(old_IPC_status);
- // win.QUIT();
newIPC.destroyIPCProc();
fireConnectionStatus(AnChangeEvent.Type.REMOTE_CONNECTION_CANCELLED_OR_FAILED);
return (emsg);
@@ -645,7 +649,6 @@ public final class Analyzer {
// Restore old IPC_session
IPC_session = old_IPC_session;
setIPCStarted(old_IPC_status);
- // win.QUIT();
newIPC.destroyIPCProc();
fireConnectionStatus(AnChangeEvent.Type.REMOTE_CONNECTION_CANCELLED_OR_FAILED);
return (emsg);
@@ -663,7 +666,6 @@ public final class Analyzer {
fireConnectionStatus(AnChangeEvent.Type.REMOTE_CONNECTION_CANCELLED_OR_FAILED);
return AnLocale.getString("Initialization failed");
}
- win = AnWindow.getInstance();
if (cc.cancelRequest) {
emsg = AnLocale.getString("Connection canceled");
}
@@ -674,7 +676,6 @@ public final class Analyzer {
// Could not establish new connection
IPC_session = old_IPC_session;
setIPCStarted(old_IPC_status);
- // win.QUIT();
newIPC.destroyIPCProc();
fireConnectionStatus(AnChangeEvent.Type.REMOTE_CONNECTION_CANCELLED_OR_FAILED);
return (emsg);
@@ -782,6 +783,7 @@ public final class Analyzer {
while (c-- > 0) {
Thread.sleep(100);
ask = ipc.getIPCReader().getUnknownInput();
+ AnLog.log(String.format("connectionID=%d Timestamp=%ld ask=%s;\n", ts));
if (ask.contains(pattern2)) {
break;
}
@@ -1810,29 +1812,14 @@ public final class Analyzer {
licsts = license_info[0];
fdversion = license_info[1];
- String oldVersion = "Sun Analyzer";
- String temporaryNewVersion = getAnalyzerReleaseName();
- if ((null != fdversion) && (fdversion.startsWith(oldVersion))) {
- int c1 = oldVersion.length();
- fdversion = temporaryNewVersion + fdversion.substring(c1);
- }
-
- if (licsts.equals("ERROR")) {
- emsg =
- AnLocale.getString("License Path: ")
- + licpath
- + "\n"
- + AnLocale.getString("Error: ")
- + fdversion;
+ if (licsts.equals("ERROR") || licsts.equals("FATAL")) {
+ emsg = String.format(AnLocale.getString("License Path: %s\nError: %s"),
+ licpath, fdversion);
System.err.println(emsg);
System.exit(1);
- } else if (licsts.equals("WARN") || licsts.equals("FATAL")) {
- emsg =
- AnLocale.getString("License Path: ")
- + licpath
- + "\n"
- + AnLocale.getString("Warning: ")
- + fdversion;
+ } else if (licsts.equals("WARN")) {
+ emsg = String.format(AnLocale.getString("License Path: %s\nWarning: %s"),
+ licpath, fdversion);
System.err.println(emsg);
}
if (IPC_started) {
diff --git a/org/gprofng/mpmt/persistence/UserPref.java
b/org/gprofng/mpmt/persistence/UserPref.java
index 61e425b..649818f 100644
--- a/org/gprofng/mpmt/persistence/UserPref.java
+++ b/org/gprofng/mpmt/persistence/UserPref.java
@@ -104,7 +104,6 @@ public class UserPref {
}
private static UserPref instance = null;
- private static final String THA_INIT_FILE = "tha.xml";
private static final String ANALYZER_INIT_FILE = "analyzer.xml";
/* Update OldUserDirs with old user dirs it should search for settings */
private static final String UserDir = ".gprofng/gui";
@@ -121,8 +120,8 @@ public class UserPref {
public static String binDirFromCommandLine = null;
public static String dataDirFromCommandLine = null;
public static String gprofngdir = null; // Where gp-display-text is
installed
-
- private static long threeMonth = 90l * 24l * 3600l * 1000l; // 3 month
+ public static boolean verbose = false;
+ private static final long threeMonth = 90l * 24l * 3600l * 1000l; // 3 month
private int version;
@@ -132,11 +131,11 @@ public class UserPref {
// System settings
private Dimension frameSize;
private Point frameLocation;
- private SplitPaneFixedRightSizeProp splitPane1 = new
SplitPaneFixedRightSizeProp(375);
- private SplitPaneFixedRightSizeProp splitPane2 = new
SplitPaneFixedRightSizeProp(160);
- private SplitPaneFixedRightSizeProp splitPane3 =
+ private final SplitPaneFixedRightSizeProp splitPane1 = new
SplitPaneFixedRightSizeProp(375);
+ private final SplitPaneFixedRightSizeProp splitPane2 = new
SplitPaneFixedRightSizeProp(160);
+ private final SplitPaneFixedRightSizeProp splitPane3 =
new SplitPaneFixedRightSizeProp(getDefaultSplitPane3RightSize());
- private SplitPaneFixedRightSizeProp navigationFilterSplitPane =
+ private final SplitPaneFixedRightSizeProp navigationFilterSplitPane =
new SplitPaneFixedRightSizeProp(160);
private Integer navigationPanelDividerPosition;
private ExperimentPickLists experimentsPicklists;
diff --git a/org/gprofng/mpmt/remote/ConnectionDialog.java
b/org/gprofng/mpmt/remote/ConnectionDialog.java
index 689772c..6fc2afd 100644
--- a/org/gprofng/mpmt/remote/ConnectionDialog.java
+++ b/org/gprofng/mpmt/remote/ConnectionDialog.java
@@ -252,22 +252,26 @@ public final class ConnectionDialog extends AnDialog
implements ItemListener {
p = null;
}
*/
- String connectCommand = connectCommandTextField.getText();
- if ((connectCommand == null) || (connectCommand.length() < 1)) {
+ String connectCommand = connectCommandTextField.getText().trim();
+ if (connectCommand.length() < 1) {
return (AnLocale.getString("Error: connection command is not
specified."));
}
- String path = solstudioPathTextField.getText();
- if (path != null) {
- path = path.trim();
- }
- if ((path == null) || (path.length() < 1)) {
+ connectCommand += " -o PasswordAuthentication=no " +
+ "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no";
+ String path = solstudioPathTextField.getText().trim();
+ if (path.length() < 1) {
return (AnLocale.getString("Error: remote gprofng path is not
specified."));
}
- if (!path.endsWith("gp-display-text")) {
- if (path.endsWith("bin") || path.endsWith("bin/")) {
- path = path + "/gp-display-text";
+ String appName = Analyzer.DisplayAppName;
+ if (!path.endsWith("/" + appName)) {
+ if (path.endsWith("/bin")) {
+ path = path + "/" + appName;
+ } else if (path.endsWith("/bin/")) {
+ path = path + appName;
+ } else if (path.endsWith("/")) {
+ path = path + "bin/" + appName;
} else {
- path = path + "/bin/gp-display-text";
+ path = path + "/bin/" + appName;
}
}
window.getAnalyzer().remoteGprofngPath = path.substring(0, path.length()
- 16);
--
2.43.5
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Fix remote connection issue,
vladimir . mezentsev <=