use of com.hazelcast.sql.impl.QueryId in project hazelcast by hazelcast.
the class SqlClientExecuteCloseRaceTest method testClose.
@Test
public void testClose() {
QueryId queryId = QueryId.create(UUID.randomUUID());
// Send "close"
Connection connection = clientService.getQueryConnection();
ClientMessage closeRequest = SqlCloseCodec.encodeRequest(queryId);
clientService.invokeOnConnection(connection, closeRequest);
// Make sure that we observed the cancel request.
assertEquals(1, memberService.getInternalService().getClientStateRegistry().getCursorCount());
// Wait for it to disappear.
memberService.getInternalService().getClientStateRegistry().setClosedCursorCleanupTimeoutSeconds(1L);
assertTrueEventually(() -> assertEquals(0, memberService.getInternalService().getClientStateRegistry().getCursorCount()));
}
use of com.hazelcast.sql.impl.QueryId in project hazelcast by hazelcast.
the class SqlClientService method execute.
@Nonnull
@Override
public SqlResult execute(@Nonnull SqlStatement statement) {
ClientConnection connection = getQueryConnection();
QueryId id = QueryId.create(connection.getRemoteUuid());
List<Object> params = statement.getParameters();
List<Data> params0 = new ArrayList<>(params.size());
for (Object param : params) {
params0.add(serializeParameter(param));
}
ClientMessage requestMessage = SqlExecuteCodec.encodeRequest(statement.getSql(), params0, statement.getTimeoutMillis(), statement.getCursorBufferSize(), statement.getSchema(), statement.getExpectedResultType().getId(), id, skipUpdateStatistics);
SqlClientResult res = new SqlClientResult(this, connection, id, statement.getCursorBufferSize());
try {
ClientMessage message = invoke(requestMessage, connection);
handleExecuteResponse(res, message);
return res;
} catch (Exception e) {
RuntimeException error = rethrow(e, connection);
res.onExecuteError(error);
throw error;
}
}
use of com.hazelcast.sql.impl.QueryId in project hazelcast by hazelcast.
the class PlanExecutorTest method test_insertExecution.
@Test
public void test_insertExecution() {
// given
QueryId queryId = QueryId.create(UuidUtil.newSecureUUID());
DmlPlan plan = new DmlPlan(Operation.INSERT, planKey(), QueryParameterMetadata.EMPTY, emptySet(), dag, null, false, planExecutor, Collections.emptyList());
given(hazelcastInstance.getJet()).willReturn(jet);
given(jet.newLightJob(eq(dag), isA(JobConfig.class))).willReturn(job);
// when
SqlResult result = planExecutor.execute(plan, queryId, emptyList(), 0L);
// then
assertThat(result.updateCount()).isEqualTo(0);
verify(job).join();
}
Aggregations