6.3. Prioritizing Transactions at Runtime

Documentation

VoltDB Home » Documentation » Guide to Performance and Customization

6.3. Prioritizing Transactions at Runtime

You prioritize an individual transaction by specifying the priority as an option during the procedure call. Note that you must be using the new Client2 Java client API to do this. For example, to set the priority for the Vote procedure invocation to one (1), you create a Client2CallOptions object with the priority set to 1, then include it as the first argument to the procedure call:

Client2CallOptions voteprio = new Client2CallOptions()
                              .requestPriority(1);
CompletableFuture<void> votecf;

votecf = client.callProcedureAsync(voteprio, "Vote", 
             phonenum, contestant, maxvotes);

Similarly, if you want to assign the Report procedure a priority of five (5), you specify the priority in that procedure’s invocation option:

Client2CallOptions resultprio = new Client2CallOptions()
                              .requestPriority(5);
CompletableFuture<void> resultcf;

resultcf = client.callProcedureAsync(resultprio, "Results");

Alternately, you can leave off the priority parameter and let the invocation receive a default value. So, for example, you can set the default priority to five with the .requestPriority method as part of the client configuration, and use call options to raise the priority of calls to the Vote procedure:

Client2Config config = new Client2Config()
             .requestPriority(5);
Client2 client = ClientFactory.createClient(config);

    [ ... ]

votecf = client.callProcedureAsync(voteprio, "Vote", 
             phonenum, contestant, maxvotes);

resultcf = client.callProcedureAsync("Results");

It is important to note that you can and should reuse call options for multiple calls that require the same options, rather than creating a new Client2Calloptions object for each call.