This commit is contained in:
parent
e6569729bb
commit
ed4fba74b9
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM python:3.10
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt ./
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
COPY ./src .
|
8
src/apps.py
Normal file
8
src/apps.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
class ApplicationModule:
|
||||||
|
bwRequirement: int = 0
|
||||||
|
cpuRequirement: int = 0
|
||||||
|
|
||||||
|
|
||||||
|
class Application:
|
||||||
|
name: str = ""
|
||||||
|
modules: list[ApplicationModule] = []
|
28
src/bucketresources.py
Normal file
28
src/bucketresources.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class BucketResourceType(Enum):
|
||||||
|
NetworkLink = 'network_link'
|
||||||
|
CpuResource = 'cpu_resource'
|
||||||
|
|
||||||
|
|
||||||
|
class BucketResource:
|
||||||
|
type: BucketResourceType = BucketResourceType.NetworkLink
|
||||||
|
currentUsage: int = 0
|
||||||
|
capacity: int = 0
|
||||||
|
|
||||||
|
def reserve(self, resource: int) -> bool:
|
||||||
|
if self.capacity == self.currentUsage or resource > self.capacity - self.currentUsage:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
def release(self, resource: int) -> bool:
|
||||||
|
if self.currentUsage == 0 or self.currentUsage - resource < 0:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
def releaseAll(self) -> bool:
|
||||||
|
self.currentUsage = 0
|
||||||
|
return True
|
7
src/clients.py
Normal file
7
src/clients.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from apps import Application
|
||||||
|
|
||||||
|
|
||||||
|
class Client:
|
||||||
|
startSlices: list[int] = []
|
||||||
|
lengthOfTransmission: int = 0
|
||||||
|
application: Application = Application()
|
6
src/datacentre.py
Normal file
6
src/datacentre.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from bucketresources import BucketResource
|
||||||
|
|
||||||
|
|
||||||
|
class Datacentre:
|
||||||
|
processingpower: BucketResource = BucketResource()
|
||||||
|
uplink: BucketResource = BucketResource()
|
13
src/scheduler.py
Normal file
13
src/scheduler.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from clients import Client
|
||||||
|
from apps import Application, ApplicationModule
|
||||||
|
from bucketresources import BucketResource, BucketResource
|
||||||
|
from datacentre import Datacentre
|
||||||
|
|
||||||
|
|
||||||
|
class Scheduler:
|
||||||
|
clients: list[Client] = []
|
||||||
|
cloud: Datacentre = Datacentre()
|
||||||
|
edge: Datacentre = Datacentre()
|
||||||
|
|
||||||
|
def createClients(self, numofClients: int = 1):
|
||||||
|
pass
|
Loading…
Reference in New Issue
Block a user