GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Documentation
  • Privacy Statement
  • License Agreement
  • Contact Us

This view

  • Original page
  • New address

GeezerVison is showing docs.voltactivedata.com — 5.3. Calling Procedures

  • Volt Active Data
  • Developer Hub
  • Books
    • VoltDB Tutorial
    • Using VoltDB
    • VoltDB Guide to Performance and Customization
    • VoltDB Administrator's Guide
    • Volt Kubernetes Administrator's Guide
    • VoltDB Quick Reference
  • VoltDB V16
    • VoltDB V16
    • VoltDB V15.3 LTS
    • VoltDB V14.3 LTS
    • VoltDB V13.3 LTS
    • VoltDB V12.3 LTS
    • VoltDB V11.4
    • VoltDB V10.2
    • VoltDB V9.3
5.3. Calling Procedures

Guide to Performance and Customization

  • Preface▶
    • 1. Organization of this Manual
    • 2. Other Resources
  • 1. Introduction▶
    • 1.1. What Affects Performance?
    • 1.2. How to Use This Book
  • 2. Hello, World! Revisited▶
    • 2.1. Optimizing your Application for VoltDB
    • 2.2. Applying Hello World to a Practical Problem
    • 2.3. Partitioned vs. Replicated Tables
      • 2.3.1. Defining the Partitioning Column
      • 2.3.2. Creating the Stored Procedures
    • 2.4. Using Asynchronous Stored Procedure Calls
      • 2.4.1. Understanding Asynchronous Programming
      • 2.4.2. The Callback Procedure
      • 2.4.3. Making an Asynchronous Procedure Call
    • 2.5. Connecting to all Servers
    • 2.6. Putting it All Together
    • 2.7. Next Steps
  • 3. Understanding VoltDB Execution Plans▶
    • 3.1. How VoltDB Selects Execution Plans for Individual SQL Statements
    • 3.2. Understanding VoltDB Execution Plans
    • 3.3. Reading the Execution Plan and Optimizing Your SQL Statements
      • 3.3.1. Evaluating the Use of Indexes
      • 3.3.2. Evaluating the Table Order for Joins
  • 4. Using Indexes Effectively▶
    • 4.1. Basic Principles for Effective Indexing
    • 4.2. Defining Indexes
    • 4.3. The Goals for Effective Indexing
    • 4.4. How Indexes Work
    • 4.5. Summary
  • 5. Client2, A Modern Java Client Programming Interface (API)▶
    • 5.1. Configuring the Client
    • 5.2. Connecting to the Database
    • 5.3. Calling Procedures
      • 5.3.1. Handling Backpressure
      • 5.3.2. Handling Request Timeouts
      • 5.3.3. Defining Options on a Per-Call Basis
  • 6. Creating Flexible Schemas With JSON▶
    • 6.1. Using JSON Data Structures as VoltDB Content
    • 6.2. Querying JSON Data
    • 6.3. Updating JSON Data
    • 6.4. Indexing JSON Fields
    • 6.5. Summary: Using JSON in VoltDB
  • 7. Creating Geospatial Applications▶
    • 7.1. The Geospatial Datatypes
      • 7.1.1. The GEOGRAPHY_POINT Datatype
      • 7.1.2. The GEOGRAPHY Datatype
      • 7.1.3. Sizing GEOGRAPHY Columns
      • 7.1.4. How Geospatial Values are Interpreted
    • 7.2. Entering Geospatial Data
    • 7.3. Working With Geospatial Data
      • 7.3.1. Working With Locations
      • 7.3.2. Working With Regions
  • 8. Creating Custom Importers, Exporters, and Formatters▶
    • 8.1. Writing a Custom Exporter
      • 8.1.1. The Structure and Workflow of the Export Client
      • 8.1.2. How to Use Custom Properties to Configure the Client
      • 8.1.3. How to Compile and Install the Client
      • 8.1.4. How to Configure the Export Client
    • 8.2. Writing a Custom Importer
      • 8.2.1. Designing and Coding a Custom Importer
      • 8.2.2. Packaging and Installing a Custom Importer
      • 8.2.3. Configuring and Running a Custom Importer
    • 8.3. Writing a Custom Formatter
      • 8.3.1. The Structure of the Custom Formatter
      • 8.3.2. Compiling and Packaging Custom Formatter Bundles
      • 8.3.3. Installing and Invoking Custom Formatters
      • 8.3.4. Using Custom Formatters With the kafkaloader Utility
  • 9. Creating Custom Tasks▶
    • 9.1. Overview of How Custom Tasks Work
    • 9.2. Modifying the Procedure Call and Arguments
      • 9.2.1. Designing a Java Class That Implements ActionGenerator
      • 9.2.2. Compiling and Loading the Class into VoltDB
      • 9.2.3. Declaring the Task
    • 9.3. Modifying the Interval Between Invocations
      • 9.3.1. Designing a Java Class That Implements IntervalGenerator
      • 9.3.2. Compiling and Loading the Class into VoltDB
      • 9.3.3. Declaring the Task
    • 9.4. Modifying Both the Procedure and Interval
      • 9.4.1. Designing a Java Class That Implements ActionScheduler
      • 9.4.2. Compiling and Loading the Class into VoltDB
      • 9.4.3. Declaring the Task
  • 10. Using Compound Procedures▶
    • 10.1. How Compound Procedures Work
    • 10.2. Defining the Compound Procedure
    • 10.3. Compiling and Loading the Compound Procedure
    • 10.4. Declaring the Compound Procedure
    • 10.5. Invoking the Compound Procedure
    • 10.6. Handling Errors
    • 10.7. Managing Compound Procedures and System Resources
  • 11. Understanding Memory Usage▶
    • 11.1. How the Database Uses Memory
    • 11.2. Actions that Impact Memory Usage
    • 11.3. How the Database Manages Memory
    • 11.4. How Memory is Allocated and Deallocated
    • 11.5. Controlling How Memory is Allocated and Used
      • 11.5.1. Managing the Java Heap
      • 11.5.2. Controlling the Compaction Process for Table Data
    • 11.6. Understanding Memory Usage for Specific Applications
  • 12. Managing Time▶
    • 12.1. The Importance of Time
    • 12.2. Using NTP to Manage Time
      • 12.2.1. Basic Configuration
      • 12.2.2. Troubleshooting Issues with Time
      • 12.2.3. Correcting Common Problems with Time
      • 12.2.4. Example NTP Configuration
    • 12.3. Configuring NTP in a Hosted, Virtual, or Cloud Environment
      • 12.3.1. Considerations for Hosted Environments
      • 12.3.2. Considerations for Virtual and Cloud Environments

5.3. Calling Procedures

Once the application connects to the database you are ready to make procedure calls. At its simplest, you can make a synchronous call that returns the traditional response object:

ClientResponse resp = client.callProcedureSync("AddUser", username, password);

However, asynchronous calls are where the new Client2 excels. Asynchronous calls return a CompletableFuture (a standard Java object) which can then be used to process the response. For example, you can assign different actions based on the results of the call:

CompletableFuture<ClientResponse> addUserCB;
addUserCB = client.callProcedure("AddUser",username,password);

addUserCB.whenComplete( (resp,th) -> processResponse( resp ) );

Alternately, it is possible to hand off the response to a processing thread:

client.callProcedureAsync("AddUser", username, password)
     .thenAcceptAsync((resp) -> processResponse(resp))
     .exceptionally((th) -> processException(th));

5.3.1. Handling Backpressure

The Client2 interface improves the handling of backpressure; that is, when requests are submitted faster than they can be processed. It is possible for an application to submit requests faster than the client API or the VoltDB server can handle them, particularly when using asynchronous calls. To handle this situation, the API tracks all pending requests: this includes requests queued in the API, requests in the network layer, and requests sent to the VoltDB cluster but which have not been completed yet. The application can configure three limits on the number of requests pending in the client:

  • A high and low watermark, set using .clientRequestBackpressureWarning. If the number of outstanding requests exceeds the high watermark, the application is notified to slow down. If the number of outstanding requests then falls below the low watermark, the application is notified that it can resume normal operation.

  • A maximum number of requests, set using .clientRequestLimit. Once the client reaches this limit, subsequent procedure invocations are rejected until the request count drops below the limit again.

Additionally, there is a configurable limit on the number of transactions that can be outstanding at the VoltDB cluster, set using .outstandingTransactionLimit. For example:

config.clientRequestBackpressureWarning(2500, 1000)
      .clientRequestLimit(3000)
      .outstandingTransactionLimit(1000);

This example defines the following rules:

  • When the number of pending requests goes up to 2500, the application is told to slow down. This is the high watermark.

  • When the number or requests falls to 1000 or below, the application is told it can resume normal operation. This is the low watermark.

  • If the number of pending requests exceeds 3000, callProcedure will refuse to accept any more requests.

  • If the number of outstanding requests submitted to the cluster without a response exceeds 1000, the client automatically adds additional requests to the client queue.

Notifications for the high and low watermarks are delivered to the application via a callback defined as part of the client configuration with the .requestBackpressureHandler() method:

config.requestBackpressureHandler(myQueueWarning);

If you want to provide additional context to the event handler, you can define the callback as a local function within a class and use the "this::" syntax, so the callback has access to any context available to the class:

config.requestBackpressureHandler(this::myBackpressureHandler);

The callback itself identifies the particular condition by way of a boolean argument it receives. For example:

void myQueueWarning (boolean watermark) { 
  if(watermark) { // high watermark
      [ ... ]
  } else {        // low watermark
      [ ... ]
  }
}

The argument is true when the request count has risen above the high watermark and false when it subsequently drops below the low watermark.

The client interface handles reaching the server limit internally. Once the server limit is reached, calls are queued locally until the high watermark is reached. Therefore, in the preceding example, the application can have a total of up to 2000 calls (3000 - 1000) pending transmission before the client refuses to queue any more.

5.3.2. Handling Request Timeouts

There are configurable limits for how long a request can be queued before it "times out". Requests can time out at the client before being sent to the server or after being sent. The error responses generated for these cases each have distinct status codes, allowing the application to easily identify each failure condition.

5.3.3. Defining Options on a Per-Call Basis

Some invocation attributes defined in the configuration by Client2Config can be overridden on a per-call basis by means of an options object. You create a new option object with Client2CallOptions, then apply it to a procedure call as the first argument. For example, the following code sets a call-specific timeout of 1,234 microseconds:

Client2CallOptions opts = new Client2CallOptions()
    .clientTimeout(1234, TimeUnit.MICROSECONDS);
addUserCB = callProcedureAsync(opts, "AddUser", username, password);

Options that are not specified in Client2CallOptions are defined by the configuration settings (or their defaults), so the interface is extensible without forcing application code changes.

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.