Ejemplo n.º 1
0
        public RaptorDBServer(int port, string DataPath)
        {
            _path = Directory.GetCurrentDirectory();
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            _server = new NetworkServer();

            if (_S == "/")// unix system
                _datapath = DataPath.Replace("\\", "/");
            else
                _datapath = DataPath;

            if (_datapath.EndsWith(_S) == false)
                _datapath += _S;

            _raptor = RaptorDB.Open(DataPath);
            register = _raptor.GetType().GetMethod("RegisterView", BindingFlags.Instance | BindingFlags.Public);
            save = _raptor.GetType().GetMethod("Save", BindingFlags.Instance | BindingFlags.Public);
            Initialize();
            _server.Start(port, processpayload);

            // add timer to cleanup connected clients
            _concleanuptimer = new System.Timers.Timer(30 * 1000);
            _concleanuptimer.AutoReset = true;
            _concleanuptimer.Enabled = true;
            _concleanuptimer.Elapsed += _concleanuptimer_Elapsed;
        }
        private void Initialize(string config)
        {
            _log.Debug("Starting replication server...");
            Directory.CreateDirectory(_Path + "Replication");
            Directory.CreateDirectory(_Path + "Replication" + _S + "Inbox");
            Directory.CreateDirectory(_Path + "Replication" + _S + "Outbox");
            _InboxPath = _Path + "Replication" + _S + "Inbox";
            _OutboxPath = _Path + "Replication" + _S + "Outbox";

            _config = fastJSON.JSON.ToObject<ServerConfiguration>(config);
            if (_config == null)
            {
                _log.Error("unable to read the configuration for replication, check the config file");
                return;
            }

            // read branch lastdoc counts here
            foreach (var b in _config.Where)
            {
                int i = -1;
                if (File.Exists(_Path + "Replication" + _S + b.BranchName + ".last"))
                    i = Helper.ToInt32(File.ReadAllBytes(_Path + "Replication" + _S + b.BranchName + ".last"), 0);
                Directory.CreateDirectory(_Path + "Replication" + _S + "Inbox" + _S + b.BranchName);
                Directory.CreateDirectory(_Path + "Replication" + _S + "Outbox" + _S + b.BranchName);
                _branchLastDocs.Add(b.BranchName.ToLower(), i);
            }

            _server = new NetworkServer();
            _server.Start(_config.ReplicationPort, processpayload);
        }
Ejemplo n.º 3
0
        public RaptorDBServer(int port, string DataPath)
        {
            _path = Directory.GetCurrentDirectory();
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
            _server = new NetworkServer();

            _raptor = RaptorDB.Open(DataPath);
            register = _raptor.GetType().GetMethod("RegisterView", BindingFlags.Instance | BindingFlags.Public);
            save = _raptor.GetType().GetMethod("Save", BindingFlags.Instance | BindingFlags.Public);
            Initialize();
            _server.Start(port, processpayload);
        }
Ejemplo n.º 4
0
        public RaptorDBServer(int port, string DataPath)
        {
            _path = Directory.GetCurrentDirectory();
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            _server = new NetworkServer();

            if (_S == "/")// unix system
                _datapath = DataPath.Replace("\\", "/");
            else
                _datapath = DataPath;

            if (_datapath.EndsWith(_S) == false)
                _datapath += _S;

            _raptor = RaptorDB.Open(DataPath);
            register = _raptor.GetType().GetMethod("RegisterView", BindingFlags.Instance | BindingFlags.Public);
            save = _raptor.GetType().GetMethod("Save", BindingFlags.Instance | BindingFlags.Public);
            Initialize();
            _server.Start(port, processpayload);
        }