Skip to content

Commit

Permalink
Remove triple parameter in metadata (apache#14518)
Browse files Browse the repository at this point in the history
* Remove triple parameter in metadata

* Refine default value get

* Remove triple default value test

* Remove unused import

---------

Co-authored-by: Sean Yang <[email protected]>
  • Loading branch information
finefuture and oxsean authored Aug 26, 2024
1 parent 8467329 commit 9600dc9
Show file tree
Hide file tree
Showing 17 changed files with 282 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,8 @@ public interface CommonConstants {

String DUBBO_VERSIONS_KEY = "META-INF/dubbo-versions";

String TRIPLE_PREFIX = "triple.";

/**
* System-related VM properties
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@

/**
* Configuration for the protocol.
*
* @export
*/
public class ProtocolConfig extends AbstractConfig {

Expand Down Expand Up @@ -282,11 +280,6 @@ protected void checkDefault() {
.getBean(PreferSerializationProvider.class)
.getPreferSerialization();
}

if (triple == null) {
triple = new TripleConfig();
}
triple.checkDefault();
}

@Parameter(excluded = true)
Expand Down Expand Up @@ -635,6 +628,14 @@ public TripleConfig getTriple() {
return triple;
}

@Parameter(excluded = true)
public TripleConfig getTripleOrDefault() {
if (triple == null) {
triple = new TripleConfig();
}
return triple;
}

public void setTriple(TripleConfig triple) {
this.triple = triple;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,16 @@ public ConfigManager(ApplicationModel applicationModel) {
TracingConfig.class));
}

public static ProtocolConfig getProtocol(URL url) {
return url.getOrDefaultApplicationModel().getApplicationConfigManager().getOrAddProtocol(url.getProtocol());
public static ProtocolConfig getProtocolOrDefault(URL url) {
return getProtocolOrDefault(url.getOrDefaultApplicationModel(), url.getProtocol());
}

public static ProtocolConfig getProtocolOrDefault(String idOrName) {
return getProtocolOrDefault(ApplicationModel.defaultModel(), idOrName);
}

private static ProtocolConfig getProtocolOrDefault(ApplicationModel applicationModel, String idOrName) {
return applicationModel.getApplicationConfigManager().getOrAddProtocol(idOrName);
}

// ApplicationConfig correlative methods
Expand Down Expand Up @@ -204,10 +212,19 @@ public ProtocolConfig getOrAddProtocol(String idOrName) {
if (protocol.isPresent()) {
return protocol.get();
}
ProtocolConfig protocolConfig = new ProtocolConfig(idOrName);
addProtocol(protocolConfig);

// Avoiding default protocol configuration overriding custom protocol configuration
// due to `getOrAddProtocol` being called when they are not loaded
idOrName = idOrName + ".default";
protocol = getProtocol(idOrName);
if (protocol.isPresent()) {
return protocol.get();
}

ProtocolConfig protocolConfig = addConfig(new ProtocolConfig(idOrName));

// addProtocol triggers refresh when other protocols exist in the ConfigManager.
// So refresh is only done when ProtocolConfig is not refreshed.
// so refresh is only done when ProtocolConfig is not refreshed.
if (!protocolConfig.isRefreshed()) {
protocolConfig.refresh();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@
*/
package org.apache.dubbo.config.nested;

import org.apache.dubbo.config.support.Parameter;

import java.io.Serializable;

public class Http3Config implements Serializable {

private static final long serialVersionUID = -4443828713331129834L;

public static final int DEFAULT_INITIAL_MAX_DATA = 8_388_608;
public static final int DEFAULT_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL = 1_048_576;
public static final int DEFAULT_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE = 1_048_576;
public static final int DEFAULT_INITIAL_MAX_STREAM_DATA_UNI = 1_048_576;
public static final long DEFAULT_INITIAL_MAX_STREAMS_BIDI = 1_073_741_824;
public static final long DEFAULT_INITIAL_MAX_STREAMS_UNI = 1_073_741_824;

/**
* Whether to enable HTTP/3 support
* <p>The default value is false.
Expand Down Expand Up @@ -142,6 +151,11 @@ public Integer getInitialMaxData() {
return initialMaxData;
}

@Parameter(excluded = true)
public int getInitialMaxDataOrDefault() {
return initialMaxData == null ? DEFAULT_INITIAL_MAX_DATA : initialMaxData;
}

public void setInitialMaxData(Integer initialMaxData) {
this.initialMaxData = initialMaxData;
}
Expand All @@ -166,6 +180,13 @@ public Integer getInitialMaxStreamDataBidiLocal() {
return initialMaxStreamDataBidiLocal;
}

@Parameter(excluded = true)
public int getInitialMaxStreamDataBidiLocalOrDefault() {
return initialMaxStreamDataBidiLocal == null
? DEFAULT_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL
: initialMaxStreamDataBidiLocal;
}

public void setInitialMaxStreamDataBidiLocal(Integer initialMaxStreamDataBidiLocal) {
this.initialMaxStreamDataBidiLocal = initialMaxStreamDataBidiLocal;
}
Expand All @@ -174,6 +195,13 @@ public Integer getInitialMaxStreamDataBidiRemote() {
return initialMaxStreamDataBidiRemote;
}

@Parameter(excluded = true)
public int getInitialMaxStreamDataBidiRemoteOrDefault() {
return initialMaxStreamDataBidiRemote == null
? DEFAULT_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE
: initialMaxStreamDataBidiRemote;
}

public void setInitialMaxStreamDataBidiRemote(Integer initialMaxStreamDataBidiRemote) {
this.initialMaxStreamDataBidiRemote = initialMaxStreamDataBidiRemote;
}
Expand All @@ -182,6 +210,11 @@ public Integer getInitialMaxStreamDataUni() {
return initialMaxStreamDataUni;
}

@Parameter(excluded = true)
public int getInitialMaxStreamDataUniOrDefault() {
return initialMaxStreamDataUni == null ? DEFAULT_INITIAL_MAX_STREAM_DATA_UNI : initialMaxStreamDataUni;
}

public void setInitialMaxStreamDataUni(Integer initialMaxStreamDataUni) {
this.initialMaxStreamDataUni = initialMaxStreamDataUni;
}
Expand All @@ -190,6 +223,11 @@ public Long getInitialMaxStreamsBidi() {
return initialMaxStreamsBidi;
}

@Parameter(excluded = true)
public long getInitialMaxStreamsBidiOrDefault() {
return initialMaxStreamsBidi == null ? DEFAULT_INITIAL_MAX_STREAMS_BIDI : initialMaxStreamsBidi;
}

public void setInitialMaxStreamsBidi(Long initialMaxStreamsBidi) {
this.initialMaxStreamsBidi = initialMaxStreamsBidi;
}
Expand All @@ -198,6 +236,11 @@ public Long getInitialMaxStreamsUni() {
return initialMaxStreamsUni;
}

@Parameter(excluded = true)
public long getInitialMaxStreamsUniOrDefault() {
return initialMaxStreamsUni == null ? DEFAULT_INITIAL_MAX_STREAMS_UNI : initialMaxStreamsUni;
}

public void setInitialMaxStreamsUni(Long initialMaxStreamsUni) {
this.initialMaxStreamsUni = initialMaxStreamsUni;
}
Expand Down Expand Up @@ -241,25 +284,4 @@ public String getCcAlgorithm() {
public void setCcAlgorithm(String ccAlgorithm) {
this.ccAlgorithm = ccAlgorithm;
}

public void checkDefault() {
if (initialMaxData == null) {
initialMaxData = 1 << 23;
}
if (initialMaxStreamDataBidiLocal == null) {
initialMaxStreamDataBidiLocal = 1 << 20;
}
if (initialMaxStreamDataBidiRemote == null) {
initialMaxStreamDataBidiRemote = 1 << 20;
}
if (initialMaxStreamDataUni == null) {
initialMaxStreamDataUni = 1 << 20;
}
if (initialMaxStreamsBidi == null) {
initialMaxStreamsBidi = (long) 1 << 30;
}
if (initialMaxStreamsUni == null) {
initialMaxStreamsUni = (long) 1 << 30;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.dubbo.config.nested;

import org.apache.dubbo.config.support.Nested;
import org.apache.dubbo.config.support.Parameter;

import java.io.Serializable;

Expand All @@ -27,6 +28,11 @@ public class RestConfig implements Serializable {

private static final long serialVersionUID = -8068568976367034755L;

public static final boolean DEFAULT_TRAILING_SLASH_MATCH = true;
public static final boolean DEFAULT_SUFFIX_PATTERN_MATCH = true;
public static final boolean DEFAULT_CASE_SENSITIVE_MATCH = true;
public static final String DEFAULT_FORMAT_PARAMETER_NAME = "format";

/**
* Whether path matching should be match paths with a trailing slash.
* If enabled, a method mapped to "/users" also matches to "/users/".
Expand Down Expand Up @@ -66,6 +72,11 @@ public Boolean getTrailingSlashMatch() {
return trailingSlashMatch;
}

@Parameter(excluded = true)
public boolean getTrailingSlashMatchOrDefault() {
return trailingSlashMatch == null ? DEFAULT_TRAILING_SLASH_MATCH : trailingSlashMatch;
}

public void setTrailingSlashMatch(Boolean trailingSlashMatch) {
this.trailingSlashMatch = trailingSlashMatch;
}
Expand All @@ -74,6 +85,11 @@ public Boolean getSuffixPatternMatch() {
return suffixPatternMatch;
}

@Parameter(excluded = true)
public boolean getSuffixPatternMatchOrDefault() {
return suffixPatternMatch == null ? DEFAULT_SUFFIX_PATTERN_MATCH : suffixPatternMatch;
}

public void setSuffixPatternMatch(Boolean suffixPatternMatch) {
this.suffixPatternMatch = suffixPatternMatch;
}
Expand All @@ -82,6 +98,11 @@ public Boolean getCaseSensitiveMatch() {
return caseSensitiveMatch;
}

@Parameter(excluded = true)
public boolean getCaseSensitiveMatchOrDefault() {
return caseSensitiveMatch == null ? DEFAULT_CASE_SENSITIVE_MATCH : caseSensitiveMatch;
}

public void setCaseSensitiveMatch(Boolean caseSensitiveMatch) {
this.caseSensitiveMatch = caseSensitiveMatch;
}
Expand All @@ -90,6 +111,11 @@ public String getFormatParameterName() {
return formatParameterName;
}

@Parameter(excluded = true)
public String getFormatParameterNameOrDefault() {
return formatParameterName == null ? DEFAULT_FORMAT_PARAMETER_NAME : formatParameterName;
}

public void setFormatParameterName(String formatParameterName) {
this.formatParameterName = formatParameterName;
}
Expand All @@ -98,6 +124,14 @@ public CorsConfig getCors() {
return cors;
}

@Parameter(excluded = true)
public CorsConfig getCorsOrDefault() {
if (cors == null) {
cors = new CorsConfig();
}
return cors;
}

public void setCors(CorsConfig cors) {
this.cors = cors;
}
Expand Down
Loading

0 comments on commit 9600dc9

Please sign in to comment.