[ 
https://issues.apache.org/jira/browse/KAFKA-8247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16837510#comment-16837510
 ] 

Sönke Liebau commented on KAFKA-8247:
-------------------------------------

I've experimented a bit with this, I removed all those checks and diff'ed the 
output of all shell scripts when ran without parameters.

See the results below, the number at the very end is the return code, but this 
stays the same in all instances.
 There is one additional script that differs: kafka-consumer-perf-test.sh - but 
this is only because it has a random element in the output that changes every 
run (how useful that is is another debate).

Overall this looks good to me, in some cases the output is even signicifantly 
better, because we are not killing uage reporting from the java class anymore.

The output from the two connect classes might be improved a little I guess..

zookeeper-shell is a bit of a special case, as we change behavior by removing 
this check. Currently it returns with a help message, without that check it 
would default to connecting to localhost (behavior that I actually would 
prefer).
 If anybody has this call in a script somewhere this would hang post-change, as 
it never returns. I'm not sure why someone would have that though, save for 
testing purposes..

So overall I think we'd be good to make the change, unsure about Zookeeper 
shell and the -daemon flag, anybody have an opinion on that?

Ping [~hachikuji] since you noticed this duplicate check as well.

 
{noformat}
======================
./connect-distributed.sh.out
======================

Old output:
USAGE: ./connect-distributed.sh [-daemon] connect-distributed.properties
0

-------------

New output:
[2019-05-10 09:53:16,310] INFO Usage: ConnectDistributed worker.properties 
(org.apache.kafka.connect.cli.ConnectDistributed:64)
0


======================
./connect-standalone.sh.out
======================

Old output:
USAGE: ./connect-standalone.sh [-daemon] connect-standalone.properties
0

-------------

New output:
[2019-05-10 09:53:18,139] INFO Usage: ConnectStandalone worker.properties 
connector1.properties [connector2.properties ...] 
(org.apache.kafka.connect.cli.ConnectStandalone:62)
0


======================
./kafka-run-class.sh.out
======================

Old output:
USAGE: ./kafka-run-class.sh [-daemon] [-name servicename] [-loggc] classname 
[opts]
0

-------------

New output:
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available
    -d64          use a 64-bit data model if available
    -server       to select the "server" VM
                  The default VM is server,
                  because you are running on a server-class machine.


    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for 
more details.
0


======================
./kafka-server-start.sh.out
======================

Old output:
USAGE: ./kafka-server-start.sh [-daemon] server.properties [--override 
property=value]*
0

-------------

New output:
[2019-05-10 09:53:58,855] INFO Registered kafka:type=kafka.Log4jController 
MBean (kafka.utils.Log4jControllerRegistration$)
USAGE: java [options] KafkaServer server.properties [--override property=value]*
Option               Description
------               -----------
--override <String>  Optional property that should override values set in
                       server.properties file
--version            Print version information and exit.
0


======================
./zookeeper-server-start.sh.out
======================

Old output:
USAGE: ./zookeeper-server-start.sh [-daemon] zookeeper.properties
0

-------------

New output:
[2019-05-10 09:54:12,622] INFO autopurge.snapRetainCount set to 3 
(org.apache.zookeeper.server.DatadirCleanupManager)
[2019-05-10 09:54:12,623] INFO autopurge.purgeInterval set to 0 
(org.apache.zookeeper.server.DatadirCleanupManager)
[2019-05-10 09:54:12,626] INFO Purge task is not scheduled. 
(org.apache.zookeeper.server.DatadirCleanupManager)
[2019-05-10 09:54:12,626] WARN Either no config or no quorum defined in config, 
running  in standalone mode (org.apache.zookeeper.server.quorum.QuorumPeerMain)
[2019-05-10 09:54:12,648] ERROR Invalid arguments, exiting abnormally 
(org.apache.zookeeper.server.ZooKeeperServerMain)
java.lang.IllegalArgumentException: Invalid number of arguments:[]
        at org.apache.zookeeper.server.ServerConfig.parse(ServerConfig.java:58)
        at 
org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:86)
        at 
org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:55)
        at 
org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:119)
        at 
org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:81)
[2019-05-10 09:54:12,651] INFO Usage: ZooKeeperServerMain configfile | port 
datadir [ticktime] [maxcnxns] (org.apache.zookeeper.server.ZooKeeperServerMain)
Usage: ZooKeeperServerMain configfile | port datadir [ticktime] [maxcnxns]
0


======================
./zookeeper-shell.sh.out
======================

Old output:
USAGE: ./zookeeper-shell.sh zookeeper_host:port[/path] [args...]
0

-------------

New output:
Error: no argument found for option -server
Connecting to localhost:2181
Welcome to ZooKeeper!
JLine support is disabled
{noformat}

> Duplicate error handling in kafka-server-start.sh and actual Kafka class
> ------------------------------------------------------------------------
>
>                 Key: KAFKA-8247
>                 URL: https://issues.apache.org/jira/browse/KAFKA-8247
>             Project: Kafka
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.1.1
>            Reporter: Sönke Liebau
>            Assignee: Sönke Liebau
>            Priority: Minor
>
> There is some duplication of error handling for command line parameters that 
> are passed into kafka-server-start.sh
>  
> The shell script prints an error, if no arguments are passed in, effectively 
> causing the same check in 
> [Kafka|https://github.com/apache/kafka/blob/92db08cba582668d77160b0c2853efd45a1b809b/core/src/main/scala/kafka/Kafka.scala#L43]
>  to never be triggered, unless the only option that is specified is -daemon, 
> which would be removed before passing arguments to the java class.
>  
> While not in any way critical I don't think that this is intended behavior. I 
> think we should remove the extra check in kafka-server-start.sh and leave 
> argument handling up to the Kafka class.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to