Ejemplo n.º 1
0
        /// <summary>
        /// Adds the Scatter Group Communication operator to the communication group.
        /// </summary>
        /// <typeparam name="T">The type of messages that operators will send</typeparam>
        /// <param name="configurations">The configuration for the scatter operator</param>
        /// <param name="operatorName">The name of the scatter operator</param>
        /// <param name="senderId">The sender id</param>
        /// <param name="topologyType">type of topology used in the operaor</param>
        /// <returns>The same CommunicationGroupDriver with the added Scatter operator info</returns>
        public ICommunicationGroupDriver AddScatter <T>(string operatorName, string senderId,
                                                        TopologyTypes topologyType, params IConfiguration[] configurations)
        {
            if (_finalized)
            {
                throw new IllegalStateException("Can't add operators once the spec has been built.");
            }

            var spec = new ScatterOperatorSpec(senderId, configurations);

            ITopology <T> topology;

            if (topologyType == TopologyTypes.Flat)
            {
                topology = new FlatTopology <T>(operatorName, _groupName, spec.SenderId, _driverId,
                                                spec);
            }
            else
            {
                topology = new TreeTopology <T>(operatorName, _groupName, spec.SenderId, _driverId,
                                                spec,
                                                _fanOut);
            }
            _topologies[operatorName]    = topology;
            _operatorSpecs[operatorName] = spec;

            return(this);
        }
Ejemplo n.º 2
0
        public static void RunLab3()
        {
            for (int i = 1; i < 10; i++)
            {
                TreeTopology treeTopology = new TreeTopology(ClusterType.Cluster_Lab3, Libraries.Lab3_Cross_Levels_Rule[ClusterType.Cluster_Lab3],
                                                             Libraries.Lab3_Inner_Level_Rule[ClusterType.Cluster_Lab3],
                                                             Libraries.Lab3_Inner_Side_Rule[ClusterType.Cluster_Lab3], i);

                var topologyMatrix = treeTopology.GlobalMatrix;
                //DextraTest
                DextraHelper dextra         = new DextraHelper(topologyMatrix);
                var          distanceMatrix = dextra.CalculateShortestDistances();
                double       diametr        = CalculateDiameter(distanceMatrix);
                double       averageDiametr = CalculateAverageDiameter(distanceMatrix);
                int          stage          = CalculateStage(topologyMatrix);

                Console.OutputEncoding = Encoding.UTF8;
                Console.WriteLine("<-------------------------------------------------->");
                Console.WriteLine("Итерация " + i);
                Console.WriteLine("Количество процессоров " + treeTopology.processors);
                Console.WriteLine("Диаметр: " + CalculateDiameter(distanceMatrix));
                Console.WriteLine("Средний диаметр: " + averageDiametr);
                Console.WriteLine("Степень = " + stage);
                Console.WriteLine("Цена = " + CalculateCost(diametr, treeTopology.processors, stage));
                Console.WriteLine("Торологический трафик = " + CalculateTopologyGraph(averageDiametr, stage));
                Console.WriteLine();
            }



            Console.ReadKey();
        }
        public void TestTreeTopology()
        {
            TreeTopology<int> topology = new TreeTopology<int>("Operator", "Operator", "task1", "driverid",
                new BroadcastOperatorSpec("task1", GetDefaulCodecConfig(), GetDefaulDataConverterConfig()), 2);
            for (int i = 1; i < 8; i++)
            {
                string taskid = "task" + i;
                topology.AddTask(taskid);
            }

            for (int i = 1; i < 8; i++)
            {
                var conf = topology.GetTaskConfiguration("task" + i);
            }
        }
        public void TestTreeTopology()
        {
            TreeTopology <int> topology = new TreeTopology <int>("Operator", "Operator", "task1", "driverid",
                                                                 new BroadcastOperatorSpec("task1", GetDefaultDataConverterConfig()), 2);

            for (int i = 1; i < 8; i++)
            {
                string taskid = "task" + i;
                topology.AddTask(taskid);
            }

            for (int i = 1; i < 8; i++)
            {
                var conf = topology.GetTaskConfiguration("task" + i);
            }
        }