Beispiel #1
0
 public remoting_interfaces.Tuple uniqTuple(remoting_interfaces.Tuple Tuple, int field_nember)
 {
     //see if the tuple already passed in this operador or not
     if (!tuplos.Contains(Tuple.getUser()))
     {
         tuplos.Add(Tuple.getUser());
         output = Tuple;
     }
     else
     {
         output = new remoting_interfaces.Tuple(0, "", "");
     }
     return(output);
 }
Beispiel #2
0
 private static int hashing(int field, remoting_interfaces.Tuple tp, int replicas)
 {
     if (field == 1) // get the tuple id field
     {
         string str = tp.getID().ToString();
         return(Math.Abs(str.GetHashCode()) % replicas);
     }
     else if (field == 2) // get the tuple user field
     {
         return(Math.Abs(tp.getUser().GetHashCode()) % replicas);
     }
     else if (field == 3) // get the tuple url field
     {
         return(Math.Abs(tp.getURL().GetHashCode()) % replicas);
     }
     return(0);
 }
Beispiel #3
0
            public List <String> getoutput(string dll, string method, remoting_interfaces.Tuple Tuple)
            {
                List <string> outputUsers = new List <string>();
                string        path        = Directory.GetCurrentDirectory();

                path = path.Remove(path.Length - 13);
                Assembly testDLL = Assembly.LoadFile(@path + dll);

                foreach (var type in testDLL.GetExportedTypes())
                {
                    //Get methods from class
                    MethodInfo[] members = type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod);

                    foreach (MemberInfo member in members)
                    {
                        if (member.Name.Equals(method))
                        {
                            MethodInfo methodInfo = type.GetMethod(member.Name);

                            if (methodInfo != null)
                            {
                                IList <IList <string> > result;
                                ParameterInfo[]         parameters = methodInfo.GetParameters();


                                object classInstance = Activator.CreateInstance(type, null);

                                if (parameters.Length == 0)
                                {
                                    result = (IList <IList <string> >)methodInfo.Invoke(classInstance, null);
                                }
                                else
                                {
                                    object[] arr4 = new object[1];

                                    List <string> inputLista = new List <string>();
                                    inputLista.Add(Tuple.getID().ToString());

                                    string str = Tuple.getUser();
                                    str = str.Replace(" ", String.Empty);

                                    inputLista.Add(str);
                                    arr4[0] = inputLista;

                                    result = (IList <IList <string> >)methodInfo.Invoke(classInstance, arr4);

                                    //transform the list of list returned by the method, and convert to a list of strings
                                    foreach (List <string> outputlist in result)
                                    {
                                        foreach (string output in outputlist)
                                        {
                                            outputUsers.Add(output);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return(outputUsers);
            }
Beispiel #4
0
            public remoting_interfaces.Tuple doTweeters(remoting_interfaces.Tuple input_Tuple, int field_number, string condition, string value)
            {
                List <string> tweeters = new List <string>();

                remoting_interfaces.Tuple Tuple = new remoting_interfaces.Tuple(0, "", "");

                string[] tokens = { input_Tuple.getID().ToString(), input_Tuple.getUser(), input_Tuple.getURL() };

                //know what field_number(one, two or three)
                //field_number is ID
                if (field_number == 1)
                {
                    switch (condition)
                    {
                    case "<":
                        if (Int32.Parse(tokens[0]) < Int32.Parse(value))
                        {
                            Tuple.setID(Int32.Parse(tokens[0]));
                            Tuple.setUser(tokens[1]);
                            Tuple.setURL(tokens[2]);
                        }
                        break;

                    case ">":
                        if (Int32.Parse(tokens[0]) > Int32.Parse(value))
                        {
                            Tuple.setID(Int32.Parse(tokens[0]));
                            Tuple.setUser(tokens[1]);
                            Tuple.setURL(tokens[2]);
                        }
                        break;

                    case "=":
                        if (Int32.Parse(tokens[0]) == Int32.Parse(value))
                        {
                            Tuple.setID(Int32.Parse(tokens[0]));
                            Tuple.setUser(tokens[1]);
                            Tuple.setURL(tokens[2]);
                        }
                        break;

                    default:
                        Console.WriteLine("default");
                        break;
                    }
                }
                //field_number is users
                else if (field_number == 2)
                {
                    if (tokens[1].Contains(value))
                    {
                        Tuple.setID(Int32.Parse(tokens[0]));
                        Tuple.setUser(tokens[1]);
                        Tuple.setURL(tokens[2]);
                    }
                }
                //field_nember is the URLs
                else if (field_number == 3)
                {
                    if (tokens[2].Contains(value))
                    {
                        Tuple.setID(Int32.Parse(tokens[0]));
                        Tuple.setUser(tokens[1]);
                        Tuple.setURL(tokens[2]);
                    }
                }
                return(Tuple);
            }