Skip to content

Commit

Permalink
Replace "remote process" with "target process" to avoid confusion, be…
Browse files Browse the repository at this point in the history
…cause the process should be in the same machine with the Scalive process
  • Loading branch information
ngocdaothanh committed Aug 6, 2016
1 parent 127f9f4 commit 530b59f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ import mylib.foo.Bar
Scalive uses the [Attach API](https://blogs.oracle.com/CoreJavaTechTips/entry/the_attach_api) in Java 6
to tell the target process to load an [agent](http://javahowto.blogspot.jp/2006/07/javaagent-option.html).

The agent then creates a REPL interpreter and a TCP server to let the
Scalive process interact with the interpreter remotely. The Scalive
process acts as a client.
Inside the target progress, the agent creates a REPL interpreter and a
TCP server to let the Scalive process connect and interact with the
interpreter. The Scalive process acts as a TCP client. There are 2 TCP
connections, one for REPL data and one for completion data.

Similar projects:

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/scalive/Net.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class Net {
// After this time, the REPL and completer connections should be closed,
// to avoid blocking socket reads to infinitely block threads created by Scalive in remote process
// to avoid blocking socket reads to infinitely block threads created by Scalive in target process
private static final int LONG_INACTIVITY = (int) TimeUnit.HOURS.toMillis(1);

public static final InetAddress LOCALHOST = getLocalHostAddress();
Expand All @@ -25,7 +25,7 @@ public static int getLocalFreePort() throws Exception {

/**
* {@link SocketTimeoutException} will be thrown if there's no activity for a long time.
* This is to avoid blocking reads to block threads infinitely, causing leaks in the remote process.
* This is to avoid blocking reads to block threads infinitely, causing leaks in the target process.
*/
public static void throwSocketTimeoutExceptionForLongInactivity(Socket socket) throws SocketException {
socket.setSoTimeout(LONG_INACTIVITY);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/scalive/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

class Client {
static void run(int port) throws Exception {
Log.log("Attach to remote process at port " + port);
Log.log("Attach to target process at port " + port);
final Socket replSocket = new Socket(Net.LOCALHOST, port);
final Socket completerSocket = new Socket(Net.LOCALHOST, port);

// Try to notify the remote process to clean up when the client is terminated
// Try to notify the target process to clean up when the client is terminated
final Runnable socketCleaner = Net.getSocketCleaner(replSocket, completerSocket);
Runtime.getRuntime().addShutdownHook(new Thread(Client.class.getName() + "-ShutdownHook") {
@Override
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/scalive/client/Repl.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ private static void printServerOutput(InputStream in) throws UnsupportedEncoding
System.out.flush();
}

// The loop above is broken when REPL is closed by the remote process;
// exit now
// The loop above is broken when REPL is closed by the target process; exit now
System.exit(0);
}
}
2 changes: 1 addition & 1 deletion src/main/java/scalive/server/Completer.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void run(

socketCleaner.run();

// Before logging this out, wait a litte for System.out to be restored back to the remote process
// Before logging this out, wait a litte for System.out to be restored back to the target process
Thread.sleep(1000);
Log.log("Completer closed");
}
Expand Down

0 comments on commit 530b59f

Please sign in to comment.