增加hos_init_api、hos_shutdown_api 接口

This commit is contained in:
pengxuanzheng
2020-10-23 15:05:47 +08:00
parent 9cda944013
commit 6b2bcbab23
3 changed files with 24 additions and 4 deletions

View File

@@ -482,6 +482,7 @@ int main(int argc, char *argv[])
perror(log_name); perror(log_name);
return -1; return -1;
} }
hos_init_api();
//创建client //创建client
hos_client_handle handle = hos_client_create(conf.endpoint, "default", "default", conf.pool_size); hos_client_handle handle = hos_client_create(conf.endpoint, "default", "default", conf.pool_size);
if (handle == NULL) if (handle == NULL)
@@ -552,6 +553,7 @@ int main(int argc, char *argv[])
//time /= test_times; //time /= test_times;
//printf("hos upload finished spent %llu ns\n", time); //printf("hos upload finished spent %llu ns\n", time);
} }
hos_shutdown_api();
fclose(log); fclose(log);
return 0; return 0;

View File

@@ -50,6 +50,7 @@ typedef struct hos_client_handle_s
hos_info_t *hash_hos_info[MAX_HOS_CLIENT_THREAD_NUM]; hos_info_t *hash_hos_info[MAX_HOS_CLIENT_THREAD_NUM];
size_t fd_info[MAX_HOS_CLIENT_THREAD_NUM][MAX_HOS_CLIENT_FD_NUM]; size_t fd_info[MAX_HOS_CLIENT_THREAD_NUM][MAX_HOS_CLIENT_FD_NUM];
Aws::SDKOptions options;
static size_t hash_get_min_free_fd(size_t thread_id) static size_t hash_get_min_free_fd(size_t thread_id)
{ {
@@ -115,6 +116,18 @@ void set_thread_sum(hos_client_handle client, size_t thread_sum)
return ; return ;
} }
void hos_init_api()
{
//options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
Aws::InitAPI(options);
}
void hos_shutdown_api()
{
//options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
Aws::ShutdownAPI(options);
}
hos_client_handle hos_client_create(const char *endpoint, const char *accesskeyid, const char *secretkey, size_t pool_size) hos_client_handle hos_client_create(const char *endpoint, const char *accesskeyid, const char *secretkey, size_t pool_size)
{ {
if (!endpoint || !accesskeyid || !secretkey) if (!endpoint || !accesskeyid || !secretkey)
@@ -122,9 +135,6 @@ hos_client_handle hos_client_create(const char *endpoint, const char *accesskeyi
return NULL; return NULL;
} }
Aws::SDKOptions options;
//options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
Aws::InitAPI(options);
hos_client_handle handle = (hos_client_handle)malloc(sizeof(hos_client_handle_t)); hos_client_handle handle = (hos_client_handle)malloc(sizeof(hos_client_handle_t));
memset(handle, 0, sizeof(hos_client_handle_t)); memset(handle, 0, sizeof(hos_client_handle_t));
@@ -547,7 +557,6 @@ int hos_client_destory(hos_client_handle handle)
delete handle->S3Client; delete handle->S3Client;
Aws::Vector<Aws::S3::Model::Bucket>().swap(handle->buckets); Aws::Vector<Aws::S3::Model::Bucket>().swap(handle->buckets);
Aws::ShutdownAPI((handle->options));
for (i = 0; i < handle->thread_sum; i++) for (i = 0; i < handle->thread_sum; i++)
{ {

View File

@@ -75,6 +75,15 @@ enum s3errors
typedef void (*put_finished_callback)(bool, const char *, void *); typedef void (*put_finished_callback)(bool, const char *, void *);
/*************************************************************************************
* 函数名: hos_init_api
*************************************************************************************/
void hos_init_api();
/*************************************************************************************
* 函数名: hos_shutdown_api
*************************************************************************************/
void hos_shutdown_api();
/************************************************************************************* /*************************************************************************************
* 函数名: hos_client_init * 函数名: hos_client_init
* 参数: const char *endpoint 目的地址如”http://192.168.44.12:9098/hos“ * 参数: const char *endpoint 目的地址如”http://192.168.44.12:9098/hos“