Overview
The AEC2 package consists in a Mosel package (aec2.bim), a module (aec2.dso) and the program aec2setup.mos. In addition to these components, system commands to connect to remote hosts using the SSH protocol are also required. On Unix-like platforms, the programs ssh and scp are usually available; on Windows systems, specific programs pcmdgen.exe, mpscp.exe and mplink.exe are included in the package distribution.
Using Amazon EC2 requires the availability of machine images (AMI) in order to start virtual machines. For the particular case of Mosel, the AMI must have Xpress installed and accept connections for running remote Mosel instances either via SSH or using the xprmsrv server: the provided setup program (aec2setup.mos) can be used to create appropriate images. This program, that is to be run once only, also results in a set of configuration files required to initialise the package when it is used by a model.
With the help of the mmjobs module a Mosel model can already start and manage remote instances for creating distributed applications. The AEC2 package adds a set of routines to this framework for managing EC2 virtual machines and generating the appropriate connection strings for the connect function of mmjobs AEC2 is designed such that enabling an existing distributed model to use resources in the Cloud merely requires the user to add a few statements to the original Mosel model source code. For instance, consider the following model that compiles and then executes the model "mymodel.mos" on some remote host "myserver":
model dist uses 'mmjobs' declarations minst: Mosel rmod: Model end-declarations if connect(minst, "myserver")<>0 then exit(1) end-if if compile(minst, "", "rmt:mymodel.mos", "tmp:m.bim")<>0 then exit(2) end-if load(minst, rmod, "tmp:m.bim") run(rmod) wait dropnextevent unload(rmod) disconnect(minst) end-model
The following example performs the same operations but using a virtual machine in EC2 instead of a local server:
model distec2 uses 'mmjobs','aec2' declarations ainst: EC2instance minst: Mosel rmod: Model end-declarations if not loadAEC2Config("aec2.acf") then ! load AEC2 configuration exit(-1) end-if ainst:=runInstance ! start a virtual machine in the Cloud if not waitInstanceReady(ainst, 300, true) then exit(-2) end-if if connect(minst,getConnString(ainst))<>0 then exit(1) end-if if compile(minst, "", "rmt:mymodel.mos", "tmp:m.bim")<>0 then exit(2) end-if load(minst, rmod, "tmp:m.bim") run(rmod) wait dropnextevent unload(rmod) disconnect(minst) terminateInstance(ainst) ! terminate the virtual machine end-model
Note the use of function getConnString as input parameter for the mmjobs function connect: it generates a valid connection string for the specified Amazon instance (either for an SSH or xprmsrv link depending on the default protocol).