Skip to content

Commit 3dea817

Browse files
committed
Merge branch 'master' into feature/IGNITE-28307
# Conflicts: # modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java # modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryMessageFactory.java # modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java # modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/PartitionReservationsMap.java # modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java # modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java # modules/core/src/test/java/org/apache/ignite/spi/communication/TestBadMessage.java # modules/core/src/test/java/org/apache/ignite/spi/communication/TestMessage1.java # modules/core/src/test/java/org/apache/ignite/spi/communication/TestVolatilePayloadMessage.java
2 parents c8e540a + ffaea42 commit 3dea817

94 files changed

Lines changed: 2047 additions & 1897 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/_docs/SQL/JDBC/jdbc-driver.adoc

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ See the link:security/authentication[Authentication] and link:sql-reference/ddl#
130130
| Whether to use `TCP_NODELAY` option.
131131
|`true`
132132

133+
|`keepBinary`
134+
| Enables xref:keep-binary[] mode, required for operations with custom objects involved.
135+
|`false`
136+
133137
|`skipReducerOnUpdate`
134138
|Enables server side updates.
135139
When Ignite executes a DML operation, it fetches all the affected intermediate rows and sends them to the query initiator (also known as reducer) for analysis. Then it prepares batches of updated values to be sent to remote nodes.
@@ -173,6 +177,60 @@ The example below shows how to pass three addresses via the connection string:
173177
include::{javaFile}[tags=multiple-endpoints, indent=0]
174178
----
175179

180+
=== Keep Binary [[keep-binary]]
181+
182+
The keepBinary parameter is required for operations involving fields that contain complex objects. In case this flag is set to true such fields are not deserialized upon return to the user, instead being retained in inner binary object format.
183+
184+
[source, java]
185+
----
186+
// Suppose custom object looks like as follows:
187+
class TestObject implements Serializable {
188+
@QuerySqlField
189+
int id;
190+
191+
@QuerySqlField
192+
TestInnerObject objVal;
193+
194+
TestObject(int id) {
195+
this.id = id;
196+
}
197+
}
198+
199+
// And appropriate inner class:
200+
class TestInnerObject implements Serializable {
201+
int intFld;
202+
203+
String strFld;
204+
205+
TestInnerObject(int intFld, String strFld) {
206+
this.intFld = intFld;
207+
this.strFld = strFld;
208+
}
209+
}
210+
211+
TestObject testObj = new TestObject(1);
212+
testObj.objVal = new TestInnerObject(100, "Some");
213+
214+
// Now let`s put it through key value api:
215+
IgniteCache<Integer, TestObject> cache = ignite.cache(DEFAULT_CACHE_NAME);
216+
cache.put(1, testObj);
217+
218+
// Open the JDBC connection via DriverManager with 'keepBinary=true' to have a possibility to interact with custom objects.
219+
Connection conn = DriverManager.getConnection("jdbc:ignite:thin://192.168.0.50?keepBinary=true");
220+
221+
PreparedStatement stmt = conn.prepareStatement("SELECT id, objVal FROM TestObject WHERE objVal IS NOT DISTINCT FROM ?");
222+
223+
stmt.setObject(1, new TestInnerObject(100, "Some"));
224+
225+
ResultSet rs = stmt.executeQuery();
226+
227+
while (rs.next()) {
228+
Object obj = rs.getObject("objVal");
229+
Assert.assertTrue(obj instanceof BinaryObject);
230+
BinaryObject bo = (BinaryObject)obj;
231+
Assert.assertEquals("Some", bo.field("strFld"));
232+
}
233+
----
176234

177235
=== Partition Awareness [[partition-awareness]]
178236

docs/_docs/events/listening-to-events.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Ignite can generate events for a variety of operations happening in the cluster
2222
The list of events is available in the link:events/events[Events] section.
2323

2424
== Enabling Events
25-
By default, events are disabled, and you have to enable each event type explicitly if you want to use it in your application.
25+
By default, almost all events are disabled (except for a few that are implicitly enabled because they are required by the system), and you have to enable each event type explicitly if you want to use it in your application.
2626
To enable specific event types, list them in the `includeEventTypes` property of `IgniteConfiguration` as shown below:
2727

2828
[tabs]
@@ -45,6 +45,8 @@ include::code-snippets/dotnet/WorkingWithEvents.cs[tag=enablingEvents,indent=0]
4545
tab:C++[unsupported]
4646
--
4747

48+
Events can also be enabled/disabled in runtime by the link:tools/control-script[control utility].
49+
4850
== Getting the Events Interface
4951

5052
The events functionality is available through the events interface, which provides methods for listening to cluster events. The events interface can be obtained from an instance of `Ignite` as follows:

docs/_docs/maintenance-mode.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Another restart will then be needed to bring the node back into the cluster.
9494

9595
Commands that trigger maintenance mode on the next restart:
9696

97-
- `control.sh --defragmentation` - node defragmentation;
97+
- `control.sh --defragmentation schedule` - node defragmentation scheduling;
9898
- `control.sh --cache schedule_indexes_rebuild` - schedule rebuilding cache data indexes in Maintenance Mode.
9999

100100
More details about these commands can be found in the "Control Script" section under subsections "link:tools/control-script#defragmentation[Defragmentation]" and "link:tools/control-script#rebuild_index[Rebuild index]".

docs/_docs/tools/control-script.adoc

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ control.sh|bat --cache metrics enable --caches cache-2,cache-1
16131613

16141614
== Rebuild index
16151615

1616-
The `schedule_indexes_rebuild` commands Apache Ignite to rebuild indexes for specified caches or cache groups. Target caches or cache groups must be in link:maintenance-mode[Maintenance Mode].
1616+
The `schedule_indexes_rebuild` command instructs Apache Ignite to schedule the rebuild of indexes for the specified caches or cache groups. This will result in the specified nodes being scheduled to start in link:maintenance-mode[Maintenance Mode] during the next startup.
16171617

16181618
[source, shell]
16191619
----
@@ -1628,3 +1628,55 @@ Parameters:
16281628
|--node-id | A list of nodes to rebuild indexes on. If not specified, schedules rebuild on all nodes.
16291629
|--cache-names | Comma-separated list of cache names, optionally with indexes. If indexes are not specified, all indexes of the cache will be scheduled for the rebuild operation. Can be used simultaneously with cache group names.
16301630
|--group-names | Comma-separated list of cache group names. Can be used simultaneously with cache names.
1631+
1632+
1633+
== Event management
1634+
1635+
The control utility provides commands to enable, disable and check the status of events on all server nodes.
1636+
1637+
=== Enable/disable events
1638+
1639+
To enable or disable events on all server nodes, use the `--event enable/disable` command.
1640+
1641+
[source, shell]
1642+
----
1643+
control.sh|bat --event enable|disable event1[,...,eventN]
1644+
----
1645+
1646+
Parameters:
1647+
1648+
[cols="1,3",opts="header"]
1649+
|===
1650+
| Parameter | Description
1651+
| `event1[,...,eventN]`| Specifies a comma-separated list of events to enable/disable.
1652+
|===
1653+
1654+
Examples:
1655+
[source, shell]
1656+
----
1657+
control.sh|bat --event enable EVT_CACHE_STARTED,EVT_CACHE_STOPPED
1658+
control.sh|bat --event disable EVT_CACHE_STARTED,EVT_CACHE_STOPPED
1659+
----
1660+
1661+
=== Events list and status
1662+
1663+
To get the list and status of available events, use the `--event list` command.
1664+
1665+
[source, shell]
1666+
----
1667+
control.sh|bat --event list [--enabled]
1668+
----
1669+
1670+
Parameters:
1671+
1672+
[cols="1,3",opts="header"]
1673+
|===
1674+
| Parameter | Description
1675+
| `--enabled`| List only enabled evente.
1676+
|===
1677+
1678+
Examples:
1679+
[source, shell]
1680+
----
1681+
control.sh|bat --event list --enabled
1682+
----

modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import org.apache.calcite.sql.type.SqlTypeName;
4848
import org.apache.calcite.sql.util.SqlOperatorTables;
4949
import org.apache.calcite.sql.util.SqlShuttle;
50-
import org.apache.calcite.sql.validate.SqlValidator;
5150
import org.apache.calcite.sql2rel.SqlToRelConverter;
5251
import org.apache.calcite.tools.FrameworkConfig;
5352
import org.apache.calcite.tools.Frameworks;
@@ -98,6 +97,8 @@
9897
import org.apache.ignite.internal.processors.query.calcite.prepare.ExplainPlan;
9998
import org.apache.ignite.internal.processors.query.calcite.prepare.FieldsMetadata;
10099
import org.apache.ignite.internal.processors.query.calcite.prepare.IgniteConvertletTable;
100+
import org.apache.ignite.internal.processors.query.calcite.prepare.IgniteSqlCallRewriteTable;
101+
import org.apache.ignite.internal.processors.query.calcite.prepare.IgniteSqlValidator;
101102
import org.apache.ignite.internal.processors.query.calcite.prepare.IgniteTypeCoercion;
102103
import org.apache.ignite.internal.processors.query.calcite.prepare.MultiStepPlan;
103104
import org.apache.ignite.internal.processors.query.calcite.prepare.PrepareServiceImpl;
@@ -190,7 +191,8 @@ public class CalciteQueryProcessor extends GridProcessorAdapter implements Query
190191
.withParserFactory(IgniteSqlParserImpl.FACTORY)
191192
.withLex(Lex.ORACLE)
192193
.withConformance(IgniteSqlConformance.INSTANCE))
193-
.sqlValidatorConfig(SqlValidator.Config.DEFAULT
194+
.sqlValidatorConfig(IgniteSqlValidator.Config.DFLT
195+
.withSqlNodeRewriter(IgniteSqlCallRewriteTable.INSTANCE)
194196
// TODO Workaround for https://issues.apache.org/jira/browse/CALCITE-6978
195197
.withCallRewrite(false)
196198
.withIdentifierExpansion(true)

modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgniteSqlCallRewriteTable.java

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,20 @@
2626
import org.apache.calcite.sql.SqlKind;
2727
import org.apache.calcite.sql.SqlNode;
2828
import org.apache.calcite.sql.SqlNodeList;
29+
import org.apache.calcite.sql.SqlUtil;
2930
import org.apache.calcite.sql.fun.SqlCase;
3031
import org.apache.calcite.sql.fun.SqlLibraryOperators;
3132
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
3233
import org.apache.calcite.sql.parser.SqlParserPos;
33-
import org.apache.calcite.sql.util.SqlBasicVisitor;
34-
import org.apache.calcite.sql.util.SqlVisitor;
3534
import org.apache.calcite.sql.validate.SqlValidator;
36-
import org.apache.calcite.util.Util;
3735

3836
import static org.apache.calcite.util.Static.RESOURCE;
3937

4038
/**
4139
* Ignite SQL call rewrite table. Performs unconditional rewrites for some predefined Calcite SQL operators,
4240
* which can't be extended other ways by Ignite.
4341
*/
44-
public class IgniteSqlCallRewriteTable {
42+
public class IgniteSqlCallRewriteTable implements IgniteSqlNodeRewriter {
4543
/** Instance. */
4644
public static final IgniteSqlCallRewriteTable INSTANCE = new IgniteSqlCallRewriteTable();
4745

@@ -68,6 +66,14 @@ public void register(String operatorName, BiFunction<SqlValidator, SqlCall, SqlC
6866
map.put(operatorName, rewriter);
6967
}
7068

69+
/** {@inheritDoc} */
70+
@Override public SqlNode rewrite(SqlValidator validator, SqlNode node) {
71+
if (node instanceof SqlCall)
72+
return rewrite(validator, (SqlCall)node);
73+
else
74+
return node;
75+
}
76+
7177
/** Rewrites SQL call. */
7278
SqlNode rewrite(SqlValidator validator, SqlCall call) {
7379
BiFunction<SqlValidator, SqlCall, SqlCall> rewriter = map.get(call.getOperator().getName());
@@ -107,24 +113,8 @@ private static SqlCall nvlRewriter(SqlValidator validator, SqlCall call) {
107113
}
108114

109115
/** */
110-
public static boolean containsSubquery(SqlNode call) {
111-
try {
112-
SqlVisitor<Void> visitor = new SqlBasicVisitor<>() {
113-
@Override public Void visit(SqlCall call) {
114-
if (call.getKind() == SqlKind.SELECT)
115-
throw new Util.FoundOne(call);
116-
117-
return super.visit(call);
118-
}
119-
};
120-
121-
call.accept(visitor);
122-
123-
return false;
124-
}
125-
catch (Util.FoundOne e) {
126-
return true;
127-
}
116+
public static boolean containsSubquery(SqlNode node) {
117+
return SqlUtil.containsCall(node, call -> call.getKind() == SqlKind.SELECT);
128118
}
129119

130120
/** Rewrites DECODE call to CASE WHEN call. */
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.ignite.internal.processors.query.calcite.prepare;
19+
20+
import org.apache.calcite.sql.SqlNode;
21+
import org.apache.calcite.sql.validate.SqlValidator;
22+
23+
/**
24+
* SQL node rewriter interface.
25+
*/
26+
public interface IgniteSqlNodeRewriter {
27+
/** Rewrites SQL node. */
28+
public SqlNode rewrite(SqlValidator validator, SqlNode node);
29+
}

modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgniteSqlValidator.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.apache.calcite.sql.type.FamilyOperandTypeChecker;
5454
import org.apache.calcite.sql.type.SqlOperandTypeChecker;
5555
import org.apache.calcite.sql.type.SqlOperandTypeInference;
56+
import org.apache.calcite.sql.type.SqlTypeCoercionRule;
5657
import org.apache.calcite.sql.type.SqlTypeFamily;
5758
import org.apache.calcite.sql.type.SqlTypeName;
5859
import org.apache.calcite.sql.validate.SelectScope;
@@ -73,11 +74,13 @@
7374
import org.apache.ignite.internal.processors.query.calcite.type.OtherType;
7475
import org.apache.ignite.internal.processors.query.calcite.util.IgniteResource;
7576
import org.apache.ignite.internal.util.typedef.F;
77+
import org.immutables.value.Value;
7678
import org.jetbrains.annotations.Nullable;
7779

7880
import static org.apache.calcite.util.Static.RESOURCE;
7981

8082
/** Validator. */
83+
@Value.Enclosing
8184
public class IgniteSqlValidator extends SqlValidatorImpl {
8285
/** Decimal of Integer.MAX_VALUE for fetch/offset bounding. */
8386
private static final BigDecimal DEC_INT_MAX = BigDecimal.valueOf(Integer.MAX_VALUE);
@@ -345,8 +348,8 @@ else if (call.getKind() == SqlKind.CAST) {
345348

346349
node = super.performUnconditionalRewrites(node, underFrom);
347350

348-
if (node instanceof SqlCall)
349-
node = IgniteSqlCallRewriteTable.INSTANCE.rewrite(this, (SqlCall)node);
351+
if (config() instanceof Config && ((Config)config()).sqlNodeRewriter() != null)
352+
node = ((Config)config()).sqlNodeRewriter().rewrite(this, node);
350353

351354
return node;
352355
}
@@ -657,4 +660,28 @@ else if (operandTypeChecker instanceof FamilyOperandTypeChecker) {
657660

658661
super.validateUnnest(call, scope, targetRowType);
659662
}
663+
664+
/**
665+
* Interface to define extension to the configuration for a IgniteSqlValidator.
666+
*/
667+
@Value.Immutable(singleton = false)
668+
public interface Config extends SqlValidator.Config {
669+
/** Default configuration. */
670+
Config DFLT = ImmutableIgniteSqlValidator.Config.builder().from(DEFAULT).build();
671+
672+
/** Gets custom call rewriter. */
673+
@Value.Default
674+
@Nullable default IgniteSqlNodeRewriter sqlNodeRewriter() {
675+
return null;
676+
}
677+
678+
/** Sets custom call rewriter. */
679+
Config withSqlNodeRewriter(@Nullable IgniteSqlNodeRewriter rewriter);
680+
681+
/** Ovverride due to lost @Nullable annotation from the super-class by immutables generator. */
682+
@Override @Nullable SqlTypeCoercionRule typeCoercionRules();
683+
684+
/** Ovverride due to lost @Nullable annotation from the super-class by immutables generator. */
685+
@Override Config withTypeCoercionRules(@Nullable SqlTypeCoercionRule rules);
686+
}
660687
}

0 commit comments

Comments
 (0)