예제 #1
0
        //Gets the receiving urls of each replica, i.e the urls which will send to the each replica
        private void GetUrlsFrom()
        {
            foreach (string operator_id in config.Keys)
            {
                ArrayList array;
                repServices.TryGetValue(operator_id, out array);
                for (int i = 0; i < array.Count; i++)
                {
                    RepServices repS    = (RepServices)array[i];
                    RepInfo     ri      = repS.getRepInfoFromRep();
                    ArrayList   getFrom = getFromUrls(ri.OperatorId);
                    ri.ReceiveInfoUrls = getFrom;
                    repS.updateRepInfo(ri);
                }
            }

            RepInfos.Clear();
            foreach (string operator_id in config.Keys)
            {
                ArrayList array;
                repServices.TryGetValue(operator_id, out array);
                for (int i = 0; i < array.Count; i++)
                {
                    RepServices repS = (RepServices)array[i];
                    RepInfo     ri   = repS.getRepInfoFromRep();
                    RepInfos.Add(ri);
                }
            }
        }
예제 #2
0
        //Gives the repInfo to each replica
        private void StartRepInfo()
        {
            foreach (string operator_id in config.Keys)
            {
                ConfigInfo c;
                config.TryGetValue(operator_id, out c);
                ArrayList   urls = c.Urls;
                string      url;
                RepServices repS;

                ArrayList array;
                repServices.TryGetValue(operator_id, out array);
                for (int i = 0; i < array.Count; i++)
                {
                    repS = (RepServices)array[i];
                    url  = (string)urls[i];
                    string  urlOnly = getIPFromUrl(url);
                    RepInfo info    = new RepInfo(c.SourceInput, c.Routing, c.Routing_param, c.Next_routing, c.Next_routing_param, c.Operation,
                                                  c.OperationParam, getUrlsToSend(operator_id),
                                                  getPortFromUrl(url), loggingLvl,
                                                  "tcp://" + GetLocalIPAddress() + ":" + PM_PORT + "/" + PMSERVICE_NAME, urls, url, Semantics, operator_id);
                    repS.updateRepInfo(info);

                    RepInfos.Add(info);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Response to a Start command.
        /// Sending read tuples from files to the buffer.
        /// </summary>
        public void Start(RepInfo info)
        {
            this.repInfo   = info;
            this.repStatus = "Initialized";
            this.repStatus = "starting";
            IList <Tuple> tupleList    = new List <Tuple>();
            IList <Tuple> subTupleList = new List <Tuple>();

            SiblingsTimer = new Timer(AlivesParents.Method, this, ALIVE_TIMEOUT, ALIVE_TIMEOUT);
            ParentsTimer  = new Timer(AlivesSiblings.Method, this, ALIVE_TIMEOUT, ALIVE_TIMEOUT);
            startChildrenList();
            OperatorName = RepInfo.OperatorId + RepInfo.SiblingsUrls.IndexOf(info.MyUrl);
            foreach (string opx in repInfo.SendInfoUrls.Keys)
            {
                OpsIds.Add(opx);
            }

            foreach (string s in repInfo.Input)
            {
                if (s.Contains(".dat"))
                {
                    OpParser parser = new OpParser(s, OperatorName);
                    tupleList = parser.processFile();
                    if (info.SiblingsUrls.Count == 1)
                    {
                        subTupleList = tupleList;
                        //In this case all tuples are read by the replica
                    }
                    else
                    {
                        //In this case only a part of the tuples are read by the replica
                        int index         = info.SiblingsUrls.IndexOf(info.MyUrl);
                        int tupleListSize = tupleList.Count;
                        int parts         = tupleListSize / (info.SiblingsUrls.Count);
                        if (index == info.SiblingsUrls.Count - 1)
                        {
                            for (int i = index * parts; i < tupleListSize; i++)
                            {
                                subTupleList.Add(tupleList[i]);
                            }
                        }
                        else
                        {
                            for (int i = index * parts; i < (index + 1) * parts; i++)
                            {
                                subTupleList.Add(tupleList[i]);
                            }
                        }
                    }

                    foreach (Tuple t in subTupleList)
                    {
                        threadPool.AssyncInvoke(t);//Tuples from file dont need to be acked
                    }
                }
            }
            this.repStatus = "working";
        }
예제 #4
0
        public void Start(string operator_id)
        {
            RepServices repS;

            ArrayList array;

            repServices.TryGetValue(operator_id, out array);
            for (int i = 0; i < array.Count; i++)
            {
                repS = (RepServices)array[i];
                RepInfo info = repS.getRepInfoFromRep();

                //Asynchronous call without callback
                // Create delegate to remote method
                StartAsyncDelegate RemoteDel = new StartAsyncDelegate(repS.Start);

                // Call delegate to remote method
                IAsyncResult RemAr = RemoteDel.BeginInvoke(info, null, null);

                SendToLog("Start " + operator_id);
            }
        }
예제 #5
0
 public void updateRepInfo(RepInfo repInfo)
 {
     RepInfo = repInfo;
 }