How to access to the remote server via ssh browser on GCP
- Go to GCP console, and login with jarvan-experiment Google account.
- On the navigation panel on the left side, select
Compute EngineunderVIRTUAL MACHINESmenu, selectVM instances. - You will see
jarvan-exp-1machine. On the connect column select the drop down arrow and selectOpen in browser window - There you go, you will have the access to the remote server.
How to use MySQL server on the remote server
- On the remote server, use command
mysql -u root -p. - You will be asked for a password. Please use the password provided in order to access to the MySQL server.
- After that you will be allowed to access to MySQL server as root.
- There is only one database available which is
sotorrent. Please useuse sotorrentcommand to select the database. - There are two data tables available in the database which are
PostBlockVersionandPostBlockDiff. - You may use SQL command to query for data such as
select,insert,deleteetc.
How to compile and run Java program on the remote server
- On the remote server, the Java program is located in
/StackOverflowStudy/SOTOrrentAnalyzer/. You may run this commandcd StackOverflowStudy/SOTOrrentAnalyzer/to change directory to here. - There will be several java files, but there is only one with the main class for running which is
PostBlockProcessor.java. - Run the following command to compile the java program
javac PostBlockProcessor.java. You may need to change the location of the SO answer file in the code. - Add the MySQL connector to the Java CLASSPATH
export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java-8.0.27.jar. - In the
PostBlockProcessor.javafile, in line 84-95 are the options where you may select the program to do. There are 4 options currently. You may find what they can do in the file. - Run the following command to execute the java program
java PostBlockProcessor.
Diff File Naming Convention
For diff files, there is a pattarn of file naming which is PostId-PostHistoryId-LocalId-CurrentPostBlockId-PreviousPostBlockId-PostBlockTypeId.txt where PostBlockTypeId can be either 0 or 1, 0 is Text block and 1 is Code block.
Remark: Sometimes, you may encounter error while compiling the Java program. The error is that the compiler cannot find .jar for SQL. Please run this command export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar to bypass the error.