changeset 61:1a42115e51bb

fix
author KaitoMaeshiro <aosskaito@cr.ie.u-ryukyu.ac.jp>
date Fri, 28 Jan 2022 23:15:05 +0900
parents 14222beab95b
children 12b7528000da
files Test/RewritingTest/IPAddress.cs Test/Topology/TreeTestTopology/StartTreeTestTopology.cs topology/HostMessage.cs topology/TopologyDataGear.cs topology/manager/CheckComingHost.cs topology/manager/ConfigWaiter.cs topology/manager/CreateHash.cs topology/manager/CreateTreeTopology.cs topology/manager/IncomingHosts.cs topology/manager/Parent.cs topology/manager/ParentManager.cs topology/manager/RecordTopology.cs topology/manager/SearchHostName.cs topology/manager/StartTopologyManager.cs topology/manager/TopologyFinish.cs topology/manager/TopologyManager.cs topology/manager/TopologyManagerConfig.cs topology/manager/TopologyType.cs topology/node/ConfigurationFinish.cs topology/node/CreateConnectionList.cs topology/node/IncomingConnectionInfo.cs topology/node/PrepareToClose.cs topology/node/Start.cs topology/node/StartTopologyNode.cs topology/node/TopologyNode.cs topology/node/TopologyNodeConfig.cs
diffstat 26 files changed, 54 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Test/RewritingTest/IPAddress.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -0,0 +1,20 @@
+using System;
+using System.Net;
+
+namespace get_local_ip_address
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            String strHostName = string.Empty;
+            IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName());
+            IPAddress[] addr = ipEntry.AddressList;
+
+            for (int i = 0; i < addr.Length; i++)
+            {
+                Console.WriteLine("IP Address {0}: {1} ", i, addr[i].ToString());
+            }
+        }
+    }
+}
\ No newline at end of file
--- a/Test/Topology/TreeTestTopology/StartTreeTestTopology.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/Test/Topology/TreeTestTopology/StartTreeTestTopology.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -6,11 +6,11 @@
 
 namespace Christie_net.Test.Topology.TreeTestTopology
 {
-    public class StartTreeTopology : StartCodeGear
+    public class StartTreeTestTopology : StartCodeGear
     {
-        public StartTreeTopology(CodeGearManager cgm) : base(cgm) { }
+        public StartTreeTestTopology(CodeGearManager cgm) : base(cgm) { }
 
-        public static void Main(string[] args)
+        public static void Main(String[] args)
         {
             int topologyManagerPort = 10000;
             int topologyNodePort = 10001;
--- a/topology/HostMessage.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/HostMessage.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,9 +1,8 @@
 using System;
 using System.Net;
-using System.Collections.Generic;
+using Christie_net.datagear.dg;
 
-
-namespace Christie_net.topology {
+namespace Christie_net.topology{
     public class HostMessage /*: Cloneable*/ { 
         private String hostName = "";
     private int port ;
@@ -19,19 +18,9 @@
 
     public void setLocalHostAndPort(int port){
         
-        hostName = Dns.GetHostName();
-        hostName = Dns.GetHostAddresses(hostName).ToString();
+        //localhostからIPアドレスを取得
+        hostName = IPAddress.Loopback.ToString();
         this.port = port;
-        /*
-        try
-        {
-            hostName = Dns.GetHostName();
-            hostName = Dns.GetHostAddresses(hostName).ToString();
-            this.port = port;
-        } catch (UnknownHostException e) {
-            e.printStackTrace();
-        }
-        */
     }
 
     public void setHostAndPort(HostMessage hostMessage) {
--- a/topology/TopologyDataGear.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/TopologyDataGear.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,6 +1,4 @@
 using System;
-using System.Net;
-using System.Collections;
 using System.Collections.Generic;
 
 namespace Christie_net.topology {
--- a/topology/manager/CheckComingHost.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/CheckComingHost.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -2,7 +2,6 @@
 using System.Collections.Generic;
 using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology.manager;
 
 namespace Christie_net.topology.manager
 {
--- a/topology/manager/ConfigWaiter.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/ConfigWaiter.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,9 +1,7 @@
 using System;
 using System.Collections.Generic;
-using Christie_net.daemon;
 using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology;
 
 
 namespace Christie_net.topology.manager {
--- a/topology/manager/CreateHash.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/CreateHash.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -3,10 +3,8 @@
 using System.Linq;
 using System.Security.Cryptography;
 using System.Collections.Generic;
-using Christie_net.daemon;
 using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology;
 
 
 namespace Christie_net.topology.manager {
@@ -74,10 +72,17 @@
 
         private String convertMD5(String raw) /*throws NoSuchAlgorithmException*/
         {
-            
+            /*
             MessageDiges md = MessageDiges.getInstance("MD5");
             md.update(raw.GetBytes());
             byte[] hash = md.digest();
+            */
+            
+            var sha1 = SHA1Managed.Create();
+            byte[] inputBytes = Encoding.ASCII.GetBytes(raw);
+            byte[] hash = sha1.ComputeHash(inputBytes);
+            
+            //return BitConverter.ToString(outputBytes).Replace("-", "").ToLower();
             
             
             StringBuilder builder = new StringBuilder();
@@ -85,11 +90,11 @@
             {
                 if ((0xff & aHash) < 0x10)
                 {
-                    builder.Append("0" + Integer.ToHexString((0xff & aHash)));
+                    builder.Append("0" + (0xff & aHash).ToString("x"));
                 }
                 else
                 {
-                    builder.Append(Integer.toHexString((0xff & aHash)));
+                    builder.Append((0xff & aHash).ToString("x"));
                 }
             }
             return builder.ToString();
--- a/topology/manager/CreateTreeTopology.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/CreateTreeTopology.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,9 +1,7 @@
 using System;
 using System.Collections.Generic;
-using Christie_net.daemon;
 using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology.manager;
 
 
 namespace Christie_net.topology.manager {
--- a/topology/manager/IncomingHosts.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/IncomingHosts.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,10 +1,8 @@
 using System;
-using System.Net.Sockets;
 using System.Collections.Generic;
+using System.Linq;
 using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology.manager;
-using Microsoft.VisualBasic;
 
 namespace Christie_net.topology.manager {
 
@@ -24,7 +22,8 @@
         public override void Run(CodeGearManager cgm)
         {
             // not have or match cookie
-        String nodeName = nodeNames.poll();
+        String nodeName = nodeNames.ElementAt(0);
+        nodeNames.RemoveFirst();
         GetLocalDgm().Put("nodeNames", nodeNames);
 
         // Manager connect to Node
@@ -66,7 +65,7 @@
         GetLocalDgm().Put("topology", topology);
 
 
-        if (nodeNames.isEmpty()) {//文字列が空かどうかの判定
+        if (nodeNames.Any()) {//文字列が空かどうかの判定
             // configuration finish
             foreach (String key in resultParse.Keys) {//キーの取得
                 topoDG.setNodeName(key);
--- a/topology/manager/Parent.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/Parent.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,5 +1,4 @@
 using System;
-using System.Collections.Generic;
 
 namespace Christie_net.topology.manager
 {
--- a/topology/manager/ParentManager.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/ParentManager.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,8 +1,7 @@
 using System;
 using System.Collections.Generic;
-using Christie_net.annotation;
-using Christie_net.codegear;
-using Christie_net.topology.manager;
+using System.Linq;
+
 
 namespace Christie_net.topology.manager
 {
@@ -18,19 +17,19 @@
 
         public String getMyParent() {
             checkChildNumber();
-            return list.get(position).getName();
+            return list.ElementAt(position).getName();
         }
 
         public int getMyNumber() {
             checkChildNumber();
-            int num = list.get(position).children();
-            list.get(position).increment();
+            int num = list.ElementAt(position).children();
+            list.ElementAt(position).increment();
             return num;
         }
 
         private void checkChildNumber() {
             for (;;next()) {
-                if (list.get(position).children() < maxChildren)
+                if (list.ElementAt(position).children() < maxChildren)
                     break;
             }
         }
@@ -50,7 +49,7 @@
 
         public void replaceAndRemove(String remove, String replace) {
             Parent removeNode = find(remove);
-            Remove(replace);
+            //Remove(replace);
             removeNode.setName(replace);
         }
 
@@ -63,20 +62,20 @@
             Boolean found = false;
             int i = 0;
             for (;i<list.Count;i++) {
-                if (list.get(i).getName().equals(name)) {
+                if (list.ElementAt(i).getName().Equals(name)) {
                     found = true;
                     break;
                 }
             }
             if (found) {
-                return list.get(i);
+                return list.ElementAt(i);
             } else {
                 return null;
             }
         }
 
         public Parent getLastNode(){
-            return list.get();
+            return list.ElementAt(0);
         }
 
         public void show() {
--- a/topology/manager/RecordTopology.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/RecordTopology.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,9 +1,7 @@
 using System;
 using System.Collections.Generic;
-using Christie_net.daemon;
 using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology;
 
 
 namespace Christie_net.topology.manager {
--- a/topology/manager/SearchHostName.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/SearchHostName.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,8 +1,9 @@
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology.manager;
+
 
 namespace Christie_net.topology.manager {
 
@@ -68,7 +69,7 @@
 
             foreach (LinkedList<HostMessage> list in topology.Values)
             {
-                Console.WriteLine(list.get(0).getRemoteNodeName() + " : ");
+                Console.WriteLine(list.ElementAt(0).getRemoteNodeName() + " : ");
                 foreach (HostMessage host in list)
                 {
                     Console.WriteLine("[ " + host.getNodeName() + " "
--- a/topology/manager/StartTopologyManager.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/StartTopologyManager.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,9 +1,5 @@
-using System;
-using System.Threading;
-using Christie_net.annotation;
 using Christie_net.codegear;
 using Christie_net.topology.node;
-using Christie_net.topology.manager;
 
 namespace Christie_net.topology.manager {
     
--- a/topology/manager/TopologyFinish.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/TopologyFinish.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,9 +1,6 @@
 using System;
-using System.Collections.Generic;
-using Christie_net.daemon;
 using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology;
 
 
 namespace Christie_net.topology.manager {
--- a/topology/manager/TopologyManager.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/TopologyManager.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,9 +1,7 @@
 using System;
 using System.Collections.Generic;
-using Christie_net.daemon;
 using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology;
 
 
 namespace Christie_net.topology.manager {
--- a/topology/manager/TopologyManagerConfig.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/TopologyManagerConfig.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,7 +1,5 @@
 using System;
-using System.Threading;
 using Christie_net.daemon;
-using Christie_net.topology.manager;
 
 namespace Christie_net.topology.manager {
 
--- a/topology/manager/TopologyType.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/manager/TopologyType.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,6 +1,3 @@
-using System;
-using System.Threading;
-
 namespace Christie_net.topology.manager {
     
     public enum TopologyType {
--- a/topology/node/ConfigurationFinish.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/node/ConfigurationFinish.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,11 +1,5 @@
-using System;
-using System.Threading;
-using System.Collections.Generic;
 using Christie_net.annotation;
-using Christie_net.daemon;
 using Christie_net.codegear;
-using Christie_net.topology;
-using Christie_net.topology.node;
 
 
 namespace Christie_net.topology.node
--- a/topology/node/CreateConnectionList.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/node/CreateConnectionList.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,7 +1,6 @@
 using System;
 using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology;
 
 
 namespace Christie_net.topology.node
--- a/topology/node/IncomingConnectionInfo.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/node/IncomingConnectionInfo.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,7 +1,6 @@
 using System;
 using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology;
 
 
 namespace Christie_net.topology.node
--- a/topology/node/PrepareToClose.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/node/PrepareToClose.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,11 +1,7 @@
 using System;
-using System.Threading;
 using System.Collections.Generic;
 using Christie_net.annotation;
-using Christie_net.daemon;
 using Christie_net.codegear;
-using Christie_net.topology;
-using Christie_net.topology.node;
 
 
 namespace Christie_net.topology.node
--- a/topology/node/Start.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/node/Start.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,8 +1,5 @@
-using System;
-using System.Threading;
 using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology;
 
 namespace Christie_net.topology.node {
     
--- a/topology/node/StartTopologyNode.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/node/StartTopologyNode.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,8 +1,4 @@
-using System;
-using System.Threading;
-using Christie_net.annotation;
 using Christie_net.codegear;
-using Christie_net.topology.manager;
 
 
 namespace Christie_net.topology.node
--- a/topology/node/TopologyNode.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/node/TopologyNode.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,10 +1,5 @@
-using System;
-using System.Threading;
-using System.Collections.Generic;
 using Christie_net.annotation;
-using Christie_net.daemon;
 using Christie_net.codegear;
-using Christie_net.topology;
 
 
 namespace Christie_net.topology.node
--- a/topology/node/TopologyNodeConfig.cs	Thu Jan 27 18:05:42 2022 +0900
+++ b/topology/node/TopologyNodeConfig.cs	Fri Jan 28 23:15:05 2022 +0900
@@ -1,7 +1,4 @@
 using System;
-using System.Threading;
-using System.Collections.Generic;
-using Christie_net.annotation;
 using Christie_net.daemon;