1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.persistence.spi;
import com.yahoo.document.*;
import com.yahoo.document.fieldset.AllFields;
import com.yahoo.persistence.spi.*;
import com.yahoo.persistence.spi.result.*;
import java.util.ArrayList;
import java.util.List;
/**
* An abstract class that implements persistence provider functionality that some providers
* may not have use for.
*/
public abstract class AbstractPersistenceProvider implements PersistenceProvider {
@Override
public Result initialize() {
return new Result();
}
@Override
public PartitionStateListResult getPartitionStates() {
List<PartitionState> partitionStates = new ArrayList<PartitionState>();
partitionStates.add(new PartitionState(PartitionState.State.UP, ""));
return new PartitionStateListResult(partitionStates);
}
@Override
public Result setClusterState(ClusterState state) {
return new Result();
}
@Override
public Result setActiveState(Bucket bucket, BucketInfo.ActiveState active) {
return new Result();
}
@Override
public RemoveResult removeIfFound(Bucket bucket, long timestamp, DocumentId id) {
return remove(bucket, timestamp, id);
}
@Override
public Result removeEntry(Bucket bucket, long timestampToRemove) {
return new Result();
}
@Override
public Result flush(Bucket bucket) {
return new Result();
}
@Override
public BucketIdListResult getModifiedBuckets() {
return new BucketIdListResult(new ArrayList<BucketId>());
}
@Override
public Result maintain(Bucket bucket, MaintenanceLevel level) {
return new Result();
}
@Override
public Result move(Bucket bucket, short partitionId) {
return new Result();
}
@Override
public UpdateResult update(Bucket bucket, long timestamp, DocumentUpdate update) {
GetResult result = get(bucket, new AllFields(), update.getId());
if (result.wasFound()) {
Document doc = result.getDocument().clone();
update.applyTo(doc);
put(bucket, timestamp, doc);
return new UpdateResult(result.getLastModifiedTimestamp());
} else {
return new UpdateResult();
}
}
}
|