コード例 #1
0
ファイル: model.py プロジェクト: strategist922/sonar
 def get_assignment_list(self):
     from control import domains
     from virtual import nodes
     assignment = {}
     for node in self.get_hosts(types.NODE):
         for domain_name in node.domains.keys():
             assignment[domains.index_of(domain_name)] = nodes.index_of(node.name)
                
     return assignment
コード例 #2
0
ファイル: driver.py プロジェクト: strategist922/sonar
 def start(self):
     print 'Connecting with Times'
     connection = times_client.connect()
     
     self.min_ts_length = sys.maxint  # Minimum length across all TS
     ts_freq = 0  # Frequency of the TS from Times
     
     # Iterate over all domains and assign them a TS
     for domain in self.model.get_hosts(model.types.DOMAIN):
         # Select and load TS (based on the configuration)
         index = domains.index_of(domain.name)
         mapping = domains.domain_profile_mapping[index]
         # load = profiles.get_cpu_profile_for_initial_placement(mapping.profileId)
         load = profiles.get_cpu_profile_for_initial_placement(mapping.profileId)
         
         ts = connection.load(load)
         
         # Convert TS to a numpy array
         # select TS not time index
         ts_freq = ts.frequency
         ts = wutil.to_array(ts)[1]
         
         # Add noise to the time series
         if NOISE:
             # random = np.random.lognormal(mean=NOISE_MEAN, sigma=NOISE_SIGMA, size=len(ts))
             random = np.random.normal(loc=NOISE_MEAN, scale=NOISE_SIGMA, size=len(ts))
             ts += random
             ts[ts > 100] = 100
             ts[ts < 0] = 0
         
         # Attach TS to domain 
         domain.ts = ts
         
         # Update max length
         self.min_ts_length = min(self.min_ts_length, len(ts))
     
     # Close times connection
     times_client.close()
     
     # Reduce length of time series to 6 hours
     # Calculation: Adjust frequency by (new duration / current TS duration)
     self.freq = (ts_freq * profiles.EXPERIMENT_DURATION) / (self.min_ts_length * ts_freq)
     
     # Calculate ramp up delete time
     self.ramp_up = profiles.RAMP_UP
     self.ramp_down = profiles.RAMP_DOWN
     
     # Schedule message pump
     self.pump.callLater(0, self.run)