Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id AF1B8200C2B for ; Thu, 2 Mar 2017 12:06:58 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id ADA3E160B6F; Thu, 2 Mar 2017 11:06:58 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AD18E160B61 for ; Thu, 2 Mar 2017 12:06:57 +0100 (CET) Received: (qmail 99934 invoked by uid 500); 2 Mar 2017 11:06:56 -0000 Mailing-List: contact dev-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jmeter.apache.org Delivered-To: mailing list dev@jmeter.apache.org Received: (qmail 99920 invoked by uid 99); 2 Mar 2017 11:06:56 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Mar 2017 11:06:56 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 320F31A7BA5 for ; Thu, 2 Mar 2017 11:06:56 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.18 X-Spam-Level: * X-Spam-Status: No, score=1.18 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Ce2ifRozFe72 for ; Thu, 2 Mar 2017 11:06:54 +0000 (UTC) Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id C15545F257 for ; Thu, 2 Mar 2017 11:06:53 +0000 (UTC) Received: by mail-wm0-f51.google.com with SMTP id t193so8239396wmt.1 for ; Thu, 02 Mar 2017 03:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=JleBJ2pqa4Fz6UY9nP/2HKjztAYMrx5yMkG8NCbI04A=; b=ZQz3Fa/kL8AaP/cLKQrdQKTX666CcE6p7YYuCINhus50fUKb+5liD0tAnt5I7j4cot v1kuiQspPg0GpCrtb2gLH4yAuZecJoXvbEcwcOufVeL/EHmTstw7axUJWDEc+hcPiezN X1kfaB9MqzhG33an7SxSp8XWK/n8DyHcGaHJuxTlYaao/Qda+hzR62djX9/9WoA5TL6+ RGYAdv/L8pyq83GUxOl5Se4zhs9kVlX13fdZn9X0tIvWsUVLa9XOSP+V2KydWCArrG+X ICs3hi1W3ng7uTEylDX7HYQElofCl+db5joNGpO+MgVqZuRlGwyZHpkskwaNOgZQF4k0 AEvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=JleBJ2pqa4Fz6UY9nP/2HKjztAYMrx5yMkG8NCbI04A=; b=bmdzzr2Mu/t1EgEZ6GjlbOhpK9bcYk75vGUujTP7GUKOR74+xhM806GyR+Cu+x4vf+ mJxjRaeONGNFVT5aUGjb5MCKFluKKDSrdJhCdyeqkFm6QzJAgaUIgDVQQnrQ07JlBbm5 +PpR+vpukqs5aCw3iM7BgQq41htmC5UHoAMfJ/PoEWpl0W32sCAytyIViGw8btaan4at N/6vBbqaSrle2K5YaP3Uz+90SsCzT5bWxeKYZKCHtGhJbk5IQEGGfngX4aE3PhS3IlLw C6Ee9xOfzePu1O9MmbWRaZbmOMbzt4/GPpn6G35RGD+gl2SRGP7Q5NmXWkO7pBCObzdx QR6Q== X-Gm-Message-State: AMke39kqZXJmSlbUjFb9QAafv2H562e6Cy7p2eO69t2n0DhXaz/AE1Zb3CL8W3qImqngZsKJd0zBxYOOxhv0HQ== X-Received: by 10.28.28.69 with SMTP id c66mr7975442wmc.28.1488452781287; Thu, 02 Mar 2017 03:06:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.169.48 with HTTP; Thu, 2 Mar 2017 03:06:20 -0800 (PST) In-Reply-To: References: <20170301222242.841693A0112@svn01-us-west.apache.org> From: sebb Date: Thu, 2 Mar 2017 11:06:20 +0000 Message-ID: Subject: Re: svn commit: r1785057 - in /jmeter/trunk: src/components/org/apache/jmeter/sampler/TestAction.java src/components/org/apache/jmeter/timers/TimerService.java src/core/org/apache/jmeter/threads/JMeterThread.java xdocs/changes.xml To: dev@jmeter.apache.org Content-Type: text/plain; charset=UTF-8 archived-at: Thu, 02 Mar 2017 11:06:58 -0000 On 2 March 2017 at 06:52, Philippe Mouawad wrote: > On Thursday, March 2, 2017, sebb wrote: > >> On 1 March 2017 at 22:22, > wrote: >> > Author: pmouawad >> > Date: Wed Mar 1 22:22:42 2017 >> > New Revision: 1785057 >> > >> > URL: http://svn.apache.org/viewvc?rev=1785057&view=rev >> > Log: >> > Bug 60797 - TestAction in pause mode can last beyond configured duration >> of test >> > Bugzilla Id: 60797 >> > >> > Added: >> > jmeter/trunk/src/components/org/apache/jmeter/timers/TimerService.java >> (with props) >> > Modified: >> > jmeter/trunk/src/components/org/apache/jmeter/sampler/ >> TestAction.java >> > jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java >> > jmeter/trunk/xdocs/changes.xml >> > >> > Modified: jmeter/trunk/src/components/org/apache/jmeter/sampler/ >> TestAction.java >> > URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/ >> org/apache/jmeter/sampler/TestAction.java?rev=1785057& >> r1=1785056&r2=1785057&view=diff >> > ============================================================ >> ================== >> > --- jmeter/trunk/src/components/org/apache/jmeter/sampler/TestAction.java >> (original) >> > +++ jmeter/trunk/src/components/org/apache/jmeter/sampler/TestAction.java >> Wed Mar 1 22:22:42 2017 >> > @@ -33,6 +33,7 @@ import org.apache.jmeter.testelement.pro >> > import org.apache.jmeter.testelement.property.StringProperty; >> > import org.apache.jmeter.threads.JMeterContext; >> > import org.apache.jmeter.threads.JMeterContextService; >> > +import org.apache.jmeter.timers.TimerService; >> > import org.slf4j.Logger; >> > import org.slf4j.LoggerFactory; >> > >> > @@ -45,6 +46,8 @@ public class TestAction extends Abstract >> > >> > private static final Logger log = LoggerFactory.getLogger( >> TestAction.class); >> > >> > + private static final TimerService TIMER_SERVICE = >> TimerService.getInstance(); >> > + >> > private static final long serialVersionUID = 241L; >> > >> > private static final Set APPLIABLE_CONFIG_CLASSES = new >> HashSet<>( >> > @@ -121,7 +124,7 @@ public class TestAction extends Abstract >> > try { >> > pauseThread = Thread.currentThread(); >> > if(millis>0) { >> > - TimeUnit.MILLISECONDS.sleep(millis); >> > + TimeUnit.MILLISECONDS.sleep(TIMER_SERVICE.adjustDelay( >> millis)); >> > } else if(millis<0) { >> > throw new IllegalArgumentException("Configured sleep >> is negative:"+millis); >> > } // else == 0 we do nothing >> > >> > Added: jmeter/trunk/src/components/org/apache/jmeter/timers/ >> TimerService.java >> > URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/ >> org/apache/jmeter/timers/TimerService.java?rev=1785057&view=auto >> > ============================================================ >> ================== >> > --- jmeter/trunk/src/components/org/apache/jmeter/timers/TimerService.java >> (added) >> > +++ jmeter/trunk/src/components/org/apache/jmeter/timers/TimerService.java >> Wed Mar 1 22:22:42 2017 >> > @@ -0,0 +1,74 @@ >> > +/* >> > + * 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.jmeter.timers; >> > + >> > +import org.apache.jmeter.threads.JMeterContextService; >> > +import org.apache.jmeter.threads.JMeterThread; >> > + >> > +/** >> > + * Manages logic related to timers and pauses >> > + * @since 3.2 >> > + */ >> > +public class TimerService { >> > + >> > + private TimerService() { >> > + super(); >> > + } >> > + >> > + /** >> > + * Initialization On Demand Holder pattern >> > + */ >> > + private static class TimerServiceHolder { >> > + public static final TimerService INSTANCE = new TimerService(); >> >> This should be package protected; no point in being public. > > Yes, I'll fix it > >> >> > + } >> > + >> > + /** >> > + * @return ScriptEngineManager singleton >> > + */ >> > + public static TimerService getInstance() { >> > + return TimerServiceHolder.INSTANCE; >> > + } >> >> But why is the IODH idiom used here? >> >> It looks just like a utility class. >> >> The methods could just be static. > > Inthe future the service might have state. Or it might not. But if it does acquire state, then it's likely that it cannot be a singleton. In the meantime, it's harder to use. Besides, the IODH idiom is intended for classes that include expensive initialisation. > Also ?? > >> >> > + >> > + /** >> > + * Adjust delay so that initialDelay does not exceed end of test >> > + * @param delay initial delay in millis >> > + * @return initialDelay or adjusted delay >> > + */ >> > + public long adjustDelay(final long initialDelay) { >> > + JMeterThread thread = JMeterContextService. >> getContext().getThread(); >> > + long endTime = thread != null ? thread.getEndTime() : 0; >> > + return adjustDelay(initialDelay, endTime); >> > + } >> > + >> > + /** >> > + * Adjust delay so that initialDelay does not exceed end of test >> > + * @param initialDelay initial delay in millis >> > + * @param endTime End time of JMeterThread >> > + * @return initialDelay or adjusted delay >> > + */ >> > + public long adjustDelay(final long initialDelay, long endTime) { >> > + if (endTime > 0) { >> > + long now = System.currentTimeMillis(); >> > + if(now + initialDelay > endTime) { >> > + return endTime - now; >> > + } >> > + } >> > + return initialDelay; >> > + } >> > +} >> > >> > Propchange: jmeter/trunk/src/components/org/apache/jmeter/timers/ >> TimerService.java >> > ------------------------------------------------------------ >> ------------------ >> > svn:eol-style = native >> > >> > Propchange: jmeter/trunk/src/components/org/apache/jmeter/timers/ >> TimerService.java >> > ------------------------------------------------------------ >> ------------------ >> > svn:mime-type = text/plain >> > >> > Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/ >> JMeterThread.java >> > URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/ >> apache/jmeter/threads/JMeterThread.java?rev=1785057& >> r1=1785056&r2=1785057&view=diff >> > ============================================================ >> ================== >> > --- jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java >> (original) >> > +++ jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java >> Wed Mar 1 22:22:42 2017 >> > @@ -47,6 +47,7 @@ import org.apache.jmeter.testelement.Tes >> > import org.apache.jmeter.testelement.TestIterationListener; >> > import org.apache.jmeter.testelement.ThreadListener; >> > import org.apache.jmeter.timers.Timer; >> > +import org.apache.jmeter.timers.TimerService; >> > import org.apache.jmeter.util.JMeterUtils; >> > import org.apache.jorphan.collections.HashTree; >> > import org.apache.jorphan.collections.HashTreeTraverser; >> > @@ -79,6 +80,7 @@ public class JMeterThread implements Run >> > >> > private static final float TIMER_FACTOR = >> JMeterUtils.getPropDefault("timer.factor", 1.0f); >> > >> > + private static final TimerService TIMER_SERVICE = >> TimerService.getInstance(); >> > /** >> > * 1 as float >> > */ >> > @@ -842,10 +844,7 @@ public class JMeterThread implements Run >> > if(scheduler) { >> > // We reduce pause to ensure end of test is not >> delayed by a sleep ending after test scheduled end >> > // See Bug 60049 >> > - long now = System.currentTimeMillis(); >> > - if(now + totalDelay > endTime) { >> > - totalDelay = endTime - now; >> > - } >> > + totalDelay = TIMER_SERVICE.adjustDelay(totalDelay, >> endTime); >> > } >> > TimeUnit.MILLISECONDS.sleep(totalDelay); >> > } catch (InterruptedException e) { >> > >> > Modified: jmeter/trunk/xdocs/changes.xml >> > URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes. >> xml?rev=1785057&r1=1785056&r2=1785057&view=diff >> > ============================================================ >> ================== >> > --- jmeter/trunk/xdocs/changes.xml [utf-8] (original) >> > +++ jmeter/trunk/xdocs/changes.xml [utf-8] Wed Mar 1 22:22:42 2017 >> > @@ -276,6 +276,7 @@ JMeter now requires Java 8. Ensure you u >> >
  • 60730The JSON PostProcessor should set the >> _ALL variable even if the JSON path matches only once.
  • >> >
  • 60747Response Assertion : Add Request Headers to >> Field to Test
  • >> >
  • 60763XMLAssertion should not leak errors to >> console
  • >> > +
  • 60797TestAction in pause mode can last beyond >> configured duration of test
  • >> > >> > >> >

    Functions

    >> > >> > >> > > > -- > Cordialement. > Philippe Mouawad.