DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
| ID | IEP-129 | ||||||||
| Author | |||||||||
| Sponsor | Unknown User (nizhikov) | ||||||||
| Created | 10.09.2024 | ||||||||
| Status |
|
| Table of Contents |
|---|
Currently user have some opportunities Ignite provides a few options to set custom attributes on client side :
ServiceCallContextUserAttributes, SecuritySubjectIt has limitations:
ServiceCallContext helps solve similar problems, but has several limitations - available only by calls via the IgniteService API and cannot be used for primitive cache operations.UserAttributes - allows to set user attributes, but the attribute values are fixed for the entire lifetime of the connection.While processing data users want to have access to application specific non-tabular (not stored in cache structures) data:
- per call (ServiceCallContext) or per connection (UserAttributes). But there is no opportunity to specify attributes on "application level". Scenario is:
application Application attributes - an associative array of Strings specified on an application side. Business logic might depend on such attributes - application language, application name for audit, etc ([2], [4]).It's proposed to provide such opportunity. Then there will be hierarchy of attributes:
ServiceCallContextApplicationAttributesUserAttributes, SecuritySubjectUser defined functions might want access to different level of attributes. For example, SecuritySubject can be used to provide fine-grained access control to cache data. For example, CacheInterceptor saves the subject id it along with data and it can be used for fine-grained access control.
...
Then it's proposed to introduce API that provides access to all this attributes while processing data in hierarchical order.
Requirements:
...
The requirements:
Ignite, IgniteClient, JDBC).QuerySqlFunctionCacheInterceptorServiceComputeTask, ComputeJob...
ServiceCallContext helps solve similar problems, but has several limitations - available only by calls via the IgniteService API and cannot be used for primitive cache operations.UserAttributes - allows to set user attributes, but the attribute values are fixed for the entire lifetime of the connection.ClientListenerConnectionContext - it's available only on single node which directly accepts a client connection.ComputeTaskSession - this mechanism is available only within Compute API. It allows attributes to be changed during task lifetime, use-case is different - send sync/async notifications between jobs about events happened during task lifetime.Attributes hierarchy:
...
Similar mechanisms in other DBMSs:
Naming:
...
...
ApplicationContext is an entrypoint for accessing all non-tabular data.QuerySqlFunction are static, CacheInterceptor is a cache singleton).QuerySqlFunction to get access to the attributes in SQL queries if needed (see example below)....
...
| language | java |
|---|
...
/** ApplicationContext interface. It's an entrypoint for all non-tabular data. */
public class ApplicationContext {
/** @return Application attributes set for current thread. */
public static @Nullable Map<String, String> getAttributes();
/** @return Current SecuritySubject. */
public static @Nullable SecuritySubject getSecuritySubject();
}
/** Example, use it in QuerySqlFunction. */
public static class UserDefinedFunctions {
/** @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");
}
}
IgniteCache#withApplicationAttributes.GridIoSecurityAwareMessage)ThreadLocal<Map<String, String>> in each thread that process operation (similar to SecurityContext#withSecurityContext() )....
| Code Block | ||
|---|---|---|
| ||
// Example of usage.
try (Ignite ign = Ignition.start(ignCfg)) {
Map<String, String> appAttrs = F.asMap("SESSION_ID", "1234");
IgniteCache<?, ?> cache = ign.cache("CACHE").withApplicationAttributes(appAttrs);
...
}
|
ClientCache#withApplicationAttributes.ClientBitmaskFeature protocol....
| Code Block | ||
|---|---|---|
| ||
// Example of usage.
try (IgniteClient cln = Ignition.startClient(clnCfg)) {
Map<String, String> appAttrs = F.asMap("SESSION_ID", "1234");
ClientCache<?, ?> cache = cln.cache("CACHE").withApplicationAttributes(appAttrs);
...
}
|
The standard jdbc protocol describes the methods Connection#setClientInfo, which allow changing the values of client attributes during the life of the connection [3]. Implementation features:
...
| Code Block | ||
|---|---|---|
| ||
// JDBC connection to Ignite server.
try (Connection conn = DriverManager.getConnection(URL)) {
conn.setClientInfo("SESSION_ID", "1234");
...
}
|
ApplicationContext is an entrypoint for accessing all non-tabular data.QuerySqlFunction are static, CacheInterceptor is a cache singleton).QuerySqlFunction to get access to the attributes in SQL queries if needed (see example below).| Code Block | ||
|---|---|---|
| ||
/** ApplicationContext interface. It's an entrypoint for all non-tabular data. */ public class ApplicationContext { /** @return Application attributes set for current thread. */ public static @Nullable Map<String, String> getAttributes(); /** @return Current SecuritySubject. */ public static @Nullable SecuritySubject getSecuritySubject(); } /** Example, use it in QuerySqlFunction. */ public static class UserDefinedFunctions { /** @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"); } } |
// Links to discussions on the devlist, if applicable.
...
[9] https://dev.mysql.com/doc/refman/8.4/en/user-variables.html
// Links or report with relevant JIRA tickets.