yiguolei commented on a change in pull request #1678: Add rowset id generator to FE and BE URL: https://github.com/apache/incubator-doris/pull/1678#discussion_r315608293
########## File path: be/src/runtime/fe_based_rowset_id_generator.cpp ########## @@ -0,0 +1,108 @@ +// 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. +#include <string> +#include <fstream> +#include <thrift/Thrift.h> +#include <thrift/transport/TSocket.h> +#include <thrift/transport/TBufferTransports.h> +#include <thrift/protocol/TBinaryProtocol.h> +#include <thrift/TApplicationException.h> +#include "gen_cpp/FrontendService.h" +#include "gen_cpp/MasterService_types.h" +#include "gen_cpp/HeartbeatService_types.h" +#include "runtime/client_cache.h" + +#include "runtime/fe_based_rowset_id_generator.h" + +namespace doris { + +using apache::thrift::TException; +using apache::thrift::transport::TTransportException; + +FeBasedRowsetIdGenerator::FeBasedRowsetIdGenerator(ExecEnv* exec_env) : + _exec_env(exec_env) { +} + +OLAPStatus FeBasedRowsetIdGenerator::get_next_id(RowsetId* gen_rowset_id) { + std::lock_guard<std::mutex> l(_lock); + + while (_next_id >= _id_batch_end) { + // call fe to get another batch rowset ids + OLAPStatus res = _re_init_ids(); + if (res != OLAP_SUCCESS) { + // init rowset id failed, then sleep 1 sec and try again + sleep(1); + } + } + *gen_rowset_id = _next_id; + ++_next_id; + return OLAP_SUCCESS; +} + +OLAPStatus FeBasedRowsetIdGenerator::_re_init_ids() { + // Call fe to get latest user resource + Status master_status; + // using 500ms as default timeout value + FrontendServiceConnection client(_exec_env->frontend_client_cache(), Review comment: done ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
