public VoteNode put(int i_index, NodePool i_pool) { VoteNode[] n = this.nodes; int ridx = this.remining - 1; for (int i = n.Length - 1; i >= 0; i--) { if (i == ridx) { VoteNode t = i_pool.prePush(); if (t == null) { return(null); } //新規作成 n[i] = t; t.index = i_index; t.count++; this.remining--; return(t); } if (n[i].index == i_index) { //既存に追記 n[i].count++; return(n[i]); } } //終端到達で無効 return(null); }
private Node CreateNode(int touchIndex) { Node n = NodePool.Get(); n.TouchIndex = touchIndex; return(n); }
private static void GetClsuterMetrics(NodePool item) { string metricurl = MySettings.metricpath.Replace("REPLACEME", item.clusterId); var json = GetJsonData.GetJson(metricurl, MySettings.token); item.Servers = json["items"].ToObject <List <Server> >(); }
static void Main(string[] args) { Console.SetWindowSize(160, Console.WindowHeight); var log = new StreamWriter("performance.log", false); log.AutoFlush = true; int m = 160; int node_count = 1000; long iteration = 0; double heartbeat = 0; // one cycle of the test loop per 15ms double stab_freq = 1; // a random node is stabilized every cycle double join_freq = 100; // a random node is joined every 15 cycles double test_freq = 2; // a successor(n) test is performed every 2 cycles double print_freq = 10; // 1 successor(n) test is printed to the console for every 10 tests var pool = new NodePool(node_count, m, IPAddress.Loopback, 30100); var n = pool.First(); // our node Console.WriteLine($"We're {n.ID.ToUsefulString()}"); Console.WriteLine("Starting all listeners..."); pool.StartAll(); Console.WriteLine("Joining first node to the network..."); n.Join(default);
public ElasticsearchClientSettings( NodePool nodePool, ITransportClient connection, SourceSerializerFactory sourceSerializer, IPropertyMappingProvider propertyMappingProvider) : base(nodePool, connection, sourceSerializer, propertyMappingProvider) { }
/// <summary> /// Returns node pools that have the names in nodePoolNames array in cluster 'clusterName' /// of zone 'zone' in project 'project'. /// </summary> private IEnumerable <NodePool> GetNodePoolsByName(string project, string zone, string clusterName, string[] nodePoolNames) { foreach (string poolName in NodePoolName) { NodePool result = null; try { ProjectsResource.ZonesResource.ClustersResource.NodePoolsResource.GetRequest getRequest = Service.Projects.Zones.Clusters.NodePools.Get(Project, Zone, ClusterName, poolName); result = getRequest.Execute(); } catch (GoogleApiException apiEx) when(apiEx.HttpStatusCode == HttpStatusCode.NotFound) { WriteResourceMissingError( exceptionMessage: $"Nodepool '{poolName}' cannot be found in cluster '{clusterName}'" + $" in zone '{zone}' of project '{Project}'.", errorId: "NodePoolNotFound", targetObject: poolName); } if (result != null) { yield return(result); } } }
/** * Update a node pool and waits until the work request finished * * @param containerEngineClient the service client to use to update the node pool * @param nodePoolId the node pool ID * @param newNodePoolName The new node pool name * */ private static async Task UpdateNodePool(ContainerEngineClient containerEngineClient, string nodePoolId, string newDisplayName) { var updateNodePoolDetails = new UpdateNodePoolDetails { Name = newDisplayName }; var updateNodePoolRequest = new UpdateNodePoolRequest { NodePoolId = nodePoolId, UpdateNodePoolDetails = updateNodePoolDetails }; var updateNodePoolResponse = await containerEngineClient.UpdateNodePool(updateNodePoolRequest); string workRequestId = updateNodePoolResponse.OpcWorkRequestId; var workRequestResponse = WaitForWorkRequestFinished(containerEngineClient, workRequestId); GetNodePoolRequest getNodePoolRequest = new GetNodePoolRequest { NodePoolId = nodePoolId }; GetNodePoolResponse getNodePoolResponse = await containerEngineClient.GetNodePool(getNodePoolRequest); NodePool nodePool = getNodePoolResponse.NodePool; logger.Info($"Node pool name changed to {nodePool.Name}"); }
/// <summary> /// Helper function to build a NodePool object. /// InitialNodeCount will default to 1. /// MaximumNodesToScaleTo have to be greater than MinimumNodesToScaleTo, which defaults to 1. /// </summary> /// <param name="name">The name of the node pool.</param> /// <param name="config">The config of the node pool.</param> /// <param name="initialNodeCount">The number of nodes created in the pool initially.</param> /// <param name="autoUpgrade">If true, nodes will have auto-upgrade enabled.</param> /// <param name="minimumNodesToScaleTo">The maximum number of nodes to scale to.</param> /// <param name="maximumNodesToScaleTo"> /// The minimum number of nodes to scale to. Defaults to 1. /// </param> /// <returns></returns> protected NodePool BuildNodePool(string name, NodeConfig config, int?initialNodeCount, bool autoUpgrade, int?minimumNodesToScaleTo, int?maximumNodesToScaleTo) { var nodePool = new NodePool() { Name = name, InitialNodeCount = initialNodeCount ?? 1, Config = config }; if (maximumNodesToScaleTo != null) { nodePool.Autoscaling = BuildAutoscaling(maximumNodesToScaleTo, minimumNodesToScaleTo); } if (autoUpgrade) { var nodeManagement = new NodeManagement() { AutoUpgrade = true }; nodePool.Management = nodeManagement; } return(nodePool); }
private BaseGrid createDynamicGridWithPool(bool[][] array) { NodePool nodePool = new NodePool(); var grid = new DynamicGridWPool(nodePool); initGrid(grid, array); return(grid); }
private BaseGrid createPartialGridWithPool(bool[][] array) { NodePool nodePool = new NodePool(); var grid = new PartialGridWPool(nodePool, new GridRect(0, 0, array.Length, array[0].Length)); initGrid(grid, array); return(grid); }
public PartialGridWPool(NodePool iNodePool, GridRect? iGridRect = null) : base() { if (iGridRect == null) m_gridRect = new GridRect(); else m_gridRect = iGridRect.Value; m_nodePool = iNodePool; }
public IActionResult GetOne() { var node = NodePool.Get().GetOne(); if (node != null) { return(ApiResult.OK(node.ToApiNodeInfo())); } return(ApiResult.Failure()); }
public IActionResult GetAllNodes() { var result = new List <ApiNodeManagerModel.NodeInfo>(); foreach (var node in NodePool.Get().Nodes) { result.Add(node.ToApiNodeInfo()); } return(ApiResult.OK(result)); }
public DynamicGridWPool(NodePool iNodePool) : base() { m_gridRect = new GridRect(); m_gridRect.minX = 0; m_gridRect.minY = 0; m_gridRect.maxX = 0; m_gridRect.maxY = 0; m_notSet = true; m_nodePool = iNodePool; }
public static void Main(string[] args) { log4net.Config.XmlConfigurator.Configure(); log.Info("=== Matrix Master Server Launching ==="); keyDb = new EncryptionKeyDB("EncryptionKeys"); manager = new NodeManager("CompiledNodes"); manager.Initialize(); manager.LogLoadedModules(); INodeController controller = manager.InstantiateNodeController(); if(controller == null) { log.Error("No INodeController found, the server will not do anything! Exiting..."); manager.Shutdown(); Console.ReadLine(); return; } hostInterface = new HostInterface(Settings.Default.Port, controller); pool = new NodePool(hostInterface); hostInterface.Startup(); nodeLibraryManager = new NodeLibraryManager("CompiledNodes"); nodeLibraryManager.Initialize(); host = new NodeHost("CompiledNodes"); log.Debug("Test download uri: "+host.GetDownloadUrl("MMOController.dll")); var controllerRmiType = manager.ControllerRMIType(); if(controllerRmiType == null) { log.Error("The node controller does not have an RMI interface! It will not function properly!"); } else pool.RegisterNode(new NodeInfo() { HostID = new byte[1], Id = 0, RMITypeName = controllerRmiType.FullName, RMIResolvedType = controllerRmiType }); var webServer = NodeWebServer.Create(Settings.Default.HTTPPort); Console.WriteLine("Press any key to quit..."); Console.ReadLine(); Console.WriteLine("Shutting down..."); webServer.Stop(); manager.Shutdown(); Console.WriteLine("Manager shutdown..."); hostInterface.Shutdown(); }
public IActionResult RedialAll(string id) { if (NodePool.Get().ReDialAll()) { return(ApiResult.OK()); } else { return(ApiResult.Failure()); } }
public DynamicGridWPool(NodePool iNodePool) : base() { MGridRect = new GridRect(); MGridRect.MinX = 0; MGridRect.MinY = 0; MGridRect.MaxX = 0; MGridRect.MaxY = 0; mNotSet = true; mNodePool = iNodePool; }
/// <summary> /// 释放节点 /// </summary> internal void Free() { if (Nodes.Length != 0) { foreach (KeyValue <keyType, int> node in Nodes) { NodePool.Pool[node.Value >> ArrayPool.ArraySizeBit][node.Value & ArrayPool.ArraySizeAnd].Free(); } NodePool.FreeNoLock(Nodes); } CancelBuilder(); }
/// <summary> /// Initializes a new instance of the <see cref="LZWCompressPT"/> class. /// </summary> /// <param name="alphabet">The alphabet.</param> public LZWCompressPT(string alphabet) { if (alphabet.Distinct().Count() != alphabet.Count()) { throw new ArgumentException("Dictionary elements are not distinct."); } this.alphabet = alphabet.ToCharArray(); Array.Sort(this.alphabet); this.nodePool = new NodePool((alphabet.Length * 2) + 1); }
public DynamicGridWPool(NodePool _nodePool) { gridRect = new GridRect { Left = 0, Top = 0, Right = 0, Bottom = 0 }; notSet = true; nodePool = _nodePool; }
public VideoInputTrunkFull(string trunkId, IStreamerBase streamer, Action inputChanged) { DecoderQueue = new UnorderedStreamQueue <Packet>(new NodeName("V", trunkId, "Dq", 2), streamer.PacketPool); FilterQueue = new OrderedStreamQueue <Frame>(new NodeName("V", trunkId, "F1q", 3), streamer.FramePool); Filter2Queue = new OrderedStreamQueue <Frame>(new NodeName("V", trunkId, "F2q", 4), streamer.FramePool); Input = new InputNode(new NodeName("V", trunkId, "I", 0), inputChanged, streamer); DecoderPool = new NodePool <IDecoderContext, DecoderSetup, Packet, Frame>(new NodeName("V", trunkId, "D", 2), streamer, i => new DecoderNode(new NodeName("V", trunkId, "D", 2), streamer)); FilterPool = new NodePool <IFilterContext, FilterSetup, Frame, Frame>(new NodeName("V", trunkId, "F1", 3), streamer, i => new FilterNode(new NodeName("V", trunkId, "F1", 3), streamer)); Filter2 = new FilterNode(new NodeName("V", trunkId, "F2", 4), streamer); }
public IActionResult GetAll() { var result = NodePool.Get().GetAll().Select(i => i.ToApiNodeInfo()).ToArray(); if (result.Length > 0) { return(ApiResult.OK(result)); } else { return(ApiResult.Failure()); } }
public PartialGridWPool(NodePool iNodePool, GridRect? iGridRect = null) : base() { if (iGridRect == null) { this.m_gridRect = new GridRect(); } else { this.m_gridRect = iGridRect.Value; } this.m_nodePool = iNodePool; }
public PartialGridWPool(NodePool iNodePool, GridRect iGridRect = null) : base() { if (iGridRect == null) { MGridRect = new GridRect(); } else { MGridRect = iGridRect; } mNodePool = iNodePool; }
public PartialGridWPool(NodePool iNodePool, GridRect?iGridRect = null) : base() { if (iGridRect == null) { m_gridRect = new GridRect(); } else { m_gridRect = iGridRect.Value; } m_nodePool = iNodePool; }
public void Dispose() { if (!m_Disposed) { GC.SuppressFinalize(this); m_Disposed = true; Allocator.Cleanup(); NodePool.Cleanup(); Allocator = null; NodePool = null; } }
// On tente de creer private void button1_Click(object sender, EventArgs e) { if (validate()) { var node = NodePool.getInstance().createNodeInstance((String)(nodeJsComboBox.Items[nodeJsComboBox.SelectedIndex]), instanceNameTextBox.Text.Trim(), openFileDialog1.FileName); node.restartOnCrash = restartOnCrashCheckBox.Checked; node.restartOnFileChangePatternsString = restartOnChangeTextBox.Text; node.restartOnMainJsFileChange = restartOnFileChangesCheckBox.Checked; node.run(); Close(); new Form.NodeInstanceStandardOutputForm(node).Show(); } }
public void pool_NodeInstanceCreated(NodePool sender, NodeInstanceCreatedEventArgs e) { /* * var nodeinst = new System.Windows.Forms.ToolStripDropDownButton(e.nodeInstance.name, null); * nodeinst.DropDownItems.Add(new ToolStripButton("start")); * nodeinst.DropDownItems.Add(new ToolStripButton("kill")); * nodeinst.DropDownItems.Add(new ToolStripButton("restart")); */ var nodeinst = new NodeInstanceToolStripItem(e.nodeInstance); nodeinst.Image = global::nodepool.Resources.icon.stop_16; systrayMenuStrip.Items.Insert(0, nodeinst); }
private void ClearTree(Node node) { if (node == null) { return; } foreach (var n in node.Neighbors) { ClearTree(n); } NodePool.Release(node); }
public MinerViewModel() : base(650, 650) { AllNodes = new NodePool(5); var fileMan = new FileManager(NetworkType.TestNet); var clientSettings = new ClientSettings(false, NetworkType.TestNet, 5, NodeServiceFlags.NodeNone, AllNodes, fileMan, new UtxoDatabase(fileMan), new MemoryPool()) { UserAgent = "/Satoshi:0.20.1/", Relay = false, Network = NetworkType.TestNet, }; connector = new NodeConnector(AllNodes, clientSettings); }
public IActionResult SaveConfig([FromBody] SaveConfigModel _config) { string _oldredial = this.config.GetSection("MainConfig").GetSection("RedialInterval").Value; string _oldauto = this.config.GetSection("MainConfig").GetSection("AutoRedial").Value; this.config.GetSection("MainConfig").GetSection("HeartInterval").Value = _config.heart_interval.ToString(); this.config.GetSection("MainConfig").GetSection("AutoRedial").Value = _config.auto_redial.ToString(); this.config.GetSection("MainConfig").GetSection("RedialInterval").Value = _config.redial_interval.ToString(); if (_oldredial != _config.redial_interval.ToString() || _oldauto != _config.auto_redial.ToString()) { NodePool.Get().UpdateRedialInterval(); } return(ApiResult.OK()); }
private PathNode FindReversePath(Vector2 start, Vector2 end, NavTerrainTypes linkTypeMask) { NodePool pool = new NodePool(minX, maxX, minY, maxY, distBetweenNodes); MinHeap <PathNode> openNodes = new MinHeap <PathNode>(); PathNode endNode = pool.GetAt(start); PathNode startNode = new PathNode(end, -1, NavTerrainTypes.Floor); startNode.pathRemainderEstimate = Vector2.Distance(start, end); openNodes.Add(startNode); while (openNodes.size > 0) { PathNode node = openNodes.Pop(); if (node == endNode) { return(endNode); } node.isClosed = true; foreach (PathNode adjacent in pool.GetAdjacentNodes(node)) { if (adjacent.isClosed || (linkTypeMask & adjacent.terrainType) == 0) { continue; } float cost = node.knownCost + Vector2.Distance(node.position, adjacent.position); if (!openNodes.Contains(adjacent)) { adjacent.knownCost = cost; adjacent.pathRemainderEstimate = Vector2.Distance(adjacent.position, endNode.position); openNodes.Add(adjacent); adjacent.pathParent = node; } else if (cost < adjacent.knownCost) { adjacent.knownCost = cost; adjacent.pathParent = node; openNodes.PriorityLowered(adjacent); } } } return(endNode); }
/// <summary> /// Retrieves a node from the list's pool of nodes. /// </summary> /// <returns>The node that was retrieved.</returns> private LinkedListNode <T> RetrieveNode() { LinkedListNode <T> node; if (NodePool.Count == 0) { node = new LinkedListNode <T>(default(T)); NodePool.Capacity++; } else { node = NodePool[NodePool.Count - 1]; NodePool.RemoveAt(NodePool.Count - 1); } return(node); }
public PartialGridWPool(PartialGridWPool b) : base(b) { m_nodePool = b.m_nodePool; }
public DynamicGridWPool(DynamicGridWPool b) : base(b) { m_notSet = b.m_notSet; m_nodePool = b.m_nodePool; }