GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.voltdb.com — 2.6. Putting it All Together Guide to Performance and Customization2.6. Putting it All TogetherNow that we have defined the schema, created the stored procedures and the callback routines for asynchronous calls, and created connections to all of the nodes in the cluster, we can put together the new and improved Hello World application. We start by loading the HELLOWORLD table just as we did in the previous version. Since this is only done once to initialize the run, we can make them synchronous calls. Note that we do not need to worry about constraint violations. If the client application is run two or more times, we can reuse the pre-loaded content. /*
* Load the database.
*/
try {
myApp.callProcedure("Insert", language[0], "Hello", "World");
myApp.callProcedure("Insert", language[1], "Bonjour", "Monde");
myApp.callProcedure("Insert", language[2], "Hola", "Mundo");
myApp.callProcedure("Insert", language[3], "Hej", "Verden");
myApp.callProcedure("Insert", language[4], "Ciao", "Mondo");
} catch (Exception e) {
// Not to worry. Ignore constraint violations if we
// load this table more than once.
}
To show off the performance, we then emulate the running system. We need some users. So, again, we initialize a few user records using the RegisterUser stored procedure. As a demonstration, we use a utility method for generating pseudo-random email addresses. /*
* Start by making sure there are at least 5 accounts
*/
while (maxaccountID < 5) {
String first = firstname[seed.nextInt(10)];
String last = lastname[seed.nextInt(10)];
String dialect = language[seed.nextInt(5)];
String email = generateEmail(maxaccountID);
myApp.callProcedure(new RegisterCallback(),"RegisterUser",
email,first,last,dialect );
maxaccountID++;
}
Finally, we want to repeatedly call the SignIn stored procedure, while occasionally registering a new user (say, once every 100 sign ins). /*
* Emulate a busy system: 100 signins for every 1 new registration.
* Run for 5 minutes.
*/
long countdowntimer = System.currentTimeMillis() + (60 * 1000 * 5);
while (countdowntimer > System.currentTimeMillis()) {
for (int i=0; i<100; i++) {
//int id = seed.nextInt(maxaccountID);
String user = generateEmail(seed.nextInt(maxaccountID));
myApp.callProcedure(new SignInCallback(), "SignIn",
user, System.currentTimeMillis()*1000);
}
String first = firstname[seed.nextInt(10)];
String last = lastname[seed.nextInt(10)];
String dialect = language[seed.nextInt(5)];
String email = generateEmail(maxaccountID);
myApp.callProcedure(new RegisterCallback(),"RegisterUser",
email,first,last,dialect);
maxaccountID++;
}
Note that the The completed source code can be found (and run) in the |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |