Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 39d40ff

Browse files
bdevore17billkalter
authored andcommitted
Migration service + double writing (#120)
Delta block writing + service to migrate existing delta columns
1 parent eb6e6a7 commit 39d40ff

82 files changed

Lines changed: 6285 additions & 258 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

common/dropwizard/src/main/java/com/bazaarvoice/emodb/common/dropwizard/service/EmoServiceMode.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* A typical use case for this is running command-line tools, such as reports.</li>
2323
* <li>SCANNER:
2424
* Only services, tasks, and resources required to support the scan and upload server.</li>
25+
* <li>SCANNER:
26+
* Only services, tasks, and resources required to migrate all delta from old tables to new "blocked" tables.</li>
2527
* </ul>
2628
*/
2729
public enum EmoServiceMode {
@@ -95,6 +97,18 @@ public enum EmoServiceMode {
9597
Aspect.scanner,
9698
Aspect.security,
9799
Aspect.full_consistency
100+
),
101+
102+
DELTA_MIGRATOR(
103+
Aspect.web,
104+
Aspect.cache,
105+
Aspect.leader_control,
106+
Aspect.dataCenter,
107+
Aspect.dataStore_module,
108+
Aspect.blobStore_module, // needed for permission resolver
109+
Aspect.delta_migrator,
110+
Aspect.security,
111+
Aspect.full_consistency
98112
);
99113

100114
private final EnumSet<Aspect> aspects;
@@ -156,6 +170,7 @@ public enum Aspect {
156170
security,
157171
invalidation_cache_listener, // This makes sure the node is registered in zookeeper to invalidate its caches
158172
scanner(false),
173+
delta_migrator(false),
159174
swagger,
160175
uac;
161176

sdk/src/main/resources/emodb-default-config-ddl.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ systemOfRecord:
77
keyspace: ugc_global
88
table.audit: ugc_audit
99
table.delta: ugc_delta
10+
table.delta_v2: ugc_delta_v2
1011
table.history: ugc_history
1112
catalog_global:
1213
replicationFactor: 1
@@ -15,6 +16,7 @@ systemOfRecord:
1516
keyspace: catalog_global
1617
table.audit: cat_audit
1718
table.delta: cat_delta
19+
table.delta_v2: cat_delta_v2
1820
table.history: cat_history
1921
app_global:
2022
replicationFactor: 1
@@ -23,11 +25,13 @@ systemOfRecord:
2325
keyspace: app_global
2426
table.audit: default_audit
2527
table.delta: default_delta
28+
table.delta_v2: default_delta_v2
2629
table.history: default_history
2730
sys:
2831
keyspace: app_global
2932
table.audit: sys_audit
3033
table.delta: sys_delta
34+
table.delta_v2: sys_delta_v2
3135
table.history: sys_history
3236

3337
databus:

sor/src/main/java/com/bazaarvoice/emodb/sor/DataStoreConfiguration.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ public class DataStoreConfiguration {
6262
@JsonProperty("stashRoot")
6363
private Optional<String> _stashRoot = Optional.absent();
6464

65+
@Valid
66+
@NotNull
67+
@JsonProperty("migrationPhase")
68+
private DeltaMigrationPhase _migrationPhase = DeltaMigrationPhase.PRE_MIGRATION;
69+
70+
71+
/*
72+
Only temporarily configurable during the migration period
73+
*/
74+
@Valid
75+
@NotNull
76+
@JsonProperty
77+
private int _deltaBlockSizeInKb = 64;
78+
6579
public String getSystemTablePlacement() {
6680
return _systemTablePlacement;
6781
}
@@ -155,4 +169,12 @@ public DataStoreConfiguration setDeltaEncodingVersion(int deltaEncodingVersion)
155169
_deltaEncodingVersion = deltaEncodingVersion;
156170
return this;
157171
}
172+
173+
public DeltaMigrationPhase getMigrationPhase() {
174+
return _migrationPhase;
175+
}
176+
177+
public int getDeltaBlockSizeInKb() {
178+
return _deltaBlockSizeInKb;
179+
}
158180
}

sor/src/main/java/com/bazaarvoice/emodb/sor/DataStoreModule.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,7 @@
2424
import com.bazaarvoice.emodb.datacenter.api.KeyspaceDiscovery;
2525
import com.bazaarvoice.emodb.sor.admin.RowKeyTask;
2626
import com.bazaarvoice.emodb.sor.api.DataStore;
27-
import com.bazaarvoice.emodb.sor.core.AuditStore;
28-
import com.bazaarvoice.emodb.sor.core.DataProvider;
29-
import com.bazaarvoice.emodb.sor.core.DataStoreProviderProxy;
30-
import com.bazaarvoice.emodb.sor.core.DataTools;
31-
import com.bazaarvoice.emodb.sor.core.DefaultAuditStore;
32-
import com.bazaarvoice.emodb.sor.core.DefaultDataStore;
33-
import com.bazaarvoice.emodb.sor.core.DeltaHistoryTtl;
34-
import com.bazaarvoice.emodb.sor.core.LocalDataStore;
35-
import com.bazaarvoice.emodb.sor.core.StashRoot;
36-
import com.bazaarvoice.emodb.sor.core.SystemDataStore;
27+
import com.bazaarvoice.emodb.sor.core.*;
3728
import com.bazaarvoice.emodb.sor.db.astyanax.DAOModule;
3829
import com.bazaarvoice.emodb.sor.db.astyanax.DeltaPlacementFactory;
3930
import com.bazaarvoice.emodb.sor.db.cql.CqlForMultiGets;
@@ -237,6 +228,9 @@ protected void configure() {
237228
// Data tools used to generate reports
238229
bind(DataTools.class).to(DefaultDataStore.class);
239230
expose(DataTools.class);
231+
232+
bind(MigratorTools.class).to(DefaultMigratorTools.class);
233+
expose(MigratorTools.class);
240234
}
241235

242236
@Provides @Singleton
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.bazaarvoice.emodb.sor;
2+
3+
public enum DeltaMigrationPhase {
4+
PRE_MIGRATION(true, true, false),
5+
DOUBLE_WRITE_LEGACY_READ(true, true, true),
6+
DOUBLE_WRITE_BLOCKED_READ(false, true, true),
7+
FULLY_MIGRATED(false, false, true);
8+
9+
private final boolean _readFromLegacyDeltaTables;
10+
private final boolean _writeToLegacyDeltaTables;
11+
private final boolean _writeToBlockedDeltaTables;
12+
13+
DeltaMigrationPhase(boolean readFromLegacyDeltaTables, boolean writeToLegacyDeltaTables, boolean writeToBlockedDeltaTables) {
14+
_readFromLegacyDeltaTables = readFromLegacyDeltaTables;
15+
_writeToLegacyDeltaTables = writeToLegacyDeltaTables;
16+
_writeToBlockedDeltaTables = writeToBlockedDeltaTables;
17+
}
18+
19+
public boolean isReadFromLegacyDeltaTables() {
20+
return _readFromLegacyDeltaTables;
21+
}
22+
23+
public boolean isWriteToLegacyDeltaTables() {
24+
return _writeToLegacyDeltaTables;
25+
}
26+
27+
public boolean isWriteToBlockedDeltaTables() {
28+
return _writeToBlockedDeltaTables;
29+
}
30+
}

sor/src/main/java/com/bazaarvoice/emodb/sor/core/DataTools.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ public interface DataTools {
5050

5151
/** Return a consistent TableSet view of all tables in the system. */
5252
TableSet createTableSet();
53+
5354
}

sor/src/main/java/com/bazaarvoice/emodb/sor/core/DefaultDataStore.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,8 +823,6 @@ private void checkValidTableOrAttributeName(String tableOrAttribute, String name
823823

824824
}
825825

826-
827-
828826
@Override
829827
public URI getStashRoot()
830828
throws StashNotAvailableException {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.bazaarvoice.emodb.sor.core;
2+
3+
import com.bazaarvoice.emodb.sor.db.MigrationScanResult;
4+
import com.bazaarvoice.emodb.sor.db.MigratorReaderDAO;
5+
import com.bazaarvoice.emodb.sor.db.MigratorWriterDAO;
6+
import com.bazaarvoice.emodb.sor.db.ScanRange;
7+
import com.google.inject.Inject;
8+
9+
import java.util.Iterator;
10+
11+
import static com.google.common.base.Preconditions.checkNotNull;
12+
13+
public class DefaultMigratorTools implements MigratorTools {
14+
15+
private final MigratorReaderDAO _migratorReaderDao;
16+
private final MigratorWriterDAO _migratorWriterDao;
17+
18+
@Inject
19+
public DefaultMigratorTools(MigratorReaderDAO migratorReaderDAO, MigratorWriterDAO migratorWriterDAO) {
20+
_migratorReaderDao = checkNotNull(migratorReaderDAO, "migratorReaderDao");
21+
_migratorWriterDao = checkNotNull(migratorWriterDAO, "migratorWriterDao");
22+
}
23+
24+
public void writeRows(String placement, Iterator<MigrationScanResult> results, int maxConcurrentWrites) {
25+
checkNotNull(placement, "placement");
26+
checkNotNull(results, "rows");
27+
_migratorWriterDao.writeRows(placement, results, maxConcurrentWrites);
28+
}
29+
30+
public Iterator<MigrationScanResult> readRows(String placement, ScanRange scanRange) {
31+
checkNotNull(placement, "placement");
32+
checkNotNull(scanRange, scanRange);
33+
return _migratorReaderDao.readRows(placement, scanRange);
34+
}
35+
36+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.bazaarvoice.emodb.sor.core;
2+
3+
4+
import com.bazaarvoice.emodb.sor.db.MigrationScanResult;
5+
import com.bazaarvoice.emodb.sor.db.ScanRange;
6+
7+
import java.util.Iterator;
8+
9+
// interface to migrate deltas from old tables to new tables with blocking
10+
public interface MigratorTools {
11+
12+
void writeRows(String placement, Iterator<MigrationScanResult> results, int maxConcurrentWrites);
13+
14+
Iterator<MigrationScanResult> readRows(String placement, ScanRange scanRange);
15+
}

sor/src/main/java/com/bazaarvoice/emodb/sor/core/test/InMemoryDataStore.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.bazaarvoice.emodb.sor.core.test;
22

33
import com.bazaarvoice.emodb.sor.core.DefaultDataStore;
4-
import com.bazaarvoice.emodb.sor.db.test.InMemoryDataDAO;
4+
import com.bazaarvoice.emodb.sor.db.test.InMemoryDataReaderDAO;
55
import com.bazaarvoice.emodb.sor.log.NullSlowQueryLog;
66
import com.bazaarvoice.emodb.table.db.test.InMemoryTableDAO;
77
import com.codahale.metrics.MetricRegistry;
@@ -17,14 +17,14 @@
1717
public class InMemoryDataStore extends DefaultDataStore {
1818

1919
public InMemoryDataStore(MetricRegistry metricRegistry) {
20-
this(new InMemoryDataDAO(), metricRegistry);
20+
this(new InMemoryDataReaderDAO(), metricRegistry);
2121
}
2222

23-
public InMemoryDataStore(InMemoryDataDAO dataDao, MetricRegistry metricRegistry) {
23+
public InMemoryDataStore(InMemoryDataReaderDAO dataDao, MetricRegistry metricRegistry) {
2424
this(new EventBus(), dataDao, metricRegistry);
2525
}
2626

27-
public InMemoryDataStore(EventBus eventBus, InMemoryDataDAO dataDao, MetricRegistry metricRegistry) {
27+
public InMemoryDataStore(EventBus eventBus, InMemoryDataReaderDAO dataDao, MetricRegistry metricRegistry) {
2828
super(eventBus, new InMemoryTableDAO(), dataDao, dataDao,
2929
new NullSlowQueryLog(), MoreExecutors.sameThreadExecutor(), new InMemoryAuditStore(),
3030
Optional.<URI>absent(), metricRegistry);

0 commit comments

Comments
 (0)