public static InstanceConfig newDefaultInstanceConfig ( BackupProvider provider ) { List < EncodedConfigParser . FieldValue > backupDefaultValues = Lists . newArrayList ( ) ; if ( provider != null ) { for ( BackupConfigSpec spec : provider . getConfigs ( ) ) { backupDefaultValues . add ( new EncodedConfigParser . FieldValue ( spec . getKey ( ) , spec . getDefaultValue ( ) ) ) ; } } final String backupExtraValue = new EncodedConfigParser ( backupDefaultValues ) . toEncoded ( ) ; return new InstanceConfig ( ) { @ Override public String getString ( StringConfigs config ) { switch ( config ) { case ZOO_CFG_EXTRA : { return "syncLimit=5&tickTime=2000&initLimit=10" ; } case BACKUP_EXTRA : { return backupExtraValue ; } } return "" ; } @ Override public int getInt ( IntConfigs config ) { switch ( config ) { case CLIENT_PORT : { return 2181 ; } case CONNECT_PORT : { return 2888 ; } case ELECTION_PORT : { return 3888 ; } case CHECK_MS : { return ( int ) TimeUnit . MILLISECONDS . convert ( 30 , TimeUnit . SECONDS ) ; } case CLEANUP_PERIOD_MS : { return ( int ) TimeUnit . MILLISECONDS . convert ( 12 , TimeUnit . HOURS ) ; } case CLEANUP_MAX_FILES : { return 3 ; } case BACKUP_PERIOD_MS : { return ( int ) TimeUnit . MILLISECONDS . convert ( 1 , TimeUnit . MINUTES ) ; } case BACKUP_MAX_STORE_MS : { return ( int ) TimeUnit . MILLISECONDS . convert ( 1 , TimeUnit . DAYS ) ; } case AUTO_MANAGE_INSTANCES_SETTLING_PERIOD_MS : { return ( int ) TimeUnit . MILLISECONDS . convert ( 3 , TimeUnit . MINUTES ) ; } case OBSERVER_THRESHOLD : { return 999 ; } case AUTO_MANAGE_INSTANCES_APPLY_ALL_AT_ONCE : { return 1 ; } } return 0 ; } } ; }
Return the standard default properties as an instance config