1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2013 CohortFS, LLC
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #include <sys/types.h>
22 #include "common/config.h"
23 #include "msg/xio/XioMessenger.h"
24 #include "msg/xio/FastStrategy.h"
25 #include "msg/xio/QueueStrategy.h"
26 #include "common/Timer.h"
27 #include "common/ceph_argparse.h"
28 #include "global/global_init.h"
29 #include "global/signal_handler.h"
30 #include "perfglue/heap_profiler.h"
31 #include "common/address_helper.h"
32 #include "xio_dispatcher.h"
34 #define dout_subsys ceph_subsys_simple_server
37 int main(int argc, const char **argv)
39 vector<const char*> args;
41 Dispatcher *dispatcher;
42 std::vector<const char*>::iterator arg_iter;
44 entity_addr_t bind_addr;
49 std::string addr = "localhost";
50 std::string port = "1234";
53 cout << "Xio Server starting..." << endl;
55 argv_to_vec(argc, argv, args);
58 global_init(NULL, args, CEPH_ENTITY_TYPE_ANY, CODE_ENVIRONMENT_DAEMON,
61 for (arg_iter = args.begin(); arg_iter != args.end();) {
62 if (ceph_argparse_witharg(args, arg_iter, &val, "--addr",
65 } else if (ceph_argparse_witharg(args, arg_iter, &val, "--port",
68 } else if (ceph_argparse_flag(args, arg_iter, "--dfast",
76 string dest_str = "tcp://";
80 entity_addr_from_url(&bind_addr, dest_str.c_str());
82 DispatchStrategy* dstrategy;
84 dstrategy = new FastStrategy();
86 dstrategy = new QueueStrategy(2);
88 messenger = new XioMessenger(g_ceph_context,
89 entity_name_t::MON(-1),
95 static_cast<XioMessenger*>(messenger)->set_magic(
96 MSG_MAGIC_REDUPE /* resubmit messages on delivery (REQUIRED) */ |
97 MSG_MAGIC_TRACE_CTR /* timing prints */);
99 messenger->set_default_policy(
100 Messenger::Policy::stateless_server(0));
102 r = messenger->bind(bind_addr);
106 // Set up crypto, daemonize, etc.
107 //global_init_daemonize(g_ceph_context, 0);
108 common_init_finish(g_ceph_context);
110 dispatcher = new XioDispatcher(messenger);
112 messenger->add_dispatcher_head(dispatcher); // should reach ready()
114 messenger->wait(); // can't be called until ready()
120 cout << "Simple Server exit" << endl;