Unknown macro: {style}

.ia-secondary-container

Unknown macro: { margin}
Unknown macro: {div}
Kaa releases
Unknown macro: {div}
Shortcuts

Page tree
Skip to end of metadata
Go to start of metadata

Endpoint profile is a virtual identity or "passport" of the endpoint. By filtering against the data in the profiles, endpoints may be aggregated into independently managed groups. Please review the Kaa profiling design reference for more background.

This guide will familiarize you with the basic concepts of designing endpoint profiles and programming the Kaa profiling subsystem. It is assumed that you have either set up a Kaa Sandbox, or a fully-blown Kaa cluster already and that you have created a tenant and an application in Kaa.

Configuring Kaa

The default profile schema installed for Kaa applications is empty. In order to make use of the Kaa profiling / identity management capabilities, you should load a profile schema that reflects the application you are designing. Think about the profile schema as of a virtual identity of your client application that will later be available to you in Kaa server.

You can configure your own profile schema using the Admin UI or REST API. For the purpose of this guide we will use a fairly abstract profile schema shown below.

{
    "type":"record",
    "name":"Profile",
    "namespace":"org.kaaproject.kaa.schema.sample.profile",
    "fields":[
        {
            "name":"id",
            "type":"string"
        },
        {
            "name":"os",
            "type":{
                "type":"enum",
                "name":"OS",
                "symbols":[
                    "Android",
                    "iOS",
                    "Linux"
                ]
            }
        },
        {
            "name":"os_version",
            "type":"string"
        },
        {
            "name":"build",
            "type":"string"
        }
    ]
}

Coding

Profile updates are reported to the endpoint SDK using a profile container. The profile related API varies depending on the target SDK platform, however the general approach is the same.

Java
import org.kaaproject.kaa.client.Kaa;
import org.kaaproject.kaa.client.KaaClient;
import org.kaaproject.kaa.client.profile.AbstractProfileContainer;
import org.kaaproject.kaa.client.profile.ProfileContainer;
import org.kaaproject.kaa.schema.sample.profile.OS;
import org.kaaproject.kaa.schema.sample.profile.Profile;

// Profile container based on AbstractProfileContainer class that is provided by the SDK
public static class BasicProfileContainer extends AbstractProfileContainer {
    private Profile profile;
    public BasicProfileContainer(Profile profile) {
        super();
        this.profile = profile;
    }
    @Override
    public Profile getProfile() {
        return profile;
    }
    public void updateProfile(Profile profile) throws IOException {
        this.profile = profile;
        // Update method should be called to notify about changes in the profile.
        updateProfile();
    }
}

// Desktop Kaa client initialization based on BasicProfileContainer 
private void init() {
    // Create instance of desktop Kaa application
    Kaa kaa = new KaaDesktop();
    // Create client for Kaa SDK
    KaaClient client = kaa.getClient();
    // Sample profile
    Profile profile = new Profile("deviceId", OS.Android, "3.17", "0.0.1-SNAPSHOT");
    // Create instance of profile container
    ProfileContainer container = new BasicProfileContainer(profile);
    // Set simple profile container to profile manager
    client.getProfileManager().setProfileContainer(container);
    // Starts Kaa
    kaa.start();
}
C++
#include <kaa/Kaa.hpp>
#include <kaa/profile/AbstractProfileContainer.hpp>
#include <kaa/gen/ProfileGen.hpp> // auto-generated header

using namespace kaa;

// Profile container based on AbstractProfileContainer class that is provided by the SDK
class BasicProfileContainer : public AbstractProfileContainer<Profile> {
public:
    BasicProfileContainer(const Profile &profile) : profile_(profile) { }
    virtual Profile getProfile() {
        return profile_;
    }
    virtual void changeProfile(const Profile &profile) {
        profile_ = profile;

        // Update method should be called to notify about changes in the profile.
        updateProfile();
    }
private:
    Profile profile_;
};
// Kaa client initialization based on BasicProfileContainer
void init(){
    // Create client for Kaa SDK
    Kaa::init(0);
    IKaaClient &client = Kaa::getKaaClient();
    // Sample profile
    Profile profile;
    profile.id = "deviceId";
    profile.os_version = "3.17";
    profile.os = OS::Linux;
    profile.build = "0.0.1-SNAPSHOT";
    // Create instance of profile container
    ProfileContainerPtr container(new BasicProfileContainer(profile));
    // Set simple profile container to profile manager
    client.getProfileManager().setProfileContainer(container);
    // Starts Kaa
    Kaa::start();
}
C
#include <stdlib.h>
#include <string.h>

#include <kaa.h>
#include <gen/kaa_profile_gen.h> // auto-generated header

void init() {
    const char* id = "deviceId";
    const char* kernel_version = "2.67.5";
    const char* build = "0.1";

    kaa_init();

    // Create profile instance using auto-generated constructor
    kaa_profile_t *profile = kaa_profile_create_profile();

    // Fill in profile
    profile->os = ENUM_OS_Linux; // auto-generated enum
    profile->id = (char*)calloc(strlen(id) + 1, sizeof(char));
    strcpy(profile->id, id);
    profile->build = (char*)calloc(strlen(build) + 1, sizeof(char));
    strcpy(profile->build, build);
    profile->os_version = (char*)calloc(strlen(os_version) + 1, sizeof(char));
    strcpy(profile->os_version, os_version);

    // Notify about profile update
    kaa_set_profile(profile);

    // Destroy if profile instance is not needed
    profile->destruct(profile);
    free(profile);
}

Copyright © 2014, CyberVision, Inc.

  • No labels