home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / njpipes.zip / faq.txt next >
Text File  |  1999-05-28  |  11KB  |  292 lines

  1.  
  2.                    njPipes FAQ Version 0.50, May 30, 1999
  3.  
  4.  
  5. 1.  How does line continuation work in .njp files?
  6.  
  7.     If a line ends with either a stage seprator or an end character or if the
  8.     next nonblank line begins with either of these characters, the pipe is
  9.     continued.  You can also end a line with a contination character (defaults
  10.     to comma).
  11.  
  12.  
  13. 2.  What is the problem with \ (backslash)?
  14.  
  15.     Backslash is used as an escape character by netrexx.  This implies that it
  16.     cannot be used as an end character.  It also means that you often have to
  17.     use two backslashes to get one...
  18.  
  19.  
  20. 3.  What is the problem with | (bar)?
  21.     Why diskr and diskw instead of < and > ?
  22.  
  23.     Bar is used as a piping character by many shells, including dos, w95, os2
  24.     and some unixes.  Using it as the njPipes stage sep character eventually
  25.     will cause you problems.  Both < and > are also used by many shells...
  26.  
  27.  
  28. 4.  njPipes is not finding stages?
  29.  
  30.     Java is case sensitive.  CHANGE is not equal to change or Change.  The
  31.     stages njPipes supplies all have lower case names.
  32.  
  33.     Make very sure your classpath is correct.  If using unix, ensure you have
  34.     permission for all the items in your classpath.  See Question 29.
  35.  
  36.  
  37. 5.  Do you have to quote pipes in netrexx code like CMS?
  38.  
  39.     No, but you should suffix the code with .njp instead of .nrx and pass it
  40.     through the njPipes compiler.  To pass arguements or variables to a stage
  41.     you enclose the variable name or auguement number in braces.
  42.  
  43.     {}  -  pass arg(), which is the complete arguement, to the stage
  44.     {2} -  pass arg(2), or the second word of the arguement, to the stage
  45.     {a} -  pass the a reference to object a to the stage.  The object is no
  46.            longer restricted to be of class rexx.
  47.  
  48.     Also see question 22.
  49.  
  50.  
  51. 6.  Are there any examples?
  52.  
  53.     For pipes, see the .njp files in the njpipes\examples directory.  The
  54.     njpipes\stages directory has the NetRexx (.nrx) source of all the stages.
  55.  
  56.  
  57. 7.  Why the rexx stage?
  58.  
  59.     njPipes moves objects.  Many stages expect all objects to be of class rexx.
  60.     The rexx stage modifier will convert objects to rexx if possible.
  61.  
  62.     ... ! rexx in change //xxx/ ! ...  to insure inputs are rexx
  63.     ... ! rexx out diskr ! ...         to insure output are rexx
  64.     ... ! rexx somestage ! ...         both inputs and outputs are rexx
  65.  
  66.  
  67. 8.  Why do I have to compile pipes?
  68.  
  69.     When I started out it seemed the only way to do it.  Once I learned how to
  70.     use dynamicly loaded classes, njPipes was building nexrexx source, via
  71.     StageExit, for some stages to increase performance.
  72.  
  73.  
  74. 9.  Why do I need to name every pipe?
  75.  
  76.     Since pipes are compiled they need to be named...
  77.  
  78.  
  79. 10. Is there a maximum number of stages in a pipe?
  80.  
  81.     No, if the pipe does not seem to be finding all the stages check for a
  82.     missing end or stage sep character.  If you have pipes with many stages
  83.     contact me, there are a few pieces of code that could be optimized for
  84.     large numbers of stages.  You can see what njPipes compiles by using
  85.     the -gen compile option.
  86.  
  87.  
  88. 11. My pipes waits thiry seconds before terminating correctly, why?
  89.  
  90.     njPipes uses a thread pool.  The threads are kept thirty seconds before
  91.     they are terminated.  You can force them to end earlier by using 'exit' or
  92.     by calling ThreadPool.stop()
  93.  
  94.  
  95. 12. What is a StageExit?
  96.  
  97.     They are used to produce faster running stages.  A StageExit is an
  98.     extension to the njPipes compiler.  They are invoked by the compiler
  99.     in conjuction with rexxArg and stageArg, to generate optimized netrexx
  100.     code.  Consider them a very sharp knife and use with care and only when
  101.     they will really help.
  102.  
  103.  
  104. 13. Can I determine what streams are connected in a stageExit?
  105.  
  106.     No, at compile time, when stageExits are run its just not possible.
  107.  
  108.  
  109. 14. What does the runaway option do?
  110.  
  111.     njPipes creates a thread to monitor each pipe for deadlocks.  The thread
  112.     wakes up once in the runaway interval to check if the pipe is deadlocked.
  113.  
  114.  
  115. 15. What is the JITCache option for and when do you use it?
  116.  
  117.     Its to used in netrexx or java code.  You create a hashtable and pass it
  118.     as a JITCache.  Its used to keep references to the pipes you use.  This
  119.     is done so the JIT does not discard the code it has built for all the
  120.     pipes and stages that you use.
  121.  
  122.  
  123. 16. What stages are examples of using multithreaded stages?
  124.  
  125.     tcpclient, tcpdata and elastic each use two threads, the command
  126.     stage uses three.
  127.  
  128.  
  129. 18. What stages are examples of using StageExit?
  130.  
  131.     There are many stages exploiting StageExit.  The append and prefix stages
  132.     are basic examples as is frtarget.  The unique and specs stages completly
  133.     generate the stage code (this is very tricky to get right).   Stages like
  134.     change, zone and casei are a good compromise.
  135.  
  136.  
  137. 19. Where else could StageExit be used?
  138.  
  139.     Parts of the lookup stage's code would benifit from a stageExit...
  140.  
  141.     If you are using IRanges take a good look at BuildIRangeExit in the
  142.     pipes\IRange.nrx file.
  143.  
  144.  
  145. 20. What does the doSetup method do?
  146.  
  147.     doSetup is used to avoid overhead for stages that are apt to be called
  148.     in loops.  Structuring your stages as in tcpdata, tcpclient & lookup avoids
  149.     calling the stage's setup method if it not necessary.  This will occur
  150.     when the arguement to the stage is static and the pipe is called in a loop.
  151.     See Question 24.  If there is stage setup that needs to be done every time
  152.     a pipe (and stage) objects are reused override the reuse() method.
  153.     See tests/timer.nrx
  154.  
  155.  
  156. 21. I see { and } in .njp source.  What are they used for?
  157.  
  158.     They are use to pass the pipe's (also see #22) arguements to stages.
  159.     Using {} passes the complete arguement, Using {N}, where N is a number,
  160.     passes the Nth word of the arguement to the stage.
  161.  
  162.  
  163. 22. How do I pass arguements to a callpipe or addpipe?
  164.  
  165.     You use {name} or {n}, where name is a variable of class rexx or N
  166.     to pass Nth word of the arguement of the calling stage. For this to work,
  167.     be sure to pass the source through the pipes compiler.
  168.  
  169.     Note {} (with no name or number between the braces) will not work in a
  170.     callpipe or an addpipe, assign arg() to a variable and pass it instead.
  171.  
  172.  
  173. 23. I am not getting the return code I expect from a stage or pipe...
  174.  
  175.     Try compiling the pipe with a 'debug 72' in the options.  This will show
  176.     each StageError raised by pipes and output infomation when each stage
  177.     ends.  Often the cause of this error is a stage using 'rc = rc()' in the
  178.     'catch StageError' clause.  Unless this is in every 'catch StageError', the
  179.     stage will sometimes get an invalid return code.  Often you can fix this
  180.     by adding a 'rc = mrc()' just before any 'exit(rc*(rc<>12)'.
  181.  
  182.  
  183. 24. How should I structure my stages?
  184.  
  185.     I have included some simple templates in the njpipes directory
  186.  
  187.     template1.nrx - a basic stage
  188.     template2.nrx - a basic stage using doSetup
  189.     template3.nrx - a basic stage showing an alternate way to set the final rc
  190.     template2.nrx - a stage with a simple stageExit using BuildIRangeExit
  191.  
  192.  
  193. 25. How do I report errors in the parameters of stages?
  194.  
  195.     Issue a StageError(11,'your error') before the first stage commits to -1.
  196.     Where 11 is the suggested return code and 'your error' is a message.  The
  197.     deblock stage has an example of this.  Also see Questions 24 & 26.
  198.  
  199.  
  200. 26. How do commit levels work in njPipes?
  201.  
  202.     All stages now start at a commit level of -2.  Unless autocommit is
  203.     disabled with nocommit(), they commit to -1 at the first interaction
  204.     with the pipe.  To see the commits happen compile the pipe with option
  205.     'debug 48'.  Like in CMS, commit levels usually take care of themselves.
  206.  
  207.  
  208. 27. Is it safe to pass .java or .nrx files through the pipes compiler.
  209.  
  210.     Yes.
  211.  
  212.  
  213. 28. What are the debug options?
  214.  
  215.       1  -  Show all pipes starting
  216.       2  -  Show all pipes ending
  217.       4  -  Show all stages starting
  218.       8  -  Show all stages stopping
  219.      16  -  Show all Commit requests
  220.      32  -  Show all Commit completions
  221.      64  -  Show StageErrors raised via stage's Error(int,String) method.  The
  222.             stage class uses Error for all its StageError signals.
  223.     128  -  Show the arguement that each stage is recieving.  Handy since
  224.             shells have a habbit of doing unexpected thing to arguements.
  225.             (try: java findtext exit *.nrx vs java findtext "exit *.nrx")
  226.  
  227.     I find using a debug code of 72 (8+64) very handy when debugging pipes.
  228.     try: java njp (test debug 72) literal 1 ! dup 10 ! console
  229.  
  230.  
  231. 29. Explain what should be in the classpath?
  232.  
  233.     Ensure your classpath contains a good reference to njpipesC.jar.  It
  234.     should also have a reference to . or the directory you are building
  235.     your stages in before the njpipesC.jar.  Remember to remove the package
  236.     stagement if your stage is not part of a package.  Java defines packages
  237.     as sub directories of directories in the classpath.  For instance, I
  238.     reference d:\njpipes in my classpath.  Under njpipes there are a couple
  239.     of directories.  The stages directory contains the stages package, the
  240.     pipes directory the pipes package.  If you were to unzip the njpipesC.jar
  241.     you would find all the class files in these same directories.
  242.  
  243.  
  244. 30. I am writing a stage and want it to be fast, how do I optimize it?
  245.  
  246.     First use doSetup() as presented in template2.nrx or template3.nrx.
  247.     Second, if you are using a range see if you cannot exploit the canned
  248.     stageExit BuildIRangeExit as presented in template4.nrx.  If these two
  249.     items do not speed your stage up enought try generating parts of your
  250.     code using stageExit.
  251.  
  252.  
  253. 31. How do I kill a pipe?
  254.  
  255.     Interrupting its pipe object will do the trick.  This like a unix kill -9
  256.     and should be used with care and only when really necessary.
  257.  
  258.  
  259. 32. How do I find the pipe object?
  260.  
  261.     Pass your code thru the pipes compiler and insert njpObject() after a pipe,
  262.     callpipe or addpipe command.  Note the pipe object can get reused after
  263.     a pipe completes.
  264.  
  265.  
  266. 33. Now do I get the RC of a pipe?
  267.  
  268.     Pass your code thru the pipes compiler and insert njpRC() after the
  269.     callpipe or pipe command.
  270.  
  271.  
  272. 34. Pipes and Stages do not seem to get garbage collected.
  273.  
  274.     There are a few things happening here.  First, a reference to an object
  275.     of each pipe class is kept in the JITCache hashtable.  This helps the
  276.     JIT.  Without this it tends to forget the code compiled for the various
  277.     stages.  Since stages are very heavily reused this is not good...  Second,
  278.     njPipes reuses pipe objects.  This helps considerably when pipes are used
  279.     in loops or multiple instances of a callpipe/addpipe are used.
  280.  
  281.  
  282. 35. When compiling .njp files containing java code a .nrx file is built along
  283.     with the .java file.  Why?
  284.  
  285.     The .nrx file contains is a dummy file to allow the NetRexx compiler to
  286.     compiler to process without errors.  This is intended for .njp files that
  287.     contain stages that are used in pipes also defined in the same .njp file.
  288.     See: njpipes\examples\addtest4.njp
  289.  
  290.  
  291.  
  292.