Re: tapestry.thread-pool.max-pool-size not doing anything
You're rigth. If multiple threads are scheduling jobs and the pool has reached a threadcount of maxsize-1, chances are that a RejectedExecutionException is thrown. The offer-method should use a lock. Like so: public boolean offer(Runnable inJob) { _lock.lock(); try { if (_executor.getPoolSize() < _executor.getMaximumPoolSize()) { return false; } return super.offer(inJob); } finally { _lock.unlock(); } } --Arjan Verstoep On 2 Jul 2014, at 09:52, Lance Java wrote: > I'm not convinced this solution is thread-safe. > On 1 Jul 2014 17:21, "Arjan Verstoep" > wrote: > >> Yes, the default implementation is very counter-intuitive. I have >> invesigated once, and it was possible to 'repair' the ThreadPoolExecutor if >> you provide the 'right' work-queue. >> >> I don't know if you can apply this to Tapestry's ThreadPoolExecutor, but >> anyhow: here's how I do it: >> >> --Arjan Verstoep >> >> /** >> * Specific implementation of the {@link LinkedBlockingQueue} that won't >> * accept offered elements as long as the given {@link >> ThreadPoolExecutor} has >> * not yet reached its maximum capacity. >> * The intended effect is to have a ThreadPoolExecutor that will only >> start >> * adding Runnables to the Queue after the maximum number of >> Threads is >> * reached. The default implementation of the ThreadPoolExecutor is, >> that it >> * first starts new Threads when the Queue is full, which with an >> unbounded >> * Queue will never be the case. >> * This class will throw an >> * unchecked {@link java.lang.NullPointerException} if the >> ThreadPoolExecutor >> * is not set with {@link #setExecutor(ThreadPoolExecutor)} ! >> */ >> class ThreadCreationTriggeringLinkedBlockingQueue extends >> LinkedBlockingQueue { >>private static final long serialVersionUID = 1L; >>private transient ThreadPoolExecutor _executor; >> >>/** >> * If the Executor's current pool size is below the maximum pool >> size, >> * this method will not add the {@link Runnable} to the Queue. >> * The {@link ThreadPoolExecutor} will then be forced to start a new >> Thread. >> * {@inheritDoc} >> */ >>@Override >>public boolean offer(Runnable inJob) { >> if (_executor.getPoolSize() < _executor.getMaximumPoolSize()) { >>return false; >> } >> return super.offer(inJob); >>} >> >>/** >> * Sets the executor which will be used to decide whether or not to >> add the >> * Runnable to the Queue. >> * >> * @param inExecutor the ThreadPoolExecutor >> */ >>public void setExecutor(ThreadPoolExecutor inExecutor) { >> _executor = inExecutor; >>} >> } >> >> ThreadCreationTriggeringLinkedBlockingQueue queue = new >> ThreadCreationTriggeringLinkedBlockingQueue(); >> ThreadPoolExecutor threadpoolExecutor = new >> ThreadPoolExecutor(availableProcessors(), THREADPOOLMULTIPLICATOR * >> availableProcessors(), 10, TimeUnit.MINUTES, queue); >> queue.setExecutor(threadpoolExecutor); >> >> >> On 1 Jul 2014, at 16:04, Lance Java wrote: >> >>> I feel the implementation is flawed. >>> >>> I would prefer that the pool size would increase from minimum to maximum >>> under load to increase throughput and then revert back to the minimum >> when >>> not under load. >>> >>> But instead, the pool size stays at minimum until the queue is full. In >> my >>> opinion, the application is about to fall over at this point. Only then >>> will the pool size increase which i think is crazy / stupid. >>> >>> Because of this, I've always seen core pool size and max pool size set to >>> the same value. >>> >>> To achieve my preferred behaviour (above) I think you can specify >> different >>> pooling behaviour. I think it required throwing exceptions and extending >>> ThreadPoolExecutor or something nasty like that. >>> On 1 Jul 2014 12:14, "D Tim Cummings" wrote: >>> >>>> Ok, thanks for explaining this... I think :) >>>> >>>> I had a read of the ThreadPoolExecutor javadoc. It seems to me that >>>> core-pool-size should be described as the maximum pool size before >> queuing. >>>> Describing it as the minimum pool size is misleading bec
Re: tapestry.thread-pool.max-pool-size not doing anything
Yes, the default implementation is very counter-intuitive. I have invesigated once, and it was possible to 'repair' the ThreadPoolExecutor if you provide the 'right' work-queue. I don't know if you can apply this to Tapestry's ThreadPoolExecutor, but anyhow: here's how I do it: --Arjan Verstoep /** * Specific implementation of the {@link LinkedBlockingQueue} that won't * accept offered elements as long as the given {@link ThreadPoolExecutor} has * not yet reached its maximum capacity. * The intended effect is to have a ThreadPoolExecutor that will only start * adding Runnables to the Queue after the maximum number of Threads is * reached. The default implementation of the ThreadPoolExecutor is, that it * first starts new Threads when the Queue is full, which with an unbounded * Queue will never be the case. * This class will throw an * unchecked {@link java.lang.NullPointerException} if the ThreadPoolExecutor * is not set with {@link #setExecutor(ThreadPoolExecutor)} ! */ class ThreadCreationTriggeringLinkedBlockingQueue extends LinkedBlockingQueue { private static final long serialVersionUID = 1L; private transient ThreadPoolExecutor _executor; /** * If the Executor's current pool size is below the maximum pool size, * this method will not add the {@link Runnable} to the Queue. * The {@link ThreadPoolExecutor} will then be forced to start a new Thread. * {@inheritDoc} */ @Override public boolean offer(Runnable inJob) { if (_executor.getPoolSize() < _executor.getMaximumPoolSize()) { return false; } return super.offer(inJob); } /** * Sets the executor which will be used to decide whether or not to add the * Runnable to the Queue. * * @param inExecutor the ThreadPoolExecutor */ public void setExecutor(ThreadPoolExecutor inExecutor) { _executor = inExecutor; } } ThreadCreationTriggeringLinkedBlockingQueue queue = new ThreadCreationTriggeringLinkedBlockingQueue(); ThreadPoolExecutor threadpoolExecutor = new ThreadPoolExecutor(availableProcessors(), THREADPOOLMULTIPLICATOR * availableProcessors(), 10, TimeUnit.MINUTES, queue); queue.setExecutor(threadpoolExecutor); On 1 Jul 2014, at 16:04, Lance Java wrote: > I feel the implementation is flawed. > > I would prefer that the pool size would increase from minimum to maximum > under load to increase throughput and then revert back to the minimum when > not under load. > > But instead, the pool size stays at minimum until the queue is full. In my > opinion, the application is about to fall over at this point. Only then > will the pool size increase which i think is crazy / stupid. > > Because of this, I've always seen core pool size and max pool size set to > the same value. > > To achieve my preferred behaviour (above) I think you can specify different > pooling behaviour. I think it required throwing exceptions and extending > ThreadPoolExecutor or something nasty like that. > On 1 Jul 2014 12:14, "D Tim Cummings" wrote: > >> Ok, thanks for explaining this... I think :) >> >> I had a read of the ThreadPoolExecutor javadoc. It seems to me that >> core-pool-size should be described as the maximum pool size before queuing. >> Describing it as the minimum pool size is misleading because there is no >> minimum. The number of threads in the pool before any have been invoked is >> always zero. >> >> Tim >> >> On 1 Jul 2014, at 16:25, Lance Java wrote: >> >>> If you read the javadoc for java.util.concurrent ThreadPoolExecutor >> you'll >>> see that the number of threads will only increase when the queue has >>> reached its capacity. Crazy / stupid behaviour if you ask me... But >>> expected. >>> >>> I've been caught out by this before when I set core pool size to 1, >>> expecting the thread size to increase under load. >>> On 1 Jul 2014 02:53, "D Tim Cummings" wrote: >>> >>>> Hi >>>> >>>> I am using Tapestry 5.3.7 and the ParallelExecutor. When I increase the >>>> max-pool-size I am not able to use any more threads. However when I >>>> increase the core-pool-size I am able to use more threads. It looks like >>>> the max-pool-size is not doing anything (or I am not understanding what >> it >>>> is supposed to do). >>>> >>>> When I use the defaults I get a maximum of 3 threads and other threads >>>> seem to wait in a queue and execute later. >>>> >>>> When I use the following settings in web.xml I still get only 3 threads >>>>
Re: OutOfMemoryError after serving N pages
[EMAIL PROTECTED] wrote: We had the same thing, and in our case it was related to a small PermGen Space setting in our Tomcat container. My understanding of the Sun JVM is that it partitions up its allocated memory into heap, perm gen, etc. chunks and that the Perm Gen space is where all "meta data" about classes gets stored. In "modern" JEE programming with all the CGLIB and just-in-time abstract class overrides & instantiation, the Perm Gen space tends to blow up quicker. Anyway, try throwing a -XX:MaxPermSize=256m on your JVM startup and see if that helps. Note: if you're actually running out of PermGen space, you'll see a reference to that in your OOME. If you are just getting plain old OOMEs, it sounds like something more sinister. HTH, Tom My JVM is complaining about heap space, so I fear that it is something sinister... 10:36:23,289 ERROR [MusiController4]:253 - Servlet.service() for servlet MusiController4 threw exception java.lang.OutOfMemoryError: Java heap space ~Arjan Verstoep - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
OutOfMemoryError after serving N pages
Hi, I'm building an application with the Tapestry 4.0.2 framework, which manages my music-collection. I'm getting OutOfMemoryErrors since I've created a small ajax-ish component that refreshes every 10 seconds to show the song that is currently playing. A piece of javascript gets the Tapestry-page with the currently-playing song on it, and puts the generated html into a . After 24 hours or so making these page-requests, an out of memory error occurs. I have the feeling that this new auto-refreshing component of mine only quickens the OutOfMemoryError, since I did get these errors before, but only after much longer uptimes. What am I doing wrong here? Is it the Spring OpenSessionInView-filter that I use that is wasting memory, am I not cleaning-up everything myself? Should I use Tapestry 4.1.1? Can anybody help? The code of the page follows: (You can also have a look at http://musicontroller.cvs.sourceforge.net/musicontroller/ for more sourcecode) Thanks, ~Arjan Verstoep public abstract class CurrentlyPlaying extends BasePage { public abstract SessionUserState getSessionUserState(); public abstract Dao getDao(); private Song _song = null; public Song getCurrentSong() { if (_song==null) { _song = getDao().getSongById(getSessionUserState().getDJ().getCurrentSongId()); } return _song; } public void finishLoad() { super.finishLoad(); _song = null; } } http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";> object="sessionUserState"/> - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Populating Tapestry ASO after successful Acegi Auth
[EMAIL PROTECTED] wrote: Greetings: I'm using Tapestry 4 and Acegi 1.0.1. I have acegi set up to perform authentication using the AuthenticationProcessingFilter. I have a requirement to place the domain object the Acegi UserDetails object is based upon into a Tapestry ASO for use during the user session. =20 My question is: what the best practice for filling the Tapestry ASO with the domain model's user object upon successful authentication with Acegi? Thanks, -jason Hi Jason, Set up your login-prcedure to redirect you to a certain page after successful login. Then, on that particular page put this code to get the Authentication-object. Then, You can put the Authentication object into the ASO-object. I currently use this code in my border-component, so it executes way too often. But I'll get to that eventually. ~ Arjan Verstoep private Authentication getAuthentication(IRequestCycle cycle) { Authentication auth = null; WebSession session = cycle.getInfrastructure().getRequest().getSession(false); if (session!=null) { SecurityContext sc = (SecurityContext) session.getAttribute(HttpSessionContextIntegrationFilter.ACEGI_SECURITY_CONTEXT_KEY); if (sc!=null) { auth = sc.getAuthentication(); } } return auth; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]