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
10 changes: 10 additions & 0 deletions cloud/src/meta-service/meta_service_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,8 @@ void MetaServiceImpl::alter_obj_store_info(google::protobuf::RpcController* cont
msg = "Unknown alter info " + proto_to_json(*request);
return;
} break;
case AlterObjStoreInfoRequest::UNSET_DEFAULT_VAULT:
break;
}

// TODO(dx): check s3 info right
Expand Down Expand Up @@ -798,6 +800,14 @@ void MetaServiceImpl::alter_obj_store_info(google::protobuf::RpcController* cont
response->set_storage_vault_id(*id_itr);
break;
}
case AlterObjStoreInfoRequest::UNSET_DEFAULT_VAULT: {
LOG_INFO("unset instance's default vault, instance id {}, previoud default vault {}, id {}",
instance.instance_id(), instance.default_storage_vault_name(),
instance.default_storage_vault_id());
instance.clear_default_storage_vault_id();
instance.clear_default_storage_vault_name();
break;
}
default: {
code = MetaServiceCode::INVALID_ARGUMENT;
ss << "invalid request op, op=" << request->op();
Expand Down
10 changes: 9 additions & 1 deletion fe/fe-core/src/main/cup/sql_parser.cup
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ nonterminal List<StatementBase> stmts;
nonterminal StatementBase stmt, show_stmt, show_param, help_stmt, load_stmt,
create_routine_load_stmt, pause_routine_load_stmt, resume_routine_load_stmt, stop_routine_load_stmt,
show_routine_load_stmt, show_routine_load_task_stmt, show_create_routine_load_stmt, show_create_load_stmt, show_create_reporitory_stmt,
describe_stmt, alter_stmt, unset_var_stmt,
describe_stmt, alter_stmt, unset_var_stmt, unset_default_storage_vault_stmt,
create_job_stmt, pause_job_stmt, resume_job_stmt,stop_job_stmt, cancel_job_task_stmt,
use_stmt, use_cloud_cluster_stmt, kill_stmt, drop_stmt, recover_stmt, grant_stmt, revoke_stmt, create_stmt, set_stmt, sync_stmt, cancel_stmt, cancel_param, delete_stmt,
switch_stmt, transaction_stmt, unsupported_stmt, export_stmt, admin_stmt, truncate_stmt,
Expand Down Expand Up @@ -1151,6 +1151,8 @@ stmt ::=
{: RESULT = set; :}
| unset_var_stmt:stmt
{: RESULT = stmt; :}
| unset_default_storage_vault_stmt:stmt
{: RESULT = stmt; :}
| kill_stmt:kill
{: RESULT = kill; :}
| kill_analysis_job_stmt: k
Expand Down Expand Up @@ -5281,6 +5283,12 @@ unset_var_stmt ::=
:}
;

unset_default_storage_vault_stmt ::=
KW_UNSET KW_DEFAULT KW_STORAGE KW_VAULT
{:
RESULT = new UnsetDefaultStorageVaultStmt();
:};

user_property_list ::=
user_property:property
{:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.apache.doris.analysis;

public class UnsetDefaultStorageVaultStmt extends DdlStmt {

public UnsetDefaultStorageVaultStmt() {}

@Override
public String toSql() {
final String stmt = "UNSET DEFAULT STORAGE VAULT";
return stmt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ public void setDefaultStorageVault(SetDefaultStorageVaultStmt stmt) throws DdlEx
setDefaultStorageVault(Pair.of(stmt.getStorageVaultName(), vaultId));
}

public void unsetDefaultStorageVault() throws DdlException {
Cloud.AlterObjStoreInfoRequest.Builder builder = Cloud.AlterObjStoreInfoRequest.newBuilder();
builder.setOp(Operation.UNSET_DEFAULT_VAULT);
try {
Cloud.AlterObjStoreInfoResponse resp =
MetaServiceProxy.getInstance().alterObjStoreInfo(builder.build());
if (resp.getStatus().getCode() != Cloud.MetaServiceCode.OK) {
LOG.warn("failed to unset default storage vault");
throw new DdlException(resp.getStatus().getMsg());
}
} catch (RpcException e) {
LOG.warn("failed to unset default storage vault");
throw new DdlException(e.getMessage());
}
defaultVaultInfo = null;
}

public void setDefaultStorageVault(Pair<String, String> vaultInfo) {
try {
rwLock.writeLock().lock();
Expand Down
3 changes: 3 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
import org.apache.doris.analysis.SyncStmt;
import org.apache.doris.analysis.TruncateTableStmt;
import org.apache.doris.analysis.UninstallPluginStmt;
import org.apache.doris.analysis.UnsetDefaultStorageVaultStmt;
import org.apache.doris.catalog.EncryptKeyHelper;
import org.apache.doris.catalog.Env;
import org.apache.doris.common.DdlException;
Expand Down Expand Up @@ -409,6 +410,8 @@ public static void execute(Env env, DdlStmt ddlStmt) throws Exception {
env.getStorageVaultMgr().createStorageVaultResource((CreateStorageVaultStmt) ddlStmt);
} else if (ddlStmt instanceof SetDefaultStorageVaultStmt) {
env.getStorageVaultMgr().setDefaultStorageVault((SetDefaultStorageVaultStmt) ddlStmt);
} else if (ddlStmt instanceof UnsetDefaultStorageVaultStmt) {
env.getStorageVaultMgr().unsetDefaultStorageVault();
} else {
LOG.warn("Unkown statement " + ddlStmt.getClass());
throw new DdlException("Unknown statement.");
Expand Down
1 change: 1 addition & 0 deletions gensrc/proto/cloud.proto
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ message AlterObjStoreInfoRequest {
ADD_S3_VAULT = 103;

SET_DEFAULT_VAULT = 200;
UNSET_DEFAULT_VAULT = 201;
}
optional string cloud_unique_id = 1; // For auth
optional ObjectStoreInfoPB obj = 2;
Expand Down