portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r499149 - in /portals/jetspeed-2/trunk/components/portal/src: java/org/apache/jetspeed/aggregator/impl/ java/org/apache/jetspeed/engine/servlet/ test/org/apache/jetspeed/aggregator/
Date Tue, 23 Jan 2007 21:55:34 GMT
Author: taylor
Date: Tue Jan 23 13:55:33 2007
New Revision: 499149

URL: http://svn.apache.org/viewvc?view=rev&rev=499149
Log:
Two fixed bugs:

1. Sometimes, JSF demo portlet throws exceptions in parallel mode as follows:

2007-01-23 15:57:28 ApplicationDispatcher[/jsf-demo] Servlet.service() for servlet jsp threw
exception
java.lang.IllegalStateException: parent is null?
    at javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:367)
    at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:219)
    at
org.apache.jsp.WEB_002dINF.view.calendar_002dview_jsp._jspx_meth_h_outputText_0(calendar_002dview_jsp.java:210)
    ...

 --> The old implementation of org.apache.jetspeed.engine.servlet.ServletRequestImpl put
attributes both into the worker context and into http request.
Meanwhile, the javax.faces.webapp.UIComponentTag class retrieves the parent UI component and
store
child count into that.
If a worker store a UIComponent into the request, then another parallel worker can steal the
UIComponent of other worker. In this case, the javax.faces.webapp.UIComponentTag throws an
exception.
I modified the org.apache.jetspeed.engine.servlet.ServletRequestImpl class not to put attributes
into the request when the current context is under an asynchoronous worker. Under an asynchronous
worker, the attributes are stored only in the current context and retrieved from the current
context.
When I tested this modification, it seems working correctly.

2. In the first visit under parallel mode just after Tomcat's restart, some portlet throws
NoClassDefFoundError as follows:

2007-01-23 16:07:22 ApplicationDispatcher[/jsf-demo] Servlet.service() for servlet jsp threw
exception
java.lang.NoClassDefFoundError: org.apache.myfaces.taglib.html.HtmlCommandButtonTag
    at org.apache.jsp.greeting_jsp.class$(greeting_jsp.java:97)
    at org.apache.jsp.greeting_jsp._jspx_meth_h_commandButton_0(greeting_jsp.java:261)
    ...

--> Actually, I could not figure out why this problem occurred in detail. However, I found
that
this symptom occurs only when the tag pool serialization file (tldCache.ser) of Tomcat exists.
If we remove the file before restarting Tomcat, this symptom does not occur any more.
Therefore, I concluded that this problem should be investigated in the Tomcat side hereafter.
Anyway, after the second visit, this symptom does not occur.


Some improved codes:

1. MockRenderJob.java was modified to implement the new RenderingJob interface, which was
modified
in the last patch.
2. AsynchPageAggregatorImpl.java now checks if the rendering job is not null; sometimes a
portlet
entity is pointed to invalid portlet definition for some reason, such as wrong psml file.
PortletRendererImpl.java and WorkerMonitorImpl.java check that also.
3. WorkerMonitorImpl now puts timeout workers into a temporary collection, and after that,
it
tries to kill jobs. Because job killing during iteration corrupt the collection itself, I
changed
this class.

contribution from Woonsan Ko

Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/aggregator/MockRenderJob.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java?view=diff&rev=499149&r1=499148&r2=499149
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java
Tue Jan 23 13:55:33 2007
@@ -190,7 +190,8 @@
                         // and store the portlet rendering job into the portlet jobs list.
                         RenderingJob job = renderer.render(child, context);
 
-                        if (job.getTimeout() > 0) 
+                        // The returned job can be null for some reason, such as invalid
portlet entity.
+                        if ((job != null) && (job.getTimeout() > 0)) 
                         {
                             portletJobs.add(job);
                         }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java?view=diff&rev=499149&r1=499148&r2=499149
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
Tue Jan 23 13:55:33 2007
@@ -323,8 +323,12 @@
         }
 
         long timeoutMetadata = 0;
+        Collection timeoutFields = null;
 
-        Collection timeoutFields = portletDefinition.getMetadata().getFields("timeout");
+        if (portletDefinition != null)
+        {
+            timeoutFields = portletDefinition.getMetadata().getFields("timeout");
+        }
 
         if (timeoutFields != null) 
         {

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java?view=diff&rev=499149&r1=499148&r2=499149
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
Tue Jan 23 13:55:33 2007
@@ -18,6 +18,7 @@
 
 import java.security.AccessControlContext;
 import java.security.AccessController;
+import java.util.Iterator;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Stack;
@@ -211,7 +212,13 @@
         // backlog job to this worker, else reset job count and put
         // it on the idle queue.
 
-        long jobTimeout = ((RenderingJob) worker.getJob()).getTimeout();
+        long jobTimeout = 0;
+
+        RenderingJob oldJob = (RenderingJob) worker.getJob();
+        if (oldJob != null)
+        {
+            jobTimeout = oldJob.getTimeout();
+        }
 
         synchronized (worker)
         {
@@ -274,33 +281,55 @@
 
         public void run() {
             while (true) {
-                try {
-                    int size = workersMonitored.size();
-
-                    for (int i = 0; i < size; i++) {
-                        WorkerImpl worker = (WorkerImpl) workersMonitored.get(i);
-
-                        if (null == worker) {
-                            break;
+                try 
+                {
+                    // Because a timeout worker can be removed 
+                    // in the workersMonitored collection during iterating,
+                    // copy timeout workers in the following collection to kill later.
+
+                    List timeoutWorkers = new ArrayList();
+
+                    synchronized (workersMonitored) 
+                    {
+                        for (Iterator it = workersMonitored.iterator(); it.hasNext(); )
+                        {
+                            WorkerImpl worker = (WorkerImpl) it.next();
+                            RenderingJob job = (RenderingJob) worker.getJob();
+                            
+                            if ((null != job) && (job.isTimeout()))
+                            {
+                                timeoutWorkers.add(worker);
+                            }
                         }
+                    }
 
+                    // Now, we can kill the timeout worker(s).
+                    for (Iterator it = timeoutWorkers.iterator(); it.hasNext(); )
+                    {
+                        WorkerImpl worker = (WorkerImpl) it.next();
                         RenderingJob job = (RenderingJob) worker.getJob();
 
-                        if (null != job) {
-                            if (job.isTimeout()) {
-                                killJob(worker, job);
-                            }
+                        // If the job is just completed, then do not kill the worker.
+                        if ((null != job) && (job.isTimeout()))
+                        {
+                            killJob(worker, job);
                         }
                     }
-                } catch (Exception e) {
+                } 
+                catch (Exception e) 
+                {
                     log.error("Exception during job monitoring.", e);
                 }
                
-                try {
-                    synchronized (this) {
+                try 
+                {
+                    synchronized (this) 
+                    {
                         wait(this.interval);
                     }
-                } catch (InterruptedException e) {
+                } 
+                catch (InterruptedException e) 
+                {
                     ;
                 }
             }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java?view=diff&rev=499149&r1=499148&r2=499149
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
Tue Jan 23 13:55:33 2007
@@ -386,10 +386,11 @@
                 CurrentWorkerContext.setAttribute(name, value);
             }
         }
-
-        // put attribute into request also.
-
-        setAttributeInternal(name, value);
+        else
+        {
+            // put attribute into request.
+            setAttributeInternal(name, value);
+        }
     }
 
     private void setAttributeInternal( String name, Object value )

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/aggregator/MockRenderJob.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/aggregator/MockRenderJob.java?view=diff&rev=499149&r1=499148&r2=499149
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/aggregator/MockRenderJob.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/aggregator/MockRenderJob.java
Tue Jan 23 13:55:33 2007
@@ -30,6 +30,9 @@
     private long mockTime;
     private String jobName;
     private PortletWindow window;
+
+    protected long startTimeMillis = 0;
+    protected long timeout;
     
     public MockRenderJob(String jobName, long mockTime, PortletWindow window)
     {
@@ -37,9 +40,38 @@
         this.jobName = jobName;
         this.window = window;
     }
+
+    /**
+     * Sets portlet timout in milliseconds.
+     */
+    public void setTimeout(long timeout) {
+        this.timeout = timeout;
+    }
+
+    /**
+     * Gets portlet timout in milliseconds.
+     */
+    public long getTimeout() {
+        return this.timeout;
+    }
+
+    /**
+     * Checks if the portlet rendering is timeout
+     */
+    public boolean isTimeout() {
+        if ((this.timeout > 0) && (this.startTimeMillis > 0)) {
+            return (System.currentTimeMillis() - this.startTimeMillis > this.timeout);
+        }
+
+        return false;
+    }
     
     public void run()
     {       
+        if (this.timeout > 0) {
+            this.startTimeMillis = System.currentTimeMillis();
+        }
+
         execute();
     }
     



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


Mime
View raw message