From: <bra...@us...> - 2010-03-24 00:20:44
|
Revision: 3002 http://archive-access.svn.sourceforge.net/archive-access/?rev=3002&view=rev Author: bradtofel Date: 2010-03-24 00:20:31 +0000 (Wed, 24 Mar 2010) Log Message: ----------- TWEAK: added simplistic PerformanceLogger Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java Added Paths: ----------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PerformanceLogger.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java 2010-03-23 23:46:12 UTC (rev 3001) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java 2010-03-24 00:20:31 UTC (rev 3002) @@ -424,7 +424,9 @@ throws IOException, ServletException, WaybackException { Resource resource = null; try { + PerformanceLogger p = new PerformanceLogger("replay"); SearchResults results = collection.getResourceIndex().query(wbRequest); + p.queried(); if(!(results instanceof CaptureSearchResults)) { throw new ResourceNotAvailableException("Bad results..."); } @@ -434,9 +436,12 @@ CaptureSearchResult closest = captureResults.getClosest(wbRequest, useAnchorWindow); resource = collection.getResourceStore().retrieveResource(closest); + p.retrieved(); ReplayRenderer renderer = replay.getRenderer(wbRequest, closest, resource); renderer.renderResource(httpRequest, httpResponse, wbRequest, closest, resource, uriConverter, captureResults); + p.rendered(); + p.write(wbRequest.getReplayTimestamp() + " " + wbRequest.getRequestUrl()); } finally { if(resource != null) { resource.close(); @@ -448,7 +453,9 @@ HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws ServletException, IOException, WaybackException { + PerformanceLogger p = new PerformanceLogger("query"); SearchResults results = collection.getResourceIndex().query(wbRequest); + p.queried(); if(results instanceof CaptureSearchResults) { CaptureSearchResults cResults = (CaptureSearchResults) results; cResults.markClosest(wbRequest); @@ -462,6 +469,8 @@ } else { throw new WaybackException("Unknown index format"); } + p.rendered(); + p.write(wbRequest.getRequestUrl()); } /** Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PerformanceLogger.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PerformanceLogger.java (rev 0) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PerformanceLogger.java 2010-03-24 00:20:31 UTC (rev 3002) @@ -0,0 +1,71 @@ +/* PerformanceLogger + * + * $Id$: + * + * Created on Mar 19, 2010. + * + * Copyright (C) 2006 Internet Archive. + * + * This file is part of Wayback. + * + * Wayback is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * any later version. + * + * Wayback is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with Wayback; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package org.archive.wayback.webapp; + +import org.apache.log4j.Logger; + +/** + * @author brad + * + */ +public class PerformanceLogger { + private static final Logger LOGGER = Logger.getLogger( + PerformanceLogger.class.getName()); + + private static char delim = '\t'; + + private String type = null; + private long start = 0; + private long query = 0; + private long retrieve = -1; + private long render = 0; + public PerformanceLogger(String type) { + this.type = type; + this.start = System.currentTimeMillis(); + } + public void queried() { + this.query = System.currentTimeMillis(); + } + public void retrieved() { + this.retrieve = System.currentTimeMillis(); + } + public void rendered() { + this.render = System.currentTimeMillis(); + } + public void write(String info) { + StringBuilder sb = new StringBuilder(40); + sb.append(type).append(delim); + sb.append(query - start).append(delim); + if(retrieve == -1) { + sb.append(render - query).append(delim); + } else { + sb.append(retrieve - query).append(delim); + sb.append(render - retrieve).append(delim); + } + sb.append(info); + LOGGER.debug(sb.toString()); + } +} Property changes on: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PerformanceLogger.java ___________________________________________________________________ Added: svn:keywords + Author Date Revision Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2010-04-27 22:14:57
|
Revision: 3075 http://archive-access.svn.sourceforge.net/archive-access/?rev=3075&view=rev Author: bradtofel Date: 2010-04-27 22:14:50 +0000 (Tue, 27 Apr 2010) Log Message: ----------- REFACTORED: to package org.archive.wayback.util.webapp Removed Paths: ------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestContext.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestMapper.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/ServletRequestContext.java Deleted: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestContext.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestContext.java 2010-04-27 22:12:31 UTC (rev 3074) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestContext.java 2010-04-27 22:14:50 UTC (rev 3075) @@ -1,50 +0,0 @@ -/* RequestContext - * - * $Id$ - * - * Created on 4:46:47 PM Jul 19, 2007. - * - * Copyright (C) 2007 Internet Archive. - * - * This file is part of wayback-core. - * - * wayback-core is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * any later version. - * - * wayback-core is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser Public License for more details. - * - * You should have received a copy of the GNU Lesser Public License - * along with wayback-core; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package org.archive.wayback.webapp; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * - * @author brad - * @version $Date$, $Revision$ - */ -public interface RequestContext { - /** - * @param httpRequest - * @param httpResponse - * @return true if the RequestContent returned data to the client. - * @throws ServletException - * @throws IOException - */ - public boolean handleRequest(HttpServletRequest httpRequest, - HttpServletResponse httpResponse) - throws ServletException, IOException; -} Deleted: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java 2010-04-27 22:12:31 UTC (rev 3074) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestFilter.java 2010-04-27 22:14:50 UTC (rev 3075) @@ -1,165 +0,0 @@ -/* RequestHandler - * - * $Id$ - * - * Created on 4:24:06 PM Apr 20, 2007. - * - * Copyright (C) 2007 Internet Archive. - * - * This file is part of wayback-webapp. - * - * wayback-webapp is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * any later version. - * - * wayback-webapp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser Public License for more details. - * - * You should have received a copy of the GNU Lesser Public License - * along with wayback-webapp; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package org.archive.wayback.webapp; - -import java.io.IOException; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.httpclient.URIException; -import org.apache.log4j.Logger; -import org.archive.net.UURI; -import org.archive.net.UURIFactory; -import org.archive.util.ArchiveUtils; -import org.archive.wayback.exception.ConfigurationException; -import org.archive.wayback.util.url.UrlOperations; - -/** - * - * - * @author brad - * @version $Date$, $Revision$ - */ -public class RequestFilter implements Filter { - private static final Logger LOGGER = Logger.getLogger(RequestFilter.class - .getName()); - private RequestMapper mapper = null; - - /* (non-Javadoc) - * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) - */ - public void init(FilterConfig config) throws ServletException { - - LOGGER.info("Wayback Filter initializing..."); - try { - mapper = new RequestMapper(config.getServletContext()); - } catch (ConfigurationException e) { - throw new ServletException(e.getMessage()); - } - LOGGER.info("Wayback Filter initialization complete."); - } - - /* (non-Javadoc) - * @see javax.servlet.Filter#destroy() - */ - public void destroy() { - LOGGER.info("Wayback Filter de-initialization starting..."); - mapper.destroy(); - LOGGER.info("Wayback Filter de-initialization complete."); - } - - /* (non-Javadoc) - * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) - */ - public void doFilter(ServletRequest request, ServletResponse response, - FilterChain chain) throws IOException, ServletException { - boolean handled = false; - - if(request instanceof HttpServletRequest) { - if(response instanceof HttpServletResponse) { - handled = handle((HttpServletRequest) request, - (HttpServletResponse) response); - } - } - if(!handled) { - chain.doFilter(request,response); - } - } - - protected boolean handle(HttpServletRequest httpRequest, - HttpServletResponse httpResponse) - throws IOException, ServletException { - - boolean handled = false; - RequestContext context = mapper.mapContext(httpRequest); - if(context == null) { - try { - handled = - handleServerRelativeArchivalRedirect(httpRequest, httpResponse); - } catch(URIException e) { - // TODO: Log this? - handled = false; - } - } else { - handled = context.handleRequest(httpRequest,httpResponse); - } - return handled; - } - - private boolean handleServerRelativeArchivalRedirect( - HttpServletRequest httpRequest, HttpServletResponse httpResponse) - throws IOException { - - boolean handled = false; - // hope that it's a server relative request, with a valid referrer: - String referer = httpRequest.getHeader("Referer"); - if(referer != null) { - UURI uri = UURIFactory.getInstance(referer); - String path = uri.getPath(); - int secondSlash = path.indexOf('/',1); - if(secondSlash > -1) { - String collection = path.substring(0,secondSlash); - String remainder = path.substring(secondSlash+1); - int thirdSlash = remainder.indexOf('/'); - if(thirdSlash > -1) { - String datespec = remainder.substring(0,thirdSlash); - String url = ArchiveUtils.addImpliedHttpIfNecessary( - remainder.substring(thirdSlash+1)); - String thisPath = httpRequest.getRequestURI(); - String queryString = httpRequest.getQueryString(); - if (queryString != null) { - thisPath += "?" + queryString; - } - - String resolved = UrlOperations.resolveUrl(url, thisPath); - String contextPath = httpRequest.getContextPath(); - String finalUrl = uri.getScheme() + "://" + - uri.getAuthority() + contextPath + collection + "/" - + datespec + "/" + resolved; - // cross your fingers!!! - LOGGER.info("Server-Relative-Redirect:\t" + referer + "\t" - + thisPath + "\t" + finalUrl); - - // Gotta make sure this is properly cached, or - // weird things happen: - httpResponse.addHeader("Vary", "Referer"); - httpResponse.sendRedirect(finalUrl); - handled = true; - - } - } - } - - return handled; - - } -} Deleted: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestMapper.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestMapper.java 2010-04-27 22:12:31 UTC (rev 3074) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/RequestMapper.java 2010-04-27 22:14:50 UTC (rev 3075) @@ -1,168 +0,0 @@ -/* RequestMapper - * - * $Id$ - * - * Created on 5:36:36 PM Apr 20, 2007. - * - * Copyright (C) 2007 Internet Archive. - * - * This file is part of wayback-webapp. - * - * wayback-webapp is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * any later version. - * - * wayback-webapp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser Public License for more details. - * - * You should have received a copy of the GNU Lesser Public License - * along with wayback-webapp; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package org.archive.wayback.webapp; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; - -import org.apache.log4j.Logger; -import org.archive.wayback.exception.ConfigurationException; -import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; -import org.springframework.beans.factory.xml.XmlBeanFactory; -import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; - -/** - * RequestMapper accepts a request, and maps that request to - * a WaybackContext suitable for that request. - * - * This object is a singleton, and the class provides methods for constructing - * and accessing the singleton. - * - * @author brad - * @version $Date$, $Revision$ - */ -public class RequestMapper { - private static final Logger LOGGER = Logger.getLogger(RequestMapper.class - .getName()); - - private final static String PORT_SEPARATOR = ":"; - - private final static String CONFIG_PATH = "config-path"; - - private XmlBeanFactory factory = null; - /** - * @param configPath - * @param servletContext - * @throws ConfigurationException - */ - @SuppressWarnings("unchecked") - public RequestMapper(ServletContext servletContext) throws ConfigurationException { - - String configPath = servletContext.getInitParameter(CONFIG_PATH); - if(configPath == null) { - throw new ConfigurationException("Missing " + CONFIG_PATH - + " parameter"); - } - String resolvedPath = servletContext.getRealPath(configPath); - Resource resource = new FileSystemResource(resolvedPath); - factory = new XmlBeanFactory(resource); - Map map = factory.getBeansOfType(PropertyPlaceholderConfigurer.class); - if(map != null) { - Collection<PropertyPlaceholderConfigurer> macros = map.values(); - for(PropertyPlaceholderConfigurer macro : macros) { - macro.postProcessBeanFactory(factory); - } - } - factory.preInstantiateSingletons(); - } - - private String getContextID(HttpServletRequest request) { - String requestPath = request.getRequestURI(); - String contextPath = request.getContextPath(); - if(requestPath.startsWith(contextPath)) { - requestPath = requestPath.substring(contextPath.length()); - } - String collection = ""; - if(requestPath.startsWith("/")) { - int secondSlash = requestPath.indexOf("/",1); - if(secondSlash != -1) { - collection = PORT_SEPARATOR + - requestPath.substring(1,requestPath.indexOf("/",1)); - } else { - collection = PORT_SEPARATOR + requestPath.substring(1); - } - } - return String.valueOf(request.getLocalPort()) + collection; - } - - /** - * @param request - * @return WaybackContext that handles the specific incoming HTTP request - */ - public RequestContext mapContext(HttpServletRequest request) { - - RequestContext context = null; - String portStr = String.valueOf(request.getLocalPort()); - if(factory.containsBean(portStr)) { - Object o = factory.getBean(portStr); - if(o instanceof RequestContext) { - context = (RequestContext) o; - } - } else { - String contextID = getContextID(request); - if(factory.containsBean(contextID)) { - Object o = factory.getBean(contextID); - if(o instanceof RequestContext) { - context = (RequestContext) o; - } - } - } - if(context == null) { - ArrayList<String> names = getAccessPointNamesOnPort(portStr); - request.setAttribute("AccessPointNames", names); - } - return context; - } - - public ArrayList<String> getAccessPointNamesOnPort(String portStr) { - ArrayList<String> names = new ArrayList<String>(); - String[] apNames = factory.getBeanNamesForType(AccessPoint.class); - String portStrColon = portStr + ":"; - for(String apName : apNames) { - if(apName.startsWith(portStrColon)) { - names.add(apName.substring(portStrColon.length())); - } - } - return names; - } - /** - * clean up all WaybackContexts, which should release resources gracefully. - */ - @SuppressWarnings("unchecked") - public void destroy() { - LOGGER.info("shutting down contexts..."); - Map beanMap = factory.getBeansOfType(AccessPoint.class); - Collection accessPoints = beanMap.values(); - for(Object o : accessPoints) { - if(o instanceof AccessPoint) { - AccessPoint ap = (AccessPoint) o; - try { - String apName = ap.getBeanName(); - LOGGER.info("Shutting down AccessPoint " + apName); - ap.shutdown(); - LOGGER.info("Successfully shut down " + apName); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } -} Deleted: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/ServletRequestContext.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/ServletRequestContext.java 2010-04-27 22:12:31 UTC (rev 3074) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/ServletRequestContext.java 2010-04-27 22:14:50 UTC (rev 3075) @@ -1,77 +0,0 @@ -/* ServletRequestContext - * - * $Id$ - * - * Created on 4:51:05 PM Jul 19, 2007. - * - * Copyright (C) 2007 Internet Archive. - * - * This file is part of wayback-core. - * - * wayback-core is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * any later version. - * - * wayback-core is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser Public License for more details. - * - * You should have received a copy of the GNU Lesser Public License - * along with wayback-core; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package org.archive.wayback.webapp; - -import java.io.IOException; -import java.text.ParseException; -import java.util.Map; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * - * @author brad - * @version $Date$, $Revision$ - */ -public abstract class ServletRequestContext implements RequestContext { - - protected static String getMapParam(Map<String,String[]> queryMap, - String field) { - String arr[] = (String[]) queryMap.get(field); - if (arr == null || arr.length == 0) { - return null; - } - return arr[0]; - } - - protected static String getRequiredMapParam(Map<String,String[]> queryMap, - String field) - throws ParseException { - String value = getMapParam(queryMap,field); - if(value == null) { - throw new ParseException("missing field " + field,0); - } - if(value.length() == 0) { - throw new ParseException("empty field " + field,0); - } - return value; - } - - protected static String getMapParamOrEmpty(Map<String,String[]> map, - String param) { - String val = getMapParam(map,param); - return (val == null) ? "" : val; - } - /* (non-Javadoc) - * @see org.archive.wayback.webapp.RequestContext#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) - */ - public abstract boolean handleRequest(HttpServletRequest httpRequest, - HttpServletResponse httpResponse) throws ServletException, - IOException; - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2010-04-27 22:45:47
|
Revision: 3080 http://archive-access.svn.sourceforge.net/archive-access/?rev=3080&view=rev Author: bradtofel Date: 2010-04-27 22:45:40 +0000 (Tue, 27 Apr 2010) Log Message: ----------- JAVADOC Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PerformanceLogger.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/WaybackCollection.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PerformanceLogger.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PerformanceLogger.java 2010-04-27 22:35:18 UTC (rev 3079) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PerformanceLogger.java 2010-04-27 22:45:40 UTC (rev 3080) @@ -28,6 +28,9 @@ import org.apache.log4j.Logger; /** + * Brutally simple, barely functional class to allow simple recording of + * millisecond level timing within a particular request, enabling rough logging + * of the time spent in various parts of the handling of a WaybackRequest * @author brad * */ @@ -42,19 +45,41 @@ private long query = 0; private long retrieve = -1; private long render = 0; + /** + * Construct a Performance logger with the specified String "type" + * @param type the String type to report with the logged output + */ public PerformanceLogger(String type) { this.type = type; this.start = System.currentTimeMillis(); } + /** + * record the time when the query associated with this request completed + */ public void queried() { this.query = System.currentTimeMillis(); } + /** + * record the time when the retrieval of a Resource required for this + * request completed, implies a Replay request... + */ public void retrieved() { this.retrieve = System.currentTimeMillis(); } + /** + * record the time when the replayed resource, or the query results were + * returned to the client, implies the bulk of the request processing is + * complete. + */ public void rendered() { this.render = System.currentTimeMillis(); } + /** + * Produce a debug message to this classes logger, computing the time + * taken to query the index, retrieve the resource (if a replay request) + * and render the results to the client. + * @param info String suffix to append to the log message + */ public void write(String info) { StringBuilder sb = new StringBuilder(40); sb.append(type).append(delim); Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/WaybackCollection.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/WaybackCollection.java 2010-04-27 22:35:18 UTC (rev 3079) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/WaybackCollection.java 2010-04-27 22:45:40 UTC (rev 3080) @@ -33,8 +33,8 @@ import org.archive.wayback.exception.ConfigurationException; /** - * Abstraction point for sharing document collection and index across multiple - * AccessPoints. + * Composite class containing a ResourceStore, and a ResourceIndex, to simplify + * sharing them as a pair across multiple AccessPoints. * * @author brad * @version $Date$, $Revision$ @@ -45,6 +45,10 @@ private List<Shutdownable> shutdownables = null; private boolean shutdownDone = false; + /** + * close/release any resources held by this WaybackCollection + * @throws IOException when thrown by an internal class being shut down. + */ public void shutdown() throws IOException { if(shutdownDone) { return; @@ -63,29 +67,51 @@ shutdownDone = true; } + /** + * @return the ResourceStore used with this WaybackCollection + * @throws ConfigurationException if none is configured + */ public ResourceStore getResourceStore() throws ConfigurationException { if(resourceStore == null) { throw new ConfigurationException("No resourceStore declared"); } return resourceStore; } + /** + * @param resourceStore the ResourceStore to use with this WaybackCollection + */ public void setResourceStore(ResourceStore resourceStore) { this.resourceStore = resourceStore; } + /** + * @return the ResourceIndex used with this WaybackCollection + * @throws ConfigurationException if none is configured + */ public ResourceIndex getResourceIndex() throws ConfigurationException { if(resourceIndex == null) { throw new ConfigurationException("No resourceIndex declared"); } return resourceIndex; } + /** + * @param resourceIndex the ResourceIndex to use with this WaybackCollection + */ public void setResourceIndex(ResourceIndex resourceIndex) { this.resourceIndex = resourceIndex; } + /** + * @return List of Shutdownable objects associated with this + * WaybackCollection, or null, if none are configured + */ public List<Shutdownable> getShutdownables() { return shutdownables; } + /** + * @param shutdownables set a List of Shutdownable objects associated with + * this WaybackCollection + */ public void setShutdownables(List<Shutdownable> shutdownables) { this.shutdownables = shutdownables; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2011-03-09 05:54:03
|
Revision: 3428 http://archive-access.svn.sourceforge.net/archive-access/?rev=3428&view=rev Author: bradtofel Date: 2011-03-09 05:53:57 +0000 (Wed, 09 Mar 2011) Log Message: ----------- FEATURE: now sets Thread.name to something hopefully helpful when debugging via jstack Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/LiveWebAccessPoint.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java 2011-03-09 05:51:36 UTC (rev 3427) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/AccessPoint.java 2011-03-09 05:53:57 UTC (rev 3428) @@ -175,6 +175,11 @@ boolean handled = false; try { + String inputPath = translateRequestPathQuery(httpRequest); + Thread.currentThread().setName("Thread " + + Thread.currentThread().getId() + " " + getBeanName() + + " handling: " + inputPath); + wbRequest = getParser().parse(httpRequest, this); if(wbRequest != null) { Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/LiveWebAccessPoint.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/LiveWebAccessPoint.java 2011-03-09 05:51:36 UTC (rev 3427) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/LiveWebAccessPoint.java 2011-03-09 05:53:57 UTC (rev 3428) @@ -77,6 +77,10 @@ wbRequest.setRequestUrl(urlString); URL url = null; try { + Thread.currentThread().setName("Thread " + + Thread.currentThread().getId() + " " + getBeanName() + + " handling: " + urlString); + try { url = new URL(urlString); } catch(MalformedURLException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2011-09-06 03:38:15
|
Revision: 3509 http://archive-access.svn.sourceforge.net/archive-access/?rev=3509&view=rev Author: bradtofel Date: 2011-09-06 03:38:08 +0000 (Tue, 06 Sep 2011) Log Message: ----------- INITIAL REV: classes to simplify embargo of specific file prefixes - not very clean.. Added Paths: ----------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoPeriodTuple.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoResultFilterFactory.java Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoPeriodTuple.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoPeriodTuple.java (rev 0) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoPeriodTuple.java 2011-09-06 03:38:08 UTC (rev 3509) @@ -0,0 +1,30 @@ +package org.archive.wayback.webapp; + +public class PrefixEmbargoPeriodTuple { + protected String prefix; + protected long embargoMS; + /** + * @return the prefix + */ + public String getPrefix() { + return prefix; + } + /** + * @param prefix the prefix to set + */ + public void setPrefix(String prefix) { + this.prefix = prefix; + } + /** + * @return the embargoMS + */ + public long getEmbargoMS() { + return embargoMS; + } + /** + * @param embargoMS the embargoMS to set + */ + public void setEmbargoMS(long embargoMS) { + this.embargoMS = embargoMS; + } +} Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoResultFilterFactory.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoResultFilterFactory.java (rev 0) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoResultFilterFactory.java 2011-09-06 03:38:08 UTC (rev 3509) @@ -0,0 +1,40 @@ +package org.archive.wayback.webapp; + +import java.util.ArrayList; +import java.util.List; + +import org.archive.wayback.core.CaptureSearchResult; +import org.archive.wayback.resourceindex.filters.CompositeFilter; +import org.archive.wayback.resourceindex.filters.FilePrefixDateEmbargoFilter; +import org.archive.wayback.util.ObjectFilter; + +public class PrefixEmbargoResultFilterFactory implements CustomResultFilterFactory { + protected List<PrefixEmbargoPeriodTuple> tuples = null; + public ObjectFilter<CaptureSearchResult> get(AccessPoint ap) { + if(tuples == null) { + return null; + } + CompositeFilter composite = new CompositeFilter(); + ArrayList<ObjectFilter<CaptureSearchResult>> filters = + new ArrayList<ObjectFilter<CaptureSearchResult>>(); + for(PrefixEmbargoPeriodTuple tuple : tuples) { + filters.add(new FilePrefixDateEmbargoFilter(tuple.getPrefix(), + tuple.getEmbargoMS())); + } + composite.setFilters(filters); + return composite; + } + /** + * @return the tuples + */ + public List<PrefixEmbargoPeriodTuple> getTuples() { + return tuples; + } + /** + * @param tuples the tuples to set + */ + public void setTuples(List<PrefixEmbargoPeriodTuple> tuples) { + this.tuples = tuples; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2011-09-06 03:41:37
|
Revision: 3511 http://archive-access.svn.sourceforge.net/archive-access/?rev=3511&view=rev Author: bradtofel Date: 2011-09-06 03:41:31 +0000 (Tue, 06 Sep 2011) Log Message: ----------- LICENSE Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoPeriodTuple.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoResultFilterFactory.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoPeriodTuple.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoPeriodTuple.java 2011-09-06 03:40:40 UTC (rev 3510) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoPeriodTuple.java 2011-09-06 03:41:31 UTC (rev 3511) @@ -1,3 +1,22 @@ +/* + * This file is part of the Wayback archival access software + * (http://archive-access.sourceforge.net/projects/wayback/). + * + * Licensed to the Internet Archive (IA) by one or more individual + * contributors. + * + * The IA 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.archive.wayback.webapp; public class PrefixEmbargoPeriodTuple { Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoResultFilterFactory.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoResultFilterFactory.java 2011-09-06 03:40:40 UTC (rev 3510) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/webapp/PrefixEmbargoResultFilterFactory.java 2011-09-06 03:41:31 UTC (rev 3511) @@ -1,3 +1,22 @@ +/* + * This file is part of the Wayback archival access software + * (http://archive-access.sourceforge.net/projects/wayback/). + * + * Licensed to the Internet Archive (IA) by one or more individual + * contributors. + * + * The IA 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.archive.wayback.webapp; import java.util.ArrayList; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |