Shared Access Management (SAM)

Shared Access Management (SAM) pools enable a single set of credentials to be shared between client side threads to leverage multiple threads of parallelism on the 1010data Insights Platform.

Creating a new Session object for a SAM pool user is similar to creating a single-user Session object.
Session session = new Session(gateway, owner, group, pw, LoginType.POSSESS)
The SAM pool user session takes two different parameters. Instead of the individual user name user, this Session object takes the owner parameter. The owner parameter is the group owner's user name. The group parameter is the group ID. The SAM pool Session constructor takes the following parameter variables:
  • gateway - a 1010data Insights Platform URI
  • group - a group ID
  • owner - the group owner ID
  • password - the group owner password

If your users are using a SAM pool to log in, they will not have their own platform IDs. The users share a single set of credentials to log into the platform. A SAM pool has a number of IDs to use, but it is not limitless. You may have to account for cases where peak utilization creates a situation where more threads are trying to access the platform than your SAM pool is configured to handle.

The .NET SDK is designed to queue during Session object construction when a SAM pool is fully utilized. During this queuing time the thread trying to construct a new Session object retries the request every ten seconds.

To ensure that your SAM pool is fully utilized, release sessions as soon as your thread is done to prevent a full pool of IDs where all of the threads of database concurrency are in use at the same time. For more information, see Cleaning up a session.

In this example, two threads construct two separate Session objects and log in with a SAM pool. The application retrieves data from two different tables and downloads them into two separate files.

using System;
using System.Threading;
using System.Linq;
using TenTenSDK;

    private static void DownloadTable(Object obj) {
        Uri gateway = new Uri(((String[])obj)[0]);
        String owner = ((String[])obj)[1];
        String group = ((String[])obj)[2];
        String pwd = ((String[])obj)[3];
        String path = ((String[])obj)[4];
        String outpath = ((String[])obj)[5];
        
        using (Session s = new Session(gateway, owner, group, pwd,
                                       LoginType.POSSESS)) {
            var query = new Query(path, "<sel value=""(i_<200000)""/>");
            Table t = query.RunOn(s);
            using (var file = new System.IO.StreamWriter(outpath, false)) {
                foreach (Row row in t.Rows) {
                    file.WriteLine(String.Join("\t", 
                                       row.Select(d => d.ToString())));
                }
            }
        }
    }

    
    public static void Main(String[] args) {
        String gateway = "https://www2.1010data.com/cgi-bin/gw.k";
        String group = "[GROUPID]";
        String owner = "[OWNERNAME]";
        String pwd = "[PASSWORD]";
        String path1 = "pub.public_data.census.acs.all_acs_processed_tables";
        String path2 = "pub.public_data.census.acs.reference.column_names";
        String[] args1 = {gateway, owner, group, pwd, path1,
            Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
                                      "\\Output1.txt" };
        String[] args2 = {gateway, owner, group, pwd, path2,
            Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
                                      "\\Output2.txt" };
        Thread t1 = new Thread(DownloadTable);
        Thread t2 = new Thread(DownloadTable);
        t1.Start(args1);
        t2.Start(args2);
        t1.Join();
        t2.Join();
    }
}
Note: [GROUPID], [OWNERNAME], and [PASSWORD] are placeholders for valid Insights Platform gateway, group ID, owner name, and password.