Ejemplo n.º 1
0
        public CoreNode(NodeRunner runner, NodeConfigParameters configParameters, string configfile, bool useCookieAuth = false)
        {
            this.runner = runner;

            this.State = CoreNodeState.Stopped;
            string user = Encoders.Hex.EncodeData(RandomUtils.GetBytes(20));
            string pass = Encoders.Hex.EncodeData(RandomUtils.GetBytes(20));

            this.creds      = new NetworkCredential(user, pass);
            this.Config     = Path.Combine(this.runner.DataFolder, configfile);
            this.CookieAuth = useCookieAuth;

            this.ConfigParameters = new NodeConfigParameters();
            if (configParameters != null)
            {
                this.ConfigParameters.Import(configParameters);
            }

            var randomFoundPorts = new int[3];

            IpHelper.FindPorts(randomFoundPorts);
            this.ConfigParameters.SetDefaultValueIfUndefined("port", randomFoundPorts[0].ToString());
            this.ConfigParameters.SetDefaultValueIfUndefined("rpcport", randomFoundPorts[1].ToString());
            this.ConfigParameters.SetDefaultValueIfUndefined("apiport", randomFoundPorts[2].ToString());

            this.loggerFactory = ExtendedLoggerFactory.Create();

            CreateConfigFile(this.ConfigParameters);
        }
Ejemplo n.º 2
0
        protected CoreNode CreateNode(NodeRunner runner, string configFile = "bitcoin.conf", bool useCookieAuth = false, NodeConfigParameters configParameters = null)
        {
            var node = new CoreNode(runner, configParameters, configFile, useCookieAuth);

            this.Nodes.Add(node);
            return(node);
        }
Ejemplo n.º 3
0
 public void SetUp()
 {
     _messageBroker = Substitute.For <IMessageBroker>();
     _node          = new Node(NodeName, _messageBroker)
     {
         Status = new LeaderStatus(0)
     };
     _timer            = Substitute.For <ITimer>();
     _leaderNodeRunner = new NodeRunner(_node, _timer, new StrategySelector(3));
 }
Ejemplo n.º 4
0
 public void SetUp()
 {
     _messageBroker = Substitute.For <IMessageBroker>();
     _node          = new Node(NodeName, _messageBroker)
     {
         Status = new CandidateStatus(1)
     };
     _timer     = Substitute.For <ITimer>();
     _candidate = new NodeRunner(_node, _timer, new StrategySelector(3));
 }
Ejemplo n.º 5
0
        public NodeRunner InitializeFollower(string name)
        {
            var node = new Node(name, Broker)
            {
                Status = new FollowerStatus(0)
            };
            var timer      = new ElectionTimer(TimeoutGenerator.GenerateElectionTimeout() * 10);
            var nodeRunner = new NodeRunner(node, timer, new StrategySelector(Nodes.Length));

            Broker.Register(nodeRunner);
            return(nodeRunner);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            var wd = Directory.GetCurrentDirectory();
            // this block starts vue spa application
            var        p = Path.Combine(wd, "samples", "hello-vue");
            NodeRunner r = new NodeRunner();

            r.Command          = "yarn";
            r.Arguments        = "serve";
            r.WorkingDirectory = p;
            r.Timeout          = TimeSpan.FromSeconds(10);
            r.Launch(null);
            if (r.Uri != null)
            {
                Console.WriteLine("vue spa project is served " + r.Uri);
            }
            r.Dispose();

            // this block starts vite spa application
            var        pVite = Path.Combine(wd, "samples", "hello-vite");
            NodeRunner rVite = new NodeRunner();

            rVite.Command          = "yarn";
            rVite.Arguments        = "dev";
            rVite.WorkingDirectory = pVite;
            rVite.Timeout          = TimeSpan.FromSeconds(10);
            rVite.Launch(null);
            if (rVite.Uri != null)
            {
                Console.WriteLine("vite spa project is served " + rVite.Uri);
            }
            rVite.Dispose();

            // this block starts nuxt spa application
            var        pNuxt = Path.Combine(wd, "samples", "hello-nuxt");
            NodeRunner rNuxt = new NodeRunner();

            rNuxt.Command          = "yarn";
            rNuxt.Arguments        = "dev";
            rNuxt.WorkingDirectory = pNuxt;
            rNuxt.Timeout          = TimeSpan.FromSeconds(10);
            rNuxt.Launch(null);
            if (rNuxt.Uri != null)
            {
                Console.WriteLine("nuxt spa project is served " + rNuxt.Uri);
            }
            rNuxt.Dispose();

            Console.WriteLine("Hello World!");
        }
Ejemplo n.º 7
0
        public void FindKthElementTest()
        {
            var r = new NodeRunner();

            Node case1 = null;
            int  k1    = 2;

            Node case2 = new Node(1);

            case2.next      = new Node(2);
            case2.next.next = new Node(3);
            int k2 = 0;

            Node case3 = new Node(1);

            case3.next      = new Node(2);
            case3.next.next = new Node(3);
            int k3 = 1;

            Node case4 = new Node(1);

            case4.next      = new Node(2);
            case4.next.next = new Node(3);
            int k4 = 2;

            Node case5 = new Node(1);

            case5.next      = new Node(2);
            case5.next.next = new Node(3);
            int k5 = 3;

            Node case6 = new Node(1);

            case6.next      = new Node(2);
            case6.next.next = new Node(3);
            int k6 = 4;

            true.ShouldSatisfyAllConditions(
                () => r.FindKthToLastElement(case1, k1).ShouldBe(-1),
                () => r.FindKthToLastElement(case2, k2).ShouldBe(-1),
                () => r.FindKthToLastElement(case3, k3).ShouldBe(3),
                () => r.FindKthToLastElement(case4, k4).ShouldBe(2),
                () => r.FindKthToLastElement(case5, k5).ShouldBe(1),
                () => r.FindKthToLastElement(case6, k6).ShouldBe(-1)
                );
        }
Ejemplo n.º 8
0
        public static void Generate(string sourcePath, ThemeId baseThemeId, string customMetaFilePath, string outputPath)
        {
            var baseThemeBuilderItem = ThemeBuilderItem.Get(sourcePath, baseThemeId, ThemeBuilderLessFilesReader.GetLessPaths(sourcePath, baseThemeId));
            var baseThemeBuilderMeta = baseThemeBuilderItem.Metadata.ToDictionary(item => item.Key, item => item);
            var customThemeMeta      = JsonConvert.DeserializeObject <CustomThemeMeta>(File.ReadAllText(customMetaFilePath));

            var additionalConstants = new StringBuilder();

            if (customThemeMeta.HighlightColor != null)
            {
                foreach (var entry in baseThemeBuilderMeta)
                {
                    var isAccent = entry.Value.PaletteColorOpacity != null;
                    if (isAccent)
                    {
                        additionalConstants.AppendFormat(
                            LESS_VAR_FORMAT,
                            entry.Key,
                            ApplyOpacity(customThemeMeta.HighlightColor, double.Parse(entry.Value.PaletteColorOpacity, CultureInfo.InvariantCulture))
                            );
                    }
                }
            }

            foreach (var item in customThemeMeta.Items)
            {
                additionalConstants.AppendFormat(LESS_VAR_FORMAT, item.Key, item.Value);
            }

            var css = NodeRunner.CompileLess(baseThemeBuilderItem.LessTemplate + additionalConstants);

            var outputDir = Path.GetDirectoryName(outputPath);

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }

            File.WriteAllText(outputPath, THEME_BUILDER_PROMO + css);
        }
 public override void ExecuteRecursive(TaskExecutionNode node)
 {
     var nodeRunner = new NodeRunner(Server);
     nodeRunner.RunNode(node);
 }
 public FixieListener(IRemoteTaskServer server, NodeRunner nodeRunner, bool isParameterized)
 {
     this.server = server;
     this.nodeRunner = nodeRunner;
     this.isParameterized = isParameterized;
 }