Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge UI Branch #1

Merged
merged 32 commits into from
Feb 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3e568ec
ui initial commit
haoyuan Feb 9, 2013
580d2f6
Initial UI modifications
calvinjia Feb 10, 2013
22343a5
Experimenting with servlets
calvinjia Feb 11, 2013
1db614e
Embedded Jetty with servlets.
calvinjia Feb 11, 2013
6762a3a
twitter bootstrap resources
calvinjia Feb 11, 2013
cf3e3a8
moved around some files
calvinjia Feb 11, 2013
fd911ef
Reverting to working model.
calvinjia Feb 11, 2013
fe30181
Changed jetty version to 7.6.9, added jetty security and webapp libra…
calvinjia Feb 16, 2013
40abb92
some filekeeping and the base for the browse.jsp page
calvinjia Feb 16, 2013
5f1e170
Starting to populate fields
calvinjia Feb 16, 2013
d9c154c
Resolve the merge confict.
haoyuan Feb 19, 2013
e694987
Adding file system browsing servlet and page, updating general info page
calvinjia Feb 19, 2013
742e53c
merge conflict
calvinjia Feb 20, 2013
a221b12
Fix the build and a big.
haoyuan Feb 20, 2013
335d524
Merge branch 'master' into ui
haoyuan Feb 20, 2013
22ba4fe
Merge branch 'master' into ui
haoyuan Feb 20, 2013
f93a5a5
populated some more fields
calvinjia Feb 20, 2013
14e937b
Merge branch 'master' into ui
haoyuan Feb 20, 2013
abf3aef
removed mortbay plugin
calvinjia Feb 21, 2013
dd50352
Format the code a bit.
haoyuan Feb 21, 2013
4bf5263
Changed jetty version to 8.1.9, added JSTL libraries, completed basic…
calvinjia Feb 22, 2013
1f9c507
Merge branch 'master' into ui
haoyuan Feb 22, 2013
2a1c9e1
Changed mortbay library to the eclipse version and added glassfish, c…
calvinjia Feb 22, 2013
900a69d
Merge branch 'ui' of https://github.com/amplab/tachyon into ui
calvinjia Feb 22, 2013
829afd9
merge
haoyuan Feb 22, 2013
35fc4fa
Added debugging in UI, fixed bugs in browsing file system
calvinjia Feb 22, 2013
83f0ad0
tune.
haoyuan Feb 23, 2013
0aca698
Merge branch 'master' into ui
haoyuan Feb 24, 2013
6c2f59f
remove .class from .gitignore. remove unnecessary plugin from pom.xml
haoyuan Feb 24, 2013
101128c
Clean UI branch for merging it back to the master branch.
haoyuan Feb 24, 2013
4a0c8f4
tune ui
haoyuan Feb 25, 2013
143a18e
put jquery locally to avoid long timeout if the system is not connect…
haoyuan Feb 25, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ data/
logs/
src/main/java/tachyon/thrift
tachyon.iml
target/
target/
52 changes: 41 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,53 @@
<hadoop.version>0.20.205.0</hadoop.version>
<libthrift.version>0.7.0</libthrift.version>
<cxf.version>2.7.0</cxf.version>
<jetty.version>7.5.3.v20111011</jetty.version>
<jetty.version>8.1.9.v20130131</jetty.version>
</properties>

<repositories>
</repositories>

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp-2.1</artifactId>
<version>7.5.4.v20111024</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jsp-impl</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -45,16 +85,6 @@
<artifactId>hadoop-core</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/tachyon/CommonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import tachyon.thrift.InvalidPathException;

/**
* Utility class shared by all components of the system.
*
Expand Down Expand Up @@ -55,13 +57,13 @@ public static String cleanPath(String path) {
return path;
}

public static String convertMillis(long Millis) {
public static String convertMsToClockTime(long Millis) {
return String.format("%d hour(s), %d minute(s), and %d second(s)",
Millis / (1000L * 60 * 60), (Millis % (1000L * 60 * 60)) / (1000 * 60),
(Millis % (1000L * 60)) / 1000);
}

public static String convertMillisToDate(long Millis) {
public static String convertMsToDate(long Millis) {
DateFormat formatter = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss:SSS");
return formatter.format(new Date(Millis));
}
Expand Down Expand Up @@ -274,4 +276,11 @@ public static String[] toStringArray(ArrayList<String> src) {
String[] ret = new String[src.size()];
return src.toArray(ret);
}

public static void validatePath(String path) throws InvalidPathException {
if (path == null || !path.startsWith(Config.SEPARATOR) ||
(path.length() > 1 && path.endsWith(Config.SEPARATOR))) {
throw new InvalidPathException("Path " + path + " is invalid.");
}
}
}
1 change: 1 addition & 0 deletions src/main/java/tachyon/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class Config {
public static final boolean USING_HDFS;

public static final int MAX_COLUMNS = 100;
public static final String SEPARATOR = "/";

public static final ArrayList<String> WHITELIST = new ArrayList<String>();
public static final ArrayList<String> PINLIST = new ArrayList<String>();
Expand Down
27 changes: 24 additions & 3 deletions src/main/java/tachyon/Master.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tachyon;

import java.io.File;
import java.net.InetSocketAddress;

import org.apache.thrift.server.THsHaServer;
Expand All @@ -9,6 +10,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.webapp.WebAppContext;

import tachyon.thrift.MasterService;

/**
Expand All @@ -30,12 +37,26 @@ private Master(InetSocketAddress address, int selectorThreads, int acceptQueueSi
int workerThreads) {
try {
mMasterInfo = new MasterInfo(address);

mWebServer = new WebServer("Tachyon Master Server",
new InetSocketAddress(address.getHostName(), Config.MASTER_WEB_PORT));
mWebServer.setHandler(new WebServerMasterHandler(mMasterInfo));

WebAppContext webappcontext = new WebAppContext();

webappcontext.setContextPath("/");
File warPath = new File(new File("").getAbsolutePath(), "src/main/java/tachyon/webapps");
webappcontext.setWar(warPath.getAbsolutePath());
HandlerList handlers = new HandlerList();
webappcontext.addServlet(
new ServletHolder(new WebInterfaceGeneralServlet(mMasterInfo)), "/home");
webappcontext.addServlet(
new ServletHolder(new WebInterfaceBrowseServlet(mMasterInfo)), "/browse");

handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
mWebServer.setHandler(handlers);

mWebServer.startWebServer();

mMasterServiceHandler = new MasterServiceHandler(mMasterInfo);
MasterService.Processor<MasterServiceHandler> processor =
new MasterService.Processor<MasterServiceHandler>(mMasterServiceHandler);
Expand Down
40 changes: 23 additions & 17 deletions src/main/java/tachyon/MasterInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
* @author Haoyuan Li [email protected]
*/
public class MasterInfo {
public static final String SEPARATOR = "/";
public static final String COL = "COL_";

private final Logger LOG = LoggerFactory.getLogger(MasterInfo.class);
Expand Down Expand Up @@ -226,7 +225,7 @@ public int createRawTable(String path, int columns, List<Byte> metadata)
int id = createFile(path, true, columns, metadata);

for (int k = 0; k < columns; k ++) {
createFile(path + SEPARATOR + COL + k, true);
createFile(path + Config.SEPARATOR + COL + k, true);
}

return id;
Expand Down Expand Up @@ -272,7 +271,6 @@ public List<ClientFileInfo> getFilesInfo(String path)
throw new FileDoesNotExistException(path);
}

ret.add(getClientFileInfo(inode.getId()));
if (inode.isDirectory()) {
List<Integer> childernIds = ((InodeFolder) inode).getChildrenIds();

Expand All @@ -284,11 +282,22 @@ public List<ClientFileInfo> getFilesInfo(String path)
ret.add(getClientFileInfo(k));
}
}
} else {
ret.add(getClientFileInfo(inode.getId()));
}

return ret;
}

public ClientFileInfo getFileInfo(String path)
throws FileDoesNotExistException, InvalidPathException {
Inode inode = getInode(path);
if (inode == null) {
throw new FileDoesNotExistException(path);
}
return getClientFileInfo(inode.getId());
}

public void delete(int id) {
LOG.info("delete(" + id + ")");
// Only remove meta data from master. The data in workers will be evicted since no further
Expand Down Expand Up @@ -367,21 +376,14 @@ private Inode getInode(String[] pathNames) throws InvalidPathException {
}
}

private static void validatePath(String path) throws InvalidPathException {
if (path == null || !path.startsWith(SEPARATOR) ||
(path.length() > 1 && path.endsWith(SEPARATOR))) {
throw new InvalidPathException("Path " + path + " is invalid.");
}
}

private static String[] getPathNames(String path) throws InvalidPathException {
validatePath(path);
if (path.length() == 1 && path.equals(SEPARATOR)) {
CommonUtils.validatePath(path);
if (path.length() == 1 && path.equals(Config.SEPARATOR)) {
String[] ret = new String[1];
ret[0] = "";
return ret;
}
return path.split(SEPARATOR);
return path.split(Config.SEPARATOR);
}

private void writeCheckpoint() {
Expand Down Expand Up @@ -472,7 +474,7 @@ private void recoveryFromLog() {
public String toHtml() {
long timeMs = System.currentTimeMillis() - START_TIME_MS;
StringBuilder sb = new StringBuilder("<h1> Tachyon has been running @ " + MASTER_ADDRESS +
" for " + CommonUtils.convertMillis(timeMs) + " </h1> \n");
" for " + CommonUtils.convertMsToClockTime(timeMs) + " </h1> \n");

sb.append(mWhiteList.toHtml("WhiteList"));

Expand Down Expand Up @@ -513,7 +515,7 @@ private int generateFileNamesForHtml(String curPath, Inode inode, StringBuilder
if (inode.isDirectory()) {
List<Integer> childrenIds = ((InodeFolder) inode).getChildrenIds();
if (inode.getId() != 1) {
curPath += SEPARATOR;
curPath += Config.SEPARATOR;
}
for (int id : childrenIds) {
int t = generateFileNamesForHtml(curPath, mInodes.get(id), sb, cnt);
Expand Down Expand Up @@ -715,9 +717,9 @@ private String getPath(Inode inode) {
return "/";
}
if (inode.getParentId() == 1) {
return SEPARATOR + inode.getName();
return Config.SEPARATOR + inode.getName();
}
return getPath(mInodes.get(inode.getParentId())) + SEPARATOR + inode.getName();
return getPath(mInodes.get(inode.getParentId())) + Config.SEPARATOR + inode.getName();
}
}

Expand Down Expand Up @@ -897,6 +899,10 @@ public long registerWorker(NetAddress workerNetAddress, long totalBytes,
return id;
}

public long getStarttimeMs() {
return START_TIME_MS;
}

public int getNumberOfFiles(String path) throws InvalidPathException, FileDoesNotExistException {
Inode inode = getInode(path);
if (inode == null) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/tachyon/MasterServiceHandler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tachyon;

import java.nio.ByteBuffer;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -199,4 +198,4 @@ public long worker_register(NetAddress workerNetAddress, long totalBytes, long u
List<Integer> currentFileIds) throws TException {
return mMasterInfo.registerWorker(workerNetAddress, totalBytes, usedBytes, currentFileIds);
}
}
}
Loading