compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (6)

View Page History
The Java client library, and it's dependencies, will require changes to return the CAS value through the OperationStatus object.

The first approach is a synchronous (possibly the simplest from a developer viewpoint) approach
This allows specifying requirements across the cluster (2 persists and
2 replicas).

{code:java}
public enum PersistTo {
ZERO, ONE, TWO, THREE, FOUR
}


public enum ReplicateTo {
ZERO, ONE, TWO, THREE
}

try {
c1.set("a", 0 "foo", PersistTo.4); // this blocks until 4 copies persisted to disk
c1.set("b", 0, "foo", ReplicateTo.2); // this blocks until 2 replicas are complete
c2.add("c", 0, "foo", PersistTo.2, ReplicateTo.2); // this blocks until 2 copies persisted to disk and 2 replicas complete on cluster
} catch (ObservedException ex) {
// Warn if observe requirements are more stringent than bucket settings
} catch (ObservedTimeoutException ex) {
// do something
} catch (ObservedModifiedException ex) {
// do something
}

{code}

It's possible to take an asynchronous approach as well, but, the api usage becomes a bit
more involved.

The basic idea is that given the OperationStatus object (or optionally, multiple OperationStatus objects), an Observer can report on whether or not the operation has been replicated, persisted, or processed for indexing.


It's possible to do multiple operations asynchronously. However, the downside of this
approach is that it would not be possible to use multiple connections
(on different buckets) with different replication factors which makes it confusing.

{code}

Finally, a more synchronous (possibly the simplest from a developer viewpoint) approach
would involve. This allows specifying requirements across the cluster (2 disk writes and
2 replicas complete) or specifying requirements for just the master (should be persisted
to memory or to disk).

{code:java}
public enum PersistMemory {
ZERO, ONE, TWO, THREE, FOUR
}
There are pros and cons (as listed) to the different approaches. We will go with the
simplest approach with a likelihood of a course correction at some point.

public enum PersistDisk {
ZERO, ONE, TWO, THREE, FOUR
}

public enum Replica {
ZERO, ONE, TWO, THREE
}

// The persistenceRequirement takes in a tuple - persist to memory, persist to disk and replicas
// 0s are essentially treated as NoOps

// Persist 4 copies to disk and 3 replicas complete across cluster
clusterPersistenceRequirement cpr1 = new clusterPersistenceRequirement(
PersistMemory.ZERO, PersistDisk.FOUR, Replica.THREE);

// Persist 4 copies to memory (no disk requirement) and 3 replicas complete across cluster
clusterPersistenceRequirement cpr2 = new clusterPersistenceRequirement(
PersistMemory.FOUR, PersistDisk.ZERO, Replica.THREE);

// Persist 2 copies to disk and 2 replicas complete across cluster
clusterPersistenceRequirement cpr3 = new clusterPersistenceRequirement(
PersistMemory.ZERO, PersistDisk.TWO, Replica.TWO);

// masterPersistenceRequirement is based on persistence of master to memory and/or disk
// Persist Master to Disk - anything other than ZERO or ONE is deemed as ONE
masterPersistenceRequirement mpr = new masterPersistenceRequirement(
PersistMemory.ZERO, PersistDisk.ONE)

try {
c1.set("a", 0 "foo", cpr1); // this blocks until 4 copies persisted to disk and 3 replicas complete on cluster
c1.set("b", 0, "foo", cpr2); // this blocks until 4 copies persisted to memory and 3 replicas complete on cluster
c2.add("c", 0, "foo", cpr3); // this blocks until 2 copies persisted to disk and 2 replicas complete on cluster
c3.replace("d", 0, "foo", mpr); // this blocks until master is persisted on to disk
} catch (ObservedException ex) {
// Warn if observe requirements are more stringent than bucket settings
} catch (ObservedTimeoutException ex) {
// do something
} catch (ObservedModifiedException ex) {
// do something
}

{code}

There are pros and cons (as listed) to the different approaches. We need to possibly
pick an approach (for now) and keep ourselves open to alternate approaches for the
future.

h2. .NET