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.

testSession=py1010.Session(gateway, owner, pwd, py1010.POSSESS, group)

The SAM pool user session takes two different parameters. Instead of the individual user name, 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 Python 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, clean up 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.

import py1010
import threading
import sys

gateway = ""
group = "[GROUP_ID]"
tablename = ""

def runQuery(table, ops, outfilename):
        with py1010.Session(gateway, owner, pwd, py1010.POSSESS,
                            group) as session:
            print("Logged in as {}".format(session.username))
            query = session.query(table, ops)
            with open(outfilename, "w") as outfile:
                print("Starting to write to " + outfilename)
                for r in query.rows:
                    outfile.write("\t".join([str(x) for x in r]) + "\n")
    except py1010.TentenException as e:
        print("Error: {}".format(e))

                          '<sel value="(i_<100000)"/>', "Output1.txt"))
                          '<sel value="(i_<100000)"/>', "Output2.txt"))

Note: [GROUP_ID], [GROUP_OWNER_USERNAME], and [GROUP_OWNER_PASSWORD] are placeholders for valid Insights Platform group ID, owner name, and password.