GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||
GeezerVison is showing university.voltdb.com — 16.4. VoltDB Import Connectors Using VoltDB16.4. VoltDB Import ConnectorsJust as VoltDB can export data from selected streams and tables to external targets, it supports importing data into selected tables from external sources. Import works in two ways:
The following sections discuss these two approaches to data import. 16.4.1. Bulk Loading Data Using VoltDB Standalone UtilitiesOften, when migrating data from one database to another or when pre-loading a set of data into VoltDB as a starting point, you just want to perform the import once and then use the data natively within VoltDB. For these one-time uses, or when you prefer to manage the import process externally, VoltDB provides separate data loader utilities. Each data loader supports a different source format. You can load data from text files — such as comma-separated value (CSV) files — using the csvloader utility. You can load data from another JDBC-compliant database using the jdbcloader utility. Or you can load data from a streaming message service with the Kafka loader utility, kafkaloader. All of the data loaders operate in much the same way. For each utility you specify the source for the import and either a table that the data will be loaded into or a stored procedure that will be used to load the data. So, for example, to load records from a CSV file named staff.csv into the table EMPLOYEES, the command might be the following: $ csvloader employees --file=staff.csv If instead you are copying the data from a JDBC-compliant database, the command might look like this: $ jdbcloader employees \
--jdbcurl=jdbc:postgresql://remotesvr/corphr \
--jdbctable=employees \
--jdbcdriver=org.postgresql.DriverEach utility has arguments unique to the data source (such as 16.4.2. Streaming Import Using Built-in Import FeaturesIf importing data is an ongoing business process, rather than a one-time event, then it is desirable to make it an integral part of the database system. This can be done by building a custom application to push data into VoltDB using one of its standard APIs, such as the JDBC interface. Or you can take advantage of VoltDB's built-in import infrastructure. The built-in importers work in much the same way as the data loading utilities, where incoming data is written into one or more database tables using an existing stored procedure. The difference is that the built-in importers start automatically whenever the database starts and stop when the database stops, making import an integral part of the database process. You set up the built-in importers in the configuration the same way you configure export connections. Within the
deployment:
import:
configurations:
type: kafka
format: csv
enabled: true
properties:
- name: brokers
value: kafkasvr:9092
- name: topics
value: employees
- name: procedure
value: EMPLOYEE.insertWhen the database starts, the import infrastructure starts any enabled configurations. If you are importing multiple streams to separate tables through separate procedures, you must include multiple configurations, even if they come from the same source. For example, the following configuration imports data from two Kafka topics from the same Kafka servers into separate VoltDB tables. deployment:
import:
configurations:
- nickname: employees
type: kafka
format: csv
enabled: true
properties:
- name: brokers
value: kafkasvr:9092
- name: topics
value: employees
- name: procedure
value: EMPLOYEE.insert
- nickname: managers
type: kafka
format: csv
enabled: true
properties:
- name: brokers
value: kafkasvr:9092
- name: topics
value: managers
- name: procedure
value: MANAGER.insertNote the addition of the $ voltadmin set deployment.import.configurations[managers].enabled=false Without the nickname, you would have to update the entire database configuration to modify just one import connector. VoltDB currently provides support for a Kafka importer. It also supports two import formats: comma-separated values (csv) and tab-separated values (tsv). Comma-separated values are the default format. So if you are using CSV-formatted input, you can leave out the format attribute, as in the preceding example. The following sections describe the Kafka importer and the CSV/TSV formatter in more detail. 16.4.3. The Kafka ImporterThe Kafka importer connects to the specified Kafka messaging service and imports one or more Kafka topics and writes the records into the VoltDB database. The data is decoded according to the specified format — comma-separated values (CSV) by default — and is inserted into the VoltDB database using the specified stored procedure. The Kafka importer supports Kafka version 0.10 or later. You must specify at least the following properties for each configuration:
When import starts, the importer first checks to make sure the specified stored procedure exists in the database schema. If not (for example, when you first create a database and before a schema is loaded), the importer issues periodic warnings to the console. Once the specified stored procedure is declared, the importer looks for the specified Kafka brokers and topics. If the specified brokers cannot be found or the specified topics do not exist on the brokers, the importer reports an error and stops. You will need to restart import once this error condition is corrected. You can restart import using any of the following methods:
If the brokers are found and the topics exist, the importer starts fetching data from the Kafka topics and submitting it to the stored procedure to insert into the database. In the simplest case, you can use the default insert procedure for a table to insert records into a single table. For more complex data you can write your own import stored procedure to interpret the data and insert it into the appropriate table(s). Table 16.7, “Kafka Import Properties” lists the allowable properties for the Kafka importer. You can also specify properties associated with the formatter, as described in Table 16.8, “CSV and TSV Formatter Properties”. Table 16.7. Kafka Import Properties
| ||||||||||||||||||||||||
| 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. | ||||||||||||||||||||||||