Skip to content

Commit 690831c

Browse files
committed
Apply auto-formatter
Adding as a separate commit because otherwise the diff is hard to understand in contrast to what it actually does.
1 parent 043e5bb commit 690831c

File tree

1 file changed

+71
-70
lines changed

1 file changed

+71
-70
lines changed

integration-tests/src/test/java/com/datastax/oss/driver/core/metadata/DefaultMetadataTabletMapIT.java

Lines changed: 71 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -233,54 +233,54 @@ public void every_statement_should_deliver_tablet_info() {
233233
continue;
234234
}
235235
try (CqlSession session = sessionEntry.getValue().get()) {
236-
// Empty out tablets information
237-
if (session.getMetadata().getTabletMap().isPresent()) {
238-
session
239-
.getMetadata()
240-
.getTabletMap()
241-
.get()
242-
.removeByKeyspace(CqlIdentifier.fromCql(KEYSPACE_NAME));
243-
}
244-
Statement stmt;
245-
try {
246-
stmt = stmtEntry.getValue().apply(session);
247-
} catch (Exception e) {
248-
RuntimeException ex =
249-
new RuntimeException(
236+
// Empty out tablets information
237+
if (session.getMetadata().getTabletMap().isPresent()) {
238+
session
239+
.getMetadata()
240+
.getTabletMap()
241+
.get()
242+
.removeByKeyspace(CqlIdentifier.fromCql(KEYSPACE_NAME));
243+
}
244+
Statement stmt;
245+
try {
246+
stmt = stmtEntry.getValue().apply(session);
247+
} catch (Exception e) {
248+
RuntimeException ex =
249+
new RuntimeException(
250+
String.format(
251+
"Failed to build statement %s on session %s",
252+
stmtEntry.getKey(), sessionEntry.getKey()));
253+
ex.addSuppressed(e);
254+
throw ex;
255+
}
256+
try {
257+
if (!executeOnAllHostsAndReturnIfResultHasTabletsInfo(session, stmt)) {
258+
testErrors.add(
250259
String.format(
251-
"Failed to build statement %s on session %s",
260+
"Statement %s on session %s got no tablet info",
252261
stmtEntry.getKey(), sessionEntry.getKey()));
253-
ex.addSuppressed(e);
254-
throw ex;
255-
}
256-
try {
257-
if (!executeOnAllHostsAndReturnIfResultHasTabletsInfo(session, stmt)) {
262+
continue;
263+
}
264+
} catch (Exception e) {
265+
testErrors.add(
266+
String.format(
267+
"Failed to execute statement %s on session %s: %s",
268+
stmtEntry.getKey(), sessionEntry.getKey(), e));
269+
continue;
270+
}
271+
if (!waitSessionLearnedTabletInfo(session)) {
258272
testErrors.add(
259273
String.format(
260-
"Statement %s on session %s got no tablet info",
274+
"Statement %s on session %s did not trigger session tablets update",
261275
stmtEntry.getKey(), sessionEntry.getKey()));
262276
continue;
263277
}
264-
} catch (Exception e) {
265-
testErrors.add(
266-
String.format(
267-
"Failed to execute statement %s on session %s: %s",
268-
stmtEntry.getKey(), sessionEntry.getKey(), e));
269-
continue;
270-
}
271-
if (!waitSessionLearnedTabletInfo(session)) {
272-
testErrors.add(
273-
String.format(
274-
"Statement %s on session %s did not trigger session tablets update",
275-
stmtEntry.getKey(), sessionEntry.getKey()));
276-
continue;
277-
}
278-
if (!checkIfRoutedProperly(session, stmt)) {
279-
testErrors.add(
280-
String.format(
281-
"Statement %s on session %s was routed to different nodes",
282-
stmtEntry.getKey(), sessionEntry.getKey()));
283-
}
278+
if (!checkIfRoutedProperly(session, stmt)) {
279+
testErrors.add(
280+
String.format(
281+
"Statement %s on session %s was routed to different nodes",
282+
stmtEntry.getKey(), sessionEntry.getKey()));
283+
}
284284
}
285285
}
286286
}
@@ -296,46 +296,47 @@ public void every_statement_should_deliver_tablet_info() {
296296
public void should_receive_each_tablet_exactly_once() {
297297
int counter = 0;
298298
try (CqlSession session =
299-
CqlSession.builder().addContactEndPoints(CCM_RULE.getContactPoints()).build()) {
300-
PreparedStatement preparedStatement = session.prepare(STMT_INSERT);
301-
for (int i = 1; i <= QUERIES; i++) {
302-
if (executeAndReturnIfResultHasTabletsInfo(session, preparedStatement.bind(i, i))) {
303-
counter++;
299+
CqlSession.builder().addContactEndPoints(CCM_RULE.getContactPoints()).build()) {
300+
PreparedStatement preparedStatement = session.prepare(STMT_INSERT);
301+
for (int i = 1; i <= QUERIES; i++) {
302+
if (executeAndReturnIfResultHasTabletsInfo(session, preparedStatement.bind(i, i))) {
303+
counter++;
304+
}
304305
}
305-
}
306-
Assert.assertEquals(INITIAL_TABLETS, counter);
307-
assertSessionTabletMapIsFilled(session);
306+
Assert.assertEquals(INITIAL_TABLETS, counter);
307+
assertSessionTabletMapIsFilled(session);
308308
}
309309

310-
try (CqlSession session = CqlSession.builder().addContactEndPoints(CCM_RULE.getContactPoints()).build()) {
311-
counter = 0;
312-
PreparedStatement preparedStatement = session.prepare(STMT_SELECT);
313-
for (int i = 1; i <= QUERIES; i++) {
314-
if (executeAndReturnIfResultHasTabletsInfo(session, preparedStatement.bind(i, i))) {
315-
counter++;
310+
try (CqlSession session =
311+
CqlSession.builder().addContactEndPoints(CCM_RULE.getContactPoints()).build()) {
312+
counter = 0;
313+
PreparedStatement preparedStatement = session.prepare(STMT_SELECT);
314+
for (int i = 1; i <= QUERIES; i++) {
315+
if (executeAndReturnIfResultHasTabletsInfo(session, preparedStatement.bind(i, i))) {
316+
counter++;
317+
}
316318
}
317-
}
318319

319-
LOG.debug("Ran first set of queries");
320+
LOG.debug("Ran first set of queries");
320321

321-
// With enough queries we should hit a wrong node for each tablet exactly once.
322-
Assert.assertEquals(INITIAL_TABLETS, counter);
323-
assertSessionTabletMapIsFilled(session);
322+
// With enough queries we should hit a wrong node for each tablet exactly once.
323+
Assert.assertEquals(INITIAL_TABLETS, counter);
324+
assertSessionTabletMapIsFilled(session);
324325

325-
// All tablet information should be available by now (unless for some reason cluster did sth on
326-
// its own)
327-
// We should not receive any tablet payloads now, since they are sent only on mismatch.
328-
for (int i = 1; i <= QUERIES; i++) {
326+
// All tablet information should be available by now (unless for some reason cluster did sth
327+
// on its own). We should not receive any tablet payloads now, since they are sent only on
328+
// mismatch.
329+
for (int i = 1; i <= QUERIES; i++) {
329330

330-
ResultSet rs = session.execute(preparedStatement.bind(i, i));
331-
Map<String, ByteBuffer> payload = rs.getExecutionInfo().getIncomingPayload();
331+
ResultSet rs = session.execute(preparedStatement.bind(i, i));
332+
Map<String, ByteBuffer> payload = rs.getExecutionInfo().getIncomingPayload();
332333

333-
if (payload.containsKey(TabletInfo.TABLETS_ROUTING_V1_CUSTOM_PAYLOAD_KEY)) {
334-
throw new RuntimeException(
335-
"Received non empty payload with tablets routing information: " + payload);
334+
if (payload.containsKey(TabletInfo.TABLETS_ROUTING_V1_CUSTOM_PAYLOAD_KEY)) {
335+
throw new RuntimeException(
336+
"Received non empty payload with tablets routing information: " + payload);
337+
}
336338
}
337339
}
338-
}
339340
}
340341

341342
private static boolean waitSessionLearnedTabletInfo(CqlSession session) {

0 commit comments

Comments
 (0)