Distributing Aggregate Computations on Top of Akka Actors
Total Page:16
File Type:pdf, Size:1020Kb
Alma Mater Studiorum Universita` di Bologna Campus di· Cesena Scuola di Ingegneria e Architettura Corso di Laurea Magistrale in Ingegneria e Scienze Informatiche Distributing Aggregate Computations on top of Akka Actors Tesi in Pervasive Computing Relatore: Presentata da: Prof. MIRKO VIROLI MANUEL PERUZZI Co-Relatore: Dott. ROBERTO CASADEI Anno Accademico 2017-2018 Sessione II Contents Abstract (italiano) i Abstract iii Introduction v 1 Background 1 1.1 Aggregate programming........................1 1.1.1 Field calculus..........................3 1.1.2 Building block operators....................5 1.1.3 Developer APIs.........................6 1.2 scafi ..................................7 1.2.1 Project organization......................7 1.2.2 Field calculus DSL and VM..................8 1.2.3 Aggregate programming platform...............9 2 Analysis 11 2.1 Requirements.............................. 11 2.1.1 Serialization........................... 11 2.1.2 Hybrid platform......................... 12 2.1.3 Spatial platform......................... 12 2.1.4 Code mobility.......................... 13 2.1.5 Platform/view integration................... 14 2.2 Requirements analysis......................... 14 2.2.1 Serialization........................... 14 2.2.2 Hybrid platform......................... 15 CONTENTS 2.2.3 Spatial platform......................... 16 2.2.4 Code mobility.......................... 16 2.2.5 Platform/view integration................... 18 2.3 Problem analysis............................ 19 2.3.1 Neighborhood control in the spatial platform......... 19 2.3.2 Communication......................... 21 2.3.3 Simulation versus control.................... 22 3 Design 25 3.1 Platform architecture.......................... 25 3.2 Detail design.............................. 27 3.2.1 Devices............................. 27 3.2.2 Hybrid platform......................... 29 3.2.3 Serialization........................... 30 3.3 Platform monitoring.......................... 32 3.3.1 Simulation front-end...................... 33 3.3.2 Monitoring of the actor platform............... 34 4 Implementation 37 4.1 Hybrid platform............................. 37 4.1.1 Base actor platform....................... 38 4.1.2 Spatial actor platform..................... 39 4.2 Serialization............................... 41 4.3 Code mobility.............................. 43 4.4 Platform monitoring.......................... 45 5 Evaluation 49 5.1 Demos.................................. 49 5.1.1 Spatial nets........................... 49 5.1.2 Platform monitoring...................... 56 5.2 Requirements verification........................ 59 6 Conclusion 63 CONTENTS 6.1 Future work............................... 63 References 66 Abstract (italiano) Nel contesto dell'Internet of Things, lo sviluppo di sistemi adattivi, su larga scala, solitamente si concentra sul comportamento del singolo dispositivo. Ag- gregate programming `eun paradigma che fornisce un approccio alternativo, nel quale l’unit`adi base della computazione `eun insieme di dispositivi che cooperano tra loro, invece del singolo dispositivo. scafi `eun framework basato su Scala, e fornisce una piattaforma basata su Akka per lo sviluppo di applicazioni aggre- gate, supportando sia reti peer-to-peer che server-based. Inoltre, scafi mette a disposizione un modulo simulator per simulare un sistema aggregato. Il lavoro descritto in questa tesi consiste nell'analisi di scafi, nella parziale reingegnerizzazione della sua piattaforma ad attori, e nello sviluppo di nuove feature. L'obiettivo principale `eincrementare la flessibilit`adi scafi in un con- testo distribuito, favorendo la sua adozione per programmare spatial systems. Per prima cosa, `estata resa possibile la comunicazione tra nodi distribuiti, attraverso la definizione di una strategia di serializzazione basata su JSON, che favorisce interoperabilit`a. Inoltre, vi `el'introduzione di una piattaforma, che mette in atto una comunicazione peer-to-peer tra i dispositivi, con un’unit`acentrale che gestisce tutte le informazioni rilevanti relative alla distribuzione spaziale. Questa piattaforma colma la principale mancanza dell'approccio peer-to-peer in un am- biente distribuito: il tracciamento di dispositivi remoti. Inoltre, `eimplementato un approccio di code mobility, in modo da permettere l'assegnamento di nuovi programmi ai dispositivi, a tempo di esecuzione. Infine, `eemerso il concetto di monitoraggio di un sistema aggregato distribuito, portando allo sviluppo di un'interfaccia grafica, che permette di osservare i dispositivi di un sistema in ese- cuzione. i In questa tesi, presento la nuova architettura e API della piattaforma ad attori di scafi, progettata con lo scopo di garantire un approccio pi`uflessibile per lo sviluppo di applicazioni distribuite con aggregate computing. Parole chiave { aggregate programming, sistemi distribuiti, attori, Akka, Scala, scafi ii Abstract In the context of the Internet of Things, development of large-scale, adaptive systems usually focuses on the behavior of the single device. Aggregate program- ming is a paradigm that provides an alternative approach, in which the basic unit of computing is a cooperating collection of devices, instead of a single de- vice. scafi is a Scala framework for aggregate programming, and provides an Akka-based platform for aggregate applications, supporting both peer-to-peer and server-based networks. Moreover, scafi offers a simulator module for the simula- tion of an aggregate system. The work described in this thesis consists in the analysis of scafi, in the partial re-engineering of its internal actor platform, and in the development of new fea- tures. The main goal is to enhance the flexibility of scafi in a distributed context, promoting its adoption for programming spatial systems. First of all, communica- tion between distributed nodes is enabled, by defining a JSON-based serialization strategy, which promotes interoperability. A hybrid platform is also introduced, exploiting a peer-to-peer communication between devices, with a central unit that manages all the relevant space-related information. This platform fills the main gap of the peer-to-peer approach in a distributed environment: tracking of remote devices. Moreover, a code mobility approach is implemented, allowing the assign- ment of new programs to devices, at runtime. Lastly, the concept of monitoring a distributed aggregate system emerged, leading to the development of a graphical user interface, observing the devices in a running system. In this thesis, I present the new architecture and API of the actor platform of scafi, designed with the aim of ensure a more flexible approach for the develop- ment of distributed applications with aggregate computing. iii Keywords { aggregate programming, distributed systems, actors, Akka, Scala, scafi iv Introduction Pervasive computing is the growing trend of embedding computational capa- bility into everyday objects to make them effectively communicate and perform tasks of various kind, minimizing the user's need to interact with computers as computers. Programming these large-scale situated systems is complex, since de- vices are heterogeneous, and they often demand for proximity-based interactions with neighboring devices. Traditional approaches address development of these applications focusing on the behavior of the single device, deriving the global be- havior of the system from the interaction of devices. Programming interaction of complex systems involves management of robust coordination, efficient and reliable communication, fault-tolerance techniques, and so on. Aggregate programming is a paradigm that addresses the development of large- scale adaptive systems focusing on the global behavior of the system. With this approach, the basic unit of computation is a cooperating collection of devices. A layered and compositional approach, based on field calculus, allows to provide developers with a simple programming API, that provides robust and adaptive coordination, guaranteeing resilience and safety. In [1], an aggregate programming framework, scafi, has been developed in Scala, providing an implementation of the field calculus semantics and an Akka- based distributed platform for simulating and executing aggregate applications. In order to support development of systems based on different architectural models, scafi offers the possibility of relying on a peer-to-peer platform, or on a server- based platform. Distribution and interaction are key concepts in scafi; both of them must be handled at platform-level, in order to provide the developer with high-level API. v This thesis addresses these topics and their implementation in the framework, and it aims to propose interventions that allow to enhance the flexibility of scafi in a distributed context, promoting its adoption for programming spatial systems. In particular, the main interventions concern: implementation of a JSON-based serialization strategy, to enable communi- • cation between different nodes with a standard format; introduction of an actor-based hybrid platform as a combination of the pre- • existing platforms (p2p and server-based), to fill the main gap of the p2p approach in a distributed environment: tracking of remote devices; support for a form of code mobility, allowing the assignment of new programs • to devices at runtime; monitoring of the actor-based platform, in order to make a distributed ag- • gregate system observable during its execution. This thesis is organized into