private void upsertBucketConfig ( final BucketConfig newConfig ) { ClusterConfig cluster = currentConfig ; BucketConfig oldConfig = cluster . bucketConfig ( newConfig . name ( ) ) ; if ( newConfig . rev ( ) > 0 && oldConfig != null && newConfig . rev ( ) <= oldConfig . rev ( ) ) { LOGGER . trace ( "Not applying new configuration, older or same rev ID." ) ; return ; } // If the current password of the config is empty and an old config exists // make sure to transfer the password over to the new config. Otherwise it // is possible that authentication errors because of a null password arise. // See JVMCBC-185 if ( newConfig . password ( ) == null && oldConfig != null ) { newConfig . password ( oldConfig . password ( ) ) ; } //copy the username as well if ( oldConfig != null ) { newConfig . username ( oldConfig . username ( ) ) ; } // this is the first config, decide on external networking if ( oldConfig == null ) { externalNetwork = determineNetworkResolution ( newConfig , environment . networkResolution ( ) , seedHosts ) ; LOGGER . info ( "Selected network configuration: {}" , externalNetwork != null ? externalNetwork : "default" ) ; } if ( externalNetwork != null ) { newConfig . useAlternateNetwork ( externalNetwork ) ; } cluster . setBucketConfig ( newConfig . name ( ) , newConfig ) ; LOGGER . debug ( "Applying new configuration {}" , newConfig ) ; currentConfig = cluster ; boolean tainted = newConfig . tainted ( ) ; for ( Refresher refresher : refreshers . values ( ) ) { if ( tainted ) { refresher . markTainted ( newConfig ) ; } else { refresher . markUntainted ( newConfig ) ; } } configObservable . onNext ( currentConfig ) ; }
Helper method which takes the given bucket config and applies it to the cluster config .