Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="jsonConfiguration">json representation of Raft.NodeSettings</param>
        /// <param name="dbreezePath"></param>
        /// <param name="port"></param>
        /// <param name="log"></param>
        /// <param name="OnCommit"></param>
        /// <returns></returns>
        public static TcpRaftNode GetFromConfig(string jsonConfiguration, string dbreezePath, int port, IWarningLog log, Func <string, ulong, byte[], bool> OnCommit)
        {
            try
            {
                TcpRaftNode  rn = null;
                NodeSettings ns = NodeSettings.BiserJsonDecode(jsonConfiguration);

                //Biser.JsonEncoder encc = new Biser.JsonEncoder(new NodeSettings() { TcpClusterEndPoints = eps, RaftEntitiesSettings = reSettings });
                //var str = encc.GetJSON(Biser.JsonSettings.JsonStringStyle.Prettify);

                //NodeSettings nhz = NodeSettings.BiserJsonDecode(str);

                //encc = new Biser.JsonEncoder(nhz);
                //str = encc.GetJSON(Biser.JsonSettings.JsonStringStyle.Prettify);

                rn = new TcpRaftNode(ns, dbreezePath, OnCommit, port, log);
                return(rn);
            }
            catch (Exception ex)
            {
                if (log != null)
                {
                    log.Log(new WarningLogEntry {
                        LogType = WarningLogEntry.eLogType.ERROR, Exception = ex, Method = "TcpRaftNode.GetFromConfig JSON"
                    });
                }
            }
            return(null);
        }