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 | ACTIVE |
Ignite provides a few options to set custom attributes on client side - per call (ServiceCallContext) or per connection (UserAttributes). But there is no opportunity to specify attributes on "application level". Scenario is:
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:
Ignite, IgniteClient, JDBC).QuerySqlFunctionCacheInterceptorServiceComputeTask, ComputeJobAttributes API that aren't part of the IEP:
ClientListenerConnectionContext#attributes - it's how client stores UserAttribute in connection context.ComputeTaskSession#setAttribute - 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.Similar mechanisms in other DBMSs:
Ignite#withApplicationAttributes. It returns Ignite instance that is aware of the attributes.GridIoSecurityAwareMessage)// Example of usage.
try (Ignite ign = Ignition.start(ignCfg)) {
Map<String, String> appAttrs = F.asMap("SESSION_ID", "1234");
Ignite app = Ignite.withApplicationAttributes(appAttrs);
...
}
IgniteClient#withApplicationAttributes.ClientBitmaskFeature protocol.// Example of usage.
try (IgniteClient cln = Ignition.startClient(clnCfg)) {
Map<String, String> appAttrs = F.asMap("SESSION_ID", "1234");
IgniteClient app = cln.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:
#setClientInfo is arbitrary. The documentation recommends strictly limiting the set of attributes, but this is not necessary. For example, Oracle does not have such a limitation [5]. The setClientInfo array is completely translated into the getClientAttributes array.setClientInfo are passed along with each JdbcRequest (this requires a new feature in JdbcThinFeature).// JDBC connection to Ignite server.
try (Connection conn = DriverManager.getConnection(URL)) {
conn.setClientInfo("SESSION_ID", "1234");
...
}
SessionContext is an entrypoint for accessing attributes on all levels and other session-level data (e.g. SecurutySubject).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.
/** SessionContext interface. It's an entrypoint for all attributes. */
public class SessionContext {
/** @return Attribute by name. */
public @Nullable String getAttribute(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() {
SessionContext sesCtx = sesCtxProv.getSessionContext();
return sesCtx == null ? null : sesCtx.getAttribute("SESSION_ID");
}
}
// Links to discussions on the devlist, if applicable.
[4] https://torofimofu.blogspot.com/2014/05/oracle.html
[5] https://docs.oracle.com/database/121/JJDBC/jdbcvers.htm#BABDAEEC
[6] https://stackoverflow.com/search?tab=newest&q=SYS_CONTEXT
[7] https://docs.snowflake.com/en/sql-reference/session-variables#session-variable-functions
[9] https://dev.mysql.com/doc/refman/8.4/en/user-variables.html
// Links or report with relevant JIRA tickets.