You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Anthony Baker (JIRA)" <ji...@apache.org> on 2016/11/01 17:58:59 UTC

[jira] [Commented] (GEODE-182) Generate "random" member names if no name is provided

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

Anthony Baker commented on GEODE-182:
-------------------------------------

Here's a quick take on a phrase generator:

{code}
package org.apache.geode.internal.util;

import java.security.SecureRandom;
import java.util.Random;

public class ThreePhraseGenerator {
  private static final String[] adjectives = "agreeable, alive, better, brave, calm, careful, clever, dead, delightful, eager, easy, faithful, famous, gentle, gifted, happy, helpful, important, inexpensive, jolly, kind, lively, mushy, nice, obedient, odd, powerful, proud, relieved, rich, shy, silly, tender, thankful, uninterested, vast, victorious, witty, wrong, zealous"
      .split(", ");

  private static final String[] nouns = "ball, bat, bed, book, boy, bun, can, cake, cap, car, cat, cow, cub, cup, dad, day, dog, doll, dust, fan, feet, girl, gun, hall, hat, hen, jar, kite, man, map, men, mom, pan, pet, pie, pig, pot, rat, son, sun, toe, tub, van"
      .split(", ");
    
  private static final String[] verbs = "add, allow, bake, bang, call, chase, damage, drop, end, escape, fasten, fix, gather, grab, hang, hug, imagine, itch, jog, jump, kick, knit, land, lock, march, mix, name, notice, obey, open, pass, promise, question, reach, rinse, scatter, stay, talk, turn, untie, use, vanish, visit, walk, work, yawn, yell, zip, zoom"
      .split(", ");

  private final Random prng;
  
  public ThreePhraseGenerator() {
    prng = new SecureRandom();
  }
  
  public String generate(char separator) {
    return new StringBuilder()
        .append(select(verbs))
        .append(separator)
        .append(select(adjectives))
        .append(separator)
        .append(select(nouns))
        .toString();
  }
  
  private String select(String[] dictionary) {
    return dictionary[prng.nextInt(dictionary.length)];
  }
  
  public static void main(String[] args) {
    ThreePhraseGenerator gen = new ThreePhraseGenerator();
    for (int i = 0; i < 100; i++) {
      System.out.println(gen.generate('-'));
    }
  }
}
{code}

{noformat}
reach-victorious-boy
escape-kind-boy
promise-shy-tub
talk-gifted-pig
bake-delightful-pot
imagine-wrong-girl
kick-lively-van
stay-calm-can
obey-uninterested-fan
vanish-dead-ball
drop-happy-sun
jog-rich-doll
imagine-tender-pie
allow-inexpensive-hall
open-shy-sun
jump-shy-dog
pass-odd-dog
yawn-happy-girl
untie-better-bed
vanish-mushy-pig
zoom-better-map
damage-shy-tub
end-mushy-son
march-tender-hall
stay-delightful-hat
call-eager-pan
kick-uninterested-dog
hug-inexpensive-ball
fix-brave-car
lock-better-gun
chase-victorious-toe
question-proud-cow
jog-lively-pan
open-agreeable-feet
knit-brave-pie
end-clever-doll
march-inexpensive-dad
turn-obedient-book
bake-uninterested-gun
call-happy-toe
work-vast-boy
untie-gentle-cow
add-helpful-dad
hug-rich-day
yawn-shy-hall
obey-inexpensive-book
bang-gifted-bat
escape-important-pie
question-shy-tub
use-calm-cup
zip-zealous-cat
itch-proud-bed
lock-brave-fan
lock-calm-hall
obey-clever-girl
lock-uninterested-cup
zoom-wrong-cap
kick-clever-sun
march-gentle-pot
yawn-silly-bun
mix-gifted-rat
yell-rich-doll
yell-wrong-hen
knit-easy-gun
...
{noformat}

> Generate "random" member names if no name is provided
> -----------------------------------------------------
>
>                 Key: GEODE-182
>                 URL: https://issues.apache.org/jira/browse/GEODE-182
>             Project: Geode
>          Issue Type: New Feature
>          Components: configuration
>            Reporter: William Markito Oliveira
>            Assignee: Jens Deppe
>            Priority: Minor
>
> In current cloud and container deployments it's very common to allow the infrastructure to just re-execute the same command in order to provision a new node for a system.
> Since Geode require unique member names on a system I'm proposing to create something similar to what Docker and other projects does and generate "random" names on when none are provided.
> Following the Docker implementation, I'd suggest something like:
> * List of adjectives
> * List of gems 
> and a combination using _ for example:
> {code}
> clever_alexandrite
> sharp_emerald
> tender_sapphire
> {code}
> Those would be server names when *-name* param is not specified OR if a *property file* doesn't have a name as well. 
> From the initial list I'm thinking the model would have:
> * Adjectives = 56
> * Names = 70
> * Total names possible = 3920
> Other benefits I can see for non-cloud deployments as well is for example setting member ports to 0 and by providing no name, it's also easier to create multiple geode nodes on the same physical host without specifying names.
> This wouldn't change current naming features and capabilities.  I'm not planning to implement the feature for locators initially.



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