Beispiel #1
0
 public static void AddNode(MySqlConnection connection, NodeInfo node)
 {
     MySqlCommand command = connection.CreateCommand();
     command.CommandText = "INSERT INTO fog.node_data (Token, Name, LastIP) VALUE (" + string.Format("'{0}', '{1}', '{2}'", node.TokenID.ToHexString(), node.Name, node.Host) + ");";
     command.ExecuteNonQuery();
 }
Beispiel #2
0
 public override Guid Register(string accessToken, string name)
 {
     if (AllowRegistration && accessToken == null || accessToken != AccessToken)
         return Guid.Empty;
     if (name == null)
         return Guid.Empty;
     NodeInfo node = new NodeInfo(name);
     nodes.Add(node.TokenID, node);
     nodeList.Add(node);
     Console.WriteLine("Node: {0} ({1}) registered", node.TokenID.ToHexString(), name);
     return node.TokenID;
 }
Beispiel #3
0
 private NodeInfo StringToNode(string[] lines)
 {
     string[] data = lines[0].Split('\t');
     NodeInfo node = new NodeInfo(data[0].HexStringToGuid(), data[1]);
     for (int i = 1; i < lines.Length; i++)
     {
         Guid storeID = lines[i].HexStringToGuid();
         node.FileStores.Add(storeID, stores[storeID]);
     }
     return node;
 }
Beispiel #4
0
 //tmp: NodeInfo Serialization
 private string NodeToString(NodeInfo info)
 {
     System.Text.StringBuilder builder = new System.Text.StringBuilder();
     builder.AppendLine(info.TokenID.ToHexString() + "\t" + info.Name);
     foreach (Guid storeID in info.FileStores.Keys)
         builder.AppendLine(storeID.ToHexString());
     return builder.ToString();
 }
Beispiel #5
0
 public AvailableStore(NodeInfo node, FileStore store)
     : this()
 {
     Node = node;
     Store = store;
 }
Beispiel #6
0
 public void AddNode(NodeInfo node)
 {
     nodes.Add(node.TokenID, node);
     nodeList.Add(node);
 }