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

Steve Loughran commented on YARN-679:
-------------------------------------

BTW, we've been using a precursor to this in Slider happily; this is what the 
entry point to the client looks like; the AM looks similar
{code}
public class Slider extends SliderClient {


  public static final String SERVICE_CLASSNAME = "org.apache.slider.Slider";

  /**
   * This is the main entry point for the service launcher.
   * @param args command line arguments.
   */
  public static void main(String[] args) {
    
    //turn the args to a list
    List<String> argsList = Arrays.asList(args);
    //create a new list, as the ArrayList type doesn't push() on an insert
    List<String> extendedArgs = new ArrayList<String>(argsList);
    //insert the service name
    extendedArgs.add(0, SERVICE_CLASSNAME);
    //now have the service launcher do its work
    ServiceLauncher.serviceMain(extendedArgs);
  }

}
{code}

This handles all the setup, parsing, exit reporting, shutdown hook 
registration, interrupt registration with escalation on a double signal, etc, 
etc. Stuff you need, especially in the AM.

One thing the patch here does is uses {{org.apache.commons.cli}} for CLI work. 
Slider uses JCommander which is way, way better -it uses introspection to 
configure classes, e.g 
[ActionPackageArgs|https://github.com/apache/incubator-slider/blob/develop/slider-core/src/main/java/org/apache/slider/common/params/ActionPackageArgs.java].
 These structs become the same ones that the test runner and anything using it 
as a library use to execute operations, giving us a nicely extensible API (we 
just add new fields) and very simple parsing.

I've not got jcommander stuff in this patch, because it will only add another 
dependency.

> add an entry point that can start any Yarn service
> --------------------------------------------------
>
>                 Key: YARN-679
>                 URL: https://issues.apache.org/jira/browse/YARN-679
>             Project: Hadoop YARN
>          Issue Type: New Feature
>          Components: api
>    Affects Versions: 2.4.0
>            Reporter: Steve Loughran
>            Assignee: Steve Loughran
>              Labels: BB2015-05-TBR
>         Attachments: YARN-679-001.patch, YARN-679-002.patch, 
> YARN-679-002.patch, YARN-679-003.patch, org.apache.hadoop.servic...mon 
> 3.0.0-SNAPSHOT API).pdf
>
>          Time Spent: 72h
>  Remaining Estimate: 0h
>
> There's no need to write separate .main classes for every Yarn service, given 
> that the startup mechanism should be identical: create, init, start, wait for 
> stopped -with an interrupt handler to trigger a clean shutdown on a control-c 
> interrrupt.
> Provide one that takes any classname, and a list of config files/options



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to