Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.doris.qe.ConnectContext;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;

import java.util.Map;

Expand All @@ -42,15 +43,15 @@ public class CreateResourceStmt extends DdlStmt implements NotFallbackInParser {
private final boolean isExternal;
private final boolean ifNotExists;
private final String resourceName;
private final Map<String, String> properties;
private final ImmutableMap<String, String> properties;
private ResourceType resourceType;

public CreateResourceStmt(boolean isExternal, boolean ifNotExists, String resourceName,
Map<String, String> properties) {
this.isExternal = isExternal;
this.ifNotExists = ifNotExists;
this.resourceName = resourceName;
this.properties = properties;
this.properties = ImmutableMap.copyOf(properties);
this.resourceType = ResourceType.UNKNOWN;
}

Expand All @@ -62,7 +63,7 @@ public String getResourceName() {
return resourceName;
}

public Map<String, String> getProperties() {
public ImmutableMap<String, String> getProperties() {
return properties;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.doris.qe.ConnectContext;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;

import java.util.Map;

Expand All @@ -48,7 +49,7 @@ public class CreateStorageVaultStmt extends DdlStmt implements NotFallbackInPars

private final boolean ifNotExists;
private final String vaultName;
private final Map<String, String> properties;
private final ImmutableMap<String, String> properties;
private boolean setAsDefault;
private int pathVersion = 0;
private int numShard = 0;
Expand All @@ -57,7 +58,7 @@ public class CreateStorageVaultStmt extends DdlStmt implements NotFallbackInPars
public CreateStorageVaultStmt(boolean ifNotExists, String vaultName, Map<String, String> properties) {
this.ifNotExists = ifNotExists;
this.vaultName = vaultName;
this.properties = properties;
this.properties = ImmutableMap.copyOf(properties);
this.vaultType = vaultType.UNKNOWN;
}

Expand All @@ -81,7 +82,7 @@ public int getPathVersion() {
return pathVersion;
}

public Map<String, String> getProperties() {
public ImmutableMap<String, String> getProperties() {
return properties;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.doris.fs.obj.RemoteObjects;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.logging.log4j.LogManager;
Expand All @@ -52,32 +53,32 @@ public AzureResource(String name) {
}

@Override
protected void setProperties(Map<String, String> newProperties) throws DdlException {
protected void setProperties(ImmutableMap<String, String> newProperties) throws DdlException {
Preconditions.checkState(newProperties != null);
this.properties = Maps.newHashMap(newProperties);
// check properties
S3Properties.requiredS3PingProperties(newProperties);
S3Properties.requiredS3PingProperties(this.properties);
// default need check resource conf valid, so need fix ut and regression case
boolean needCheck = isNeedCheck(newProperties);
boolean needCheck = isNeedCheck(this.properties);
if (LOG.isDebugEnabled()) {
LOG.debug("azure info need check validity : {}", needCheck);
}

// the endpoint for ping need add uri scheme.
String pingEndpoint = newProperties.get(S3Properties.ENDPOINT);
String pingEndpoint = this.properties.get(S3Properties.ENDPOINT);
if (!pingEndpoint.startsWith("http://")) {
pingEndpoint = "http://" + newProperties.get(S3Properties.ENDPOINT);
newProperties.put(S3Properties.ENDPOINT, pingEndpoint);
newProperties.put(S3Properties.Env.ENDPOINT, pingEndpoint);
pingEndpoint = "http://" + this.properties.get(S3Properties.ENDPOINT);
this.properties.put(S3Properties.ENDPOINT, pingEndpoint);
this.properties.put(S3Properties.Env.ENDPOINT, pingEndpoint);
}

if (needCheck) {
String bucketName = newProperties.get(S3Properties.BUCKET);
String rootPath = newProperties.get(S3Properties.ROOT_PATH);
pingAzure(bucketName, rootPath, newProperties);
String bucketName = this.properties.get(S3Properties.BUCKET);
String rootPath = this.properties.get(S3Properties.ROOT_PATH);
pingAzure(bucketName, rootPath, this.properties);
}
// optional
S3Properties.optionalS3Property(newProperties);
this.properties = newProperties;
S3Properties.optionalS3Property(this.properties);
}

protected static void pingAzure(String bucketName, String rootPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.doris.common.proc.BaseProcResult;
import org.apache.doris.datasource.es.EsUtil;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.annotations.SerializedName;
Expand Down Expand Up @@ -96,7 +97,7 @@ public void modifyProperties(Map<String, String> properties) throws DdlException
}

@Override
protected void setProperties(Map<String, String> properties) throws DdlException {
protected void setProperties(ImmutableMap<String, String> properties) throws DdlException {
valid(properties, false);
this.properties = processCompatibleProperties(properties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.doris.datasource.property.PropertyConverter;
import org.apache.doris.datasource.property.constants.HMSProperties;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.annotations.SerializedName;
Expand Down Expand Up @@ -63,7 +64,7 @@ public void modifyProperties(Map<String, String> properties) throws DdlException
}

@Override
protected void setProperties(Map<String, String> properties) throws DdlException {
protected void setProperties(ImmutableMap<String, String> properties) throws DdlException {
for (String field : HMSProperties.REQUIRED_FIELDS) {
if (!properties.containsKey(field)) {
throw new DdlException("Missing [" + field + "] in properties.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.doris.thrift.THdfsConf;
import org.apache.doris.thrift.THdfsParams;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.annotations.SerializedName;
Expand Down Expand Up @@ -73,13 +74,13 @@ public void modifyProperties(Map<String, String> properties) throws DdlException
}

@Override
protected void setProperties(Map<String, String> properties) throws DdlException {
protected void setProperties(ImmutableMap<String, String> newProperties) throws DdlException {
// `dfs.client.read.shortcircuit` and `dfs.domain.socket.path` should be both set to enable short circuit read.
// We should disable short circuit read if they are not both set because it will cause performance down.
this.properties = Maps.newHashMap(newProperties);
if (!(enableShortCircuitRead(properties))) {
properties.put(HADOOP_SHORT_CIRCUIT, "false");
this.properties.put(HADOOP_SHORT_CIRCUIT, "false");
}
this.properties = properties;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.gson.annotations.SerializedName;
Expand Down Expand Up @@ -90,7 +91,7 @@ public HdfsStorageVault(String name, boolean ifNotExists, boolean setAsDefault)
}

@Override
public void modifyProperties(Map<String, String> newProperties) throws DdlException {
public void modifyProperties(ImmutableMap<String, String> newProperties) throws DdlException {
for (Map.Entry<String, String> kv : newProperties.entrySet()) {
replaceIfEffectiveValue(this.properties, kv.getKey(), kv.getValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.annotations.SerializedName;
Expand Down Expand Up @@ -194,10 +195,10 @@ public void checkProperties(Map<String, String> properties) throws AnalysisExcep
}

@Override
protected void setProperties(Map<String, String> properties) throws DdlException {
protected void setProperties(ImmutableMap<String, String> properties) throws DdlException {
Preconditions.checkState(properties != null);
validateProperties(properties);
configs = properties;
this.configs = Maps.newHashMap(properties);
validateProperties(this.configs);
applyDefaultProperties();
String currentDateTime = LocalDateTime.now(ZoneId.systemDefault()).toString().replace("T", " ");
configs.put(CREATE_TIME, currentDateTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.doris.common.proc.BaseProcResult;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.annotations.SerializedName;
Expand Down Expand Up @@ -167,10 +168,10 @@ public int getSignature(int signatureVersion) {
}

@Override
protected void setProperties(Map<String, String> properties) throws DdlException {
protected void setProperties(ImmutableMap<String, String> properties) throws DdlException {
Preconditions.checkState(properties != null);

configs = properties;
configs = Maps.newHashMap(properties);

checkProperties(HOST);
checkProperties(PORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.doris.persist.gson.GsonUtils;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.gson.annotations.SerializedName;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -242,7 +243,7 @@ protected void replaceIfEffectiveValue(Map<String, String> properties, String ke
/**
* Set and check the properties in child resources
*/
protected abstract void setProperties(Map<String, String> properties) throws DdlException;
protected abstract void setProperties(ImmutableMap<String, String> properties) throws DdlException;

public abstract Map<String, String> getCopiedProperties();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.doris.fs.obj.S3ObjStorage;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.annotations.SerializedName;
Expand Down Expand Up @@ -85,8 +86,10 @@ public String getProperty(String propertyKey) {
}

@Override
protected void setProperties(Map<String, String> properties) throws DdlException {
Preconditions.checkState(properties != null);
protected void setProperties(ImmutableMap<String, String> newProperties) throws DdlException {
Preconditions.checkState(newProperties != null);
this.properties = Maps.newHashMap(newProperties);

// check properties
S3Properties.requiredS3PingProperties(properties);
// default need check resource conf valid, so need fix ut and regression case
Expand All @@ -112,7 +115,6 @@ protected void setProperties(Map<String, String> properties) throws DdlException
}
// optional
S3Properties.optionalS3Property(properties);
this.properties = properties;
}

protected static void pingS3(String bucketName, String rootPath, Map<String, String> newProperties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.doris.datasource.property.PropertyConverter;
import org.apache.doris.datasource.property.constants.S3Properties;

import com.google.common.collect.ImmutableMap;
import com.google.gson.annotations.SerializedName;

import java.util.Arrays;
Expand Down Expand Up @@ -77,7 +78,7 @@ public S3StorageVault(String name, boolean ifNotExists,
}

@Override
public void modifyProperties(Map<String, String> properties) throws DdlException {
public void modifyProperties(ImmutableMap<String, String> properties) throws DdlException {
resource.setProperties(properties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.doris.load.loadv2.SparkYarnConfigFiles;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.annotations.SerializedName;
Expand Down Expand Up @@ -282,7 +283,7 @@ private void updateProperties(Map<String, String> properties) throws DdlExceptio
}

@Override
protected void setProperties(Map<String, String> properties) throws DdlException {
protected void setProperties(ImmutableMap<String, String> properties) throws DdlException {
Preconditions.checkState(properties != null);

// get spark configs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.doris.qe.ShowResultSetMetaData;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.protobuf.TextFormat;

import java.util.ArrayList;
Expand Down Expand Up @@ -172,7 +173,7 @@ public StorageVaultType getType() {
* @param properties
* @throws DdlException
*/
public abstract void modifyProperties(Map<String, String> properties) throws DdlException;
public abstract void modifyProperties(ImmutableMap<String, String> properties) throws DdlException;

/**
* Check properties in child resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6771,7 +6771,7 @@ public UserDesc visitGrantUserIdentify(DorisParser.GrantUserIdentifyContext ctx)
@Override
public LogicalPlan visitCreateResource(DorisParser.CreateResourceContext ctx) {
String resourceName = visitIdentifierOrText(ctx.name);
Map<String, String> properties = new HashMap<>(visitPropertyClause(ctx.properties));
ImmutableMap<String, String> properties = ImmutableMap.copyOf(visitPropertyClause(ctx.properties));

CreateResourceInfo createResourceInfo = new CreateResourceInfo(
ctx.EXTERNAL() != null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.doris.qe.ConnectContext;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;

import java.util.Map;

Expand All @@ -42,14 +43,14 @@ public class CreateResourceInfo {
private final boolean isExternal;
private final boolean ifNotExists;
private final String resourceName;
private final Map<String, String> properties;
private ImmutableMap<String, String> properties;
private ResourceType resourceType;

/**
* CreateResourceInfo
*/
public CreateResourceInfo(boolean isExternal, boolean ifNotExists, String resourceName,
Map<String, String> properties) {
ImmutableMap<String, String> properties) {
this.isExternal = isExternal;
this.ifNotExists = ifNotExists;
this.resourceName = resourceName;
Expand Down Expand Up @@ -121,7 +122,7 @@ public String getResourceName() {
return resourceName;
}

public Map<String, String> getProperties() {
public ImmutableMap<String, String> getProperties() {
return properties;
}

Expand Down
Loading
Loading