예제 #1
0
 def instantiateAggregator(self, task):
     """!
     Instantiate DeviceAggregator. Check in create_needed_childAggregators
     if the aggregator has enough capacity for the amount of Device,
     if not create childAggregators recursively. Add task and devices
     to aggregator
     
     @param numDevices amount of devices
     """
     choosen_devices = self.getDevicesForAggregator(task)
     aggregator = DeviceAggregator(
         devices=choosen_devices,
         task=task,
         maxSizeDeviceHolder=self._maxSizeDeviceHolder,
         maxNumDeviceHolder=self._maxNumDeviceHolder,
         maxNumChildAggregators=self._maxNumChildAggregators,
         logServer=None)
     self.logger.log().info("max # devices in aggregator: " +
                            str(aggregator.get_max_number_devices()))
     self.addAggregator(aggregator)
     return aggregator
예제 #2
0
 def testNumberDeviceHolders(self):
     "Check if deviceHolders are sucessfully instantiated "
     maxSizeDeviceHolder = 1
     maxNumDeviceHolder = 2
     maxNumChildAggregators = 2
     deviceAggregator = DeviceAggregator( [ self.deviceOne
                                          , self.deviceTwo
                                          ]
                                         , self.task
                                         , maxSizeDeviceHolder = maxSizeDeviceHolder
                                         , maxNumDeviceHolder  = maxNumDeviceHolder
                                         , maxNumChildAggregators = maxNumChildAggregators
                                         , logServer = None
                                         )
     self.assertTrue( len(deviceAggregator.deviceHolders) == 2
                    , msg = "wrong number of deviceHolder"
                    )
예제 #3
0
 def testRequestAggregationWithChildAggrators(self):
     "Get the result of the task with child aggregators"
     maxSizeDeviceHolder = 1
     maxNumDeviceHolder = 1
     maxNumChildAggregators = 2
     deviceAggregator = DeviceAggregator( [ self.deviceOne
                                          , self.deviceTwo
                                          ]
                                         , self.task
                                         , maxSizeDeviceHolder = maxSizeDeviceHolder
                                         , maxNumDeviceHolder  = maxNumDeviceHolder
                                         , maxNumChildAggregators = maxNumChildAggregators
                                         , logServer = None
                                         )
     self.assertTrue( len(deviceAggregator.requestAggregation()) == 0
                    , msg = "there is no result atm available"
                    )
     deviceAggregator.sendTask()
     self.assertTrue( len(deviceAggregator.requestAggregation()) == 2
                    , msg = "each device should return a result"
                    )
예제 #4
0
 def testisTaskFinishedWithChildAggrators(self):
     "Check if task is finished with child aggregators"
     maxSizeDeviceHolder = 1
     maxNumDeviceHolder = 1
     maxNumChildAggregators = 2
     deviceAggregator = DeviceAggregator( [ self.deviceOne
                                          , self.deviceTwo
                                          ]
                                         , self.task
                                         , maxSizeDeviceHolder = maxSizeDeviceHolder
                                         , maxNumDeviceHolder  = maxNumDeviceHolder
                                         , maxNumChildAggregators = maxNumChildAggregators
                                         , logServer = None
                                         )
     self.assertTrue( deviceAggregator.isTaskFinished() == False
                    , msg = "task shouldn't be finished"
                    )
     deviceAggregator.sendTask()
     self.assertTrue( deviceAggregator.isTaskFinished() == True
                    , msg = "task should be finished"
                    )