Пример #1
0
        /**
         * Connect to a file. Open a StreamReader on the file and parse its contents.
         */
        public ListOfTuples connectToFile(string path)
        {
            string        line;
            Tuple         inputTuple;
            List <string> listItems;
            ListOfTuples  result = new ListOfTuples();

            System.IO.StreamReader file = new System.IO.StreamReader("..\\..\\doc\\" + path);

            while ((line = file.ReadLine()) != null)
            {
                if (line.Length != 0)
                {
                    listItems = new List <string>();
                    if ((!String.Equals(line[0].ToString(), "%")))
                    {
                        string[] fields = line.Split(',');
                        foreach (string item in fields)
                        {
                            listItems.Add(item.Trim(' ').Trim('"'));
                        }
                        inputTuple = new Tuple(listItems);
                        result.addToList(inputTuple);
                    }
                }
            }
            file.Close();
            return(result);
        }
Пример #2
0
        /**
         * Connect to the input. This can either be a file or another operator.
         */
        public void connectToInput()
        {
            printStatus();
            // Collect all input Tuples from all input sources
            foreach (string operatorInput in information.inputsource)
            {
                if (isOperator(operatorInput)) //operator in format OP1, OP2, ..., OPn
                {
                    // Wait until signalled that the input is uploaded by the inputOperator
                    EventWaitHandle inputReadySignaller = new EventWaitHandle(false, EventResetMode.AutoReset, operatorInput + information.name + information.port);
                    inputReadySignaller.WaitOne();
                }
                else // input file
                {
                    while (isreplicaIDuploaded == false)
                    {
                        Thread.Sleep(200);
                    }
                    Console.WriteLine("replicaID = " + replicaID);
                    input.addToList(connectToFile(operatorInput));
                }
            }
            informationUploaded = true;

            Console.WriteLine("INPUTS:  --------");
            input.showAll();
            LogService.log("Operator: inputs", true);
            foreach (Tuple s in input.tuplesArray)
            {
                LogService.log("Operator: input " + s.ToString(), true);
            }

            //chronological logic
            checkIfFreeze();
            checkIfStart();

            checkIfFreeze();

            createOutput();
        }