You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2011/05/16 16:47:48 UTC

svn commit: r1103756 - in /activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util: DiskBenchmark.java cli/CommandLineSupport.java cli/CommonsCLISupport.java cli/OptionBuilder.java

Author: tabish
Date: Mon May 16 14:47:48 2011
New Revision: 1103756

URL: http://svn.apache.org/viewvc?rev=1103756&view=rev
Log:
Fix the package declarations (was making eclipse unhappy)

Modified:
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/DiskBenchmark.java
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/CommandLineSupport.java
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/CommonsCLISupport.java
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/OptionBuilder.java

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/DiskBenchmark.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/DiskBenchmark.java?rev=1103756&r1=1103755&r2=1103756&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/DiskBenchmark.java (original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/DiskBenchmark.java Mon May 16 14:47:48 2011
@@ -22,7 +22,7 @@ import java.io.RandomAccessFile;
 import java.util.ArrayList;
 import java.util.Arrays;
 
-import org.apache.activemq.util.cli.CommandLineSupport;
+import org.apache.activemq.apollo.util.cli.CommandLineSupport;
 
 
 /**
@@ -32,11 +32,11 @@ public class DiskBenchmark {
 
     boolean verbose;
     // reads and writes work with 4k of data at a time.
-    int bs=1024*4; 
+    int bs=1024*4;
     // Work with 100 meg file.
-    long size=1024*1024*500; 
-    long sampleInterval = 10*1000; 
-    
+    long size=1024*1024*500;
+    long sampleInterval = 10*1000;
+
     public static void main(String[] args) {
 
         DiskBenchmark benchmark = new DiskBenchmark();
@@ -70,23 +70,23 @@ public class DiskBenchmark {
         }
 
     }
-    
+
     public static class Report {
 
         public int size;
-        
+
         public int writes;
         public long writeDuration;
-        
+
         public int syncWrites;
         public long syncWriteDuration;
-        
+
         public int reads;
         public long readDuration;
 
         @Override
         public String toString() {
-            return 
+            return
             "Writes: \n" +
             "  "+writes+" writes of size "+size+" written in "+(writeDuration/1000.0)+" seconds.\n"+
             "  "+getWriteRate()+" writes/second.\n"+
@@ -109,40 +109,40 @@ public class DiskBenchmark {
             float rc = writes;
             rc *= size;
             rc /= (1024*1024); // put it in megs
-            rc /= (writeDuration/1000.0); // get rate. 
+            rc /= (writeDuration/1000.0); // get rate.
             return rc;
         }
 
         private float getWriteRate() {
             float rc = writes;
-            rc /= (writeDuration/1000.0); // get rate. 
+            rc /= (writeDuration/1000.0); // get rate.
             return rc;
         }
-        
+
         private float getSyncWriteSizeRate() {
             float rc = syncWrites;
             rc *= size;
             rc /= (1024*1024); // put it in megs
-            rc /= (syncWriteDuration/1000.0); // get rate. 
+            rc /= (syncWriteDuration/1000.0); // get rate.
             return rc;
         }
 
         private float getSyncWriteRate() {
             float rc = syncWrites;
-            rc /= (syncWriteDuration/1000.0); // get rate. 
+            rc /= (syncWriteDuration/1000.0); // get rate.
             return rc;
         }
         private float getReadSizeRate() {
             float rc = reads;
             rc *= size;
             rc /= (1024*1024); // put it in megs
-            rc /= (readDuration/1000.0); // get rate. 
+            rc /= (readDuration/1000.0); // get rate.
             return rc;
         }
 
         private float getReadRate() {
             float rc = reads;
-            rc /= (readDuration/1000.0); // get rate. 
+            rc /= (readDuration/1000.0); // get rate.
             return rc;
         }
 
@@ -206,17 +206,17 @@ public class DiskBenchmark {
 
     public Report benchmark(File file) throws IOException {
         Report rc = new Report();
-        
+
         // Initialize the block we will be writing to disk.
         byte []data = new byte[bs];
         for (int i = 0; i < data.length; i++) {
             data[i] = (byte)('a'+(i%26));
         }
-        
+
         rc.size = data.length;
         RandomAccessFile raf = new RandomAccessFile(file, "rw");
         raf.setLength(size);
-        
+
         // Figure out how many writes we can do in the sample interval.
         long start = System.currentTimeMillis();
         long now = System.currentTimeMillis();
@@ -234,14 +234,14 @@ public class DiskBenchmark {
                     break;
                 }
             }
-            // Sync to disk so that the we actually write the data to disk.. otherwise 
+            // Sync to disk so that the we actually write the data to disk.. otherwise
             // OS buffering might not really do the write.
             IOHelper.sync(raf.getFD());
         }
         IOHelper.sync(raf.getFD());
         raf.close();
         now = System.currentTimeMillis();
-        
+
         rc.size = data.length;
         rc.writes = ioCount;
         rc.writeDuration = (now-start);
@@ -290,7 +290,7 @@ public class DiskBenchmark {
             }
         }
         raf.close();
-        
+
         rc.reads = ioCount;
         rc.readDuration = (now-start);
         return rc;

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/CommandLineSupport.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/CommandLineSupport.java?rev=1103756&r1=1103755&r2=1103756&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/CommandLineSupport.java (original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/CommandLineSupport.java Mon May 16 14:47:48 2011
@@ -15,7 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.activemq.util.cli;
+package org.apache.activemq.apollo.util.cli;
 
 import java.util.ArrayList;
 
@@ -24,66 +24,66 @@ import org.apache.activemq.apollo.util.I
 /**
  * Support utility that can be used to set the properties on any object
  * using command line arguments.
- * 
+ *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
 public class CommandLineSupport {
-	
+
 	/**
 	 * Sets the properties of an object given the command line args.
-	 * 
-	 * if args contains: --ack-mode=AUTO --url=tcp://localhost:61616 --persistent 
-	 * 
+	 *
+	 * if args contains: --ack-mode=AUTO --url=tcp://localhost:61616 --persistent
+	 *
 	 * then it will try to call the following setters on the target object.
-	 * 
+	 *
 	 * target.setAckMode("AUTO");
 	 * target.setURL(new URI("tcp://localhost:61616") );
 	 * target.setPersistent(true);
-	 * 
-	 * Notice the the proper conversion for the argument is determined by examining the 
-	 * setter argument type.  
-	 * 
+	 *
+	 * Notice the the proper conversion for the argument is determined by examining the
+	 * setter argument type.
+	 *
 	 * @param target the object that will have it's properties set
 	 * @param args the command line options
 	 * @return any arguments that are not valid options for the target
 	 */
 	static public String[] setOptions(Object target, String []args) {
 		ArrayList<String> rc = new ArrayList<String>();
-		
+
 		for (int i = 0; i < args.length; i++) {
 			if( args[i] == null )
 				continue;
-			
+
 			if( args[i].startsWith("--") ) {
-				
+
 				// --options without a specified value are considered boolean flags that are enabled.
 				String value="true";
 				String name = args[i].substring(2);
-				
+
 				// if --option=value case
 				int p = name.indexOf("=");
 				if( p > 0 ) {
 					value = name.substring(p+1);
 					name = name.substring(0,p);
 				}
-				
+
 				// name not set, then it's an unrecognized option
 				if( name.length()==0 ) {
 					rc.add(args[i]);
 					continue;
 				}
-				
+
 				String propName = convertOptionToPropertyName(name);
-				if( !IntrospectionSupport.setProperty(target, propName, value) ) {					
+				if( !IntrospectionSupport.setProperty(target, propName, value) ) {
 					rc.add(args[i]);
 					continue;
 				}
 			} else {
                             rc.add(args[i]);
 			}
-			
+
 		}
-		
+
 		String r[] = new String[rc.size()];
 		rc.toArray(r);
 		return r;
@@ -96,20 +96,20 @@ public class CommandLineSupport {
 	 */
 	private static String convertOptionToPropertyName(String name) {
 		String rc="";
-		
+
 		// Look for '-' and strip and then convert the subsequent char to uppercase
 		int p = name.indexOf("-");
 		while( p > 0 ) {
 			// strip
 			rc += name.substring(0, p);
 			name = name.substring(p+1);
-			
+
 			// can I convert the next char to upper?
 			if( name.length() >0 ) {
 				rc += name.substring(0,1).toUpperCase();
 				name = name.substring(1);
 			}
-			
+
 			p = name.indexOf("-");
 		}
 		return rc+name;

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/CommonsCLISupport.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/CommonsCLISupport.java?rev=1103756&r1=1103755&r2=1103756&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/CommonsCLISupport.java (original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/CommonsCLISupport.java Mon May 16 14:47:48 2011
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.activemq.util.cli;
+package org.apache.activemq.apollo.util.cli;
 
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -25,19 +25,19 @@ import org.apache.commons.cli.CommandLin
 import org.apache.commons.cli.Option;
 
 public class CommonsCLISupport {
-    
+
     /**
      */
     static public String[] setOptions(Object target,  CommandLine cli) {
         Option[] options = cli.getOptions();
         for (Option option : options) {
             String name = option.getLongOpt();
-            if( name==null ) 
+            if( name==null )
                 continue;
-            
+
             String propName = convertOptionToPropertyName(name);
-            
-            
+
+
             String value = option.getValue();
             if( value!=null ) {
                 Class<?> type = IntrospectionSupport.getPropertyType(target, propName);
@@ -51,7 +51,7 @@ public class CommonsCLISupport {
                     IntrospectionSupport.setProperty(target, propName, value);
                 }
             } else {
-                IntrospectionSupport.setProperty(target, propName, true);                  
+                IntrospectionSupport.setProperty(target, propName, true);
             }
         }
         return cli.getArgs();
@@ -64,20 +64,20 @@ public class CommonsCLISupport {
      */
     private static String convertOptionToPropertyName(String name) {
         String rc="";
-        
+
         // Look for '-' and strip and then convert the subsequent char to uppercase
         int p = name.indexOf("-");
         while( p > 0 ) {
             // strip
             rc += name.substring(0, p);
             name = name.substring(p+1);
-            
+
             // can I convert the next char to upper?
             if( name.length() >0 ) {
                 rc += name.substring(0,1).toUpperCase();
                 name = name.substring(1);
             }
-            
+
             p = name.indexOf("-");
         }
         return rc+name;

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/OptionBuilder.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/OptionBuilder.java?rev=1103756&r1=1103755&r2=1103756&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/OptionBuilder.java (original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/cli/OptionBuilder.java Mon May 16 14:47:48 2011
@@ -14,14 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.activemq.util.cli;
+package org.apache.activemq.apollo.util.cli;
 
 import org.apache.commons.cli.Option;
 
 /**
  * a better version of org.apache.commons.cli.OptionBuilder
  * IDE provides nicer auto complete and less compiler warnings.
- * 
+ *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
 public class OptionBuilder {