public ReplicatorCapabilities(TungstenProperties props) throws Exception {
  Set<String> keys=props.keyNames();
  for (  String key : keys) {
    if (key.equals(ROLES)) {
      List<String> tags=props.getStringList(key);
      for (      String tag : tags) {
        if (tag.equalsIgnoreCase(ROLE_MASTER)) {
          addRole(ReplicatorCapabilities.ROLE_MASTER);
        }
 else         if (tag.equalsIgnoreCase(ROLE_SLAVE)) {
          addRole(ReplicatorCapabilities.ROLE_SLAVE);
        }
 else         if (tag.equalsIgnoreCase(ROLE_STANDBY)) {
          addRole(ReplicatorCapabilities.ROLE_STANDBY);
        }
 else {
          throw new Exception("Unknown capability role: " + tag);
        }
      }
    }
 else     if (key.equals(MODEL)) {
      String tag=props.getString(key);
      if (tag.equalsIgnoreCase(MODEL_PUSH)) {
        setModel(MODEL_PUSH);
      }
 else       if (tag.equalsIgnoreCase(MODEL_PULL)) {
        setModel(MODEL_PULL);
      }
 else       if (tag.equalsIgnoreCase(MODEL_PEER)) {
        setModel(MODEL_PEER);
      }
 else       if (tag.equalsIgnoreCase(UNKNOWN)) {
        setModel(UNKNOWN);
      }
 else {
        throw new Exception("Unknown value for model: " + tag);
      }
    }
 else     if (key.equals(CAP_CONSISTENCY)) {
      setConsistencyCheck(props.getBoolean(CAP_CONSISTENCY));
    }
 else     if (key.equals(CAP_HEARTBEAT)) {
      setHeartbeat(props.getBoolean(CAP_HEARTBEAT));
    }
 else     if (key.equals(CAP_FLUSH)) {
      setFlush(props.getBoolean(CAP_FLUSH));
    }
 else     if (key.equals(PROVISION)) {
      String tag=props.getString(key);
      if (tag.equalsIgnoreCase(PROVISION_DONOR)) {
        setProvisionDriver(PROVISION_DONOR);
      }
 else       if (tag.equalsIgnoreCase(PROVISION_JOINER)) {
        setProvisionDriver(PROVISION_JOINER);
      }
 else       if (tag.equalsIgnoreCase(UNKNOWN)) {
        setProvisionDriver(UNKNOWN);
      }
 else {
        throw new Exception("Unknown provision driver: " + tag);
      }
    }
 else {
      throw new Exception("Unknown capability: " + key);
    }
  }
}

public ReplicatorCapabilities ( TungstenProperties props ) throws Exception { Set < String > keys = props . keyNames ( ) ; for ( String key : keys ) { if ( key . equals ( ROLES ) ) { List < String > tags = props . getStringList ( key ) ; for ( String tag : tags ) { if ( tag . equalsIgnoreCase ( ROLE_MASTER ) ) { addRole ( ReplicatorCapabilities . ROLE_MASTER ) ; } else if ( tag . equalsIgnoreCase ( ROLE_SLAVE ) ) { addRole ( ReplicatorCapabilities . ROLE_SLAVE ) ; } else if ( tag . equalsIgnoreCase ( ROLE_STANDBY ) ) { addRole ( ReplicatorCapabilities . ROLE_STANDBY ) ; } else { throw new Exception ( "Unknown capability role: " + tag ) ; } } } else if ( key . equals ( MODEL ) ) { String tag = props . getString ( key ) ; if ( tag . equalsIgnoreCase ( MODEL_PUSH ) ) { setModel ( MODEL_PUSH ) ; } else if ( tag . equalsIgnoreCase ( MODEL_PULL ) ) { setModel ( MODEL_PULL ) ; } else if ( tag . equalsIgnoreCase ( MODEL_PEER ) ) { setModel ( MODEL_PEER ) ; } else if ( tag . equalsIgnoreCase ( UNKNOWN ) ) { setModel ( UNKNOWN ) ; } else { throw new Exception ( "Unknown value for model: " + tag ) ; } } else if ( key . equals ( CAP_CONSISTENCY ) ) { setConsistencyCheck ( props . getBoolean ( CAP_CONSISTENCY ) ) ; } else if ( key . equals ( CAP_HEARTBEAT ) ) { setHeartbeat ( props . getBoolean ( CAP_HEARTBEAT ) ) ; } else if ( key . equals ( CAP_FLUSH ) ) { setFlush ( props . getBoolean ( CAP_FLUSH ) ) ; } else if ( key . equals ( PROVISION ) ) { String tag = props . getString ( key ) ; if ( tag . equalsIgnoreCase ( PROVISION_DONOR ) ) { setProvisionDriver ( PROVISION_DONOR ) ; } else if ( tag . equalsIgnoreCase ( PROVISION_JOINER ) ) { setProvisionDriver ( PROVISION_JOINER ) ; } else if ( tag . equalsIgnoreCase ( UNKNOWN ) ) { setProvisionDriver ( UNKNOWN ) ; } else { throw new Exception ( "Unknown provision driver: " + tag ) ; } } else { throw new Exception ( "Unknown capability: " + key ) ; } } }
create a capabilities instance from tungstenproperties instance .
