hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1338256 - in /incubator/hama/trunk/core/src/main/java/org/apache/hama/util: BSPServletUtil.java RunJar.java ZKUtil.java
Date Mon, 14 May 2012 15:36:49 GMT
Author: tommaso
Date: Mon May 14 15:36:49 2012
New Revision: 1338256

URL: http://svn.apache.org/viewvc?rev=1338256&view=rev
Log:
[HAMA-572] - removing + for concatenations and setting the collections initial size for boosting
performance in util package

Modified:
    incubator/hama/trunk/core/src/main/java/org/apache/hama/util/BSPServletUtil.java
    incubator/hama/trunk/core/src/main/java/org/apache/hama/util/RunJar.java
    incubator/hama/trunk/core/src/main/java/org/apache/hama/util/ZKUtil.java

Modified: incubator/hama/trunk/core/src/main/java/org/apache/hama/util/BSPServletUtil.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/core/src/main/java/org/apache/hama/util/BSPServletUtil.java?rev=1338256&r1=1338255&r2=1338256&view=diff
==============================================================================
--- incubator/hama/trunk/core/src/main/java/org/apache/hama/util/BSPServletUtil.java (original)
+++ incubator/hama/trunk/core/src/main/java/org/apache/hama/util/BSPServletUtil.java Mon May
14 15:36:49 2012
@@ -56,7 +56,7 @@ public class BSPServletUtil extends Serv
   public static String generateJobTable(String label, JobStatus[] jobs,
       int refresh, int rowId) throws IOException {
 
-    StringBuffer sb = new StringBuffer();
+    StringBuilder sb = new StringBuilder();
 
     if (jobs.length > 0) {
       sb.append("<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\">\n");
@@ -64,8 +64,7 @@ public class BSPServletUtil extends Serv
           + "<th>SuperSteps</th>" + "<th>Tasks</th>" + "<th>Starttime</th>"
           + "</tr>\n");
       for (JobStatus status : jobs) {
-        sb.append("<tr><td><a href=\"bspjob.jsp?jobid=" + status.getJobID()
-            + "\">");
+        sb.append("<tr><td><a href=\"bspjob.jsp?jobid=").append(status.getJobID()).append("\">");
         sb.append(status.getJobID());
         sb.append("</a></td><td>");
         sb.append(status.getUsername());
@@ -103,12 +102,11 @@ public class BSPServletUtil extends Serv
     for (Entry<String, GroomServerStatus> entry : status
         .getActiveGroomServerStatus().entrySet()) {
       sb.append("<tr><td>");
-      sb.append(entry.getKey() + "</td><td>");
-      sb.append(entry.getValue().getGroomHostName() + "</td>" + "<td>"
-          + entry.getValue().getMaxTasks() + "</td><td>");
-      sb.append(entry.getValue().countTasks() + "</td><td>");
-      sb.append(entry.getValue().getFailures() + "</td><td>");
-      sb.append(entry.getValue().getLastSeen() + "</td>");
+      sb.append(entry.getKey()).append("</td><td>");
+      sb.append(entry.getValue().getGroomHostName()).append("</td>").append("<td>").append(entry.getValue().getMaxTasks()).append("</td><td>");
+      sb.append(entry.getValue().countTasks()).append("</td><td>");
+      sb.append(entry.getValue().getFailures()).append("</td><td>");
+      sb.append(entry.getValue().getLastSeen()).append("</td>");
       sb.append("</tr>\n");
     }
     sb.append("</table>\n");

Modified: incubator/hama/trunk/core/src/main/java/org/apache/hama/util/RunJar.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/core/src/main/java/org/apache/hama/util/RunJar.java?rev=1338256&r1=1338255&r2=1338256&view=diff
==============================================================================
--- incubator/hama/trunk/core/src/main/java/org/apache/hama/util/RunJar.java (original)
+++ incubator/hama/trunk/core/src/main/java/org/apache/hama/util/RunJar.java Mon May 14 15:36:49
2012
@@ -128,19 +128,20 @@ public class RunJar {
     classPath.add(new File(workDir, "classes/").toURI().toURL());
     File[] libs = new File(workDir, "lib").listFiles();
     if (libs != null) {
-      for (int i = 0; i < libs.length; i++) {
-        classPath.add(libs[i].toURI().toURL());
+      for (File lib : libs) {
+        classPath.add(lib.toURI().toURL());
       }
     }
     ClassLoader loader = new URLClassLoader((URL[]) classPath
-        .toArray(new URL[0]));
+      .toArray(new URL[classPath.size()]));
 
     Thread.currentThread().setContextClassLoader(loader);
     Class<?> mainClass = loader.loadClass(mainClassName);
     Method main = mainClass.getMethod("main", new Class[] { Array.newInstance(
         String.class, 0).getClass() });
-    String[] newArgs = (String[]) Arrays.asList(args).subList(firstArg,
-        args.length).toArray(new String[0]);
+    List<String> var = Arrays.asList(args).subList(firstArg,
+      args.length);
+    String[] newArgs = (String[]) var.toArray(new String[var.size()]);
     try {
       main.invoke(null, new Object[] { newArgs });
     } catch (InvocationTargetException e) {

Modified: incubator/hama/trunk/core/src/main/java/org/apache/hama/util/ZKUtil.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/core/src/main/java/org/apache/hama/util/ZKUtil.java?rev=1338256&r1=1338255&r2=1338256&view=diff
==============================================================================
--- incubator/hama/trunk/core/src/main/java/org/apache/hama/util/ZKUtil.java (original)
+++ incubator/hama/trunk/core/src/main/java/org/apache/hama/util/ZKUtil.java Mon May 14 15:36:49
2012
@@ -60,7 +60,7 @@ public class ZKUtil {
     StringBuilder builder = new StringBuilder();
     for (String part : parts) {
       try {
-        builder.append(ZKUtil.ZK_SEPARATOR + part);
+        builder.append(ZKUtil.ZK_SEPARATOR).append(part);
         if (null == zk.exists(builder.toString(), false)) {
           zk.create(builder.toString(), null, Ids.OPEN_ACL_UNSAFE,
               CreateMode.PERSISTENT);



Mime
View raw message