-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
217d14d
commit 3311834
Showing
15 changed files
with
372 additions
and
1 deletion.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE HTML><html lang="en"><head> | ||
<meta charset="UTF-8"> | ||
<title>DiDAP Job Monitor</title> | ||
</head> | ||
<body> | ||
<p> | ||
<h2>DiDAP Job Monitor</h2> | ||
<ul> | ||
<li><a href="HelloWorldExample">Hello World Servlet</a></li> | ||
<li><a href="MSTIFF">Compile and Run MSTIFF Extraction Code</a></li> | ||
</ul> | ||
</body></html> | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.util.ResourceBundle; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
public class HelloWorld extends HttpServlet { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public void doGet(HttpServletRequest request, | ||
HttpServletResponse response) | ||
throws IOException, ServletException | ||
{ | ||
response.setContentType("text/html"); | ||
response.setCharacterEncoding("UTF-8"); | ||
PrintWriter out = response.getWriter(); | ||
|
||
out.println("<!DOCTYPE html><html>"); | ||
out.println("<head>"); | ||
out.println("<meta charset=\"UTF-8\" />"); | ||
|
||
String title = "Hello, World!"; | ||
|
||
out.println("<title>" + title + "</title>"); | ||
out.println("</head>"); | ||
out.println("<body bgcolor=\"white\">"); | ||
|
||
out.println("<h1>" + title + "</h1>"); | ||
out.println("</body>"); | ||
out.println("</html>"); | ||
} | ||
} | ||
|
||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.io.BufferedReader; | ||
import java.io.InputStreamReader; | ||
import java.util.ResourceBundle; | ||
import java.util.Arrays; | ||
|
||
import java.sql.SQLException; | ||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.Statement; | ||
import java.sql.DriverManager; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
public class MetadataTableCreation extends HttpServlet { | ||
private Connection conn; | ||
private Statement stmt; | ||
private boolean connEstablished = false; | ||
private PrintWriter out; | ||
|
||
public void DBinit() { | ||
if (!connEstablished) { | ||
try { | ||
// Register driver and create driver instance | ||
String driverName = "com.cloudera.hive.jdbc4.HS1Driver"; | ||
Class.forName(driverName); | ||
} catch (ClassNotFoundException e) { | ||
e.printStackTrace(out); | ||
System.exit(1); | ||
} | ||
|
||
try { | ||
// Establish connection | ||
String url = "jdbc:hive://localhost:10000/metadata"; | ||
conn = DriverManager.getConnection(url, "", ""); | ||
out.println("Connected to Database!"); | ||
|
||
// Create statement | ||
stmt = conn.createStatement(); | ||
connEstablished = true; | ||
} catch (SQLException e) { | ||
e.printStackTrace(out); | ||
System.exit(1); | ||
} | ||
} | ||
} | ||
|
||
public void createTable(String tableName) { | ||
if (connEstablished) { | ||
try { | ||
String query = ""; | ||
// create hive table statement | ||
query = "CREATE EXTERNAL TABLE IF NOT EXISTS " + tableName | ||
+ " (filePath STRING, dateStamp INT,navTime STRING,FathTime STRING,latitude DOUBLE,longitude DOUBLE,waterDepth FLOAT,towfishDepth FLOAT)" | ||
+ "ROW FORMAT DELIMITED" | ||
+ "FIELDS TERMINATED BY ','" | ||
+ "STORED AS TEXTFILE" | ||
+ "LOCATION '/user/cloudera/successfulOutput_fullScript'"; | ||
out.println("Your query:" + query); | ||
stmt.executeQuery(query); // executeUpdate | ||
} catch (SQLException e) { | ||
e.printStackTrace(); | ||
out.println("Query Failed!!"); | ||
} | ||
} | ||
} | ||
|
||
public void DBExecuteQuery(String query) { | ||
if (connEstablished) { | ||
try { | ||
out.println("Running: " + query); | ||
stmt.execute(query); | ||
out.println("Finished!"); | ||
} catch (SQLException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
public void DBfinish() { | ||
if (connEstablished) { | ||
out.println("Connection Closed."); | ||
try { | ||
stmt.close(); | ||
conn.close(); | ||
connEstablished = false; | ||
} catch (SQLException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void doGet(HttpServletRequest request, | ||
HttpServletResponse response) | ||
throws IOException, ServletException | ||
{ | ||
response.setContentType("text/html"); | ||
response.setCharacterEncoding("UTF-8"); | ||
out = response.getWriter(); | ||
|
||
out.println("<!DOCTYPE html><html>"); | ||
out.println("<head>"); | ||
out.println("<meta charset=\"UTF-8\" />"); | ||
|
||
String title = "Metadata Table Creation"; | ||
|
||
out.println("<title>" + title + "</title>"); | ||
out.println("</head>"); | ||
|
||
out.println("<body bgcolor=\"white\">"); | ||
|
||
out.println("<h1>" + title + " Status:</h1>\n"); | ||
out.println("Metadata Table Data Being Loaded from HDFS:"); | ||
|
||
// Create DB Connection | ||
DBinit(); | ||
|
||
// Create Actual Table | ||
//createTable("florida"); | ||
|
||
// Display HDFS Data | ||
String query = "LOAD DATA INPATH '/user/cloudera/successfulOutput_fullScript/part-m-00000' OVERWRITE INTO TABLE florida"; | ||
DBExecuteQuery(query); | ||
|
||
out.println("</body>"); | ||
out.println("</html>"); | ||
|
||
// Close DB Connection | ||
DBfinish(); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.io.BufferedReader; | ||
import java.io.InputStreamReader; | ||
import java.util.ResourceBundle; | ||
import java.util.Arrays; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
public class MstiffExtraction extends HttpServlet { | ||
|
||
@Override | ||
public void doGet(HttpServletRequest request, | ||
HttpServletResponse response) | ||
throws IOException, ServletException | ||
{ | ||
response.setContentType("text/html"); | ||
response.setCharacterEncoding("UTF-8"); | ||
PrintWriter out = response.getWriter(); | ||
|
||
out.println("<!DOCTYPE html><html>"); | ||
out.println("<head>"); | ||
out.println("<meta charset=\"UTF-8\" />"); | ||
|
||
String title = "MSTIFF Extraction"; | ||
|
||
out.println("<title>" + title + "</title>"); | ||
out.println("</head>"); | ||
out.println("<body bgcolor=\"white\">"); | ||
|
||
out.println("<h1>" + title + " Job Status:</h1>\n"); | ||
|
||
String[] command = {"/bin/bash", "/usr/share/tomcat/webapps/didap/WEB-INF/scripts/mstiff.sh"}; | ||
ProcessBuilder p = new ProcessBuilder(command); | ||
Process p2 = p.start(); | ||
try { | ||
p2.waitFor(); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
System.out.println("Did not execute in hadoop!"); | ||
} | ||
|
||
BufferedReader br = new BufferedReader(new InputStreamReader(p2.getInputStream())); | ||
String line; | ||
|
||
out.println("Output of running " + Arrays.toString(command) + " is: "); | ||
while ((line = br.readLine()) != null) { | ||
out.println(line + "\n"); | ||
} | ||
|
||
out.println("</body>"); | ||
out.println("</html>"); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
su cloudera <<! | ||
cloudera | ||
javac -cp /usr/lib/hadoop/*:/usr/lib/hadoop/client-0.20/* -d /home/cloudera/MSTIFF_Code /home/cloudera/MSTIFF_Code/GET_MST_mod.java | ||
jar -cvf GET_MST_mod.jar -C /home/cloudera/MSTIFF_Code/ . | ||
# move JAR File to specified directory on the vm | ||
mv GET_MST_mod.jar /home/cloudera/MSTIFF_Code | ||
#su cloudera <<! | ||
#cloudera | ||
#chown cloudera:cloudera /home/cloudera/MSTIFF_Code/GET_MST_MOD.jar | ||
#echo $? | ||
#chmod ug+rw /home/cloudera/MSTIFF_Code/GET_MST_MOD.jar | ||
#echo $? | ||
#! | ||
hadoop jar /home/cloudera/MSTIFF_Code/GET_MST_mod.jar GET_MST_mod /user/cloudera/MSTIFF_Code /user/cloudera/successfulOutput1 | ||
echo $? | ||
#! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
javac -cp /usr/lib/hadoop/*:/usr/lib/hadoop/client-0.20/* -d /home/cloudera/MSTIFF_Code /home/cloudera/MSTIFF_Code/GET_MST_mod.java & jar -cvf GET_MST_mod.jar -C /home/cloudera/MSTIFF_Code/ . | ||
|
||
hadoop jar /home/cloudera/GET_MST_mod.jar GET_MST_mod /user/cloudera/MSTIFF_Code /user/cloudera/successfulOutput_fullScript | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<web-app> | ||
<servlet> | ||
<servlet-name>HelloWorld</servlet-name> | ||
<servlet-class>HelloWorld</servlet-class> | ||
</servlet> | ||
<servlet> | ||
<servlet-name>MetadataTableCreation</servlet-name> | ||
<servlet-class>MetadataTableCreation</servlet-class> | ||
</servlet> | ||
<servlet> | ||
<servlet-name>MSTIFF_Extraction</servlet-name> | ||
<servlet-class>MstiffExtraction</servlet-class> | ||
</servlet> | ||
<servlet-mapping> | ||
<servlet-name>HelloWorld</servlet-name> | ||
<url-pattern>/HelloWorld</url-pattern> | ||
</servlet-mapping> | ||
<servlet-mapping> | ||
<servlet-name>MetadataTableCreation</servlet-name> | ||
<url-pattern>/MetadataTableCreation</url-pattern> | ||
</servlet-mapping> | ||
<servlet-mapping> | ||
<servlet-name>MSTIFF_Extraction</servlet-name> | ||
<url-pattern>/MSTIFF_Extraction</url-pattern> | ||
</servlet-mapping> | ||
</web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<web-app> | ||
<servlet> | ||
<servlet-name>HelloWorld</servlet-name> | ||
<servlet-class>HelloWorld</servlet-class> | ||
</servlet> | ||
<servlet> | ||
<servlet-name>MetadataTableCreation</servlet-name> | ||
<servlet-class>MetadataTableCreation</servlet-class> | ||
</servlet> | ||
<servlet> | ||
<servlet-name>MSTIFF_Extraction</servlet-name> | ||
<servlet-class>MstiffExtraction</servlet-class> | ||
</servlet> | ||
<servlet-mapping> | ||
<servlet-name>HelloWorld</servlet-name> | ||
<url-pattern>/HelloWorld</url-pattern> | ||
</servlet-mapping> | ||
<servlet-mapping> | ||
<servlet-name>MetadataTableCreation</servlet-name> | ||
<url-pattern>/MetadataTableCreation</url-pattern> | ||
</servlet-mapping> | ||
<servlet-mapping> | ||
<servlet-name>MSTIFF_Extraction</servlet-name> | ||
<url-pattern>/MSTIFF_Extraction</url-pattern> | ||
</servlet-mapping> | ||
</web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<web-app> | ||
<servlet> | ||
<servlet-name>HelloWorld</servlet-name> | ||
<servlet-class>HelloWorld</servlet-class> | ||
</servlet> | ||
<servlet> | ||
<servlet-name>MSTIFF_Extraction</servlet-name> | ||
<servlet-class>MstiffExtraction</servlet-class> | ||
</servlet> | ||
<servlet-mapping> | ||
<servlet-name>HelloWorld</servlet-name> | ||
<url-pattern>/HelloWorld</url-pattern> | ||
</servlet-mapping> | ||
<servlet-mapping> | ||
<servlet-name>MSTIFF_Extraction</servlet-name> | ||
<url-pattern>/MSTIFF_Extraction</url-pattern> | ||
</servlet-mapping> | ||
</web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE HTML><html lang="en"><head> | ||
<meta charset="UTF-8"> | ||
<title>DiDAP Job Monitor</title> | ||
</head> | ||
<body> | ||
<p> | ||
<h2>DiDAP Job Monitor</h2> | ||
<ul> | ||
<li><a href="MetadataTableCreation">Moving Extracted Data to Hive</a></li> | ||
<li><a href="MSTIFF_Extraction">Compile and Run MSTIFF Extraction Code</a></li> | ||
</ul> | ||
</body></html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE HTML><html lang="en"><head> | ||
<meta charset="UTF-8"> | ||
<title>DiDAP Job Monitor</title> | ||
</head> | ||
<body> | ||
<p> | ||
<h2>DiDAP Job Monitor</h2> | ||
<ul> | ||
<li><a href="MetadataTableCreation">Moving Extracted Data to Hive</a></li> | ||
<li><a href="MSTIFF_Extraction">Compile and Run MSTIFF Extraction Code</a></li> | ||
</ul> | ||
</body></html> | ||
|