A Context Aware and Self Adaptation Strategy for Cloud Service Selection and Configuration in Run Time

Day after day, the number of mobile applications deployed on cloud computing continues in increasing because o f smartphone capabilities improvement. Cloud computing has already succeeded in the web based application, for that reason, the demand for context aware services provided by cloud computing increases. To customize a cloud service that takes into account th e consumer requirements, which depend on information change, it brings to light many recent challenges to cloud computing about environment aware, location aware, time aware. The cloud provider, moreover, has to manage personalized applications and the con straints of mobile devices in matters of interaction abilities and communication restrictions. This paper proposes a strategy for selecting automatically an appropriate cloud environment that runs out whole requirements, defines a configuration for the ass ociated cloud environment and able to easily adapt to the change of the environment on either the user or the cloud side or both. This process builds on the principles of dynamic software product lines, Agent oriented software engineering, and the MAPE k m odel to select and configure cloud environments according to the consumer needs and the context change.


Introduction
In the cloud-computing model, IT resources are provided as services, which are divided into two service models. A model is a service that is usually denoted by X (XaaS or * aaS), as X represents a layer where there is a service as infrastructure form (IaaS) and another as platform form (PaaS) (Armbrust et al., 2016). At the IaaS level, all the software stack running inside the virtual machine must be configured as well as anything that concerns the infrastructure: number of virtual machines, amount of resources, database configuration, etc. Regarding the platforms provided by PaaS, the configuration concerns only the software that makes up the platform, application ie; application server, database, libraries, etc. Thus, the cloud offers many configuration choices, so that the is deployed and the runtime environments are configurable. As a result of the large gamut of resources at different functionality levels, developers must deal with the variability of the cloud environment at the application deployment. Therefore, Cloud Computing is considered as a runtime adaptive system which can dynamically change their services, regarding user requirements changes. the system and user context are considered as inputs to adjust their behavior to the current status of users (for example, contextual activity). Cloud computing has new challenges when it asks for information about the user's environment in terms of location, device detection, and custom applications that are timed to respond to, for example, mobile device constraints, interaction capabilities, resources and communication constraints.
Selecting an appropriate cloud environment and managing its variability, in the execution phase, induces errors in the configuration phase or complex configuration results which are generally made in an ad hoc manner. Based on the findings of the research areas presented in the precedent section, we have introduced this approach. It was established to automatically select an appropriate cloud environment that fits requirements and to determine a configuration for the cloud environment associated, which can be adapted easily to the change of the environment (client and/or cloud side). and the MAPE-k model to help its user to personalize the selection and configuration of cloud services according to their needs and their context. Product line engineering is a popular and widely used technology in the industry (Clements & Northrop, 2002). The fundamental principle of this approach is the reuse of the basic product components and structures and apply planned variabilities to derive various product families. The use of product line engineering approach for product development has attained several benefits in productivity, quality, time, cost (Van der Linden, Schmid, & Rommes, 2007). An essential issue for the success of SPLs is variability management (Clements & Northrop, 2002). It is represented through variation points and variants. In the SPL artifact, a variation point represents a design decision, where each variation point is related to a set of variants, i.e., alternatives. The proposed approach uses dynamic software product lines to assure the reliability of these selection and configuration processes. It leverages also the feature model to present cloud variability and to use environment configuration files.
This framework will be managed autonomously using innovative concepts of self-management.
A Multi-Agent System (MAS) is a set of agents that collaborate and interact with their environment, due to the agent's autonomy, reactivity and mobility (Dinesh Kumar & Ashwin, 2012). It can represent the domain information and to execute necessary action to arrive at particularized goals. Multi-agent technologies provide an effective approach for scalable and open systems that are changed dynamically. Through this work we try to response to the following research questions: Q1: How can cloud services take the consumer context change into account? Q2: How can automate dynamically the the variabily management of cloud services? Q3: How can cloud services context-aware at run-time?
The article is structured as follows: Section 2 presents a brief overview of the background used throughout the paper. Motivation and the approach overview are presented in Section 3. Section 4 shows the case study of our approach consisting in deploying a mobile cloud service for Diabetes Management.
In section 5, Related work is discussed. Our conclusions and perspectives are described in Section 6.

Background and Motivations
In this section, we present briefly DSPLs in literature. Moreover, we describe the basics of the feature model, which is used to model respectively the variability and to generate the reconfiguration plan. (Clements & Northrop, 2002) defines SPL as "a set of software-intensive systems sharing a common, managed a set of features that satisfy the specific needs of a particular market segment or mission and that are developed from a common set of core assets in a prescribed way." DSPL is a method that moves the product line engineering process to the runtime phase. It addresses runtime configurations which are directed by variability specifications, ensuring that system adaptations meet the specified requirements. Indeed, a DSPL is a unique system that is talented to adapt its behavior at runtime whereas the SPL engineering process acts only at design time, generating several products of the same family. The SPL and DSPL contain a set of common and managed elements known as features (Clements & Northrop, 2002). The variability model contains a set of variable characteristics that make a product different from the others. Therefore, the SPLs processes generate products by choosing specific values and attributes from the variable features mentioned in the model.

Feature Models
Feature diagrams were introduced firstly in the Feature-Oriented Domain Analysis (FODA) method. (Kang, Cohen, Hess, Novak, & Peterson, 1990) define a Feature Model as "a way to represent the information of all possible configurations for a specific product that can be built. The features are organized hierarchically in a diagram in the form of a tree, where it contains a root element, and any feature can have sub-features, as well as constraints, usually inclusion or exclusion".

MAPE-K Reference Model
The MAPE-K reference model (Monitor, Analyze, Plan, Execute and Knowledge) is the most influential feedback control model for self-adaptive systems (Kephart & Chess, 2003).
The Monitor phase permits the collection of information from the software and the runtime environment. It bases on sensors to collect pertinent data. As a result, the plan recognizes a set of modifications to apply to meet the requirements and the manner to make this change. The result of this stage is called an adaptation plan, which uses an auto-configuration and self-optimization technique.
The Analyze phase merges the collected data and the historical data to verify if the requirements are fulfilled or not. In the negative case, it results in a need for adaptation; where the analyze phase demands the Plan phase to build the adaptation plane. This later consists of finding a relevant decision to adapt the software via different algorithms and rules. Ultimately, the Execute phase applies the adaptation plan using effectors to change the concerning element.

Motivation and Approach Overview
This section presents the motivation for our work. It discusses the challenges to surmount for context-aware cloud service selection and configuration at run-time. Then, an overview of our approach was introduced at the end of this section.

Challenges
The cloud developers have to manage, during the application deployment, a wide range of configurable resources among usable cloud environments. Besides, they must satisfy the customer need and at the same time maximize the profit of the cloud broker. The process goal is to provide a solution to manage the variability of the cloud and user context at the design-time and runtime. Furthermore, the approach has to select and configure autonomously the cloud environment to adapt its context and the context of user change. The following challenges were identified, which the proposed framework must take into consideration, to achieve these objectives:

 Challenge 1. Find a suitable environment
Cloud developers have always to find the cloud providers that affords, despite of the context change in the execution time, all the features required to satisfy the consumer requirements and to run the user application correctly, like the appropriate database and the virtual machine with at least 3GB of RAM, which is considered as a non-functional requirement.

 Challenge 2. Find a valid configuration
The variability management of the cloud and the user environment is a complex and error-prone task because of the multiple configuration choices which are usually made in an ad hoc manner. Besides that, Developers have not a global view of how a cloud environment is configured. That's why there is a height probability of inconsistencies occurrence between cloud services during the application running. Also, not taking into account the variability of the consumer environment when configuring a cloud service can cause client dissatisfaction and SLA violations. Hence, this second challenge was taken up to find a correct cloud configuration while ensuring the fulfillment of the required features.

 Challenge 3. Optimize the configuration
The customers and providers of the cloud have to establish a Service Level Agreement (SLA) to define the quality of service (QoS). The main goal of cloud providers is the cost minimization and the improvement of the customer satisfaction level (CSL).

 Challenge 4. Guarantee the correct configuration
After finding the optimal configuration that is appropriate for the required functionalities and non-functionality exigences, developers have to avoid errors during the set-up of the configuration files and scripts to make sure to obtain the correct configuration of the cloud environment.

 Challenge 5. Keep track of the configuration
Experimentally, the storage of trace entries on configurations furnishes information for a posteriori analysis. It extends from context conditions to configuration plans.

Our Approach
This section presents our proposed Method as depicted in Figure 2. Our approach is based on the agent-based method to gather information from both the consumer and the cloud environment and also interact for processing tasks. The most systems deployed on cloud computing are autonomous, context-aware, with big data information, interactive and have to provide flexible and customized user services. Agents used in this work precisely to handle the context change at the execution phase and to automatize the selection and configuration process for the cloud providers.  (Czarnecki, Helsen, & Eisenecker, 2004). This version offers an enhanced semantic expressiveness and it consequently enables more performance. Also, our approach adopts the feature model approach to express the variability of the cloud and the user environment. The cloud knowledge base and the consumer knowledge base were introduced as feature models, where features are elements of the base.

Figure 3. Metamodels Relationship
The manager agent is responsible for selectiong and configuring the features models of the cloud services using the mapping relationship between the goal model and feature model which must conform to their metamodels ( Figure 4).

Case Study
We consider a motivating example for mobile cloud services for Diabetes Management. Diabetes is viewed, referring to the World Health Organization, as an incurable disease that affects 194 million people worldwide (Hamdan, 2011). It reaches epidemic proportions (Gan, 2003) in developing and newly industrialized nations. These high percentages are the result of the wrong management of diabetes and the poor quality of the existing offered services. Diabetes needs an efficient and self-management service that is patient context-aware and interactive to every change in the patient data to keep it under continual and regular control. The service should provide the patient with his diabetes measurement, guide him in case of an increase or decrease of blood glucose level, save the patient records, reminds the patient about check-ups medication time and date.
for diabetes with a Mobile Internet Device, which can provide the current location and information of the patient. The monitored context defines the current state of User(patient) Preference, the Device Context, and Situational Context. patient preference defines specific preference settings, particularly those have a relation with services selection and invocation. The Device Context represents the environmental settings and configurations of the patient's device. Figure 5. selection and configuration of the cloud service "Glucose Measurement" According to the Situational Context, it contains a set of monitored data and information related to the user's location, level of Blood Glucose measurement, time, current lifestyle, weight, temperature, and others. The manager agent (Brocker agent) configures the ''Glucose measurement'' service basing on the goal model ( Figure  3) provided by the consumer agent in the monitor phase of the MAPE-K mode. To achieve goals, agents are created Based on the goal model presented by the identification and specification of their plans. In the Plan phase, the goal model and Feature model are linked using a mapping basing on an Agent Definition Files (ADF) which is an XML File (Figure 4) that declares static agent properties. In our example, to measure the glucose level of the patient, the manager agent needs a set of information from the consumer agent, like patient data, location, temperature, and other information about the device such as the device energy. The potential of mobile offloading mainly depends on mobile network technologies such as WIFI and cellular. However, data transmission using the WIFI network requires a considerable amount of energy from the mobile device as opposed to the cellular network. In the Analyze phase, when the battery level, for example, becomes low at run-time, the manager agent reconfigures the service by deselecting the feature 'SaveHistoricDoc' for not saving the historic documents on the cloud.

Related Work
We examine, in this section, different approaches that treat the deployment of applications in cloud environments. Then we compare, in table 2, these approaches to define their limits. The comparison is based on common characteristics shared by the studied approaches.
 Approach A: (Multi-Agent for monitoring cloud resources) (Alwada & Falah, 2018) presents an architecture based multi-agent system that is used by cloud computing to select the best resources and to create a negotiation method among the cloud consumers and the cloud providers.
 Approach B: (Infrastructure migration to the cloud) (Garcí a-Galá n, Trinidad, Rana, & Ruiz-Corté s, 2016) addresses the problem of selecting the most suitable configuration among the configurations space provided by proposing an application based on FM. The approach was implemented and compared to two well-known business tools (Amazon TCO and CHloudScreener). However, for the moment, it can only handle the Amazon EC2 configuration space.
 Approach C: (selecting and configuring cloud environments) (Quinton, Romero, & Duchien, 2014) proposes SALOON, a software product lines-based platform to handle the variability of cloud providers and the resources at the configuration and deployment stage. They based on features models to represent this variability. This approach treats the variability only in the design phase and doesn't take into consideration the context changes at the runtime.
 Approach D: (Configuring Cloud Robotics Applications) (Gherardi, Hunziker, & Mohanarajah, 2014) explored the use of Extended Feature Models (EFMs) to provide support for the design and configuration of robotic applications when migrating to a cloud environment. The Models can be automatically transformed into XML and JSON configuration files offering support for the application migration to the cloud. However, they did not handle constraints when several robots share the same cloud components. Moreover, the feature selection was done with a manual manner resulting in a complex and error-prone task.

Conclusion
In this work, the dynamic software product line approach and the multi-agent systems with the help of the MAPE-K reference model were introduced to provide support for dynamically selecting and configuring cloud environments for context-aware systems. This support takes into account the continuous change of consumer context and the system to adapt dynamically the reconfiguration of the cloud environment. Indeed, it reconfigures the cloud service at runtime to meet the consumer requirements that change in real-time (example insufficiency of a resource). The agent-oriented goal model and feature model are used to automatize the selection of the cloud service that meets the consumer requirements at the design and execution phase. The approach relies on the cloud and consumer knowledge model that contains all required data, attributes, and constraints on both environments provided by the agents. In our work, the use of a knowledge metamodel is motivated by the need to support the sharing of the knowledge base and reuse of knowledge by different consumers and even by other clouds. Mapping rules between the goal model and the feature model were adopted to allow an automated configuration of the different FMs. Indeed, the proposed approach permits an autonomy reconfiguration according to the context change. In progress, we intend to extend our approach to take into account the FM evolution with attributes and cardinalities. Indeed, the feature models with SPL evolve overtime (Sampaio, Borba, & Teixeira, 2019) to deal with the cloud market that evolves continuously. Consequently, it may occur inconsistencies between values defined and features cardinalities. In addition, we plane to employ our approach in other case studies to provide further evaluation of it.