[infinispan-commits] Infinispan SVN: r1074 - trunk/demos/ec2/src/main/java/org/infinispan/ec2demo.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Thu Oct 29 12:58:21 EDT 2009


Author: manik.surtani at jboss.com
Date: 2009-10-29 12:58:21 -0400 (Thu, 29 Oct 2009)
New Revision: 1074

Modified:
   trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/CacheBuilder.java
   trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfinispanFluDemo.java
   trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfluenzaDataLoader.java
   trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfluenzaVirusCache.java
   trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/Nucleotide_Protein_Parser.java
   trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/ProteinCache.java
Log:
Cleaned up code

Modified: trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/CacheBuilder.java
===================================================================
--- trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/CacheBuilder.java	2009-10-29 16:19:01 UTC (rev 1073)
+++ trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/CacheBuilder.java	2009-10-29 16:58:21 UTC (rev 1074)
@@ -1,73 +1,67 @@
 /**
- * 
+ *
  */
 package org.infinispan.ec2demo;
 
-import java.io.IOException;
-import java.net.URL;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.log4j.*;
 import org.infinispan.config.Configuration;
 import org.infinispan.config.GlobalConfiguration;
 import org.infinispan.manager.CacheManager;
 import org.infinispan.manager.DefaultCacheManager;
-import org.infinispan.remoting.transport.Address;
 import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
 
+import java.io.IOException;
+import java.util.Properties;
+
 /**
  * @author noconnor at redhat.com
- * 
  */
 public class CacheBuilder {
-	Logger myLogger = Logger.getLogger(CacheBuilder.class);
-	private CacheManager cache_manager;
+   private CacheManager cache_manager;
 
-	public CacheBuilder(String configFile) throws IOException {
-		String jGroupsFile = System.getProperty("EC2Demo-jgroups-config");
-		if (jGroupsFile==null)
-			throw new RuntimeException("Need to set system property EC2Demo-jgroups-config to point to the jgroups configuration file");
-		
-		GlobalConfiguration gc = GlobalConfiguration.getClusteredDefault();
-		gc.setClusterName("infinispan-demo-cluster");
-		gc.setTransportClass(JGroupsTransport.class.getName());		
-		Properties p = new Properties();
-		p.setProperty("configurationFile",jGroupsFile);
-		gc.setTransportProperties(p);
+   public CacheBuilder(String configFile) throws IOException {
+      String jGroupsFile = System.getProperty("EC2Demo-jgroups-config");
+      if (jGroupsFile == null)
+         throw new RuntimeException("Need to set system property EC2Demo-jgroups-config to point to the jgroups configuration file");
 
-		Configuration c = new Configuration();
-		c.setCacheMode(Configuration.CacheMode.DIST_SYNC);
-		c.setExposeJmxStatistics(true);
-		c.setUnsafeUnreliableReturnValues(true);
-		c.setNumOwners(3);
-		c.setL1CacheEnabled(true);
-		c.setInvocationBatchingEnabled(true);
-		c.setUseReplQueue(true);
-		c.setL1Lifespan(6000000);		 
-		cache_manager = new DefaultCacheManager(gc, c,false);
-        ShutdownHook shutdownHook = new ShutdownHook(cache_manager);
-        Runtime.getRuntime().addShutdownHook(shutdownHook);
-	}
+      GlobalConfiguration gc = GlobalConfiguration.getClusteredDefault();
+      gc.setClusterName("infinispan-demo-cluster");
+      gc.setTransportClass(JGroupsTransport.class.getName());
+      Properties p = new Properties();
+      p.setProperty("configurationFile", jGroupsFile);
+      gc.setTransportProperties(p);
 
-	public CacheManager getCacheManager() {
-		return this.cache_manager;
-	}
+      Configuration c = new Configuration();
+      c.setCacheMode(Configuration.CacheMode.DIST_SYNC);
+      c.setExposeJmxStatistics(true);
+      c.setUnsafeUnreliableReturnValues(true);
+      c.setNumOwners(3);
+      c.setL1CacheEnabled(true);
+      c.setInvocationBatchingEnabled(true);
+      c.setUseReplQueue(true);
+      c.setL1Lifespan(6000000);
+      cache_manager = new DefaultCacheManager(gc, c, false);
+      ShutdownHook shutdownHook = new ShutdownHook(cache_manager);
+      Runtime.getRuntime().addShutdownHook(shutdownHook);
+   }
 
+   public CacheManager getCacheManager() {
+      return this.cache_manager;
+   }
+
 }
 
 class ShutdownHook extends Thread {
-	private CacheManager currCache;
-    /**
-	 * @param cache_manager
-	 */
-	public ShutdownHook(CacheManager cache_manager) {
-		currCache = cache_manager;
-	}
+   private CacheManager currCache;
 
-	public void run() {
-        System.out.println("Shutting down Cache Manager");
-        currCache.stop();
-    }
+   /**
+    * @param cache_manager
+    */
+   public ShutdownHook(CacheManager cache_manager) {
+      currCache = cache_manager;
+   }
+
+   public void run() {
+      System.out.println("Shutting down Cache Manager");
+      currCache.stop();
+   }
 }

Modified: trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfinispanFluDemo.java
===================================================================
--- trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfinispanFluDemo.java	2009-10-29 16:19:01 UTC (rev 1073)
+++ trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfinispanFluDemo.java	2009-10-29 16:58:21 UTC (rev 1074)
@@ -1,13 +1,5 @@
 package org.infinispan.ec2demo;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.List;
-import java.util.Map;
-import org.apache.log4j.*;
-import org.jboss.logging.Logger;
-import org.xml.sax.SAXException;
 import com.martiansoftware.jsap.FlaggedOption;
 import com.martiansoftware.jsap.JSAP;
 import com.martiansoftware.jsap.JSAPException;
@@ -15,7 +7,13 @@
 import com.martiansoftware.jsap.Parameter;
 import com.martiansoftware.jsap.SimpleJSAP;
 import com.martiansoftware.jsap.Switch;
+import org.xml.sax.SAXException;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Map;
+
 /**
  * 
  */
@@ -29,7 +27,6 @@
 	/**
 	 * @param args
 	 * @throws InterruptedException
-	 * @throws ParseException
 	 * @throws JSAPException
 	 * @throws SAXException
 	 */

Modified: trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfluenzaDataLoader.java
===================================================================
--- trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfluenzaDataLoader.java	2009-10-29 16:19:01 UTC (rev 1073)
+++ trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfluenzaDataLoader.java	2009-10-29 16:58:21 UTC (rev 1074)
@@ -3,15 +3,16 @@
  */
 package org.infinispan.ec2demo;
 
-import java.io.IOException;
-import java.util.List;
+import com.martiansoftware.jsap.JSAPResult;
 import org.infinispan.Cache;
 import org.infinispan.remoting.transport.Address;
-import org.infinispan.statetransfer.StateTransferException;
-import org.apache.log4j.*;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
 import org.xml.sax.SAXException;
-import com.martiansoftware.jsap.JSAPResult;
 
+import java.io.IOException;
+import java.util.List;
+
 /**
  * @author noconnor at redhat.com
  * 
@@ -24,7 +25,7 @@
 	private Nucleotide_Protein_Parser npParser;
 	private Influenza_Parser iParser;
 
-	Logger myLogger = Logger.getLogger(InfluenzaDataLoader.class);
+	private static final Log myLogger = LogFactory.getLog(InfluenzaDataLoader.class);
 
 	public void populateCache(JSAPResult config) throws SAXException {
 		String cfgFileName = System.getProperty("infinispan.demo.cfg");

Modified: trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfluenzaVirusCache.java
===================================================================
--- trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfluenzaVirusCache.java	2009-10-29 16:19:01 UTC (rev 1073)
+++ trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/InfluenzaVirusCache.java	2009-10-29 16:58:21 UTC (rev 1074)
@@ -3,18 +3,18 @@
  */
 package org.infinispan.ec2demo;
 
-import java.io.IOException;
-import java.net.URL;
-import org.apache.log4j.Logger;
 import org.infinispan.Cache;
-import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
 
+import java.io.IOException;
+
 /**
  * @author noconnor at redhat.com
  * 
  */
 public class InfluenzaVirusCache {
-	Logger myLogger = Logger.getLogger(InfluenzaVirusCache.class);
+	private static final Log myLogger = LogFactory.getLog(InfluenzaVirusCache.class);
 	private Cache<String, Influenza_N_P_CR_Element> myCache;
 
 	public InfluenzaVirusCache(CacheBuilder cacheManger) throws IOException {

Modified: trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/Nucleotide_Protein_Parser.java
===================================================================
--- trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/Nucleotide_Protein_Parser.java	2009-10-29 16:19:01 UTC (rev 1073)
+++ trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/Nucleotide_Protein_Parser.java	2009-10-29 16:58:21 UTC (rev 1074)
@@ -1,62 +1,61 @@
 package org.infinispan.ec2demo;
 
+import org.milyn.Smooks;
+import org.milyn.payload.JavaResult;
+import org.xml.sax.SAXException;
+
+import javax.xml.transform.stream.StreamSource;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.List;
-import javax.xml.transform.stream.StreamSource;
-import org.milyn.Smooks;
-import org.milyn.payload.JavaResult; 
-import org.xml.sax.SAXException;
-import org.apache.log4j.*;
 
 /**
- * 
+ *
  */
 
 /**
  * @author noconnor at redhat.com
- * 
  */
 public class Nucleotide_Protein_Parser {
 
-	public Nucleotide_Protein_Parser(){
-		
-	}
-	
-	@SuppressWarnings("unchecked")
-	public List<Nucleotide_Protein_Element> parseFile(String fileName) throws IOException, SAXException{
-		System.out.println("Parsing ["+fileName+"]");
-		Smooks smooks = new Smooks("smooks-config.xml");
+   public Nucleotide_Protein_Parser() {
 
-		try {
-			JavaResult result = new JavaResult();
-			smooks.filterSource(new StreamSource(new FileInputStream(fileName.trim())), result);
-			return (List<Nucleotide_Protein_Element>) result.getBean("customerList");
-		} finally {
-			smooks.close();
-		}
-	}
-	
-	public void processFile(String fileName,ProteinCache cacheImpl) {
-		if (fileName==null){
-			System.out.println("No file to process...");
-			return;
-		}
-		System.out.println("Processing file " + fileName);
-		
-		try {
-			List<Nucleotide_Protein_Element> myData = parseFile(fileName);
-			for (Nucleotide_Protein_Element x:myData){
-				cacheImpl.addToCache(x);
-			}
-			System.out.println("Processed " + myData.size() + " records from file...");
-			System.out.println("Number stored in cache="+cacheImpl.getCacheSize());
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		} catch (SAXException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
+   }
+
+   @SuppressWarnings("unchecked")
+   public List<Nucleotide_Protein_Element> parseFile(String fileName) throws IOException, SAXException {
+      System.out.println("Parsing [" + fileName + "]");
+      Smooks smooks = new Smooks("smooks-config.xml");
+
+      try {
+         JavaResult result = new JavaResult();
+         smooks.filterSource(new StreamSource(new FileInputStream(fileName.trim())), result);
+         return (List<Nucleotide_Protein_Element>) result.getBean("customerList");
+      } finally {
+         smooks.close();
+      }
+   }
+
+   public void processFile(String fileName, ProteinCache cacheImpl) {
+      if (fileName == null) {
+         System.out.println("No file to process...");
+         return;
+      }
+      System.out.println("Processing file " + fileName);
+
+      try {
+         List<Nucleotide_Protein_Element> myData = parseFile(fileName);
+         for (Nucleotide_Protein_Element x : myData) {
+            cacheImpl.addToCache(x);
+         }
+         System.out.println("Processed " + myData.size() + " records from file...");
+         System.out.println("Number stored in cache=" + cacheImpl.getCacheSize());
+      } catch (IOException e) {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      } catch (SAXException e) {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+   }
 }

Modified: trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/ProteinCache.java
===================================================================
--- trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/ProteinCache.java	2009-10-29 16:19:01 UTC (rev 1073)
+++ trunk/demos/ec2/src/main/java/org/infinispan/ec2demo/ProteinCache.java	2009-10-29 16:58:21 UTC (rev 1074)
@@ -3,16 +3,18 @@
  */
 package org.infinispan.ec2demo;
 
-import java.io.IOException;
-import org.apache.log4j.*;
 import org.infinispan.Cache;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
 
+import java.io.IOException;
+
 /**
  * @author noelo
  * 
  */
 public class ProteinCache {
-	Logger myLogger = Logger.getLogger(ProteinCache.class);
+	private static final Log myLogger = LogFactory.getLog(ProteinCache.class);
 	private Cache<String, Nucleotide_Protein_Element> myCache;
 
 	public ProteinCache(CacheBuilder cacheManger) throws IOException {



More information about the infinispan-commits mailing list