Versions Compared

Key

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

...

  1. Users set attributes with Ignite#withApplicationAttributes. It returns Ignite instance that is aware of the attributes.
  2. Application attributes are propagated with all messages sent within operation on remote nodes (similar to GridIoSecurityAwareMessage)Application attributes set to ThreadLocal<Map<String, String>>  in each thread that process operation (similar to SecurityContext#withSecurityContext() ).


Code Block
languagejava
// Example of usage.
try (Ignite ign = Ignition.start(ignCfg)) {
    Map<String, String> appAttrs = F.asMap("SESSION_ID", "1234");

	IgniteCache<?, ?> cache = ign.cache("CACHE")Ignite app = Ignite.withApplicationAttributes(appAttrs);	

 	...
}

...

  1. Users set attributes with ClientCache#withApplicationAttributes IgniteClient#withApplicationAttributes.
  2. New feature is needed in the ClientBitmaskFeature protocol.

...

Code Block
languagejava
// Example of usage.
try (IgniteClient cln = Ignition.startClient(clnCfg)) {
    Map<String, String> appAttrs = F.asMap("SESSION_ID", "1234");

	ClientCache<?, ?> cache IgniteClient app = cln.cache("CACHE").withApplicationAttributes(appAttrs);	

 	...
}

...

Accessing application attributes

  1. ApplicationContext SessionContext is an entrypoint for accessing all non-tabular data.
  2. The access requires static methods, because objects injection isn't possible for user functions (QuerySqlFunction are static, CacheInterceptor is a cache singleton).
  3. attributes on all levels and other session-level data.
  4. User can easily create own QuerySqlFunction  to get access to the attributes in SQL queries if needed (see example below).

...

Code Block
languagejava
/** ApplicationContextSessionContext interface. It's an entrypoint for all non-tabular dataattributes. */
public class ApplicationContextSessionContext {
    /** @return ApplicationCall, attributesapplication setand foruser current threadattributes. */
    public static @Nullable Map<String, String> getAttributes();

    /** @return Current SecuritySubject. */
	public static @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 static @Nullable String sessionId() {
        Map<String, String> appAttrs = ApplicationContext.getAttributes();
 
        return appAttrs == null ? null : appAttr.get("SESSION_ID");
    }
}

...