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-126 | ||||||||
| Author | |||||||||
| Sponsor | |||||||||
| Created | 10.09.2024 | ||||||||
| Status |
|
| Table of Contents |
|---|
When processing data, users want to have access to client non-tabular (not stored in cache structures) data. Example of such data is application attributes - an associative array specified on an application side. Usage scenarios:
CacheInterceptor extracts the user from the attributes and saves it along with data).QuerySqlFunction use the same parameter and it is convenient to take it from the attributes, rather than transfer it separately to each function).Another examples of non-tabular data that can be accessed is SecuritySubject, UserAttributes and current Transaction.
The requirements also include:
QuerySqlFunction, CacheInterceptor)....
A similar context mechanism exists in Oracle [1] and it's widely used.
SessionContext ApplicationContext is an entrypoint for accessing the attributes.SessionContext can be further extended to retrieve other all non-tabular information, such as SecuritySubject, Transaction, ServiceCallContext, etcdata.QuerySqlFunction are static, CacheInterceptor is a singleton for cache)....
| Code Block | ||
|---|---|---|
| ||
/** SessionContextApplicationContext interface. It's an entrypoint for all non-tabular information. */ public class SessionContextApplicationContext { /** @return ClientApplication attributes set for current thread. */ public static @Nullable Map<String, String> getClientAttributesgetAttributes(); } /** Example, use it in QuerySqlFunction. */ public static class UserDefinedFunctions { /** @return Session ID, clientapplication attribute. */ @QuerySqlFunction public static String sessionId() { Map<String, String> clnAttrsappAttrs = SessionContextApplicationContext.getClientAttributesgetAttributes(); return clnAttrsappAttrs == null ? null : clnInfoappAttr.getPropertyget(SESSION_ID); } } |
...
Ignite instance from multiple threads by different applications. Also the same thread can be shared between multiple applications.ApplicationContext should not depend on the used API....
| Code Block | ||
|---|---|---|
| ||
// Extends the interface with new public method.
public interface IgniteTransactions {
...
/** @param clnAttrsappAttrs ClientApplication attributes. */
public IgniteTransactions withClientAttributeswithApplicationAttributes(Map<String, String> clnAttrsappAttrs);
}
// Example of usage.
try (Ignite ign = Ignition.localIgnite()) {
Map<String, String> clnAttrsappAttrs = F.asMap("SESSION_ID", "1234");
try (Transaction tx = ign.transactions().withClientAttributeswithApplicationAttributes(clnAttrsappAttrs).txStart()) {
clnAttrs.setAttribute("SESSION_ID", "1234");
...
}
} |
Implementation features:
ClientAttributes setting to transaction.ClientTransactions interface with withClientAttributes method, similar to withLabelClient should mirror the logic of Ignite node.ClientBitmaskFeature protocol).| Code Block | ||
|---|---|---|
| ||
// Extends the interface with new public method.
public interface ClientTransactions {
...
/** @param clnAttrsappAttrs ClientApplication attributes. */
public ClientTransactions withClientAttributeswithApplicationAttributes(Map<String, String> clnAttrsappAttrs);
}
// Example of usage.
try (IgniteClient cln = Ignition.startClient(clnCfg)) {
Map<String, String> clnAttrsappAttrs = F.asMap("SESSION_ID", "1234");
try (ClientTransaction tx = cln.transactions().withClientAttributeswithApplicationAttributes(clnAttrsappAttrs).txStart()) {
...
}
}
|
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");
...
}
|
QueryStartRequest SQL message protocol (for jdbc, SQL transactions)CacheInterceptor), since inserts are not always performed on the request initiator node.// Describe project risks, such as API or binary compatibility issues, major protocol changes, etc.
// Links to discussions on the devlist, if applicable.
[1] https://docs.oracle.com/en/database/oracle/oracle-database/19/
...
[4] https://torofimofu.blogspot.com/2014/05/oracle.html
[5] https://docs.oracle.com/database/121/JJDBC/jdbcvers.htm#BABDAEEC
// Links or report with relevant JIRA tickets.