Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

nfs: remove nfs from service engine, refactor nfs to a single module #142

Merged
merged 1 commit into from
Aug 6, 2018
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
38 changes: 0 additions & 38 deletions include/dsn/c/api_layer1.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,44 +565,6 @@ extern DSN_API void dsn_file_write_vector(dsn_handle_t file,
int buffer_count,
uint64_t offset,
dsn::aio_task *cb);

/*!
copy remote directory to the local machine

\param remote address of the remote nfs server
\param source_dir source dir on remote server
\param dest_dir destination dir on local server
\param overwrite true to overwrite, false to preserve.
\param high_priority true means copy in high priority.
\param cb callback aio task to be executed on completion
*/
extern DSN_API void dsn_file_copy_remote_directory(dsn::rpc_address remote,
const char *source_dir,
const char *dest_dir,
bool overwrite,
bool high_priority,
dsn::aio_task *cb);

/*!
copy remote files to the local machine

\param remote address of the remote nfs server
\param source_dir source dir on remote server
\param source_files zero-ended file string array within the source dir on remote server,
when it contains no files, all files within source_dir are copied
\param dest_dir destination dir on local server
\param overwrite true to overwrite, false to preserve.
\param high_priority true means copy in high priority.
\param cb callback aio task to be executed on completion
*/
extern DSN_API void dsn_file_copy_remote_files(dsn::rpc_address remote,
const char *source_dir,
const char **source_files,
const char *dest_dir,
bool overwrite,
bool high_priority,
dsn::aio_task *cb);

/*@}*/

/*!
Expand Down
73 changes: 26 additions & 47 deletions include/dsn/tool-api/nfs.h → include/dsn/dist/nfs_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,80 +24,59 @@
* THE SOFTWARE.
*/

/*
* Description:
* network file system component base interface
*
* Revision history:
* Mar., 2015, @imzhenyu (Zhenyu Guo), first version
* xxxx-xx-xx, author, fix bug about xxx
*/

#pragma once

#include <dsn/service_api_c.h>
#include <string>
#include <memory>
#include <dsn/utility/utils.h>
#include <dsn/utility/binary_reader.h>
#include <dsn/utility/binary_writer.h>
#include <dsn/tool-api/task.h>

namespace dsn {

/*!
@addtogroup tool-api-providers
@{
*/

struct remote_copy_request
{
::dsn::rpc_address source;
dsn::rpc_address source;
std::string source_dir;
std::vector<std::string> files;
std::string dest_dir;
bool overwrite;
bool high_priority;
};

struct remote_copy_response
{
};

DSN_API extern void marshall(::dsn::binary_writer &writer, const remote_copy_request &val);

DSN_API extern void unmarshall(::dsn::binary_reader &reader, /*out*/ remote_copy_request &val);

class service_node;
class task_worker_pool;
class task_queue;

class nfs_node
{
public:
template <typename T>
static nfs_node *create(service_node *node)
{
return new T(node);
}

typedef nfs_node *(*factory)(service_node *);
static std::unique_ptr<nfs_node> create();

public:
nfs_node(service_node *node) : _node(node) {}

aio_task_ptr copy_remote_directory(rpc_address remote,
const std::string &source_dir,
const std::string &dest_dir,
bool overwrite,
bool high_priority,
task_code callback_code,
task_tracker *tracker,
aio_handler &&callback,
int hash = 0);
aio_task_ptr copy_remote_files(rpc_address remote,
const std::string &source_dir,
const std::vector<std::string> &files, // empty for all
const std::string &dest_dir,
bool overwrite,
bool high_priority,
task_code callback_code,
task_tracker *tracker,
aio_handler &&callback,
int hash = 0);

nfs_node() {}
virtual ~nfs_node() {}

virtual ::dsn::error_code start() = 0;

virtual error_code start() = 0;
virtual error_code stop() = 0;

virtual void call(std::shared_ptr<remote_copy_request> rci, aio_task *callback) = 0;

service_node *node() { return _node; }

protected:
service_node *_node;
virtual void call(std::shared_ptr<remote_copy_request> rci, aio_task *callback) = 0;
};

/*@}*/
}
64 changes: 0 additions & 64 deletions include/dsn/tool-api/async_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ struct is_typed_rpc_callback<TFunction,
using response_t = typename std::decay<typename inspect_t::template arg_t<1>>::type;
};

/*!
@addtogroup tasking
@{
*/

namespace tasking {
inline task_ptr
create_task(task_code code, task_tracker *tracker, task_handler &&callback, int hash = 0)
Expand Down Expand Up @@ -107,12 +102,7 @@ inline task_ptr enqueue_timer(task_code evt,
return tsk;
}
}
/*@}*/

/*!
@addtogroup rpc-client
@{
*/
namespace rpc {

inline rpc_response_task_ptr create_rpc_response_task(dsn_message_t req,
Expand Down Expand Up @@ -234,12 +224,7 @@ call_wait(rpc_address server,
partition_hash));
}
}
/*@}*/

/*!
@addtogroup file
@{
*/
namespace file {

inline aio_task_ptr
Expand Down Expand Up @@ -292,55 +277,6 @@ inline aio_task_ptr write_vector(dsn_handle_t fh,
dsn_file_write_vector(fh, buffers, buffer_count, offset, tsk.get());
return tsk;
}

void copy_remote_files_impl(rpc_address remote,
const std::string &source_dir,
const std::vector<std::string> &files, // empty for all
const std::string &dest_dir,
bool overwrite,
bool high_priority,
aio_task *tsk);

inline aio_task_ptr copy_remote_files(rpc_address remote,
const std::string &source_dir,
const std::vector<std::string> &files, // empty for all
const std::string &dest_dir,
bool overwrite,
bool high_priority,
task_code callback_code,
task_tracker *tracker,
aio_handler &&callback,
int hash = 0)
{
auto tsk = create_aio_task(callback_code, tracker, std::move(callback), hash);
copy_remote_files_impl(
remote, source_dir, files, dest_dir, overwrite, high_priority, tsk.get());
return tsk;
}

inline aio_task_ptr copy_remote_directory(rpc_address remote,
const std::string &source_dir,
const std::string &dest_dir,
bool overwrite,
bool high_priority,
task_code callback_code,
task_tracker *tracker,
aio_handler &&callback,
int hash = 0)
{
return copy_remote_files(remote,
source_dir,
{},
dest_dir,
overwrite,
high_priority,
callback_code,
tracker,
std::move(callback),
hash);
}
}
/*@}*/
// ------------- inline implementation ----------------

} // end namespace
2 changes: 0 additions & 2 deletions include/dsn/tool-api/global_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ struct service_spec
std::string tool; // the main tool (only 1 is allowed for a time)
std::list<std::string> toollets; // toollets enabled compatible to the main tool
std::string data_dir; // to store all data/log/coredump etc.
bool start_nfs;

//
// we allow multiple apps in the same process in rDSN, and each app (service_app_spec)
Expand Down Expand Up @@ -192,7 +191,6 @@ CONFIG_BEGIN(service_spec)
CONFIG_FLD_STRING(tool, "", "use what tool to run this process, e.g., native or simulator")
CONFIG_FLD_STRING_LIST(toollets, "use what toollets, e.g., tracer, profiler, fault_injector")
CONFIG_FLD_STRING(data_dir, "./data", "where to put the all the data/log/coredump, etc..")
CONFIG_FLD(bool, bool, start_nfs, false, "whether to start nfs")
CONFIG_FLD(
bool,
bool,
Expand Down
9 changes: 0 additions & 9 deletions include/dsn/tool-api/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class task_queue;
class rpc_engine;
class disk_engine;
class env_provider;
class nfs_node;
class timer_service;
class task;

Expand All @@ -84,7 +83,6 @@ struct __tls_dsn__
rpc_engine *rpc;
disk_engine *disk;
env_provider *env;
nfs_node *nfs;

int last_worker_queue_size;
uint64_t node_pool_thread_ids; // 8,8,16 bits
Expand Down Expand Up @@ -258,7 +256,6 @@ class task : public ref_counter, public extensible_object<task, 4>, public trans
static rpc_engine *get_current_rpc();
static disk_engine *get_current_disk();
static env_provider *get_current_env();
static nfs_node *get_current_nfs();

static void set_tls_dsn_context(
service_node *node, // cannot be null
Expand Down Expand Up @@ -707,10 +704,4 @@ __inline /*static*/ env_provider *task::get_current_env()
return tls_dsn.env;
}

__inline /*static*/ nfs_node *task::get_current_nfs()
{
check_tls_dsn();
return tls_dsn.nfs;
}

} // end namespace
5 changes: 0 additions & 5 deletions include/dsn/tool/nfs.h

This file was deleted.

15 changes: 0 additions & 15 deletions include/dsn/tool/nfs/nfs.types.h

This file was deleted.

3 changes: 0 additions & 3 deletions include/dsn/tool_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ Component providers define the interface for the local components (e.g., network
#include <dsn/tool-api/network.h>
#include <dsn/tool-api/aio_provider.h>
#include <dsn/tool-api/env_provider.h>
#include <dsn/tool-api/nfs.h>
#include <dsn/tool-api/zlock_provider.h>
#include <dsn/tool-api/message_parser.h>
#include <dsn/tool-api/logging_provider.h>
Expand Down Expand Up @@ -159,8 +158,6 @@ register_component_provider(const char *name, env_provider::factory f, ::dsn::pr
DSN_API bool register_component_provider(const char *name,
logging_provider::factory f,
::dsn::provider_type type);
DSN_API bool
register_component_provider(const char *name, nfs_node::factory f, ::dsn::provider_type type);
DSN_API bool register_component_provider(network_header_format fmt,
const std::vector<const char *> &signatures,
message_parser::factory f,
Expand Down
2 changes: 1 addition & 1 deletion scripts/linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ echo "##########################################################################
##############################################
if [ -z "$TEST_MODULE" ]
then
TEST_MODULE="dsn.core.tests,dsn.tests,dsn.replication.simple_kv,dsn.rep_tests.simple_kv,dsn.meta.test,dsn.replica.test"
TEST_MODULE="dsn.core.tests,dsn.tests,dsn_nfs_test,dsn.replication.simple_kv,dsn.rep_tests.simple_kv,dsn.meta.test,dsn.replica.test"
fi

echo "TEST_MODULE=$TEST_MODULE"
Expand Down
2 changes: 0 additions & 2 deletions src/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
add_subdirectory(echo)
add_subdirectory(skv)
add_subdirectory(nfs)
add_subdirectory(nfs_test)
add_subdirectory(cli)
2 changes: 1 addition & 1 deletion src/apps/echo/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ semaphore_aspects =
semaphore_factory_name =

; whether to start nfs
start_nfs = false


; timer service aspect providers, usually for tooling purpose
timer_aspects =
Expand Down
Loading