public DockerRegistryMachine(int machineId,
                              NetworkSwitch networkSwitch,
                              SimulationSize simulationSize) : base(machineId, networkSwitch)
 {
     _registryTable = new RegistryTable(simulationSize);
     //StartMachine();
 }
        public async Task <IActionResult> PutNetworkSwitch(int id, NetworkSwitch networkSwitch)
        {
            if (id != networkSwitch.Id)
            {
                return(BadRequest());
            }

            _context.Entry(networkSwitch).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NetworkSwitchExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public MasterMachine(NetworkSwitch networkSwitch, IMachinePowerController powerController,
                             UtilizationTable holder, Strategies strategy, AuctionTypes pushAuctionType, AuctionTypes pullAuctionType,
                             SchedulingAlgorithm scheduling,
                             TestedHosts testedHosts)
            : base(0, networkSwitch)
        {
            switch (strategy)
            {
            case Strategies.WAshraf2017Auction:
                _handler = new AuctionManagement(CommunicationModule, powerController, holder, testedHosts);
                break;

            case Strategies.WAshraf2017:
                _handler = new InorderPropingManagement(CommunicationModule, powerController, holder);
                break;

            case Strategies.Zhao:
                _handler = new NoMasterHandlerModule(CommunicationModule);
                break;

            case Strategies.ForsmanPush:
                _handler = new NoMasterHandlerModule(CommunicationModule);
                break;

            case Strategies.ForsmanPull:
                _handler = new NoMasterHandlerModule(CommunicationModule);
                break;

            case Strategies.Proposed2018:

                _handler = new ProposedMasterHandler(CommunicationModule, powerController, holder, testedHosts, pushAuctionType, pullAuctionType);
                break;

            default:

                throw new ArgumentOutOfRangeException(nameof(strategy), strategy, null);
            }

            Holder = holder;
            //StartMachine();
            switch (scheduling)
            {
            case SchedulingAlgorithm.FF:
                scheduler = new FirstFitScheduler(holder, CommunicationModule, powerController);
                break;

            case SchedulingAlgorithm.MFull:
            case SchedulingAlgorithm.LFull:
                scheduler = new AuctionScheduler(holder, CommunicationModule, powerController, scheduling);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(scheduling), scheduling, null);
            }
        }
Ejemplo n.º 4
0
 public HostFactory(Load hostLoad, NetworkSwitch networkSwitchObject,
                    LoadPrediction loadPrediction, Strategies currentStrategy,
                    ContainersType containerTypes, SimulationSize simulationSize) : base(networkSwitchObject)
 {
     this.hostLoad        = hostLoad;
     _networkSwitchObject = networkSwitchObject;
     this.loadPrediction  = loadPrediction;
     this.currentStrategy = currentStrategy;
     this.containerTypes  = containerTypes;
     this.simulationSize  = simulationSize;
 }
Ejemplo n.º 5
0
        public HostMachine(int id,
                           Load maxLoad, NetworkSwitch networkSwitch,
                           LoadPrediction currentLoadPrediction, Strategies strategy,
                           ContainersType containerType,
                           SimulationSize simulationSize) : base(id, networkSwitch)
        {
            if (containerType == ContainersType.D)
            {
                _containerTable = new DockerContainerTable(id, new ImageManager(this.CommunicationModule));
            }
            else
            {
                _containerTable = new ContainerTable(id);
            }
            _loadManager = new HostLoadManager(this.MachineId, maxLoad, currentLoadPrediction, this.CommunicationModule, _containerTable);
            switch (strategy)
            {
            case Strategies.WAshraf2017Auction:
                _handler = new WAshrafHostHandlerModule(CommunicationModule, _containerTable, _loadManager);

                break;

            case Strategies.WAshraf2017:
                _handler = new WAshrafHostHandlerModule(CommunicationModule, _containerTable, _loadManager);

                break;

            case Strategies.Zhao:
                _handler = new ZhaoHostHandler(CommunicationModule, _containerTable, _loadManager, Global.CommonLoadManager);

                break;

            case Strategies.ForsmanPush:
                _handler = new ForsmanHostHandler(CommunicationModule, _containerTable, _loadManager, StrategyActionType.PushAction, simulationSize);

                break;

            case Strategies.ForsmanPull:
                _handler = new ForsmanHostHandler(CommunicationModule, _containerTable, _loadManager, StrategyActionType.PullAction, simulationSize);
                break;

            case Strategies.Proposed2018:
                _handler = new ProposedHostHandlerModule(CommunicationModule, _containerTable, _loadManager);
                break;

            default:

                throw new ArgumentOutOfRangeException(nameof(strategy), strategy, null);
            }
        }
Ejemplo n.º 6
0
 public MasterFactory(NetworkSwitch networkSwitchObject,
                      MachineController machineControllerObject,
                      UtilizationTable utilizationTable,
                      Strategies currentStrategy,
                      AuctionTypes pushAuctionType,
                      AuctionTypes pullAuctionType,
                      SchedulingAlgorithm schedulingAlgorithm,
                      TestedHosts testedHostsCount) : base(networkSwitchObject)
 {
     this.networkSwitchObject     = networkSwitchObject;
     this.machineControllerObject = machineControllerObject;
     this.utilizationTable        = utilizationTable;
     this.currentStrategy         = currentStrategy;
     PushAuctionType          = pushAuctionType;
     PullAuctionType          = pullAuctionType;
     this.schedulingAlgorithm = schedulingAlgorithm;
     this.testedHostsCount    = testedHostsCount;
 }
Ejemplo n.º 7
0
    public Team()
    {
        this.coffeeMachine = new CoffeeMachine();
        this.whiteboard    = new Whiteboard();
        this.networkSwitch = new NetworkSwitch();
        this.phone         = new Phone();
        this.toilet        = new Toilet();

        this.players = new List <Player>();
        for (int i = 0; i < 4; i++)
        {
            this.players.Add(new Player(i));
        }

        this.tasks = Task.CreateTaskTree(); // Creates a new tree via the factory method

        this.completed = new List <Task>();
        this.completed.Add(this.tasks);

        this.available = GetAvailableTasks();
    }
Ejemplo n.º 8
0
        public SimulationController(RunConfiguration configuration)
        {
            CurrentConfiguration   = configuration;
            MachineTableObject     = new MachineTable();
            UtilizationTable       = new UtilizationTable();
            AccountingModuleObject = new AccountingModule(MachineTableObject, UtilizationTable,
                                                          CurrentConfiguration);
            _networkSwitchObject = new NetworkSwitch(MachineTableObject, AccountingModuleObject, configuration.NetworkDealy);

            MachineControllerObject
                = new MachineController(UtilizationTable, MachineTableObject, CurrentConfiguration.ContainersType);
            _masterFactory
                = new MasterFactory(_networkSwitchObject, MachineControllerObject, UtilizationTable,
                                    CurrentConfiguration.Strategy, CurrentConfiguration.PushAuctionType, CurrentConfiguration.PullAuctionType, CurrentConfiguration.SchedulingAlgorithm, CurrentConfiguration.TestedHosts);
            var h = new Load(Global.DataCenterHostConfiguration);

            _hostFactory = new HostFactory(h,
                                           _networkSwitchObject, CurrentConfiguration.LoadPrediction, CurrentConfiguration.Strategy, CurrentConfiguration.ContainersType, configuration.SimulationSize);
            _registryFactory  = new RegistryFactory(_networkSwitchObject, configuration.SimulationSize);
            _containerFactory = new ContainerFactory(CurrentConfiguration.ContainersType, configuration.SimulationSize, configuration.LoadPrediction);
        }
        public async Task <ActionResult <NetworkSwitch> > PostNetworkSwitch(NetworkSwitch networkSwitch)
        {
            // Add all vlans from the switch to a list and check if it needs creating
            List <Vlan> vlans = new List <Vlan>();

            networkSwitch.Ports.ForEach(port =>
                                        port.Vlans.ForEach(portvlan =>
                                                           vlans.Add(new Vlan
            {
                Id   = portvlan.Vlan.Id,
                Name = portvlan.Vlan.Name
            })));

            // Compare with database list and add missing vlans to db
            vlans.RemoveAll(vlan =>
                            _context.Vlans.ToList()
                            .Exists(existing => existing.Id == vlan.Id));
            vlans.ForEach(vlan => _context.Vlans.Add(vlan));
            await _context.SaveChangesAsync();

            // Remove vlan-information and re-add tracked vlan-objects (in order)
            networkSwitch.Ports.ForEach(port =>
            {
                int[] vlannumbers = port.Vlans.Select(x => x.Vlan.Id).ToArray();
                port.Vlans.Clear();
                foreach (int number in vlannumbers)
                {
                    port.Vlans.Add(new PortVlan {
                        Vlan = _context.Vlans.FirstOrDefault(vlan => vlan.Id == number)
                    });
                }
            });

            _context.NetworkSwitches.Add(networkSwitch);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetNetworkSwitch), new { id = networkSwitch.Id }, networkSwitch));
        }
 public NetworkInterfaceCard(int machineId, NetworkSwitch networkSwitch, IMessageHandler handler)
 {
     MachineId      = machineId;
     _handler       = handler;
     _networkSwitch = networkSwitch;
 }
 public MachineFactory(NetworkSwitch networkSwitch)
 {
     _networkSwitchObject = networkSwitch;
 }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            NetworkHardware[] net;

            Router router1 = new Router();
            Router router2 = new Router();

            NetworkSwitch networkSwitch1 = new NetworkSwitch();
            NetworkSwitch networkSwitch2 = new NetworkSwitch();

            net = new NetworkHardware[4] {
                (NetworkHardware)router1, (NetworkHardware)router2, (NetworkHardware)networkSwitch1, (NetworkHardware)networkSwitch2
            };

            Console.WriteLine("Display instance with default fields\n");
            Console.WriteLine(router1.DisplayFullInformation());
            Console.WriteLine(" ");
            Console.WriteLine(networkSwitch1.DisplayFullInformation());

            for (int i = 0; i < 2; i++)
            {
                Console.Write("setNameHardware: ");
                net[i].setNameHardware(Console.ReadLine());
                Console.Write("setModel: ");
                net[i].setModel(Console.ReadLine());
                Console.Write("setSize: ");
                net[i].setSize(Convert.ToInt32(Console.ReadLine()));
                Console.Write("setNumOfPorts: ");
                net[i].setNumOfPorts(Convert.ToInt32(Console.ReadLine()));
                Console.Write("setPower: ");
                net[i].setPower(Convert.ToInt32(Console.ReadLine()));


                Router router = (Router)net[i];

                Console.Write("setNumberOfChannels: ");
                router.setNumberOfChannels(Convert.ToInt32(Console.ReadLine()));
                Console.Write("setMaximumDataRate: ");
                router.setMaximumDataRate(Convert.ToInt32(Console.ReadLine()));
                Console.Write("setNumberOfLanPorts: ");
                router.setNumberOfLanPorts(Convert.ToInt32(Console.ReadLine()));
                Console.Write("setNumbersOfAntennas: ");
                router.setNumbersOfAntennas(Convert.ToInt32(Console.ReadLine()));
                Console.Write("setNumOfFrequency: ");
                router.setNumOfFrequency(Convert.ToInt32(Console.ReadLine()));

                net[i] = router;

                Console.WriteLine(net[i].DisplayFullInformation());
            }

            for (int i = 2; i < 4; i++)
            {
                Console.Write("setNameHardware: ");
                net[i].setNameHardware(Console.ReadLine());
                Console.Write("setModel: ");
                net[i].setModel(Console.ReadLine());
                Console.Write("setSize: ");
                net[i].setSize(Convert.ToInt32(Console.ReadLine()));
                Console.Write("setNumOfPorts: ");
                net[i].setNumOfPorts(Convert.ToInt32(Console.ReadLine()));
                Console.Write("setPower: ");
                net[i].setPower(Convert.ToInt32(Console.ReadLine()));


                NetworkSwitch router = (NetworkSwitch)net[i];

                Console.Write("setNumInOfPorts: ");
                router.setNumInOfPorts(Convert.ToInt32(Console.ReadLine()));
                Console.Write("setNumOutOfPorts: ");
                router.setNumOutOfPorts(Convert.ToInt32(Console.ReadLine()));
                Console.Write("isAutonomy(1/0): ");
                int  autonomy = Convert.ToInt32(Console.ReadLine());
                bool setAutomy;
                setAutomy = autonomy == 1 ? true : false;
                router.setAutonomy(setAutomy);
                Console.Write("setWeight: ");
                router.setWeight(Convert.ToInt32(Console.ReadLine()));
                Console.Write("setTypeDuplex: ");
                router.setTypeDuplex(Console.ReadLine());

                net[i] = router;

                Console.WriteLine(net[i].DisplayFullInformation());
            }
        }
Ejemplo n.º 13
0
        private void CardControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue is Server)
            {
                Server server = e.NewValue as Server;
                card.Background = Brushes.LightCoral;

                property1.Text = server.Name;
                property2.Text = $"{server.CPUs} CPU";
                property3.Text = $"{server.Size}U";
                property4.Text = $"{server.Weight} кг";
                property5.Text = $"{server.Count} шт";
                property6.Text = $"{server.Price} USD";
            }
            else if (e.NewValue is KvmConsole)
            {
                KvmConsole kvmConsole = e.NewValue as KvmConsole;
                card.Background = Brushes.Bisque;

                property1.Text = kvmConsole.Name;
                property2.Text = $"{kvmConsole.Weight} кг";
                property3.Text = $"{kvmConsole.Count} шт";
                property4.Text = $"{kvmConsole.Price} USD";
                property5.Text = "";
                property6.Text = "";
            }
            else if (e.NewValue is NetworkSwitch)
            {
                NetworkSwitch networkSwitch = e.NewValue as NetworkSwitch;
                card.Background = Brushes.DarkKhaki;

                property1.Text = networkSwitch.Name;
                property2.Text = $"{networkSwitch.Weight} кг";
                property3.Text = $"{networkSwitch.Count} шт";
                property4.Text = $"{networkSwitch.Price} USD";
                property5.Text = "";
                property6.Text = "";
            }
            else if (e.NewValue is Storage)
            {
                Storage storage = e.NewValue as Storage;
                card.Background = Brushes.Tan;

                property1.Text = storage.Name;
                property2.Text = $"{storage.Weight} кг";
                property3.Text = $"{storage.Size} ТБ";
                property4.Text = $"{storage.Price} USD";
                property5.Text = "";
                property6.Text = "";
            }
            else if (e.NewValue is Rack)
            {
                Rack rack = e.NewValue as Rack;
                card.Background = Brushes.DimGray;

                property1.Text = rack.Name;
                property2.Text = $"{rack.Capacity} кг";
                property3.Text = $"{rack.Count} шт";
                property4.Text = $"{rack.Price} USD";
                property5.Text = "";
                property6.Text = "";
            }
        }
Ejemplo n.º 14
0
 protected Machine(int machineId, NetworkSwitch networkSwitch)
 {
     MachineId           = machineId;
     CommunicationModule = new NetworkInterfaceCard(this.MachineId, networkSwitch, this);
 }
 public RegistryFactory(NetworkSwitch networkSwitch, SimulationSize simulationSize) : base(networkSwitch)
 {
     SimulationSize = simulationSize;
 }
Ejemplo n.º 16
0
 public static void RegisterSwitch(string switchID, NetworkSwitch NetworkSwitch)
 {
     Instance.switchMap.Add(switchID, NetworkSwitch);
 }