Sounds like switching to the LinkedHashMap could address.the JVM startup flags ordering g?
Andrew On Thu, Dec 15, 2016, 1:11 PM Russell Bateman <r...@windofkeltia.com> wrote: > Joe, > > I have more detail and success to report... > > There is no problem in NiFi /per se/. It was not really necessary to dig > down into the code really because there's no problem there. It's just > how java.arg./n/is consumed that creates trouble. One must play around > with the value of /n/ when argument ordering is crucial. In the present > case, I was able to turn on JFR using the following (in bold) in > /conf/bootstrap.conf/: > > #Set headless mode by default > java.arg.14=-Djava.awt.headless=true > > *# Light up the Java Flight Recorder...** > **java.arg.32=-XX:+UnlockCommercialFeatures** > **java.arg.31=-XX:+FlightRecorder** > > **java.arg.42=-XX:StartFlightRecording=duration=120m,filename=recording.jfr* > > # Master key in hexadecimal format for encrypted sensitive > configuration values > nifi.bootstrap.sensitive.key= > > The point was that -XX:+UnlockCommercialFeatures must absolutely precede > the other two options. Because of these arguments passing through > HashMap, some values of /n/ will fail to sort an argument before others > and the addition of other arguments might also come along and disturb > this order. What I did here was by trial and error. I guess NiFi code > could man-handle /n/ in every case such that the order be respected. I'm > guessing that my case is the only or one of the very rare times options > are order-dependent. I wouldn't personally up-vote a JIRA to fix this. > > Hoping this forum has an adequate profile out there in Googleland, this > very discussion will be enough to help the next guy. > > Russ > > P.S. My trial and error went pretty fast using this command line between > reassigning instances of /n/ for these arguments. It took me maybe 6 > tries. (Script /bounce-nifi.sh/ does little more than shut down, then > start up NiFi, something I do a hundred times per day across at least > two versions.) > > ~/dev/nifi/nifi-1.1.0/logs $ rm *.log ; bounce-nifi.sh 1.1.0 ; tail > -f nifi-bootstrap.log > > > > > On 12/14/2016 07:41 PM, Joe Witt wrote: > > The way you set it up initially is what I'd thought would have done > > the trick. Perhaps we're not ordering the arguments in the same > > manner supplied. Will need to look into that. > > > > Thanks > > Joe > > > > On Wed, Dec 14, 2016 at 9:00 PM, Russell Bateman <r...@windofkeltia.com> > wrote: > >> Of course, as many have done, I've run Java applications with JFR > enabled > >> using these options against this very JVM (jdk1.8.0_112). So, it isn't a > >> problem for the JVM I'm using. I haven't finished digging down into > >> ProcessBuilder, or deeper, to figure out why these options are not > getting > >> love. I'll get back at it tomorrow and report back. > >> > >> > >> On 12/14/2016 11:05 AM, Russell Bateman wrote: > >>> > >>> I've doctored /conf/bootstrap.conf/ to contain these additional lines: > >>> > >>> java.arg.15=-XX:+UnlockCommercialFeatures > >>> java.arg.16=-XX:+FlightRecorder > >>> > >>> > java.arg.17=-XX:StartFlightRecording=duration=120m,filename=recording.jfr > >>> > >>> > >>> In the end, NiFi's grumpy about this and won't start (from > >>> /logs/nifi-bootstrap.log/): > >>> > >>> 2016-12-14 10:39:36,489 ERROR [NiFi logging handler] > >>> org.apache.nifi.StdErr Error: *To use 'FlightRecorder', first unlock > using > >>> -XX:+UnlockCommercialFeatures.* > >>> 2016-12-14 10:39:36,489 ERROR [NiFi logging handler] > >>> org.apache.nifi.StdErr Error: Could not create the Java Virtual > Machine. > >>> 2016-12-14 10:39:36,489 ERROR [NiFi logging handler] > >>> org.apache.nifi.StdErr Error: A fatal exception has occurred. Program > will > >>> exit. > >>> 2016-12-14 10:39:36,507 INFO [main] org.apache.nifi.bootstrap.RunNiFi > NiFi > >>> never started. Will not restart NiFi > >>> > >>> I tried using all options as one (in case the order is disturbed, > which it > >>> was): > >>> > >>> > >>> > java.arg.15=-XX:+UnlockCommercialFeatures-XX:+FlightRecorder-XX:StartFlightRecording=duration=120m,filename=recording.jfr > >>> > >>> > >>> and then I get: > >>> > >>> *2016-12-14 10:50:07,574 ERROR [NiFi logging handler] > >>> org.apache.nifi.StdErr Unrecognized VM option 'UnlockCommercialFeatures > >>> -XX:+FlightRecorder > >>> -XX:StartFlightRecording=duration=120m,filename=recording.jfr'* > >>> 2016-12-14 10:50:07,574 ERROR [NiFi logging handler] > >>> org.apache.nifi.StdErr Error: Could not create the Java Virtual > Machine. > >>> 2016-12-14 10:50:07,574 ERROR [NiFi logging handler] > >>> org.apache.nifi.StdErr Error: A fatal exception has occurred. Program > will > >>> exit. > >>> 2016-12-14 10:50:07,598 INFO [main] org.apache.nifi.bootstrap.RunNiFi > NiFi > >>> never started. Will not restart NiFi > >>> > >>> Here's the second command line from /logs/nifi-bootstrap.log/, which > I've > >>> wrapped for convenience in reading (see JVM version here too): > >>> > >>> 2016-12-14 10:56:40,526 INFO [main] org.apache.nifi.bootstrap.Command > >>> Working Directory: /home/russ/dev/nifi/nifi-1.1.0 > >>> 2016-12-14 10:56:40,526 INFO [main] org.apache.nifi.bootstrap.Command > >>> Command: */home/russ/dev/jdk1.8.0_112/bin/java* > >>> -classpath > >>> > /home/russ/dev/nifi/nifi-1.1.0/./conf:/home/russ/dev/nifi/nifi-1.1.0/./lib/jcl-over-slf4j-1.7.12.jar:/home/russ/dev/nifi/nifi-1.1.0/./lib/logback-core-1.1.3.jar:/home/russ/dev/nifi/nifi-1.1.0/./lib/nifi-documentation-1.1.0.jar:/home/russ/dev/nifi/nifi-1.1.0/./lib/nifi-nar-utils-1.1.0.jar:/home/russ/dev/nifi/nifi-1.1.0/./lib/logback-classic-1.1.3.jar:/home/russ/dev/nifi/nifi-1.1.0/./lib/jul-to-slf4j-1.7.12.jar:/home/russ/dev/nifi/nifi-1.1.0/./lib/nifi-runtime-1.1.0.jar:/home/russ/dev/nifi/nifi-1.1.0/./lib/slf4j-api-1.7.12.jar:/home/russ/dev/nifi/nifi-1.1.0/./lib/nifi-api-1.1.0.jar:/home/russ/dev/nifi/nifi-1.1.0/./lib/nifi-framework-api-1.1.0.jar:/home/russ/dev/nifi/nifi-1.1.0/./lib/log4j-over-slf4j-1.7.12.jar:/home/russ/dev/nifi/nifi-1.1.0/./lib/nifi-properties-1.1.0.jar > >>> -Dorg.apache.jasper.compiler.disablejsr199=true > >>> -Xmx512m > >>> -Xms512m > >>> -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9191 > >>> *-XX:+UnlockCommercialFeatures > >>> -XX:+FlightRecorder > >>> -XX:StartFlightRecording=duration=120m,filename=recording.jfr* > >>> -Dsun.net.http.allowRestrictedHeaders=true > >>> -Djava.net.preferIPv4Stack=true > >>> -Djava.awt.headless=true > >>> -XX:+UseG1GC > >>> -Djava.protocol.handler.pkgs=sun.net.www.protocol > >>> > >>> > -Dnifi.properties.file.path=/home/russ/dev/nifi/nifi-1.1.0/./conf/nifi.properties > >>> -Dnifi.bootstrap.listen.port=41736 > >>> -Dapp=NiFi > >>> > >>> > -Dorg.apache.nifi.bootstrap.config.log.dir=/home/russ/dev/nifi/nifi-1.1.0/logs > >>> org.apache.nifi.NiFi > >>> > >>> Last, I frantically tried this: > >>> > >>> java.arg.15="-XX:+UnlockCommercialFeatures -XX:+FlightRecorder > >>> -XX:StartFlightRecording=duration=120m,filename=recording.jfr" > >>> > >>> > >>> and then got: > >>> > >>> *2016-12-14 11:01:36,659 ERROR [NiFi logging handler] > >>> org.apache.nifi.StdErr Error: Could not find or load main class > >>> "-XX:+UnlockCommercialFeatures -XX:+FlightRecorder > >>> -XX:StartFlightRecording=duration=120m,filename=recording.jfr"* > >>> > >>> > >>> What's the canonical way of adding/inserting my own JVM commands? > >>> Alternatively, is NiFi analyzing and blocking -XX:arguments to the JVM > as > >>> illegal or unrecognized? > >>> > >>> Thanks, > >>> > >>> Russ > >> > >