You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@whirr.apache.org by "Lars George (JIRA)" <ji...@apache.org> on 2011/01/25 13:48:43 UTC

[jira] Created: (WHIRR-215) Add builder pattern to addRunUrl() call

Add builder pattern to addRunUrl() call
---------------------------------------

                 Key: WHIRR-215
                 URL: https://issues.apache.org/jira/browse/WHIRR-215
             Project: Whirr
          Issue Type: Improvement
          Components: core
    Affects Versions: 0.3.0
            Reporter: Lars George
            Priority: Minor
             Fix For: 0.4.0


If we get optional parameters then the code using varargs gets messy:

{code}
    String tarurl = clusterSpec.getConfiguration().getString(
      HBaseConstants.KEY_TARBALL_URL);
    if (tarurl != null) {
      addRunUrl(event, hbaseInstallRunUrl,
        HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
        HBaseConstants.PARAM_TARBALL_URL, tarurl);
    } else {
      addRunUrl(event, hbaseInstallRunUrl,
        HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
    }
{code}

We should extend or add a builder pattern so that one can do something like

{code}
  RunUrl ru = RunUrl.create(event)
    .url(hbaseInstallRunUrl)
    .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
  if (tarUrl != null) {
    st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
  }
  addRunUrl(ru);
{code}

Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WHIRR-215) Add builder pattern to addRunUrl() call

Posted by "Lars George (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WHIRR-215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lars George resolved WHIRR-215.
-------------------------------

    Resolution: Not A Problem
      Assignee: Lars George

Leaving this for later. I have implemented my approach in WHIRR-186. Maybe that can use for others as a template as well. For now this issue is void.

> Add builder pattern to addRunUrl() call
> ---------------------------------------
>
>                 Key: WHIRR-215
>                 URL: https://issues.apache.org/jira/browse/WHIRR-215
>             Project: Whirr
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 0.3.0
>            Reporter: Lars George
>            Assignee: Lars George
>            Priority: Minor
>             Fix For: 0.4.0
>
>
> If we get optional parameters then the code using varargs gets messy:
> {code}
> String tarurl = clusterSpec.getConfiguration().getString(
>   HBaseConstants.KEY_TARBALL_URL);
> if (tarurl != null) {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
>     HBaseConstants.PARAM_TARBALL_URL, tarurl);
> } else {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> }
> {code}
> We should extend or add a builder pattern so that one can do something like
> {code}
> RunUrl ru = RunUrl.create(event)
>   .url(hbaseInstallRunUrl)
>   .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> if (tarUrl != null) {
>   st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
> }
> addRunUrl(ru);
> {code}
> Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WHIRR-215) Add builder pattern to addRunUrl() call

Posted by "Lars George (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WHIRR-215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12986587#action_12986587 ] 

Lars George commented on WHIRR-215:
-----------------------------------

Ah right, you said so earlier, sorry for missing that. You mentioned a whirr-hbase-default.xml, right? Where would you put those? Simply under main/java/resources? Would I need to call addResources() or so somewhere since the current .properties are parsed by commons.configurations?

> Add builder pattern to addRunUrl() call
> ---------------------------------------
>
>                 Key: WHIRR-215
>                 URL: https://issues.apache.org/jira/browse/WHIRR-215
>             Project: Whirr
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 0.3.0
>            Reporter: Lars George
>            Priority: Minor
>             Fix For: 0.4.0
>
>
> If we get optional parameters then the code using varargs gets messy:
> {code}
> String tarurl = clusterSpec.getConfiguration().getString(
>   HBaseConstants.KEY_TARBALL_URL);
> if (tarurl != null) {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
>     HBaseConstants.PARAM_TARBALL_URL, tarurl);
> } else {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> }
> {code}
> We should extend or add a builder pattern so that one can do something like
> {code}
> RunUrl ru = RunUrl.create(event)
>   .url(hbaseInstallRunUrl)
>   .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> if (tarUrl != null) {
>   st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
> }
> addRunUrl(ru);
> {code}
> Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WHIRR-215) Add builder pattern to addRunUrl() call

Posted by "Tom White (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WHIRR-215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12987661#action_12987661 ] 

Tom White commented on WHIRR-215:
---------------------------------

I'm not sure what the reuse opportunity is yet. Should we do it for a couple of services then look for refactoring opportunities?

> Add builder pattern to addRunUrl() call
> ---------------------------------------
>
>                 Key: WHIRR-215
>                 URL: https://issues.apache.org/jira/browse/WHIRR-215
>             Project: Whirr
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 0.3.0
>            Reporter: Lars George
>            Priority: Minor
>             Fix For: 0.4.0
>
>
> If we get optional parameters then the code using varargs gets messy:
> {code}
> String tarurl = clusterSpec.getConfiguration().getString(
>   HBaseConstants.KEY_TARBALL_URL);
> if (tarurl != null) {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
>     HBaseConstants.PARAM_TARBALL_URL, tarurl);
> } else {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> }
> {code}
> We should extend or add a builder pattern so that one can do something like
> {code}
> RunUrl ru = RunUrl.create(event)
>   .url(hbaseInstallRunUrl)
>   .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> if (tarUrl != null) {
>   st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
> }
> addRunUrl(ru);
> {code}
> Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WHIRR-215) Add builder pattern to addRunUrl() call

Posted by "Tom White (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WHIRR-215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12986591#action_12986591 ] 

Tom White commented on WHIRR-215:
---------------------------------

Have a whirr-hbase-default.properties in src/main/resources, and then build a composite configuration from the default configuration constructed with {{new PropertiesConfiguration("whirr-hbase-default.properties")}}. There's some code in WHIRR-55 to do something similar for Hadoop.

> Add builder pattern to addRunUrl() call
> ---------------------------------------
>
>                 Key: WHIRR-215
>                 URL: https://issues.apache.org/jira/browse/WHIRR-215
>             Project: Whirr
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 0.3.0
>            Reporter: Lars George
>            Priority: Minor
>             Fix For: 0.4.0
>
>
> If we get optional parameters then the code using varargs gets messy:
> {code}
> String tarurl = clusterSpec.getConfiguration().getString(
>   HBaseConstants.KEY_TARBALL_URL);
> if (tarurl != null) {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
>     HBaseConstants.PARAM_TARBALL_URL, tarurl);
> } else {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> }
> {code}
> We should extend or add a builder pattern so that one can do something like
> {code}
> RunUrl ru = RunUrl.create(event)
>   .url(hbaseInstallRunUrl)
>   .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> if (tarUrl != null) {
>   st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
> }
> addRunUrl(ru);
> {code}
> Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WHIRR-215) Add builder pattern to addRunUrl() call

Posted by "Lars George (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WHIRR-215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lars George updated WHIRR-215:
------------------------------

    Description: 
If we get optional parameters then the code using varargs gets messy:

{code}
String tarurl = clusterSpec.getConfiguration().getString(
  HBaseConstants.KEY_TARBALL_URL);
if (tarurl != null) {
  addRunUrl(event, hbaseInstallRunUrl,
    HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
    HBaseConstants.PARAM_TARBALL_URL, tarurl);
} else {
  addRunUrl(event, hbaseInstallRunUrl,
    HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
}
{code}

We should extend or add a builder pattern so that one can do something like

{code}
RunUrl ru = RunUrl.create(event)
  .url(hbaseInstallRunUrl)
  .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
if (tarUrl != null) {
  st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
}
addRunUrl(ru);
{code}

Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.

  was:
If we get optional parameters then the code using varargs gets messy:

{code}
    String tarurl = clusterSpec.getConfiguration().getString(
      HBaseConstants.KEY_TARBALL_URL);
    if (tarurl != null) {
      addRunUrl(event, hbaseInstallRunUrl,
        HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
        HBaseConstants.PARAM_TARBALL_URL, tarurl);
    } else {
      addRunUrl(event, hbaseInstallRunUrl,
        HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
    }
{code}

We should extend or add a builder pattern so that one can do something like

{code}
  RunUrl ru = RunUrl.create(event)
    .url(hbaseInstallRunUrl)
    .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
  if (tarUrl != null) {
    st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
  }
  addRunUrl(ru);
{code}

Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.


> Add builder pattern to addRunUrl() call
> ---------------------------------------
>
>                 Key: WHIRR-215
>                 URL: https://issues.apache.org/jira/browse/WHIRR-215
>             Project: Whirr
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 0.3.0
>            Reporter: Lars George
>            Priority: Minor
>             Fix For: 0.4.0
>
>
> If we get optional parameters then the code using varargs gets messy:
> {code}
> String tarurl = clusterSpec.getConfiguration().getString(
>   HBaseConstants.KEY_TARBALL_URL);
> if (tarurl != null) {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
>     HBaseConstants.PARAM_TARBALL_URL, tarurl);
> } else {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> }
> {code}
> We should extend or add a builder pattern so that one can do something like
> {code}
> RunUrl ru = RunUrl.create(event)
>   .url(hbaseInstallRunUrl)
>   .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> if (tarUrl != null) {
>   st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
> }
> addRunUrl(ru);
> {code}
> Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WHIRR-215) Add builder pattern to addRunUrl() call

Posted by "Tom White (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WHIRR-215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12986524#action_12986524 ] 

Tom White commented on WHIRR-215:
---------------------------------

Alternatively, we could put all the parameter defaults on the client side (i.e. not in the scripts) so they are never null.

> Add builder pattern to addRunUrl() call
> ---------------------------------------
>
>                 Key: WHIRR-215
>                 URL: https://issues.apache.org/jira/browse/WHIRR-215
>             Project: Whirr
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 0.3.0
>            Reporter: Lars George
>            Priority: Minor
>             Fix For: 0.4.0
>
>
> If we get optional parameters then the code using varargs gets messy:
> {code}
> String tarurl = clusterSpec.getConfiguration().getString(
>   HBaseConstants.KEY_TARBALL_URL);
> if (tarurl != null) {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
>     HBaseConstants.PARAM_TARBALL_URL, tarurl);
> } else {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> }
> {code}
> We should extend or add a builder pattern so that one can do something like
> {code}
> RunUrl ru = RunUrl.create(event)
>   .url(hbaseInstallRunUrl)
>   .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> if (tarUrl != null) {
>   st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
> }
> addRunUrl(ru);
> {code}
> Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WHIRR-215) Add builder pattern to addRunUrl() call

Posted by "Lars George (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WHIRR-215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12987543#action_12987543 ] 

Lars George commented on WHIRR-215:
-----------------------------------

I had a look at the patch and understand the suggested idea. I am just a bit confused if that would need some lower level hook or if you could add this myself somewhere. The issue is reuse I guess, since I would need support in all handlers, so should go into a base CAH I presume? Or would you think this should be supported cross services (each for their own defaults) and enabled per service by for example supplying the name of the default config (or default that to "whirr-<service-name>-default.properties") etc.?

> Add builder pattern to addRunUrl() call
> ---------------------------------------
>
>                 Key: WHIRR-215
>                 URL: https://issues.apache.org/jira/browse/WHIRR-215
>             Project: Whirr
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 0.3.0
>            Reporter: Lars George
>            Priority: Minor
>             Fix For: 0.4.0
>
>
> If we get optional parameters then the code using varargs gets messy:
> {code}
> String tarurl = clusterSpec.getConfiguration().getString(
>   HBaseConstants.KEY_TARBALL_URL);
> if (tarurl != null) {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
>     HBaseConstants.PARAM_TARBALL_URL, tarurl);
> } else {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> }
> {code}
> We should extend or add a builder pattern so that one can do something like
> {code}
> RunUrl ru = RunUrl.create(event)
>   .url(hbaseInstallRunUrl)
>   .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> if (tarUrl != null) {
>   st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
> }
> addRunUrl(ru);
> {code}
> Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.