How to use this function“Database Replicas” in the lastest couchbase lite 2.0


#1

From this content “Database Replicas
Database replicas is available in the Enterprise Edition only (https://www.couchbase.com/downloads). Starting in Couchbase Lite 2.0, replication between two local databases is now supported. It allows a Couchbase Lite replicator to store data on secondary storage. It would be especially useful in scenarios where a user’s device is damaged and the data needs to be moved to a different device. Note that the code below won’t compile if you’re running the Community Edition of Couchbase Lite.”,I don’t know how to use this function.


#2

Disclaimer: Enterprise edition features may only be used in production after purchasing an enterprise license.

When you create a ReplicatorConfiguration instead of URLEndpoint use DatabaseEndpoint


#3

thank you very much! i will try it!


#4

your way is ok, do not need an enterprise license. it is free in the android .


#5

What do you mean by free? The replica features require a license (legally, not technically) to be used in production. I imagine you installed the enterprise version of the library right? Check it’s license file.


#6

Couchbase Lite Enterprise Edition

In the top-level build.gradle file, add the following Couchbase Maven repository in the allprojects section.
allprojects {
repositories {
google()
jcenter()
maven {
url “http://mobile.maven.couchbase.com/maven2/dev/
}
}
}
Next, add the following in the dependencies section of the application’s build.gradle (the one in the app folder).
dependencies {
compile ‘com.couchbase.lite:couchbase-lite-android-ee:2.0.0’
}

that is ok.no need a license.

public static void copyDataBase()
{
DatabaseConfiguration config0 = new DatabaseConfiguration(mcontext);
File folder = new File(String.format("%s/SmartKitchen", Environment.getExternalStorageDirectory()));
config0.setDirectory(folder.getAbsolutePath());
Database dbTarget=null;
try {
dbTarget = new Database(“copyDB”, config0);
} catch (CouchbaseLiteException e) {
MyLog.e(“Database Init”+e.toString());
e.printStackTrace();
}
DatabaseEndpoint databaseEndpoint = new DatabaseEndpoint(dbTarget);
ReplicatorConfiguration config1 = new ReplicatorConfiguration(SrcDb, databaseEndpoint)
.setReplicatorType(ReplicatorConfiguration.ReplicatorType.PUSH)
.setContinuous(false);
Replicator replicator1 = new Replicator(config1);
replicator1.start();
}
my code will create a copyDB from srcDB


#7

Like I said, it is not a technical barrier but a legal one. A license cannot stop you from installing from maven central or JCenter or another maven feed as you have done (at least I don’t know of any way). However the fact that you have chosen “couchbase-lite-android-ee” instead of “couchbase-lite-android” means you have downloaded the Enterprise Edition, which is not free to use in production.

You can refer to this blog post which describes how Couchbase Server classifies its products. Mobile has now adopted the same with its 2.0 release. See the section “What is Enterprise Edition?”


#8

thank you borrrden. i will check this funtion in the 2.0 release .but I don’t feel it’s necessary to charge for this small function.


#9

There will be more and more EE features over time. This is just the first one that made it in. 2.1 will bring P2P replication and encryption, for example.

For others following the thread, here is the summary:

couchbase-lite-android is free to use for development and production
couchbase-lite-android-ee is free for development, but not free for production

The same goes for iOS and .NET


#10

thanks to borrrden, i get it!


#11

Just to re-iterate what @borrrden mentions, the LICENSE.TXT file in the Android package contains our Enterprise Edition License Agreement.