You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2008/10/28 00:59:14 UTC

svn commit: r708392 - in /portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade: components/jetspeed-portal/src/main/java/org/apache/jetspeed/cluster/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/ components/jetsp...

Author: ate
Date: Mon Oct 27 16:59:13 2008
New Revision: 708392

URL: http://svn.apache.org/viewvc?rev=708392&view=rev
Log:
JS2-871 - Upgrade Pluto container to version 2.0
See:  http://issues.apache.org/jira/browse/JS2-871
- Fixing NodeManager to now use a new PA.revision (*not* an ID, its a revision only unique for a PA itself)

Modified:
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/cluster/NodeInformationImpl.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/cluster/NodeManagerImpl.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/test/java/org/apache/jetspeed/cluster/TestCluster.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/cluster/NodeInformation.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/cluster/NodeManager.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletApplication.java

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/cluster/NodeInformationImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/cluster/NodeInformationImpl.java?rev=708392&r1=708391&r2=708392&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/cluster/NodeInformationImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/cluster/NodeInformationImpl.java Mon Oct 27 16:59:13 2008
@@ -33,7 +33,7 @@
 {
 	static final long serialVersionUID = -598265530537353219L;
 
-	private Long id;
+	private Long revision;
 	private String contextName;
 	private Date lastDeployDate = null;
 	private static final int CompressVersion = 1;
@@ -52,7 +52,7 @@
 	private void writeObject(ObjectOutputStream out) throws IOException
 	{
 		out.writeByte(CompressVersion);
-		out.writeLong(id.longValue());
+		out.writeLong(revision.longValue());
 		out.writeUTF(contextName);
 		if (lastDeployDate == null)
 			out.writeByte(0);
@@ -70,10 +70,10 @@
 	private void readObject(ObjectInputStream in) throws IOException,
 			ClassNotFoundException
 	{
-		int version = in.readByte();
+		in.readByte();
 		// do changes here if version dependant
 
-		id = new Long(in.readLong());
+		revision = new Long(in.readLong());
 		contextName = in.readUTF();
 		int dateSet = in.readByte();
 		
@@ -118,7 +118,7 @@
 	public String toString()
 	{
 		StringBuffer buffer = new StringBuffer();
-		buffer.append("id= " + this.id.longValue());
+		buffer.append("revision= " + this.revision.longValue());
 		buffer.append("; contextName= " + this.getContextName());
 		buffer.append("; lastDeployDate= " + this.getContextName());
 		if (this.lastDeployDate != null)
@@ -147,19 +147,19 @@
 		this.contextName = contextName;
 	}
 
-	public Long getId()
+	public Long getRevision()
 	{
-		return id;
+		return revision;
 	}
 
-	public void setId(Long id)
+	public void setRevision(Long revision)
 	{
-		this.id = id;
+		this.revision = revision;
 	}
 
-	public void setId(long id)
+	public void setRevision(long revision)
 	{
-		this.id = new Long(id);
+		this.revision = new Long(revision);
 	}
 
 	public Date getLastDeployDate()
@@ -171,5 +171,4 @@
 	{
 		this.lastDeployDate = lastDeployDate;
 	}
-
 }

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/cluster/NodeManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/cluster/NodeManagerImpl.java?rev=708392&r1=708391&r2=708392&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/cluster/NodeManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/cluster/NodeManagerImpl.java Mon Oct 27 16:59:13 2008
@@ -44,7 +44,7 @@
      */
     private BeanFactory beanFactory;
 
-	private HashMap nodes = null; 
+	private HashMap<String, NodeInformation> nodes = null; 
 	private File rootIndexDir = null;
 	    
     /** the default criterion bean name */
@@ -80,7 +80,8 @@
 			}
 	}
     
-	protected void load()
+	@SuppressWarnings("unchecked")
+    protected void load()
 	{
 			File data = new File( rootIndexDir.getAbsolutePath()+ "/nodeInfo.ser");
 			if (data.exists())
@@ -88,13 +89,13 @@
 				try {
 				    FileInputStream fin = new FileInputStream(data.getAbsolutePath());
 				    ObjectInputStream ois = new ObjectInputStream(fin);
-				    nodes = (HashMap) ois.readObject();
+				    nodes = (HashMap<String,NodeInformation>) ois.readObject();
 				    ois.close();
 				    }
 				   catch (Exception e) 
 				   { 
 			            log.error("Failed to read nodes data file from " + data.getAbsolutePath() + " - error : " + e.getLocalizedMessage());
-					   nodes = new HashMap();
+					   nodes = new HashMap<String,NodeInformation>();
 				   }
 			}
 			else
@@ -108,27 +109,27 @@
 		            log.error("Failed to create new nodes data file error : " + e.getLocalizedMessage());
 					e.printStackTrace();
 				}
-				nodes = new HashMap();
+				nodes = new HashMap<String,NodeInformation>();
 			}
 			
 //			NodeInformationImpl temp = new NodeInformationImpl();
 //			temp.setContextName("tttt");
 	}
-	public int checkNode(Long id, String contextName)
+	public int checkNode(Long revision, String contextName)
 	{
-		if ((contextName == null) || (id == null))
+		if ((contextName == null) || (revision == null))
 			return NodeManager.INVALID_NODE_REQUEST;
 		NodeInformation info = (NodeInformation)nodes.get(contextName);
 		if (info == null)
 			return NodeManager.NODE_NEW;
-		if (info.getId().longValue() < id.longValue())
+		if (info.getRevision().longValue() < revision.longValue())
 			return NodeManager.NODE_OUTDATED;
 		return NodeManager.NODE_SAVED;
 	}
 	
-	public void addNode(Long id, String contextName) throws Exception
+	public void addNode(Long revision, String contextName) throws Exception
 	{
-		if ((contextName == null) || (id == null))
+		if ((contextName == null) || (revision == null))
 			return;
 		NodeInformation info = (NodeInformation)nodes.get(contextName);
 		if (info == null)
@@ -136,7 +137,7 @@
 			info = createNodeInformation();
 			info.setContextName(contextName);
 		}
-		info.setId(id);
+		info.setRevision(revision);
 		nodes.put(contextName, info);
 		save();
 	}
@@ -151,7 +152,6 @@
 		nodes.remove(contextName);
 		save();
 	}
-
 	
     /*
      * (non-Javadoc)
@@ -189,9 +189,5 @@
 	public int getNumberOfNodes()
 	{
 		return nodes.size();
-	}
-
-    
-    
-    
+	}    
 }

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java?rev=708392&r1=708391&r2=708392&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java Mon Oct 27 16:59:13 2008
@@ -282,8 +282,10 @@
 		PortletApplication oldPA, int paType, ClassLoader paClassLoader)
 		throws RegistryException
 	{
+	    long revision = 0;
 		if (oldPA != null)
 		{
+		    revision = oldPA.getRevision();
 			unregisterPortletApplication(oldPA, false);
 			oldPA = null;
 		}
@@ -301,6 +303,10 @@
 
 			log.info("Loading portlet.xml...." + paName);
 			pa = paWar.createPortletApp(paClassLoader, wa, paType);
+			if (revision > 0)
+			{
+			    pa.setRevision(revision);
+			}
 
 			if (paType == PortletApplication.LOCAL)
 			{
@@ -344,7 +350,7 @@
 			// and add to the current node info
             if (nodeManager != null)
             {            
-                nodeManager.addNode(new Long(pa.getId().toString()), pa.getName());
+                nodeManager.addNode(new Long(pa.getRevision()), pa.getName());
             }
             // grant default permissions to portlet application
 			grantDefaultPermissions(paName);
@@ -502,7 +508,7 @@
                     {
                         log.debug("Re-register existing portlet application " + contextName + ".");
                     }
-            		int status = nodeManager.checkNode(new Long(pa.getId().toString()), pa.getName());
+            		int status = nodeManager.checkNode(new Long(pa.getRevision()), pa.getName());
         			boolean reregister = false;
         			boolean deploy = false;
         			switch (status)
@@ -583,7 +589,7 @@
         					// and add to the current node info
         					try
         					{
-        						nodeManager.addNode(new Long(pa.getId().toString()), pa.getName());
+        						nodeManager.addNode(new Long(pa.getRevision()), pa.getName());
         					} catch (Exception e)
         					{
         					    log.error("Adding node for portlet application " + pa.getName() + " caused exception" , e);

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/test/java/org/apache/jetspeed/cluster/TestCluster.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/test/java/org/apache/jetspeed/cluster/TestCluster.java?rev=708392&r1=708391&r2=708392&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/test/java/org/apache/jetspeed/cluster/TestCluster.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/test/java/org/apache/jetspeed/cluster/TestCluster.java Mon Oct 27 16:59:13 2008
@@ -56,44 +56,44 @@
     public void testCluser() throws Exception
     {
     	String contextName = "SOME_NEW_PORTLET_APPLICATION";
-    	Long id = new Long(10);
+    	Long revision = new Long(10);
     	
         assertNotNull("Manager should be instantiated", single);
         
         int numExistingApps = single.getNumberOfNodes();
         
         //create a new node
-        int status = single.checkNode(id, contextName);
+        int status = single.checkNode(revision, contextName);
         if (status != NodeManager.NODE_NEW)
         {
         	single.removeNode(contextName); //previous run didn't clean up
-        	status = single.checkNode(id, contextName);
+        	status = single.checkNode(revision, contextName);
             assertEquals("Should be a new node",NodeManager.NODE_NEW,status);
         }
         
         // ok - create a new node
-        single.addNode(id, contextName);
+        single.addNode(revision, contextName);
         int newApps = single.getNumberOfNodes();
 
         assertEquals("Should have added new node",newApps, numExistingApps+1);
         
-        status = single.checkNode(id, contextName);
+        status = single.checkNode(revision, contextName);
         assertEquals("Should be a current (saved) node",NodeManager.NODE_SAVED,status);
         
-    	id = new Long(20);
-        status = single.checkNode(id, contextName);
+    	revision = new Long(20);
+        status = single.checkNode(revision, contextName);
         assertEquals("Should be an outdated node",NodeManager.NODE_OUTDATED,status);
 
-        single.addNode(id, contextName);
-        status = single.checkNode(id, contextName);
+        single.addNode(revision, contextName);
+        status = single.checkNode(revision, contextName);
         assertEquals("Should be again a current (saved) node",NodeManager.NODE_SAVED,status);
 
-    	id = new Long(10);
-        status = single.checkNode(id, contextName);
+    	revision = new Long(10);
+        status = single.checkNode(revision, contextName);
         assertEquals("Should still be a current (saved) node",NodeManager.NODE_SAVED,status);
 
     	single.removeNode(contextName); //previous run didn't clean up
-        status = single.checkNode(id, contextName);
+        status = single.checkNode(revision, contextName);
         assertEquals("Node should be gone....",NodeManager.NODE_NEW,status);
     }
     protected String[] getConfigurations()

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java?rev=708392&r1=708391&r2=708392&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java Mon Oct 27 16:59:13 2008
@@ -47,6 +47,9 @@
 import org.apache.jetspeed.om.portlet.UserAttribute;
 import org.apache.jetspeed.om.portlet.UserAttributeRef;
 import org.apache.jetspeed.om.servlet.WebApplicationDefinition;
+import org.apache.ojb.broker.PersistenceBroker;
+import org.apache.ojb.broker.PersistenceBrokerAware;
+import org.apache.ojb.broker.PersistenceBrokerException;
 
 /**
  *
@@ -55,12 +58,13 @@
  * @version $Id$
  * @since 1.0
  */
-public class PortletApplicationDefinitionImpl implements PortletApplication, Serializable, Support
+public class PortletApplicationDefinitionImpl implements PortletApplication, Serializable, Support, PersistenceBrokerAware
 { 
     private int applicationType = PortletApplication.WEBAPP;
     
     private String checksum = "0";
     private long checksumLong = -1;
+    private long revision;
     
     /** Holds value of property version. */
     private String version;
@@ -171,6 +175,16 @@
         this.checksumLong = checksum;
         this.checksum = Long.toString(checksum);
     }
+
+    public long getRevision()
+    {
+        return revision;
+    }
+
+    public void setRevision(long revision)
+    {
+        this.revision = revision;
+    }
     
     public String getDefaultNamespace()
     {
@@ -268,7 +282,7 @@
         }
         PortletDefinitionImpl portlet = new PortletDefinitionImpl();
         portlet.setPortletName(name);
-        portlet.setPortletApplication(this);
+        portlet.setApplication(this);
         portlets.add(portlet);
         return portlet;
     }
@@ -783,4 +797,35 @@
             ((Support)pd).postLoad(this);
         }
     }
+
+    /// PersistenceBrokerAware interface implementation
+    public void afterDelete(PersistenceBroker arg0) throws PersistenceBrokerException
+    {
+    }
+
+    public void afterInsert(PersistenceBroker arg0) throws PersistenceBrokerException
+    {
+    }
+
+    public void afterLookup(PersistenceBroker arg0) throws PersistenceBrokerException
+    {
+    }
+
+    public void afterUpdate(PersistenceBroker arg0) throws PersistenceBrokerException
+    {
+    }
+
+    public void beforeDelete(PersistenceBroker arg0) throws PersistenceBrokerException
+    {
+    }
+
+    public void beforeInsert(PersistenceBroker arg0) throws PersistenceBrokerException
+    {
+        revision++;
+    }
+
+    public void beforeUpdate(PersistenceBroker arg0) throws PersistenceBrokerException
+    {
+        revision++;
+    }
 }

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/cluster/NodeInformation.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/cluster/NodeInformation.java?rev=708392&r1=708391&r2=708392&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/cluster/NodeInformation.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/cluster/NodeInformation.java Mon Oct 27 16:59:13 2008
@@ -36,28 +36,28 @@
 	/**
 	 * setter for context name
 	 * 
-	 * @param id
+	 * @param contextName
 	 */	
 	public void setContextName(String contextName);
 
 	/**
-	 * Getter for ObjectID 
+	 * Getter for revision 
 	 * @return
 	 */
-	public Long getId();
+	public Long getRevision();
 
 	/**
-	 * setter for ObjectID 
+	 * setter for revision 
 	 * 
-	 * @param id
+	 * @param revision
 	 */	
-	public void setId(Long id);
+	public void setRevision(Long revision);
 	/**
-	 * setter for ObjectID 
+	 * setter for revision 
 	 * 
-	 * @param id
+	 * @param revision
 	 */	
-	public void setId(long id);
+	public void setRevision(long revision);
 
 	/**
 	 * Getter for Last Deploy Date

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/cluster/NodeManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/cluster/NodeManager.java?rev=708392&r1=708391&r2=708392&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/cluster/NodeManager.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/cluster/NodeManager.java Mon Oct 27 16:59:13 2008
@@ -33,20 +33,20 @@
 	/**
 	 * Returns the current "knowledge" about a given node (i.e. the portlet application).
 	 * If the contextName doesn't exist NODE_NEW is returned.
-	 * An id requested newer than what is stored is indicated by NODE_OUTDATED. 
-	 * @param id
+	 * An revision requested newer than what is stored is indicated by NODE_OUTDATED. 
+	 * @param revision
 	 * @param contextName
 	 * @return
 	 */
-	public int checkNode(Long id, String contextName);
+	public int checkNode(Long revision, String contextName);
 
 	/**
-	 * Add a new node or update the id of an existing one...(i.e. the portlet application) to the local info
-	 * @param id
+	 * Add a new node or update the revision of an existing one...(i.e. the portlet application) to the local info
+	 * @param revision
 	 * @param contextName
 	 * @throws Exception
 	 */
-	public void addNode(Long id, String contextName) throws Exception;
+	public void addNode(Long revision, String contextName) throws Exception;
 
 	/**
 	 * return the number of currently stored nodes

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletApplication.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletApplication.java?rev=708392&r1=708391&r2=708392&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletApplication.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletApplication.java Mon Oct 27 16:59:13 2008
@@ -78,6 +78,10 @@
      */
     long getChecksum();
     
+    long getRevision();
+    
+    void setRevision(long revision);
+    
     /**
      * <p>
      * Get the Jetspeed Security Constraint reference for this portlet application.



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org