Skip to content
Samy Sadi edited this page Apr 7, 2018 · 1 revision

Home > Core layer > Entities

Overview

A simulation Entity is an abstraction of a real object that we are simulating, for instance: a computer, an application, a car, etc.

It contains a set of data (properties and configuration items) and offers a set of methods. Besides, an entity can have several children entities and always has a parent (except for the Simulator entity).

Composition of an entity

You can see all fields and methods that are offered by an entity in its java doc page.

To sum up, an entity contains:

  • An id number that uniquely identifies it in the simulator;
  • An optional name;
  • An optional configuration object, that might be shared by multiple entity objects;
  • A set of properties that is specific to the current entity instance;
  • A parent entity;
  • A list of children entities.

Besides, an entity also extends the Notifier interface. As such, an entity also contains a list of notification listeners (see Notifications).

Hierarchical organization of entities

Entities are organized in a parent-child fashion. That means that each entity has a parent (except for the Simulator entity) and may have one or more children.

This organization can be useful for instance to model the membership of an object to another. For example, we can organize the Application entity as children of a Computer entity. This way, we can easily determine the applications running inside a given computer, and determine the computer where a given application is running.

The upmost ancestor of all entities is the Simulator entity which is the sole entity that does not have a parent.

Creating an entity

You can create an entity manually or using a factory.

If you create an entity manually, then you should instantiate the entity object, configure it and then assign it a parent. See the following example, for instantiating a host entity:

// instantiate an entity object
Host h = new HostDefault();

// configure the host
h.setConfig(config);
h.setName("My host");
h.setPowerState(PowerState.ON);
// eventually attach children: ram, processing units, storage disks, etc.

// set a parent
h.setParent(myCloudProvider);

The above code is indeed a little cumbersome. The alternative is to use the methods inside the Factory and FactoryUtils classes to generate entities. These methods usually rely on a supplied configuration to generate entities and use some default configuration values if none is specified. The above code can be rewritten as follows:

Host h = FactoryUtils.generateHost(config, myCloudProvider);

ACS predefined entities

Each layer of ACS defines several new entities. For example, the hardware layer defines the Host, ProcessingUnit, Ram and Storage entities among others. Have a look at each layer for a detailed list of defined entities.

The core layer of ACS defines for its part three entities:

  • The FailureProneEntity which is the base entity for all entities that can fail. For instance, a Storage can fail at some point in the simulation.
  • The PoweredEntity which is the base entity for all entities that can be powered on and powered off during the simulation. For instance, a Host can be powered on and off at some points in the simulation.
  • The RunnableEntity which is the base entity for all entities that can run for a given delay. For instance, this is the base entity for the Job entity.

Defining a custom entity

You can define custom entities by extending the EntityImpl class.

It is recommended to override the following methods: