- has many clusters.
- passes down the minimum and maximum server count
- passes down available apps for the cluster
- [model]:
- clusterId,
- availableAppTypes,
- servers,
- apps
- lastAddedServer // For Deletion.
CLUSTER takes min and max server count and available apps as props.
-
[props]:
- MIN SERVER COUNT
- MAX SERVER COUNT
- appTypes
-
starts with MINIMUM_SERVER_COUNT and deploy them. to do that:
- in initializayion (vue:created hook), generate 4 servers using server factory.
- put them in the servers array
-
fetches the available apps and assigns them to available apps. to do that:
- gets available apps from props
- set the fetched available apps to the available apps.
- do that inside the created hook.
-
lastAddedServer, servers array and update itself with the changes.
to do that / (eliminate the iteration)- in created hook, add last item of servers to the last added server
- in addServer method, update last added server with newly created server instance
-
serverAvailability iterate over all servers and return the servers that has empty app slots with sorted by their creation date. (iteration for filter/iteration for sort) to do that*
- serverAvailability iterate over servers and filtered the free servers(iteration)
- during the iteration it keeps half loaded servers and free servers
- if free servers exist then sort the servers based on their creation date and return them(iteration)
to do that
- I need to decide what sorting algorithms act more performant. Quick Sort · GitHub
- if free servers not exist but half free servers then sort the servers based on their creation date and return them(iteration)
to do that
- I need to decide what sorting algorithms act more performant. Quick Sort · GitHub
- if none of them exist which means every servers has running two apps, then return empty array.
- it only return free servers or half free servers. It does not return them both.
-
add Server[method] to do that:
- create a server using server factory
- add it to the servers
- update the lastAddedServer with same server instance
- [TBD] add it to the freeServers
-
deploy App[method(params=serverInstance)]
- create the app using appFactory very much like serverFactory or use the apps comes from parameter.
- ask server availability for servers to deploy.
- check the available server count. If all servers are full then cancel the deployment (maybe return false)
- if any server available,
-
if deployApp not received apps instances as parameters and create the app instance using appFactory
-
then assign the app to the first element of the available servers array
-
if deployApp received apps instances as parameters
-
then iterate over apps it received,
-
inside the iteartion
- push the app instance to the first element of the available servers
- check first element's apps array count on the available servers array
- if it is 2 then shift(remove) it from array
- for the second and latter iterations
- if there is no server available which has free slots,
- then create a message with un-deployed apps
- then break the iteration.
- return the message.
-
-
killServer[method] to do that
- get the last added server from lastAddedServer
- extract the apps from the toBeDeleted server
- send them to deployApp as an array if they are multiple or single app instance if they are only 1
-
killApp[method] OneTab shared tabs Clicking “-” for one of the Available Apps should kill the newest instance of that app in the cluster. to do that
- iterate over all the apps and filter the selected app type(iteration)
- reduce the apps arrays based on its creation date (iteration)
- get the server that has earliest created selected app one from the list and remove it.
servers:[
{
id:GUID,
createdAt: DATE,
apps:[app_instance, app_instance]
},
{
id:GUID,
createdAt: DATE,
apps:[app_instance, app_instance]
},
{
id:GUID,
createdAt: DATE,
apps:[app_instance, app_instance]
}
]
apps: [
{
appId:GUID,
deployedAt:DATE
serverId:GUID
},
{
appId:GUID,
deployedAt:DATE
serverId:GUID
},
{
appId:GUID,
deployedAt:DATE
serverId:GUID
}
]
[model]
- apps
[model]
- appName
- appInitial
- colorSchema
[model]
- list
[method]
- deployApp
- killApp