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.
...
Ignite provides a few options to set custom attributes on client side - : per call (ServiceCallContext) or and per connection (UserAttributes). But Now there is no opportunity to specify set attributes on the "application level". Scenario is:
application attributes - an associative array of Strings specified on an application sideApplication need specify ApplicationAttributes. Business logic might depend on such attributes - application language, application name for audit, etc ([2], [4]).It's proposed to provide such the opportunity to set attributes for application. Then there will be hierarchy of attributes:
ServiceCallContextApplicationAttributesUserAttributes, SecuritySubjectUser defined functions might want The 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 the attributes must be provided for functions that are pre-created on Ignite cluster and aren't deployed by specific application. Examples:
CacheInterceptor saves the SecuritySubject along with data and it can be used for fine-grained access control in QuerySqlFunction.Service extracts attribute from ServiceCallContext and, if absent, get default one from ApplicationAttributes.It. Then it's proposed to introduce SessionContext API that is available from the functions and provides access to all this the attributes while processing data in hierarchical order (call, application, connection).
Requirements:
Ignite, IgniteClient, JDBC).QuerySqlFunctionCacheInterceptorServiceComputeTask, ComputeJobIgnite does not have a such API:
Attributes API that aren't part of the IEP:
ClientListenerConnectionContext#attributes - it's actually how client stores UserAttribute in connection context.ComputeTaskSession#setAttribute 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....
IgniteCache#withApplicationAttributes Ignite#withApplicationAttributes. It returns Ignite instance that is aware of the attributes.GridIoSecurityAwareMessage)Application attributes set to 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 Ignite app = ign.cache("CACHE").Ignite.withApplicationAttributes(appAttrs);
...
}
|
...
ClientCache#withApplicationAttributes IgniteClient#withApplicationAttributes.ClientBitmaskFeature protocol....
| Code Block | ||
|---|---|---|
| ||
// Example of usage.
try (IgniteClient cln = Ignition.startClient(clnCfg)) {
Map<String, String> appAttrs = F.asMap("SESSION_ID", "1234");
ClientCache<?, ?> cacheIgniteClient app = cln.cache("CACHE").withApplicationAttributes(appAttrs);
...
}
|
...
#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 ApplicationAttributes.setClientInfo are passed along with each JdbcRequest (this requires a new feature in JdbcThinFeature)....
| Code Block | ||
|---|---|---|
| ||
// 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). Ignite provides SessionContextProviderResource to access to SessionContext.
CacheInterceptor or QuerySqlFunction target class for every call (every row or key).SessionContext from Ignite thread.QuerySqlFunction to inject the resourceQuerySqlFunction are static, CacheInterceptor is a cache singleton).QuerySqlFunction to get access to the attributes in SQL queries if needed (see example below).| Code Block | ||
|---|---|---|
| ||
/** ApplicationContextSessionContext interface. It's an entrypoint for all non-tabular dataattributes. */ public class ApplicationContextSessionContext { /** @return ApplicationAttribute attributes set for current threadby name. */ public static @Nullable Map<String, String> getAttributes(String getAttribute(String attrName); /** @return Current SecuritySubject. */ public static @Nullable SecuritySubject getSecuritySubject(); } /** Example, use it in QuerySqlFunction. */ public static class UserDefinedFunctions { /** Injection performs once per query. */ @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 return sesCtxProv.getSessionContext().getAttribute("SESSION_ID"); } } |
https:// Links to discussions on the devlist, if applicable.lists.apache.org/thread/c5j5yykr6tfrnp9zprhg9j69w63r11zx
...
[9] https://dev.mysql.com/doc/refman/8.4/en/user-variables.html
| Jira | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|