prepare for simulation fire
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2021-12-03 23:31:49 +01:00
parent 079e887c6a
commit 11e966d08b
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
6 changed files with 49 additions and 15 deletions

View File

@ -16,14 +16,16 @@ class BucketResource:
if self.capacity == self.currentUsage or resource > self.capacity - self.currentUsage:
return False
else:
self.currentUsage += resource
return True
def release(self, resource: int) -> bool:
if self.currentUsage == 0 or self.currentUsage - resource < 0:
return False
else:
self.currentUsage -= resource
return True
def releaseAll(self) -> bool:
def releaseall(self) -> bool:
self.currentUsage = 0
return True

View File

@ -1,4 +1,5 @@
from apps import Application
from datacentre import Datacentre
class Client:
@ -6,3 +7,6 @@ class Client:
self.startSlices: list[int] = []
self.lengthOfTransmission: int = 0
self.application: Application = Application()
def firerequest(self, edge:Datacentre, cloud: Datacentre):
pass

View File

@ -1,18 +1,36 @@
from pprint import pprint
import copy
from datacentre import Datacentre
from scenarioplanner import Scenarioplanner
from scheduler import Scheduler
def preparesimulation() -> Scenarioplanner:
scenarioplanner = Scenarioplanner()
scenarioplanner.simulationLength = 120
scenarioplanner.createapplications()
scenarioplanner.createclients(1000)
print("Number of Birbnetes clients: " + str(scenarioplanner.statsModule.birbnetesClients))
print("Number of Videochat clients: " + str(scenarioplanner.statsModule.videochatClients))
return scenarioplanner
currscenarioplanner = Scenarioplanner()
currscenarioplanner.simulationLength = 120
currscenarioplanner.createapplications()
currscenarioplanner.createclients(1000)
print("Number of Birbnetes clients: " + str(currscenarioplanner.statsModule.birbnetesClients))
print("Number of Videochat clients: " + str(currscenarioplanner.statsModule.videochatClients))
return currscenarioplanner
def preparesimulationrunner(currscenarioplanner: Scenarioplanner) -> Scheduler:
currentscheduler = Scheduler()
currentscheduler.simulationLength = currscenarioplanner.simulationLength
currscenarioplanner.clients = copy.deepcopy(currscenarioplanner.clients)
clouddatacentre = Datacentre()
clouddatacentre.processingpower = 10000000
clouddatacentre.uplink = 10000000
edgedatacentre = Datacentre()
edgedatacentre.processingpower = 10000
edgedatacentre.uplink = 10000
currentscheduler.edge = edgedatacentre
currentscheduler.cloud = clouddatacentre
currentscheduler.statsModule = currscenarioplanner.statsModule
return currentscheduler
if __name__ == '__main__':
scenarioplanner = preparesimulation()
pprint(scenarioplanner)
currscheduler = preparesimulationrunner(scenarioplanner)

View File

@ -1,4 +1,5 @@
import random
import copy
from clients import Client
from stats import Stats
from apps import Application, ApplicationModule
@ -56,7 +57,7 @@ class Scenarioplanner:
currentclient: Client = Client()
currentclient.lengthOfTransmission = random.randint(1, self.maxLengthofTransmission)
numoftransmissions: int = random.randint(1, 10)
currentclient.application = self.pickapplicationforclient()
currentclient.application = copy.deepcopy(self.pickapplicationforclient())
for j in range(numoftransmissions):
currentclient.startSlices.append(
random.randint(1, self.simulationLength - self.maxLengthofTransmission))

View File

@ -1,6 +1,7 @@
from clients import Client
from apps import Application, ApplicationModule
from bucketresources import BucketResource, BucketResource
from stats import Stats
from datacentre import Datacentre
@ -9,3 +10,11 @@ class Scheduler:
self.clients: list[Client] = []
self.cloud: Datacentre = Datacentre()
self.edge: Datacentre = Datacentre()
self.failedClients: list[Client] = []
self.simulationLength: int = 0
self.statsModule: Stats = Stats()
def runsimulation(self):
for i in range(self.simulationLength):
for currclient in self.clients:
pass