示例#1
0
 private void doOperation(string operation, ConnectionPack cp) {
     DADStormProcess.ClientProcess process = new DADStormProcess.ClientProcess(cp);
     if(operation.Equals("report", StringComparison.OrdinalIgnoreCase)) {
         MemoryStream stream = process.reportBack();
         if(stream != null) {
             stream.Position = 0;
             CSF_metric metric = correctMetric((CSF_metric)js.ReadObject(stream));
             metrics.Add(metric);
         }
     }
     if (operation.Equals("reset", StringComparison.OrdinalIgnoreCase)) {
         process.reset();
     }
 }
示例#2
0
        /// <summary>
        /// Method that from a string[] does a command in a single replica
        /// </summary>
        private void  replicaTargetOperations(string[] splitStr)
        {
            if (splitStr.Length < 3)
            {
                operatorTargetOperations(splitStr);
                return;
            }
            string command     = splitStr[0];
            string operator_id = splitStr[1];

            //Must be an integer
            int process_number = Int32.Parse(splitStr[2]);
            List <ConnectionPack> operatorList;

            if (operatorsConPacks.TryGetValue(operator_id, out operatorList))
            {
                ConnectionPack conPack = operatorList [process_number];
                DADStormProcess.ClientProcess cprocess = new DADStormProcess.ClientProcess(conPack);

                if (command.Equals("freeze", StringComparison.OrdinalIgnoreCase))
                {
                    cprocess.freeze();
                    logCommand("freezed: " + operator_id + " replica: " + conPack);
                }
                else if (command.Equals("unfreeze", StringComparison.OrdinalIgnoreCase))
                {
                    cprocess.unfreeze();
                    logCommand("unfreezed: " + operator_id + " replica: " + conPack);
                }
                else if (command.Equals("crash", StringComparison.OrdinalIgnoreCase))
                {
                    cprocess.crash();
                    logCommand("crashed: " + operator_id + " replica: " + conPack);
                }
                else if (command.Equals("start", StringComparison.OrdinalIgnoreCase))
                {
                    if (firstStart)
                    {
                        doFirstStartConnections();
                    }
                    cprocess.start();
                    logCommand("started: " + operator_id + " replica: " + conPack);
                }
            }
            else
            {
                PuppetError("Operator: " + operator_id + " not in list");
            }
        }
示例#3
0
        private void doStatus(ConnectionPack cp)
        {
            DADStormProcess.ClientProcess process = new DADStormProcess.ClientProcess(cp);
            string status = process.status();

            if (status.Equals("Machine Failed"))
            {
                Console.ForegroundColor = ConsoleColor.Red;
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Green;
            }
            System.Console.WriteLine(cp + " " + status);
            Console.ResetColor();
        }
示例#4
0
        protected void addFileToOperator(string fileLocation, string opID)
        {
            List <ConnectionPack> receivingReplicas;

            //Getting list of receiving replicas of operator
            if (operatorsConPacks.TryGetValue(opID, out receivingReplicas))
            {
                //for each replica in the receivingOperator
                PuppetDebug("adding file: " + fileLocation + " to: " + opID);
                foreach (ConnectionPack receivingPack in receivingReplicas)
                {
                    DADStormProcess.ClientProcess receivingReplica = new DADStormProcess.ClientProcess(receivingPack);
                    receivingReplica.addFile(fileLocation);
                }
            }
        }
示例#5
0
        /**
         * Method that from a string[] does a command in a whole operator, i.e., all its replicas
         */
        private void operatorTargetOperations(string[] splitStr)
        {
            string command     = splitStr[0];
            string operator_id = splitStr[1];
            bool   firstTime   = true;
            //Must be an integer
            List <ConnectionPack> operatorList;

            if (operatorsConPacks.TryGetValue(operator_id, out operatorList))
            {
                foreach (ConnectionPack conPack in operatorList)
                {
                    DADStormProcess.ClientProcess cprocess = new DADStormProcess.ClientProcess(conPack);

                    if (command.Equals("start", StringComparison.OrdinalIgnoreCase))
                    {
                        if (firstStart)
                        {
                            doFirstStartConnections();
                        }
                        cprocess.start();
                        logCommand("Started: " + operator_id, firstTime);
                        firstTime = false;
                    }
                    else if (command.Equals("interval", StringComparison.OrdinalIgnoreCase))
                    {
                        cprocess.interval(Int32.Parse(splitStr[2]));
                        logCommand(operator_id + " Interval: " + splitStr[2], firstTime);
                        firstTime = false;
                    } /*else if(command.Equals("crash", StringComparison.OrdinalIgnoreCase)){
                       *                        cprocess.crash();
                       *                }*/
                }
            }
            else
            {
                System.Console.WriteLine("Operator: " + operator_id + " not in list");
            }
        }
示例#6
0
 private void killProcess(ConnectionPack cp)
 {
     DADStormProcess.ClientProcess process = new DADStormProcess.ClientProcess(cp);
     process.crash();
 }
示例#7
0
 /// <summary>
 /// Dos the first start connections.
 /// </summary>
 private void doFirstStartConnections()
 {
     if (firstStart)
     {
         System.Console.WriteLine();
         PuppetDebug("Deploying Connections in network");
         System.Console.WriteLine();
         //Creating the network betwen all operators
         foreach (KeyValuePair <string, List <string> > item in downStreamOperators)
         {
             List <ConnectionPack> outputingReplicas;
             List <ConnectionPack> receivingReplicas;
             string emitingOperator = item.Key;
             //Getting list of Outputing replicas
             if (operatorsConPacks.TryGetValue(emitingOperator, out outputingReplicas))
             {
                 //Then it is an operator
                 //foreach output replica in outputOPerator
                 foreach (ConnectionPack outPack in outputingReplicas)
                 {
                     DADStormProcess.ClientProcess outReplica = new DADStormProcess.ClientProcess(outPack);
                     //foreach receivingOperator
                     foreach (string receiving_operator in item.Value)
                     {
                         //Getting list of receiving replicas of operator
                         if (operatorsConPacks.TryGetValue(receiving_operator, out receivingReplicas))
                         {
                             //for each replica in the receivingOperator
                             PuppetDebug("Connection: " + outPack + " outputs to: " + receiving_operator);
                             outReplica.addDownStreamOperator(receivingReplicas, receiving_operator);
                         }
                     }
                 }
                 foreach (string receiving_operator in item.Value)
                 {
                     //Getting list of receiving replicas of operator
                     if (operatorsConPacks.TryGetValue(receiving_operator, out receivingReplicas))
                     {
                         //for each replica in the receivingOperator
                         //Adding the reversed
                         foreach (ConnectionPack receivingRep in receivingReplicas)
                         {
                             PuppetDebug("Connection: receives " + receivingRep + " from: " + emitingOperator);
                             DADStormProcess.ClientProcess inReplica = new DADStormProcess.ClientProcess(receivingRep);
                             inReplica.addUpperStreamOperator(outputingReplicas, emitingOperator);
                         }
                     }
                 }
             }
             else
             {
                 //else it must be a file
                 //foreach receivingOperator
                 foreach (string receiving_operator in item.Value)
                 {
                     addFileToOperator(item.Key, receiving_operator);
                 }
             }
         }
         string         ip        = getMyIp();
         ConnectionPack myConPack = new ConnectionPack(ip, port);
         foreach (List <ConnectionPack> list in operatorsConPacks.Values)
         {
             foreach (ConnectionPack cp in list)
             {
                 DADStormProcess.ClientProcess process = new DADStormProcess.ClientProcess(cp);
                 //Telling every operator's replica all its replicas
                 process.assignReplicaList(list);
                 //Telling every operator's replica where puppetMaster is
                 process.assignPuppetConPack(myConPack);
             }
         }
         this.firstStart = false;
     }
     else
     {
         //we already started everything..
         return;
     }
 }