Exemplo n.º 1
0
 //////////////////////////////////////////////////////////////////////////////////////////////////////
 // Status Tab
 // Physical machines to ListView
 public void PhysicalMachines2ListView(Variation iDataCentreState, ref ListView oListViewPMs, ref ListView oListViewOfflines, ref ListView oListViewOnlines)
 {
     oListViewPMs.Items.Clear();
     for (int i = 0; i < iDataCentreState._pms.Count; ++i)
     {
         PhysicalMachine pm = iDataCentreState._pms[i];
         double          energyEfficency = (pm._emax - pm._emin) / pm._cpu;
         ListViewItem    listViewItem    = new ListViewItem(new string[] { pm._id.ToString(), pm._cpu.ToString(), pm._ram.ToString(), pm._emin.ToString(), pm._emax.ToString(), pm._k.ToString(), pm._vms.Count.ToString(), pm._wcpu.ToString(), pm._wram.ToString(), pm.E().ToString(), energyEfficency.ToString() });
         oListViewPMs.Items.Add(listViewItem);
     }
     oListViewOfflines.Items.Clear();
     for (int i = 0; i < iDataCentreState._vmson.Count; ++i)
     {
         VirtualMachine vm           = iDataCentreState._vmson[i];
         ListViewItem   listViewItem = new ListViewItem(new string[] { vm._id.ToString(), vm._cpu.ToString(), vm._ram.ToString() });
         oListViewOfflines.Items.Add(listViewItem);
     }
     oListViewOnlines.Items.Clear();
     for (int i = 0; i < iDataCentreState._vmsoff.Count; ++i)
     {
         VirtualMachine vm           = iDataCentreState._vmsoff[i];
         ListViewItem   listViewItem = new ListViewItem(new string[] { vm._id.ToString(), vm._cpu.ToString(), vm._ram.ToString() });
         oListViewOnlines.Items.Add(listViewItem);
     }
 }
        public void Load(StreamReader streamReader)
        {
            string[] sWords;
            sWords              = streamReader.ReadLine().Split('\t');
            _numberofpms        = int.Parse(sWords[0]);
            _numberofvms        = int.Parse(sWords[1]);
            _numberofvariations = int.Parse(sWords[2]);
            _numberofchanges    = int.Parse(sWords[3]);
            _duration           = int.Parse(sWords[4]);
            _pidmax             = -1;
            _vidmax             = -1;
            _pms.Clear();
            _vms.Clear();
            _variations.Clear();
            for (int i = 0; i < _numberofpms; ++i)
            {
                sWords = streamReader.ReadLine().Split('\t');
                PhysicalMachine pm = new PhysicalMachine(int.Parse(sWords[0]), int.Parse(sWords[1]), int.Parse(sWords[2]),
                                                         double.Parse(sWords[3]), double.Parse(sWords[4]), double.Parse(sWords[5]), new List <VirtualMachine>());
                _pms.Add(pm);
            }
            for (int i = 0; i < _numberofvms; ++i)
            {
                sWords = streamReader.ReadLine().Split('\t');
                _vms.Add(new VirtualMachine(int.Parse(sWords[0]), int.Parse(sWords[1]), int.Parse(sWords[2])));
            }
            List <VirtualMachine> vms = DeepCopy(_vms);

            for (int i = 0; i < _numberofvariations + 1; ++i)
            {
                Variation variation = new Variation();
                sWords = streamReader.ReadLine().Split('\t');
                // Time_number of onlines_number of offlines
                variation._time = int.Parse(sWords[0]);
                int iNumberOfOfflines = int.Parse(sWords[1]);
                int iNumberOfOnlines  = int.Parse(sWords[2]);
                for (int j = 0; j < iNumberOfOfflines; ++j)
                {
                    sWords = streamReader.ReadLine().Split('\t');
                    VirtualMachine vm = new VirtualMachine(int.Parse(sWords[0]), int.Parse(sWords[1]), int.Parse(sWords[2]));
                    variation._vmsoff.Add(vm);
                    vms.Remove(vm);
                }
                for (int j = 0; j < iNumberOfOnlines; ++j)
                {
                    sWords = streamReader.ReadLine().Split('\t');
                    VirtualMachine vm = new VirtualMachine(int.Parse(sWords[0]), int.Parse(sWords[1]), int.Parse(sWords[2]));
                    variation._vmson.Add(vm);
                    vms.Add(DeepCopy(vm));
                }
                variation._vms = DeepCopy(vms);
                _variations.Add(variation);
            }
        }
Exemplo n.º 3
0
        // Virtual machines to ListView
        public void VirtualMachines2ListView(int iPM, Variation iDataCentreState, ref ListView oListViewVMs)
        {
            oListViewVMs.Items.Clear();
            PhysicalMachine pm = iDataCentreState._pms[iPM];

            for (int i = 0; i < pm._vms.Count; ++i)
            {
                VirtualMachine vm           = pm._vms[i];
                ListViewItem   listViewItem = new ListViewItem(new string[] { vm._id.ToString(), vm._cpu.ToString(), vm._ram.ToString() });
                oListViewVMs.Items.Add(listViewItem);
            }
        }
        // Sort physical machines decreasingly as default for FFD
        public int CompareTo(object o)
        {
            PhysicalMachine pm = o as PhysicalMachine;

            if ((_emax - _emin) / _cpu > (pm._emax - pm._emin) / pm._cpu)  // return if this physical machine has higher energy efficiency
            {
                return(-1);
            }
            else if ((_emax - _emin) / _cpu < (pm._emax - pm._emin) / pm._cpu) // return -1 if this machine has lower energy efficiency
            {
                return(1);
            }
            else // return 0 if compared equally
            {
                return(0);
            }
        }