Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
// JDBC connection to Ignite server.
try (Connection conn = DriverManager.getConnection(URL)) {
    conn.setClientInfo("SESSION_ID", "1234");
 
    ...
}

Accessing

...

attributes

  1. SessionContext is an entrypoint for accessing attributes on all levels and other session-level data (e.g. SecurutySubject).
  2. User can easily create own QuerySqlFunction  to get access to the attributes in SQL queries if needed (see example below).

Ignite provides SessionContextProviderResource to access to SessionContext. Provider instead of direct instance of the context is used for optimization. Injecting instance requires to have new instance of CacheInterceptor or QuerySqlFunction target class. It's not optimal to create new instances for every processing key or row.

Note, it proposes to make possible use non-static QuerySqlFunction to inject the resource.

Code Block
languagejava
/** SessionContext interface. It's an entrypoint for all attributes. */
public class SessionContext {
    /** @return Call,Attribute application and user attributesby name. */
    public Map<String,@Nullable String>String getAttributesgetAttribute(String attrName);

    /** @return Current SecuritySubject. */
	public @Nullable SecuritySubject getSecuritySubject();
 }
 
/** Example, use it in QuerySqlFunction. */
public static class UserDefinedFunctions {
        /** */
        @SessionContextProviderResource
        public SessionContextProvider sesCtxProv;

     /** @return Session ID set with application attributes. */
    @QuerySqlFunction
    public @Nullable String sessionId() {
            Map<String, String> appAttrs 
		SessionContext sesCtx = ApplicationContextsesCtxProv.getAttributesgetSessionContext();
 
        return appAttrssesCtx == null ? null : appAttrsesCtx.getgetAttribute("SESSION_ID");
      }
}

Risks and Assumptions

  1. No security checks are performed on the application attributes.
  2. Application attributes keys and values are strings, to avoid serialization problems.
  3. Application attributes User should specify only few application attributes, and they should be small. 
  4. UserAttributes currently fill with node attributes (~50 items on node start), and they are not transferred between nodes. This process should be changed.

Discussion Links

// Links to discussions on the devlist, if applicable.

...