Skip to content

Commit 809648b

Browse files
committed
add configuration samples
1 parent 66159c0 commit 809648b

5 files changed

Lines changed: 150 additions & 1 deletion

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Created by https://www.gitignore.io
22

3+
### Gradle ###
4+
build/
5+
36
### Maven ###
47
target/
58
pom.xml.tag

README.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,63 @@
11
# couchbase-java-importer
2-
This is a pluggable importer for Couchbase
2+
3+
This is a pluggable importer for Couchbase. So far it supports importing documents from a CSV file, a MongoDB or CouchDB instance.
4+
5+
## How to Build
6+
7+
```
8+
$ ./gradlew build
9+
```
10+
11+
## How to Use
12+
13+
```
14+
$ cd build/distributions/
15+
$ unzip couchbase-java-importer.zip
16+
```
17+
18+
At this step you need to choose what kind of import you want to do. Configuration samples are available at the root of the repository. Let's pretend you want to import a MongoDB collection called `restaurants` from the database `test` and add a field called `couchbaseType` with the value `restaurant` for every imported documents. Let's also pretend you have a local MongoDB and local Couchbase instance. For that you would need the following configuration
19+
20+
```
21+
# Hostnames, comma separated list of Couchbase node IP or hostname
22+
hostnames: localhost,127.0.0.1
23+
# Buket name
24+
bucket: default
25+
# Bucket password
26+
password:
27+
# Log to write succesfully imported keys
28+
successLogFilename: succes.out
29+
# Log to write unsuccesfully imported keys
30+
errorLogFilename: error.out
31+
# Default RequestCancelledException delay in milliseconds and maximum number of retries
32+
requestCancelledExceptionDelay: 31000
33+
requestCancelledExceptionRetries: 100
34+
# Default TemporaryFailureException delay in milliseconds and maximum number of retries
35+
temporaryFailureExceptionDelay: 100
36+
temporaryFailureExceptionRetries: 100
37+
# Default upsert timeout in milliseconds
38+
importTimeout: 500
39+
# Choose between CSV, COUCHDB, MONGODB
40+
choosenImporter: MONGODB
41+
mongodb:
42+
# Give a valid connection string to connect to a MongoDB instance
43+
connectionString: "mongodb://127.0.0.1:27017/"
44+
# Name of the MondoDB database to connect to
45+
dbName: "test"
46+
# Name of the collection to import
47+
collectionName: "restaurants"
48+
# Couchbase does not have collection, we usually use a type field. As there could already be a type field in Mongo, you can specify another fieldName to be used as type
49+
typeField: "type"
50+
# type of the documents that will be imported
51+
type: "restaurant"
52+
```
53+
54+
This is the content of the MongoDB sample configuration. To run the import copy the configuration file and run the importer:
55+
56+
```
57+
$ cp ../../../application-mongodb.yml.sample application.yml
58+
$ ./bin/couchbase-java-importer
59+
```
60+
61+
Once the import as ran you should have one file called `success.out` that contains the id of every document imported. If something went wrong you should also have a file called `error.out`.
62+
63+
Every configuration samples contains comments that should help you understand the various import options.

application-couchdb.yml.sample

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Hostnames, comma separated list of Couchbase node IP or hostname
2+
hostnames: localhost,127.0.0.1
3+
# Buket name
4+
bucket: default
5+
# Bucket password
6+
password:
7+
# Log to write succesfully imported keys
8+
successLogFilename: succes.out
9+
# Log to write unsuccesfully imported keys
10+
errorLogFilename: error.out
11+
# Default RequestCancelledException delay in milliseconds and maximum number of retries
12+
requestCancelledExceptionDelay: 31000
13+
requestCancelledExceptionRetries: 100
14+
# Default TemporaryFailureException delay in milliseconds and maximum number of retries
15+
temporaryFailureExceptionDelay: 100
16+
temporaryFailureExceptionRetries: 100
17+
# Default upsert timeout in milliseconds
18+
importTimeout: 500
19+
# Choose between CSV, COUCHDB, JSON_GENERATOR
20+
choosenImporter: COUCHDB
21+
couchdb:
22+
# Download URL
23+
downloadURL: http://127.0.0.1:5984/database_export/_all_docs?include_docs=true

application-csv.yml.sample

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Hostnames, comma separated list of Couchbase node IP or hostname
2+
hostnames: localhost,127.0.0.1
3+
# Buket name
4+
bucket: default
5+
# Bucket password
6+
password:
7+
# Log to write succesfully imported keys
8+
successLogFilename: succes.out
9+
# Log to write unsuccesfully imported keys
10+
errorLogFilename: error.out
11+
# Default RequestCancelledException delay in milliseconds and maximum number of retries
12+
requestCancelledExceptionDelay: 31000
13+
requestCancelledExceptionRetries: 100
14+
# Default TemporaryFailureException delay in milliseconds and maximum number of retries
15+
temporaryFailureExceptionDelay: 100
16+
temporaryFailureExceptionRetries: 100
17+
# Default upsert timeout in milliseconds
18+
importTimeout: 500
19+
# Choose between CSV, COUCHDB, JSON_GENERATOR
20+
choosenImporter: CSV
21+
csv:
22+
# CSV Separating char for rows
23+
columnSeparator: ';'
24+
# CSV quotes
25+
quoteChar: ''
26+
# Path to the CSV file to import
27+
csvFilePath: /home/couchbase/csvimporter/advocates.csv
28+
# Skip the first line of the CSV for field names
29+
skipFirstLineForNames: true
30+
# Any format usable by the Java SimpleDateFormat Class
31+
dateFormat: EEE MMM dd HH:mm:ss z yyyy
32+
# Language tag used by Java's Locale class
33+
languageTag: FR_FR
34+
# Number of columns to import
35+
totalcolumns: 10
36+
# Column index to use the column value as id
37+
keyColumIndex: 0
38+
# The value of this field will be added as key prefix
39+
keyPrefix: "advocate::"
40+
#Give the type of the columns, could be String, Long, Double, Boolean, Date. Must be the exact same size as the number of columns in your file
41+
columType:
42+
- STRING
43+
- STRING
44+
- STRING
45+
- STRING
46+
- STRING
47+
- DATE
48+
- LONG
49+
# Choose the name of the fields for each column, mandatory if skipFirstLineForNames is set to true.
50+
columName:
51+
- id
52+
- type
53+
- firstname
54+
- lastname
55+
- location
56+
- creationDate
57+
- count

application-mongodb.yml.sample

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ importTimeout: 500
1919
# Choose between CSV, COUCHDB, MONGODB, JSON_GENERATOR
2020
choosenImporter: MONGODB
2121
mongodb:
22+
# Give a valid connection string to connect to a MongoDB instance
2223
connectionString: "mongodb://127.0.0.1:27017/"
24+
# Name of the MondoDB database to connect to
2325
dbName: "test"
26+
# Name of the collection to import
2427
collectionName: "restaurants"
28+
# Couchbase does not have collection, we usually use a type field. As there could already be a type field in Mongo, you can specify another fieldName to be used as type
2529
typeField: "type"
30+
# type of the documents that will be imported
2631
type: "restaurant"

0 commit comments

Comments
 (0)