Skip to content
Sebastian Echeverria edited this page May 22, 2018 · 33 revisions

KD-Cloudlet (KVM-based Discoverable Cloudlets)

Cloudlets are discoverable, generic, stateless servers located in single-hop proximity of mobile devices, that can operate in disconnected mode and are virtual-machine (VM) based to promote flexibility, mobility, scalability, and elasticity. In our implementation of cloudlets, applications are statically partitioned into a very thin client that runs on the mobile device and a computation-intensive Server that runs inside a Service VM. Read more about cloudlets at http://sei.cmu.edu/mobilecomputing/research/tactical-cloudlets/.

KD-Cloudlet comprises a total of 7 GitHub projects:

Release Information

client-lib-android (Cloudlet Android Library)

A Cloudlet-Ready app is an application that is able to use a service running on a Cloudlet. To the app, this service is composed mainly of an IP adresss and port on which a server for the app is listening. A cloudlet-ready app uses the Cloudlet Android Library (client-lib-android) to explicitly look for a service on a nearby Cloudlet, and get an IP and port to connect to.

To use the Cloudlet Android Library add the dependency edu.cmu.sei.ams.cloudlet:client-lib-android:1.7+

Finding Cloudlets

The Cloudlet Android Library provides an Android-specific way of performing the location of a Cloudlet via AsyncTasks. The use of AsyncTasks is required to do any network connectivity on Android.

The main class for a cloudlet-ready app is the FindCloudletAndStartService class. This class extends AsyncTask, so it is very easy to use. In addition to the FindCloudletAndStartService class, you will also need to pass in an implementation of the CloudletCallback interface to handle the results the task finds. The other parameters are the name of the service being searched, and the ranking method used to select a Cloudlet if several are available. An example of this is shown below:

new FindCloudletAndStartService(this, "edu.cmu.sei.ams.face_rec_service_opencv", 
    new CpuBasedRanker(), new CloudletCallback<ServiceVM>()
{
    @Override
    public void handle(ServiceVM result)
    {
        /**
         * Use the ServiceVM. The result variable with contain both the IP 
         * and port of the required service.
         * Note: The ServiceVM may be null for the following reasons:
         *      1. A cloudlet with the requested service could not be found
         *      2. The service failed to start
         */
    }
}).execute();

Example

The following is a simple example of a method findService that could be called by a cloudlet-ready app from its onCreate method on some specific activity to handle finding cloudlets.

class SphinxAndroidClientActivity extends Activity {
 
     ....

     private ServiceConnectionInfo connectionInfo = new ServiceConnectionInfo();

     protected void findService()
     {
         // Code to get cloudlet
         new FindCloudletAndStartService(this, this.SERVICE_ID, 
           new CpuBasedRanker(), 
           new CloudletCallback<ServiceVM>() {
             @Override
             public void handle(ServiceVM result) {
                 if (result == null) {
                     Toast.makeText(SphinxAndroidClientActivity.this, "Failed to locate a 
                         cloudlet for this app", Toast.LENGTH_LONG).show();
                     return;
                 }
                 Log.v("SPEECH", "GOT SERVICE RESULT: " + result.getInstanceId());
                 Toast.makeText(SphinxAndroidClientActivity.this, "Located a cloudlet to use!",   
                    Toast.LENGTH_LONG).show();
                 connectionInfo.setIpAddress(result.getAddress().getHostAddress());
                 connectionInfo.setPortNumber(result.getPort());
                 connectionInfo.storeIntoPreferences(SphinxAndroidClientActivity.this,
                    SphinxAndroidClientActivity.this.getString(R.string.pref_ipaddress),
                    SphinxAndroidClientActivity.this.getString(R.string.pref_portnumber));
             }
         }).execute();
     }
 }