portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r587066 [1/3] - in /portals/jetspeed-2/trunk: ./ components/jetspeed-portal/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/ compo...
Date Mon, 22 Oct 2007 11:57:41 GMT
Author: woonsan
Date: Mon Oct 22 04:57:40 2007
New Revision: 587066

URL: http://svn.apache.org/viewvc?rev=587066&view=rev
Log:
[JS2-785] Parallel Rendering on Websphere 6.1

Reduced errors significantly in parallel rendering on Websphere 6.1.
 - Cleaned up aggregation and rendering codes.
 - Adjusted a portal session invalidation problem.
 - Added wrapping on servlet request of WebSphere to support multithreaded request access.
 - Added CommonJ Work Manager facility to use Container's Work Manager for parallel rendering
thread pool. (Optional)

Added:
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/CommonjWorkerMonitorImpl.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/AdjustedSRTServletRequestDump.java
Modified:
    portals/jetspeed-2/trunk/components/jetspeed-portal/pom.xml
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/WorkerImpl.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/ServletPortletInvokerFactory.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/session/PortalSessionMonitorImpl.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/session/PortalSessionsManagerImpl.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java
    portals/jetspeed-2/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/aggregator/WorkerMonitor.java
    portals/jetspeed-2/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/session/PortalSessionMonitor.java
    portals/jetspeed-2/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/session/PortletApplicationSessionMonitor.java
    portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/aggregator/CurrentWorkerContext.java
    portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
    portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/container/session/PortletApplicationSessionMonitorImpl.java
    portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/aggregation.xml
    portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/pluto-factories.xml
    portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/web.xml
    portals/jetspeed-2/trunk/pom.xml

Modified: portals/jetspeed-2/trunk/components/jetspeed-portal/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/pom.xml?rev=587066&r1=587065&r2=587066&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/pom.xml (original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/pom.xml Mon Oct 22 04:57:40 2007
@@ -126,7 +126,21 @@
             <groupId>ehcache</groupId>
             <artifactId>ehcache</artifactId>
         </dependency>
-        
+
+        <dependency>
+        	<groupId>asm</groupId>
+        	<artifactId>asm</artifactId>
+        </dependency>
+        <dependency>
+        	<groupId>asm</groupId>
+        	<artifactId>asm-attrs</artifactId>
+        </dependency>
+        <dependency>
+        	<groupId>commonj</groupId>
+        	<artifactId>commonj-twm</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
         <!-- Test Dependencies -->
         <dependency>
             <groupId>${pom.groupId}</groupId>

Modified: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java?rev=587066&r1=587065&r2=587066&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java
Mon Oct 22 04:57:40 2007
@@ -197,7 +197,7 @@
             log.info("Aggregating " + page.getPath() + ". Parallel: " + parallelJobCount
+ ", Sequential: " + sequentialJobCount);
         }
         
-        CurrentWorkerContext.setCurrentWorkerContextUsed(parallelJobCount > 0 &&
sequentialJobCount > 0);
+        CurrentWorkerContext.setParallelRenderingMode(parallelJobCount > 0);
 
         // kick off the parallel rendering jobs
         Iterator iter = parallelJobs.iterator();
@@ -237,6 +237,9 @@
         {
             log.error("Exception during synchronizing all portlet rendering jobs.", e);
         }
+        
+        // Now, restore it to non parallel mode for rendering layout portlets.
+        CurrentWorkerContext.setParallelRenderingMode(false);
         
         // render layout fragments.
         iter = layoutFragments.iterator();

Added: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/CommonjWorkerMonitorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/CommonjWorkerMonitorImpl.java?rev=587066&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/CommonjWorkerMonitorImpl.java
(added)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/CommonjWorkerMonitorImpl.java
Mon Oct 22 04:57:40 2007
@@ -0,0 +1,263 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.aggregator.impl;
+
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Collections;
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.aggregator.RenderingJob;
+import org.apache.jetspeed.aggregator.WorkerMonitor;
+import org.apache.jetspeed.aggregator.PortletContent;
+import org.apache.jetspeed.aggregator.CurrentWorkerContext;
+
+import commonj.work.WorkManager;
+import commonj.work.Work;
+import commonj.work.WorkItem;
+import commonj.work.WorkListener;
+import commonj.work.WorkEvent;
+
+/**
+ * The CommonjWorkerMonitorImpl is responsible for dispatching jobs to workers
+ * It wraps CommonJ WorkManager supported by IBM WebSphere and BEA WebLogic sever.
+ *
+ * @author <a href="mailto:woon_san@apache.org">Woonsan Ko</a>
+ * @version $Id: CommonjWorkerMonitorImpl.java 568339 2007-08-22 00:14:51Z ate $
+ */
+public class CommonjWorkerMonitorImpl implements WorkerMonitor, WorkListener
+{
+
+    public static final String ACCESS_CONTROL_CONTEXT_WORKER_ATTR = AccessControlContext.class.getName();
+    
+    /** CommonJ Work Manamger provided by JavaEE container */
+    protected WorkManager workManager;
+    
+    /** Work items to be monitored for timeout checking */
+    protected List workItemsMonitored = Collections.synchronizedList(new LinkedList());
+
+    public CommonjWorkerMonitorImpl(WorkManager workManager)
+    {
+        this.workManager = workManager;
+    }
+    
+    /** Commons logging */
+    protected final static Log log = LogFactory.getLog(CommonjWorkerMonitorImpl.class);
+    
+    /** Renering Job Timeout monitor */
+    protected CommonjWorkerRenderingJobTimeoutMonitor jobMonitor = null;
+    
+    public void start()
+    {
+        jobMonitor = new CommonjWorkerRenderingJobTimeoutMonitor(1000);
+        jobMonitor.start();
+    }
+
+    public void stop()
+    {    
+    	if (jobMonitor != null)
+        {
+    		jobMonitor.endThread();
+        }
+        
+    	jobMonitor = null;
+    }
+    
+    /**
+     * Assign a job to a worker and execute it or queue the job if no
+     * worker is available.
+     *
+     * @param job the Job to process
+     */
+    public void process(RenderingJob job)
+    {
+        AccessControlContext context = AccessController.getContext();
+        job.setWorkerAttribute(ACCESS_CONTROL_CONTEXT_WORKER_ATTR, context);
+        
+        try
+        {
+            WorkItem workItem = this.workManager.schedule(new RenderingJobCommonjWork(job),
this);
+            this.workItemsMonitored.add(workItem);
+        }
+        catch (Throwable t)
+        {
+            log.error("Worker exception", t);
+        }
+    }
+
+    public int getQueuedJobsCount()
+    {
+        return 0;
+    }
+    
+    /**
+     * Returns a snapshot of the available jobs
+     * @return available jobs
+     */
+    public int getAvailableJobsCount()
+    {
+        return 0;
+    }
+    
+    public int getRunningJobsCount()
+    {
+        return 0;
+    }
+    
+    public void workAccepted(WorkEvent we)
+    {
+        WorkItem workItem = we.getWorkItem();
+        if (log.isDebugEnabled()) log.debug("[CommonjWorkMonitorImpl] workAccepted: " + workItem);
+    }
+
+    public void workRejected(WorkEvent we)
+    {
+        WorkItem workItem = we.getWorkItem();
+        if (log.isDebugEnabled()) log.debug("[CommonjWorkMonitorImpl] workRejected: " + workItem);
+        removeMonitoredWorkItem(workItem);
+    }
+
+    public void workStarted(WorkEvent we)
+    {
+        WorkItem workItem = we.getWorkItem();
+        if (log.isDebugEnabled()) log.debug("[CommonjWorkMonitorImpl] workStarted: " + workItem);
+    }
+
+    public void workCompleted(WorkEvent we)
+    {
+        WorkItem workItem = we.getWorkItem();
+        if (log.isDebugEnabled()) log.debug("[CommonjWorkMonitorImpl] workCompleted: " +
workItem);
+        removeMonitoredWorkItem(workItem);
+    }
+    
+    protected boolean removeMonitoredWorkItem(WorkItem workItem)
+    {
+        return this.workItemsMonitored.remove(workItem);
+    }
+    
+    class RenderingJobCommonjWork implements Work
+    {
+
+        protected RenderingJob job;
+
+        public RenderingJobCommonjWork()
+        {
+        }
+        
+        public RenderingJobCommonjWork(RenderingJob job)
+        {
+            this.job = job;
+        }
+
+        public boolean isDaemon()
+        {
+            return false;
+        }
+        
+        public void run()
+        {
+            this.job.run();
+        }
+        
+        public void release()
+        {
+        }
+        
+        public void setRenderingJob(RenderingJob job)
+        {
+            this.job = job;
+        }
+        
+        public RenderingJob getRenderingJob()
+        {
+            return this.job;
+        }
+
+    }
+
+    class CommonjWorkerRenderingJobTimeoutMonitor extends Thread {
+
+        long interval = 1000;
+        boolean shouldRun = true;
+        
+        CommonjWorkerRenderingJobTimeoutMonitor(long interval) 
+        {
+            super("CommonjWorkerRenderingJobTimeoutMonitor");
+
+            if (interval > 0) 
+            {
+                this.interval = interval;
+            }
+        }
+        /**
+         * Thread.stop() is deprecated.
+         * This method achieves the same by setting the run varaible "shouldRun" to false
and interrupting the Thread, 
+         * effectively causing the thread to shutdown correctly.
+         *
+         */
+        public void endThread()
+        {
+        	shouldRun = false;
+        	this.interrupt();
+        }
+        
+        public void run() {
+            while (shouldRun) {
+                try 
+                {
+                    synchronized (workItemsMonitored) 
+                    {
+                        for (Iterator it = workItemsMonitored.iterator(); it.hasNext(); )
+                        {
+                            WorkItem workItem = (WorkItem) it.next();
+                            int status = workItem.getStatus();
+                            
+                            if (status == WorkEvent.WORK_COMPLETED || status == WorkEvent.WORK_REJECTED)
+                            {
+                                it.remove();
+                            }
+                            else
+                            {
+                            }
+                        }
+                    }
+                } 
+                catch (Exception e) 
+                {
+                    log.error("Exception during job monitoring.", e);
+                }
+               
+                try 
+                {
+                    synchronized (this) 
+                    {
+                        wait(this.interval);
+                    }
+                } 
+                catch (InterruptedException e) 
+                {
+                    ;
+                }
+            }
+        }
+    }
+}

Modified: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java?rev=587066&r1=587065&r2=587066&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
Mon Oct 22 04:57:40 2007
@@ -511,7 +511,12 @@
                                                          statistics, expirationCache, contentIsCached
);
             
         }
-        setTimeoutOnJob(timeoutMetadata, rJob);
+        
+        if (isParallel)
+        {
+            setTimeoutOnJob(timeoutMetadata, rJob);
+        }
+        
         return rJob;
     }
  

Modified: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java?rev=587066&r1=587065&r2=587066&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
Mon Oct 22 04:57:40 2007
@@ -36,7 +36,6 @@
 import org.apache.jetspeed.aggregator.PortletRenderer;
 import org.apache.jetspeed.aggregator.PortletTrackingManager;
 import org.apache.jetspeed.aggregator.RenderingJob;
-import org.apache.jetspeed.aggregator.Worker;
 import org.apache.jetspeed.components.portletentity.PortletEntityImpl;
 import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
 import org.apache.jetspeed.om.page.ContentFragment;
@@ -169,7 +168,9 @@
     {       
         try
         {
-            if (this.timeout > 0) {
+            if (this.timeout > 0) 
+            {
+                CurrentWorkerContext.setParallelRenderingMode(true);
                 this.startTimeMillis = System.currentTimeMillis();
             }
 
@@ -179,7 +180,6 @@
         }
         finally
         {
-            
             synchronized (portletContent)
             {
                log.debug("Notifying completion of rendering job for fragment " + fragment.getId());
               
@@ -207,7 +207,7 @@
             // if the current thread is worker, then store attribues in that.
             if (this.workerAttributes != null)
             {
-                isParallelMode = (Thread.currentThread() instanceof Worker || CurrentWorkerContext.getCurrentWorkerContextUsed());
               
+                isParallelMode = CurrentWorkerContext.getParallelRenderingMode();
                 if (isParallelMode)
                 {
                     Iterator itAttrNames = this.workerAttributes.keySet().iterator();

Modified: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/WorkerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/WorkerImpl.java?rev=587066&r1=587065&r2=587066&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/WorkerImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/WorkerImpl.java
Mon Oct 22 04:57:40 2007
@@ -200,7 +200,7 @@
             this.jobCount++;
 
             // release the worker
-            monitor.release(this);
+            ((WorkerMonitorImpl) monitor).release(this);
         }
     }
     

Modified: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java?rev=587066&r1=587065&r2=587066&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
Mon Oct 22 04:57:40 2007
@@ -100,7 +100,7 @@
     public void start()
     {
         addWorkers(this.minWorkers);
-        setQueue(new FIFOQueue());
+        this.queue = new FIFOQueue();
 
         jobMonitor = new RenderingJobTimeoutMonitor(1000);
         jobMonitor.start();
@@ -113,11 +113,6 @@
     	jobMonitor = null;
     	
     }
-    
-    public void setQueue(Queue queue)
-    {
-        this.queue = queue;
-    }
 
     /**
      * Create the request number of workers and add them to
@@ -152,7 +147,7 @@
      *
      * @return a Worker from the idle pool or null if non available
      */
-    public Worker getWorker()
+    protected Worker getWorker()
     {
         synchronized(this.workers)
         {
@@ -214,7 +209,7 @@
      * Put back the worker in the idle queue unless there are pending jobs and
      * worker can still be committed to a new job before being released.
      */
-    public void release(Worker worker)
+    protected void release(Worker worker)
     {
         // if worker can still proces some jobs assign the first
         // backlog job to this worker, else reset job count and put
@@ -238,7 +233,7 @@
                 
                 if (job != null)
                 {
-                    AccessControlContext context = (AccessControlContext)job.getWorkerAttribute(ACCESS_CONTROL_CONTEXT_WORKER_ATTR);
+                    AccessControlContext context = (AccessControlContext) job.getWorkerAttribute(ACCESS_CONTROL_CONTEXT_WORKER_ATTR);
                     worker.setJob(job, context);
                     runningJobs--;
                     return;



---------------------------------------------------------------------
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