Author: taylor
Date: Sun Feb 18 16:12:45 2007
New Revision: 509036
URL: http://svn.apache.org/viewvc?view=rev&rev=509036
Log:
http://issues.apache.org/jira/browse/JS2-226
portlet tracking to remove non-responsive portlets from service
this completes 226 for 2.1
Added:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletTrackingManagerImpl.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletTrackingManager.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/RenderTrackable.java
Removed:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/BasicAggregator.java
Modified:
portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PortletContentImpl.java
portals/jetspeed-2/trunk/components/portal/maven.xml
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/PageAggregatorImpl.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletContentImpl.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/RenderingJobImpl.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java
portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletContent.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletRenderer.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java
portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/aggregation.xml
Modified:
portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PortletContentImpl.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PortletContentImpl.java?view=diff&rev=509036&r1=509035&r2=509036
==============================================================================
---
portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PortletContentImpl.java
(original)
+++
portals/jetspeed-2/trunk/applications/gems/src/java/org/apache/portals/gems/util/PortletContentImpl.java
Sun Feb 18 16:12:45 2007
@@ -119,6 +119,11 @@
return expiration;
}
+ public void setExpiration(int e)
+ {
+ this.expiration = e;
+ }
+
public String getTitle()
{
return title;
Modified: portals/jetspeed-2/trunk/components/portal/maven.xml
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/maven.xml?view=diff&rev=509036&r1=509035&r2=509036
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/maven.xml (original)
+++ portals/jetspeed-2/trunk/components/portal/maven.xml Sun Feb 18 16:12:45
2007
@@ -17,6 +17,6 @@
<project default="java:jar" xmlns:j="jelly:core" xmlns:define="jelly:define"
xmlns:maven="jelly:maven">
<!-- Target of maven test:single test -->
- <property name='testcase'
value='org.apache.jetspeed.aggregator.TestAggregator' />
+ <property name='testcase'
value='org.apache.jetspeed.aggregator.TestAggregator2' />
</project>
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=509036&r1=509035&r2=509036
==============================================================================
---
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
Sun Feb 18 16:12:45 2007
@@ -42,6 +42,7 @@
* and synchronization of worker threads.
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor </a>
+ * @author <a>Woonsan Ko</a>
* @version $Id: $
*/
public class AsyncPageAggregatorImpl implements PageAggregator
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java?view=diff&rev=509036&r1=509035&r2=509036
==============================================================================
---
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java
(original)
+++
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java
Sun Feb 18 16:12:45 2007
@@ -41,23 +41,11 @@
public class PageAggregatorImpl implements PageAggregator
{
private final static Log log = LogFactory.getLog(PageAggregatorImpl.class);
-
- public final static int STRATEGY_SEQUENTIAL = 0;
- public final static int STRATEGY_PARALLEL = 1;
-
- private int strategy = STRATEGY_SEQUENTIAL;
private PortletRenderer renderer;
-
- public PageAggregatorImpl( PortletRenderer renderer, int strategy)
- {
- this.renderer = renderer;
- this.strategy = strategy;
- }
-
public PageAggregatorImpl( PortletRenderer renderer)
{
- this(renderer, STRATEGY_SEQUENTIAL);
+ this.renderer = renderer;
}
/**
@@ -155,13 +143,6 @@
}
}
}
- if (strategy == STRATEGY_SEQUENTIAL)
- {
- renderer.renderNow(f, context);
- }
- else
- {
- renderer.render(f, context);
- }
+ renderer.renderNow(f, context);
}
}
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletContentImpl.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletContentImpl.java?view=diff&rev=509036&r1=509035&r2=509036
==============================================================================
---
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletContentImpl.java
(original)
+++
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletContentImpl.java
Sun Feb 18 16:12:45 2007
@@ -124,6 +124,11 @@
return expiration;
}
+ public void setExpiration(int expiration)
+ {
+ this.expiration = expiration;
+ }
+
public String getTitle()
{
return title;
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=509036&r1=509035&r2=509036
==============================================================================
---
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
Sun Feb 18 16:12:45 2007
@@ -34,6 +34,7 @@
import org.apache.jetspeed.aggregator.PortletAccessDeniedException;
import org.apache.jetspeed.aggregator.PortletContent;
import org.apache.jetspeed.aggregator.PortletRenderer;
+import org.apache.jetspeed.aggregator.PortletTrackingManager;
import org.apache.jetspeed.aggregator.RenderingJob;
import org.apache.jetspeed.aggregator.UnknownPortletDefinitionException;
import org.apache.jetspeed.aggregator.WorkerMonitor;
@@ -63,6 +64,8 @@
* </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta </a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
+ * @author <a>Woonsan Ko</a>
* @version $Id: PortletRendererImpl.java,v 1.30 2005/05/20 14:54:22 ate Exp $
*/
public class PortletRendererImpl implements PortletRenderer
@@ -74,12 +77,9 @@
protected PortletWindowAccessor windowAccessor;
protected PortalStatistics statistics;
protected DynamicTitleService addTitleService;
- /**
- * when rendering a portlet, the default timeout period in milliseconds
- * setting to zero will disable (no timeout) the timeout
- *
- */
- protected long defaultPortletTimeout;
+
+ protected PortletTrackingManager portletTracking;
+
/**
* flag indicating whether to check jetspeed-portlet.xml security
constraints
* before rendering a portlet. If security check fails, do not display
portlet content
@@ -95,14 +95,19 @@
*/
protected JetspeedCache portletContentCache;
+ /**
+ * OutOfService Cache
+ */
+ protected Map outOfService = new HashMap(); // todo
protected boolean overrideTitles = false;
+ public static final String OUT_OF_SERVICE_MESSAGE = "Portlet is not
responding and has been taken out of service.";
public PortletRendererImpl(PortletContainer container,
PortletWindowAccessor windowAccessor,
WorkerMonitor workMonitor,
PortalStatistics statistics,
DynamicTitleService addTitleService,
- long defaultPortletTimeout,
+ PortletTrackingManager portletTracking,
boolean checkSecurityConstraints,
SecurityAccessController accessController,
JetspeedCache portletContentCache,
@@ -113,7 +118,7 @@
this.workMonitor = workMonitor;
this.statistics = statistics;
this.addTitleService = addTitleService;
- this.defaultPortletTimeout = defaultPortletTimeout;
+ this.portletTracking = portletTracking;
this.checkSecurityConstraints = checkSecurityConstraints;
this.accessController = accessController;
this.portletContentCache = portletContentCache;
@@ -125,13 +130,13 @@
WorkerMonitor workMonitor,
PortalStatistics statistics,
DynamicTitleService addTitleService,
- long defaultPortletTimeout,
+ PortletTrackingManager portletTracking,
boolean checkSecurityConstraints,
SecurityAccessController accessController,
JetspeedCache portletContentCache)
{
this(container, windowAccessor, workMonitor, statistics,
- addTitleService, defaultPortletTimeout, checkSecurityConstraints,
+ addTitleService, portletTracking, checkSecurityConstraints,
accessController, portletContentCache, false);
}
@@ -141,7 +146,7 @@
PortalStatistics statistics,
DynamicTitleService addTitleService)
{
- this(container, windowAccessor, workMonitor, statistics, null, 0,
false, null, null, true);
+ this(container, windowAccessor, workMonitor, statistics, null, null,
false, null, null, true);
}
public PortletRendererImpl(PortletContainer container,
@@ -192,6 +197,14 @@
{
throw new PortletAccessDeniedException("Access Denied.");
}
+ if (portletTracking.isOutOfService(portletWindow))
+ {
+ log.info("Taking portlet out of service: " +
portletDefinition.getUniqueName() + " for window " + fragment.getId());
+ fragment.overrideRenderedContent(OUT_OF_SERVICE_MESSAGE);
+ return;
+ }
+ long timeoutMetadata = this.getTimeoutOnJob(portletDefinition);
+ portletTracking.setExpiration(portletWindow, timeoutMetadata);
int expirationCache = getExpirationCache(portletDefinition);
if (expirationCache != 0)
{
@@ -208,7 +221,7 @@
RenderingJob rJob =
buildRenderingJob(portletWindow, fragment, servletRequest,
servletResponse,
requestContext, false, portletDefinition,
dispatcher, null,
- expirationCache, contentIsCached);
+ expirationCache, contentIsCached,
timeoutMetadata);
rJob.execute();
addTitleToHeader( portletWindow, fragment, servletRequest,
servletResponse, dispatcher, contentIsCached);
}
@@ -296,15 +309,23 @@
PortletWindow portletWindow = getPortletWindow(fragment);
PortletDefinitionComposite portletDefinition =
(PortletDefinitionComposite)
portletWindow.getPortletEntity().getPortletDefinition();
+
+ long timeoutMetadata = this.getTimeoutOnJob(portletDefinition);
+ portletTracking.setExpiration(portletWindow, timeoutMetadata);
if (checkSecurityConstraints &&
!checkSecurityConstraint(portletDefinition, fragment))
{
throw new PortletAccessDeniedException("Access Denied.");
}
-
+ if (portletTracking.isOutOfService(portletWindow))
+ {
+ fragment.overrideRenderedContent(OUT_OF_SERVICE_MESSAGE);
+ return null;
+ }
int expirationCache = getExpirationCache(portletDefinition);
if (expirationCache != 0)
{
+ portletTracking.setExpiration(portletWindow,
(long)expirationCache);
contentIsCached = retrieveCachedContent(requestContext,
fragment, portletWindow,
expirationCache,
portletDefinition);
if (contentIsCached)
@@ -313,7 +334,7 @@
}
}
job = buildRenderingJob( portletWindow, fragment, requestContext,
true,
- portletDefinition, null, contentIsCached
);
+ portletDefinition, null, contentIsCached,
timeoutMetadata );
}
catch (Exception e)
{
@@ -425,7 +446,7 @@
protected RenderingJob buildRenderingJob( PortletWindow portletWindow,
ContentFragment fragment,
RequestContext requestContext,
boolean isParallel,
PortletDefinitionComposite
portletDefinition,
- PortletContent portletContent,
boolean contentIsCached )
+ PortletContent portletContent,
boolean contentIsCached, long timeoutMetadata)
throws PortletAccessDeniedException, FailedToRetrievePortletWindow,
PortletEntityNotStoredException
{
int expirationCache = getExpirationCache(portletDefinition);
@@ -436,7 +457,7 @@
return buildRenderingJob( portletWindow, fragment, request, response,
requestContext, isParallel,
portletDefinition, dispatcher,
- portletContent, expirationCache,
contentIsCached );
+ portletContent, expirationCache,
contentIsCached, timeoutMetadata );
}
protected RenderingJob buildRenderingJob( PortletWindow portletWindow,
ContentFragment fragment,
@@ -445,7 +466,7 @@
PortletDefinitionComposite
portletDefinition,
ContentDispatcherCtrl
dispatcher,
PortletContent portletContent,
- int expirationCache, boolean
contentIsCached )
+ int expirationCache, boolean
contentIsCached, long timeoutMetadata)
throws PortletAccessDeniedException,
FailedToRetrievePortletWindow, PortletEntityNotStoredException
{
RenderingJob rJob = null;
@@ -489,11 +510,11 @@
statistics,
expirationCache, contentIsCached );
}
- setTimeoutOnJob(portletDefinition, rJob);
+ setTimeoutOnJob(timeoutMetadata, rJob);
return rJob;
}
-
- protected void setTimeoutOnJob(PortletDefinitionComposite
portletDefinition, RenderingJob rJob)
+
+ protected long getTimeoutOnJob(PortletDefinitionComposite
portletDefinition)
{
long timeoutMetadata = 0;
Collection timeoutFields = null;
@@ -520,15 +541,20 @@
log.warn("Invalid timeout metadata: " + nfe.getMessage());
}
}
- }
-
+ }
+ return timeoutMetadata;
+ }
+
+ protected void setTimeoutOnJob(long timeoutMetadata, RenderingJob rJob)
+ {
+
if (timeoutMetadata > 0)
{
rJob.setTimeout(timeoutMetadata);
}
- else if (this.defaultPortletTimeout > 0)
+ else if (this.portletTracking.getDefaultPortletTimeout() > 0)
{
- rJob.setTimeout(this.defaultPortletTimeout);
+ rJob.setTimeout(this.portletTracking.getDefaultPortletTimeout());
}
}
@@ -611,5 +637,10 @@
{
if (content.getExpiration() != 0)
addToCache(content);
+ }
+
+ public PortletTrackingManager getPortletTrackingManager()
+ {
+ return this.portletTracking;
}
}
Added:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletTrackingManagerImpl.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletTrackingManagerImpl.java?view=auto&rev=509036
==============================================================================
---
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletTrackingManagerImpl.java
(added)
+++
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletTrackingManagerImpl.java
Sun Feb 18 16:12:45 2007
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.jetspeed.aggregator.PortletTrackingManager;
+import org.apache.jetspeed.aggregator.RenderTrackable;
+import org.apache.jetspeed.container.window.PortletWindowAccessor;
+import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
+import org.apache.pluto.om.window.PortletWindow;
+
+/**
+ * Tracks out of service status for portlets
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class PortletTrackingManagerImpl implements PortletTrackingManager
+{
+ protected Map outOfService = Collections.synchronizedMap(new HashMap());
+
+ /**
+ * when rendering a portlet, the default timeout period in milliseconds
+ * setting to zero will disable (no timeout) the timeout
+ *
+ */
+ protected long defaultPortletTimeout;
+
+ /**
+ * Out of service limit, if a portlet entity times out past its limit (or
default limit) n consecutive times,
+ * it is taken out of service
+ */
+ protected int outOfServiceLimit;
+
+ protected PortletWindowAccessor windowAccessor;
+
+ public PortletTrackingManagerImpl(PortletWindowAccessor windowAccessor,
long defaultPortletTimeout, int outOfServiceLimit)
+ {
+ this.windowAccessor = windowAccessor;
+ this.defaultPortletTimeout = defaultPortletTimeout;
+ this.outOfServiceLimit = outOfServiceLimit;
+ }
+
+ public long getDefaultPortletTimeout()
+ {
+ return this.defaultPortletTimeout;
+ }
+
+ public boolean exceededTimeout(long renderTime, PortletWindow window)
+ {
+ RenderTrackable trackInfo = (RenderTrackable)window.getPortletEntity();
+ long defaultTimeout = this.getDefaultPortletTimeout();
+ if (trackInfo.getExpiration() > 0)
+ {
+ return (renderTime > trackInfo.getExpiration());
+ }
+ else if (defaultTimeout > 0)
+ {
+ return (renderTime > defaultTimeout);
+ }
+ return false;
+ }
+
+ public boolean isOutOfService(PortletWindow window)
+ {
+ RenderTrackable trackable = (RenderTrackable)window.getPortletEntity();
+ if (trackable.getRenderTimeoutCount() > this.outOfServiceLimit)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public int getOutOfServiceLimit()
+ {
+ return this.outOfServiceLimit;
+ }
+
+ public void incrementRenderTimeoutCount(PortletWindow window)
+ {
+ RenderTrackable trackable = (RenderTrackable)window.getPortletEntity();
+ trackable.incrementRenderTimeoutCount();
+ }
+
+ public void success(PortletWindow window)
+ {
+ RenderTrackable trackable = (RenderTrackable)window.getPortletEntity();
+ trackable.success();
+ }
+
+ public void setExpiration(PortletWindow window, long expiration)
+ {
+ RenderTrackable trackable = (RenderTrackable)window.getPortletEntity();
+ trackable.setExpiration(expiration * 1000);
+ }
+
+ public void takeOutOfService(PortletWindow window)
+ {
+ RenderTrackable trackable = (RenderTrackable)window.getPortletEntity();
+ trackable.setRenderTimeoutCount((int)this.defaultPortletTimeout + 1);
+ }
+
+ public void putIntoService(PortletWindow window)
+ {
+ RenderTrackable trackable = (RenderTrackable)window.getPortletEntity();
+ trackable.setRenderTimeoutCount(0);
+ }
+
+ public List getOutOfServiceList(String fullPortletName)
+ {
+ List outs = new ArrayList();
+ Iterator windows = this.windowAccessor.getPortletWindows().iterator();
+ while (windows.hasNext())
+ {
+ PortletWindow window = (PortletWindow)windows.next();
+ PortletDefinitionComposite pd =
(PortletDefinitionComposite)window.getPortletEntity().getPortletDefinition();
+ if (pd.getUniqueName().equals(fullPortletName) &&
isOutOfService(window))
+ {
+ outs.add(window);
+ }
+ }
+ return outs;
+ }
+
+ public List getOutOfServiceList()
+ {
+ List outs = new ArrayList();
+ Iterator windows = this.windowAccessor.getPortletWindows().iterator();
+ while (windows.hasNext())
+ {
+ PortletWindow window = (PortletWindow)windows.next();
+ if (isOutOfService(window))
+ {
+ outs.add(window);
+ }
+ }
+ return outs;
+ }
+}
\ No newline at end of file
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java?view=diff&rev=509036&r1=509035&r2=509036
==============================================================================
---
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
(original)
+++
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
Sun Feb 18 16:12:45 2007
@@ -26,12 +26,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.aggregator.ContentDispatcherCtrl;
import org.apache.jetspeed.aggregator.CurrentWorkerContext;
import org.apache.jetspeed.aggregator.PortletContent;
+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.aggregator.ContentDispatcherCtrl;
-import org.apache.jetspeed.aggregator.PortletRenderer;
import org.apache.jetspeed.components.portletentity.PortletEntityImpl;
import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
import org.apache.jetspeed.om.page.ContentFragment;
@@ -47,6 +48,8 @@
* in its Runnable method.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
+ * @author <a>Woonsan Ko</a>
* @version $Id$
*/
public class RenderingJobImpl implements RenderingJob
@@ -63,6 +66,7 @@
protected PortletRenderer renderer = null;
protected ContentFragment fragment = null;
protected RequestContext requestContext = null;
+ protected PortletTrackingManager portletTracking = null;
protected PortletDefinition portletDefinition;
protected PortletContent portletContent;
@@ -93,6 +97,7 @@
{
this.container = container;
this.renderer = renderer;
+ this.portletTracking = renderer.getPortletTrackingManager();
this.statistics = statistics;
this.portletDefinition = portletDefinition;
this.fragment = fragment;
@@ -251,6 +256,8 @@
}
finally
{
+ long end = System.currentTimeMillis();
+ boolean exceededTimeout = portletTracking.exceededTimeout(end -
start, window);
portletContent.complete();
if (isParallelMode)
@@ -264,14 +271,24 @@
if (fragment.getType().equals(ContentFragment.PORTLET))
{
- long end = System.currentTimeMillis();
if (statistics != null)
+ {
statistics.logPortletAccess(requestContext,
fragment.getName(), PortalStatistics.HTTP_OK, end - start);
+ }
+ if (exceededTimeout)
+ {
+ // took too long to render
+ log.info("Portlet Exceeded timeout: " +
window.getPortletEntity().getPortletDefinition().getName() + " for window " +
window.getId());
+ portletTracking.incrementRenderTimeoutCount(window);
+ }
+ else
+ {
+ portletTracking.success(window);
+ }
}
}
-
}
-
+
/**
*
* <p>
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java?view=diff&rev=509036&r1=509035&r2=509036
==============================================================================
---
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java
(original)
+++
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/PortletWindowSessionNavigationalStates.java
Sun Feb 18 16:12:45 2007
@@ -281,7 +281,7 @@
{
extendedSessionState.setParametersMap(null);
requestState.setClearParameters(false);
- changed = true;
+ //changed = true;
}
else if ( extendedSessionState.getParametersMap() != null )
{
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java?view=diff&rev=509036&r1=509035&r2=509036
==============================================================================
---
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java
(original)
+++
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java
Sun Feb 18 16:12:45 2007
@@ -18,9 +18,9 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -284,5 +284,10 @@
&& pe.getPortletDefinition().getPortletApplicationDefinition()
!= null
&&
portletFactory.isPortletApplicationRegistered((PortletApplication)
pe.getPortletDefinition()
.getPortletApplicationDefinition());
+ }
+
+ public Set getPortletWindows()
+ {
+ return this.windows.entrySet();
}
}
Modified:
portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java?view=diff&rev=509036&r1=509035&r2=509036
==============================================================================
---
portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
(original)
+++
portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
Sun Feb 18 16:12:45 2007
@@ -29,6 +29,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.aggregator.RenderTrackable;
import org.apache.jetspeed.components.persistence.store.PersistenceStore;
import
org.apache.jetspeed.components.persistence.store.PersistenceStoreRuntimeExcpetion;
import org.apache.jetspeed.components.persistence.store.RemovalAware;
@@ -60,40 +61,29 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver </a>
* @version $Id: PortletEntityImpl.java,v 1.9 2005/04/29 13:59:08 weaver Exp $
*/
-public class PortletEntityImpl implements MutablePortletEntity,
PrincipalAware, RemovalAware
-{
-
+public class PortletEntityImpl implements MutablePortletEntity,
PrincipalAware, RemovalAware, RenderTrackable
+{
private long oid;
-
private JetspeedObjectID id;
-
- protected static PortletEntityAccessComponent pac;
-
+ protected static PortletEntityAccessComponent pac;
protected static PortletRegistry registry;
protected static RequestContextComponent rcc;
private static final Log log = LogFactory.getLog(PortletEntityImpl.class);
-
protected Map perPrincipalPrefs = new HashMap();
-
protected Map originalValues;
-
private PortletApplicationEntity applicationEntity = null;
-
private PortletWindowList portletWindows = new PortletWindowListImpl();
-
- private PortletDefinitionComposite portletDefinition = null;
-
+ private PortletDefinitionComposite portletDefinition = null;
protected String portletName;
-
protected String appName;
-
private boolean dirty = false;
-
private Fragment fragment;
-
private ThreadLocal fragmentPortletDefinition = new ThreadLocal();
+ protected transient int timeoutCount = 0;
+ protected transient long expiration = 0;
+
public PortletEntityImpl(Fragment fragment)
{
setFragment(fragment);
@@ -569,5 +559,36 @@
this.fragment = fragment;
// if the fragment is set, clear threadlocal fragmentPortletDefinition
cache
fragmentPortletDefinition.set(null);
- }
+ }
+
+ public int getRenderTimeoutCount()
+ {
+ return timeoutCount;
+ }
+
+ public synchronized void incrementRenderTimeoutCount()
+ {
+ timeoutCount++;
+ }
+
+ public synchronized void setExpiration(long expiration)
+ {
+ this.expiration = expiration;
+ }
+
+ public long getExpiration()
+ {
+ return this.expiration;
+ }
+
+ public void success()
+ {
+ timeoutCount = 0;
+ }
+
+ public void setRenderTimeoutCount(int timeoutCount)
+ {
+ this.timeoutCount = timeoutCount;
+ }
+
}
Modified:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletContent.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletContent.java?view=diff&rev=509036&r1=509035&r2=509036
==============================================================================
---
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletContent.java
(original)
+++
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletContent.java
Sun Feb 18 16:12:45 2007
@@ -53,6 +53,7 @@
* @return
*/
int getExpiration();
+ void setExpiration(int expiration);
/**
* Get the cache key used to cache this content
Modified:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletRenderer.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletRenderer.java?view=diff&rev=509036&r1=509035&r2=509036
==============================================================================
---
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletRenderer.java
(original)
+++
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletRenderer.java
Sun Feb 18 16:12:45 2007
@@ -30,6 +30,8 @@
* container to generate the resulting markup</p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
+ * @author <a>Woonsan Ko</a>
* @version $Id$
*/
public interface PortletRenderer
@@ -110,4 +112,6 @@
HttpServletRequest request,
HttpServletResponse response,
ContentDispatcherCtrl dispatcher, boolean
isCacheTitle );
+ PortletTrackingManager getPortletTrackingManager();
+
}
Added:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletTrackingManager.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletTrackingManager.java?view=auto&rev=509036
==============================================================================
---
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletTrackingManager.java
(added)
+++
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/PortletTrackingManager.java
Sun Feb 18 16:12:45 2007
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.util.List;
+
+import org.apache.pluto.om.window.PortletWindow;
+
+
+/**
+ * <h4>PortletRendererService<br />
+ * Jetspeed-2 Rendering service.</h4>
+ * <p>This service process all portlet rendering requests and interfaces with
the portlet
+ * container to generate the resulting markup</p>
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public interface PortletTrackingManager
+{
+ /**
+ * Get the default timeout for rendering a portlet in milliseconds
+ *
+ */
+ long getDefaultPortletTimeout();
+
+ /**
+ * Out of service limit, if a portlet entity times out past its limit (or
default limit) n consecutive times,
+ * it is taken out of service
+ *
+ * @return
+ */
+ int getOutOfServiceLimit();
+
+ boolean isOutOfService(PortletWindow window);
+
+ boolean exceededTimeout(long renderTime, PortletWindow window);
+
+ void incrementRenderTimeoutCount(PortletWindow window);
+
+ void setExpiration(PortletWindow window, long expiration);
+
+ void success(PortletWindow window);
+
+ void takeOutOfService(PortletWindow window);
+
+ void putIntoService(PortletWindow window);
+
+ List getOutOfServiceList(String fullPortletName);
+
+ List getOutOfServiceList();
+}
\ No newline at end of file
Added:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/RenderTrackable.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/RenderTrackable.java?view=auto&rev=509036
==============================================================================
---
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/RenderTrackable.java
(added)
+++
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/aggregator/RenderTrackable.java
Sun Feb 18 16:12:45 2007
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+/**
+ * Track rendering statistics
+ * For starter we need to have an object store its render timeout statistics
+ */
+public interface RenderTrackable
+{
+ int getRenderTimeoutCount();
+ void incrementRenderTimeoutCount();
+ void setExpiration(long expiration);
+ long getExpiration();
+ void success();
+ void setRenderTimeoutCount(int count);
+}
\ No newline at end of file
Modified:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java?view=diff&rev=509036&r1=509035&r2=509036
==============================================================================
---
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java
(original)
+++
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java
Sun Feb 18 16:12:45 2007
@@ -15,6 +15,8 @@
*/
package org.apache.jetspeed.container.window;
+import java.util.Set;
+
import
org.apache.jetspeed.components.portletentity.PortletEntityNotStoredException;
import org.apache.jetspeed.om.page.ContentFragment;
import org.apache.pluto.om.entity.PortletEntity;
@@ -103,5 +105,10 @@
*/
void removeWindow(PortletWindow window);
-
+ /**
+ * Get a list of all windows
+ *
+ * @return
+ */
+ Set getPortletWindows();
}
Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/aggregation.xml
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/aggregation.xml?view=diff&rev=509036&r1=509035&r2=509036
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/aggregation.xml
(original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/aggregation.xml Sun
Feb 18 16:12:45 2007
@@ -15,8 +15,25 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<beans>
-
+<beans>
+
+ <bean id="org.apache.jetspeed.aggregator.PortletTrackingManager"
class="org.apache.jetspeed.aggregator.impl.PortletTrackingManagerImpl">
+ <constructor-arg index='0'>
+ <ref bean="PortletWindowAccessor"/>
+ </constructor-arg>
+ <!-- Default portlet timeout in milliseconds:
+ Zero means no portlet timeout option by default.
+ -->
+ <constructor-arg index='1'>
+ <value>0</value>
+ </constructor-arg>
+ <!-- Out of service limit, if a portlet entity times out past its
limit (or default limit) n consecutive times, it is taken out of service -->
+ <constructor-arg index="2">
+ <value>3</value>
+ </constructor-arg>
+ </bean>
+
+
<!-- Aggregation: Portlet -->
<bean id="org.apache.jetspeed.aggregator.PortletAggregator"
class="org.apache.jetspeed.aggregator.impl.PortletAggregatorImpl">
<constructor-arg>
@@ -48,12 +65,9 @@
<constructor-arg>
<ref bean="org.apache.pluto.services.title.DynamicTitleService" />
</constructor-arg>
- <!-- Default portlet timeout in milliseconds:
- Zero means no portlet timeout option by default.
- -->
- <constructor-arg>
- <value>0</value>
- </constructor-arg>
+ <constructor-arg>
+ <ref bean="org.apache.jetspeed.aggregator.PortletTrackingManager"
/>
+ </constructor-arg>
<!-- flag indicating whether to check jetspeed-portlet.xml security
constraints
before rendering a portlet. If security check fails, do not
display portlet content
-->
@@ -86,12 +100,9 @@
<constructor-arg>
<ref bean="org.apache.pluto.services.title.DynamicTitleService" />
</constructor-arg>
- <!-- Default portlet timeout in milliseconds:
- Zero means no portlet timeout option by default.
- -->
<constructor-arg>
- <value>0</value>
- </constructor-arg>
+ <ref bean="org.apache.jetspeed.aggregator.PortletTrackingManager"
/>
+ </constructor-arg>
<!-- flag indicating whether to check jetspeed-portlet.xml security
constraints
before rendering a portlet. If security check fails, do not
display portlet content
-->
@@ -109,23 +120,12 @@
</constructor-arg>
</bean>
- <!-- Aggregation: Page Leave in place until new development completed -->
<bean id="org.apache.jetspeed.aggregator.PageAggregator"
class="org.apache.jetspeed.aggregator.impl.PageAggregatorImpl">
<constructor-arg index="0">
<ref bean="org.apache.jetspeed.aggregator.PortletRenderer" />
</constructor-arg>
- <!-- Aggregation Strategies:
- 0 = PageAggregatorImpl.STRATEGY_SEQUENTIAL
- 1 = PageAggregatorImpl.STRATEGY_PARALLEL
- -->
- <constructor-arg index="1">
- <value>0</value>
- </constructor-arg>
</bean>
-<!-- REFACTORING: this bean is not currently used, experimental -->
-
- <!-- Aggregation: Portlet -->
<bean id="org.apache.jetspeed.aggregator.AsyncPageAggregator"
class="org.apache.jetspeed.aggregator.impl.AsyncPageAggregatorImpl">
<constructor-arg index='0'>
@@ -138,15 +138,15 @@
init-method="start" destroy-method="stop" >
<constructor-arg index="0">
- <!-- Minimum number of wokers to create -->
+ <!-- Minimum number of workers to create -->
<value>5</value>
</constructor-arg>
<constructor-arg index="1">
- <!-- Maximum number of wokers to create -->
+ <!-- Maximum number of workers to create -->
<value>50</value>
</constructor-arg>
<constructor-arg index="2">
- <!-- Spare number of wokers to create -->
+ <!-- Spare number of workers to create -->
<value>3</value>
</constructor-arg>
<constructor-arg index="3">
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]