Example #1
0
  /** Create unique Session id. */
  protected String createSessionId() {
    // Use UUID if specified in config (thanks Uli Romahn)
    if (Config.hasProperty(SESSION_ID_GENERATION)
        && Config.getProperty(SESSION_ID_GENERATION).equals(SESSION_ID_GENERATION_UUID)) {
      // We want to be Java 1.4 compatible so use UID class (1.5+ we may
      // use java.util.UUID).
      return new UID().toString();
    }

    // Other cases use random name

    // Create a unique session id
    // In 99.9999 % of the cases this should be generated at once
    // We need the mutext to prevent the chance of creating
    // same-valued ids (thanks Uli Romahn)
    synchronized (mutex) {
      String id;
      while (true) {
        id = Rand.randomName(Config.getIntProperty(SESSION_ID_SIZE));
        if (!hasSession(id)) {
          // Created unique session id
          break;
        }
      }
      return id;
    }
  }
Example #2
0
 @Test
 public void hasPropertyNot() throws Exception {
   final Config config = new Config();
   assertFalse(config.hasProperty("asynchbase.nosuchkey"));
 }
Example #3
0
 @Test
 public void hasPropertyNull() throws Exception {
   final Config config = new Config();
   config.overrideConfig("asynchbase.null", null);
   assertFalse(config.hasProperty("asynchbase.null"));
 }
Example #4
0
 @Test
 public void hasProperty() throws Exception {
   final Config config = new Config();
   assertTrue(config.hasProperty("hbase.rpcs.buffered_flush_interval"));
 }