Created
June 18, 2015 16:09
-
-
Save jsanda/ce07905fa9f16f13c661 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AlertsTest { | |
@Test | |
public void createAlerts() throws Exception { | |
initSession(); | |
PreparedStatement createAlert = session.prepare( | |
"INSERT INTO alerts (tenantId, alertId, payload) VALUES (?, ?, ?)"); | |
String tenantId = "alerts-tenant"; | |
int numAlerts = 100000000; | |
CountDownLatch latch = new CountDownLatch(numAlerts); | |
final Thread mainThread = Thread.currentThread(); | |
for (int i = 0; i < numAlerts; ++i) { | |
String alertId = "alert-" + i; | |
String payload = "payload-" + i; | |
ResultSetFuture future = session.executeAsync(createAlert.bind(tenantId, alertId, payload)); | |
Futures.addCallback(future, new FutureCallback<ResultSet>() { | |
@Override | |
public void onSuccess(ResultSet result) { | |
latch.countDown(); | |
} | |
@Override | |
public void onFailure(Throwable t) { | |
mainThread.interrupt(); | |
} | |
}); | |
} | |
latch.await(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment