use of java.util.concurrent.atomic.AtomicBoolean in project kafka by apache.
the class ConsumerCoordinatorTest method testLeaveGroupOnClose.
@Test
public void testLeaveGroupOnClose() {
final String consumerId = "consumer";
subscriptions.subscribe(singleton(topic1), rebalanceListener);
client.prepareResponse(groupCoordinatorResponse(node, Errors.NONE));
coordinator.ensureCoordinatorReady();
client.prepareResponse(joinGroupFollowerResponse(1, consumerId, "leader", Errors.NONE));
client.prepareResponse(syncGroupResponse(singletonList(t1p), Errors.NONE));
coordinator.joinGroupIfNeeded();
final AtomicBoolean received = new AtomicBoolean(false);
client.prepareResponse(new MockClient.RequestMatcher() {
@Override
public boolean matches(AbstractRequest body) {
received.set(true);
LeaveGroupRequest leaveRequest = (LeaveGroupRequest) body;
return leaveRequest.memberId().equals(consumerId) && leaveRequest.groupId().equals(groupId);
}
}, new LeaveGroupResponse(Errors.NONE));
coordinator.close(0);
assertTrue(received.get());
}
use of java.util.concurrent.atomic.AtomicBoolean in project kafka by apache.
the class KafkaConsumerTest method prepareHeartbeatResponse.
private AtomicBoolean prepareHeartbeatResponse(MockClient client, Node coordinator) {
final AtomicBoolean heartbeatReceived = new AtomicBoolean(false);
client.prepareResponseFrom(new MockClient.RequestMatcher() {
@Override
public boolean matches(AbstractRequest body) {
heartbeatReceived.set(true);
return true;
}
}, new HeartbeatResponse(Errors.NONE), coordinator);
return heartbeatReceived;
}
use of java.util.concurrent.atomic.AtomicBoolean in project kafka by apache.
the class StreamTaskTest method shouldFlushRecordCollectorOnFlushState.
@Test
public void shouldFlushRecordCollectorOnFlushState() throws Exception {
final AtomicBoolean flushed = new AtomicBoolean(false);
final NoOpRecordCollector recordCollector = new NoOpRecordCollector() {
@Override
public void flush() {
flushed.set(true);
}
};
final StreamsMetrics streamsMetrics = new MockStreamsMetrics(new Metrics());
final StreamTask streamTask = new StreamTask(taskId00, "appId", partitions, topology, consumer, changelogReader, createConfig(baseDir), streamsMetrics, stateDirectory, testCache, time, recordCollector);
streamTask.flushState();
assertTrue(flushed.get());
}
use of java.util.concurrent.atomic.AtomicBoolean in project hive by apache.
the class TestTxnCommands2 method testAlterTable.
@Test
public void testAlterTable() throws Exception {
int[][] tableData = { { 1, 2 } };
runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b) " + makeValuesClause(tableData));
runStatementOnDriver("alter table " + Table.ACIDTBL + " compact 'MAJOR'");
Worker t = new Worker();
t.setThreadId((int) t.getId());
t.setHiveConf(hiveConf);
AtomicBoolean stop = new AtomicBoolean();
AtomicBoolean looped = new AtomicBoolean();
stop.set(true);
t.init(stop, looped);
t.run();
int[][] tableData2 = { { 5, 6 } };
runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b) " + makeValuesClause(tableData2));
List<String> rs1 = runStatementOnDriver("select a,b from " + Table.ACIDTBL + " where b > 0 order by a,b");
runStatementOnDriver("alter table " + Table.ACIDTBL + " add columns(c int)");
int[][] moreTableData = { { 7, 8, 9 } };
runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b,c) " + makeValuesClause(moreTableData));
List<String> rs0 = runStatementOnDriver("select a,b,c from " + Table.ACIDTBL + " where a > 0 order by a,b,c");
}
use of java.util.concurrent.atomic.AtomicBoolean in project hive by apache.
the class TestTxnCommands2 method runWorker.
public static void runWorker(HiveConf hiveConf) throws MetaException {
AtomicBoolean stop = new AtomicBoolean(true);
Worker t = new Worker();
t.setThreadId((int) t.getId());
t.setHiveConf(hiveConf);
AtomicBoolean looped = new AtomicBoolean();
t.init(stop, looped);
t.run();
}
Aggregations