Skip to content

Commit 934f9d3

Browse files
committed
Use DataLevel.USER.Name() vs hardcoded strings
Use the .Name() method for the DataLevel vs a hardcoded string value
1 parent f1413f8 commit 934f9d3

File tree

7 files changed

+25
-20
lines changed

7 files changed

+25
-20
lines changed

core/src/test/java/org/apache/accumulo/core/spi/balancer/GroupBalancerTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.apache.accumulo.core.manager.balancer.BalanceParamsImpl;
4141
import org.apache.accumulo.core.manager.balancer.TServerStatusImpl;
4242
import org.apache.accumulo.core.manager.balancer.TabletServerIdImpl;
43+
import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
4344
import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
4445
import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
4546
import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
@@ -123,8 +124,8 @@ public void balance(TabletBalancer balancer, int maxMigrations,
123124
new org.apache.accumulo.core.master.thrift.TabletServerStatus()));
124125
}
125126

126-
balancer.balance(
127-
new BalanceParamsImpl(current, migrations, migrationsOut, "USER", tablesToBalance));
127+
balancer.balance(new BalanceParamsImpl(current, migrations, migrationsOut,
128+
DataLevel.USER.name(), tablesToBalance));
128129

129130
assertTrue(migrationsOut.size() <= (maxMigrations + 5),
130131
"Max Migration exceeded " + maxMigrations + " " + migrationsOut.size());

core/src/test/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancerReconfigurationTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl;
4444
import org.apache.accumulo.core.manager.balancer.BalanceParamsImpl;
4545
import org.apache.accumulo.core.manager.balancer.TabletStatisticsImpl;
46+
import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
4647
import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
4748
import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
4849
import org.apache.accumulo.core.spi.balancer.data.TabletStatistics;
@@ -117,9 +118,9 @@ public void testConfigurationChanges() {
117118
// in the HostRegexTableLoadBalancer. For this test we want
118119
// to get into the out of bounds checking code, so we need to
119120
// populate the map with an older time value
120-
this.lastOOBCheckTimes.put("USER", System.currentTimeMillis() / 2);
121+
this.lastOOBCheckTimes.put(DataLevel.USER.name(), System.currentTimeMillis() / 2);
121122
this.balance(new BalanceParamsImpl(Collections.unmodifiableSortedMap(allTabletServers),
122-
migrations, migrationsOut, "USER", tables));
123+
migrations, migrationsOut, DataLevel.USER.name(), tables));
123124
assertEquals(5, migrationsOut.size());
124125
for (TabletMigration migration : migrationsOut) {
125126
assertTrue(migration.getNewTabletServer().getHost().startsWith("192.168.0.1")

core/src/test/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancerTest.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.apache.accumulo.core.manager.balancer.BalanceParamsImpl;
4949
import org.apache.accumulo.core.manager.balancer.TabletServerIdImpl;
5050
import org.apache.accumulo.core.manager.balancer.TabletStatisticsImpl;
51+
import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
5152
import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
5253
import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
5354
import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
@@ -97,7 +98,7 @@ public void testBalance() {
9798
List<TabletMigration> migrationsOut = new ArrayList<>();
9899
long wait =
99100
this.balance(new BalanceParamsImpl(Collections.unmodifiableSortedMap(createCurrent(15)),
100-
migrations, migrationsOut, "USER", environment.getTableIdMap()));
101+
migrations, migrationsOut, DataLevel.USER.name(), environment.getTableIdMap()));
101102
assertEquals(20000, wait);
102103
// should balance four tablets in one of the tables before reaching max
103104
assertEquals(4, migrationsOut.size());
@@ -108,7 +109,7 @@ public void testBalance() {
108109
}
109110
migrationsOut.clear();
110111
wait = this.balance(new BalanceParamsImpl(Collections.unmodifiableSortedMap(createCurrent(15)),
111-
migrations, migrationsOut, "USER", environment.getTableIdMap()));
112+
migrations, migrationsOut, DataLevel.USER.name(), environment.getTableIdMap()));
112113
assertEquals(20000, wait);
113114
// should balance four tablets in one of the other tables before reaching max
114115
assertEquals(4, migrationsOut.size());
@@ -119,7 +120,7 @@ public void testBalance() {
119120
}
120121
migrationsOut.clear();
121122
wait = this.balance(new BalanceParamsImpl(Collections.unmodifiableSortedMap(createCurrent(15)),
122-
migrations, migrationsOut, "USER", environment.getTableIdMap()));
123+
migrations, migrationsOut, DataLevel.USER.name(), environment.getTableIdMap()));
123124
assertEquals(20000, wait);
124125
// should balance four tablets in one of the other tables before reaching max
125126
assertEquals(4, migrationsOut.size());
@@ -130,7 +131,7 @@ public void testBalance() {
130131
}
131132
migrationsOut.clear();
132133
wait = this.balance(new BalanceParamsImpl(Collections.unmodifiableSortedMap(createCurrent(15)),
133-
migrations, migrationsOut, "USER", environment.getTableIdMap()));
134+
migrations, migrationsOut, DataLevel.USER.name(), environment.getTableIdMap()));
134135
assertEquals(20000, wait);
135136
// no more balancing to do
136137
assertEquals(0, migrationsOut.size());
@@ -147,7 +148,7 @@ public void testBalanceWithTooManyOutstandingMigrations() {
147148
migrations.addAll(tableTablets.get(BAR.getTableName()));
148149
long wait =
149150
this.balance(new BalanceParamsImpl(Collections.unmodifiableSortedMap(createCurrent(15)),
150-
migrations, migrationsOut, "USER", environment.getTableIdMap()));
151+
migrations, migrationsOut, DataLevel.USER.name(), environment.getTableIdMap()));
151152
assertEquals(20000, wait);
152153
// no migrations should have occurred as 10 is the maxOutstandingMigrations
153154
assertEquals(0, migrationsOut.size());
@@ -490,12 +491,12 @@ public void testOutOfBoundsTablets() {
490491
// in the HostRegexTableLoadBalancer. For this test we want
491492
// to get into the out of bounds checking code, so we need to
492493
// populate the map with an older time value
493-
this.lastOOBCheckTimes.put("USER", System.currentTimeMillis() / 2);
494+
this.lastOOBCheckTimes.put(DataLevel.USER.name(), System.currentTimeMillis() / 2);
494495
init(DEFAULT_TABLE_PROPERTIES);
495496
Set<TabletId> migrations = new HashSet<>();
496497
List<TabletMigration> migrationsOut = new ArrayList<>();
497-
this.balance(new BalanceParamsImpl(createCurrent(15), migrations, migrationsOut, "USER",
498-
environment.getTableIdMap()));
498+
this.balance(new BalanceParamsImpl(createCurrent(15), migrations, migrationsOut,
499+
DataLevel.USER.name(), environment.getTableIdMap()));
499500
assertEquals(2, migrationsOut.size());
500501
}
501502

core/src/test/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancerTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.apache.accumulo.core.manager.balancer.TabletServerIdImpl;
4343
import org.apache.accumulo.core.manager.balancer.TabletStatisticsImpl;
4444
import org.apache.accumulo.core.master.thrift.TableInfo;
45+
import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
4546
import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
4647
import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
4748
import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
@@ -178,7 +179,6 @@ SortedMap<TabletServerId,TServerStatus> getAssignments(Map<TabletServerId,FakeTS
178179

179180
@Test
180181
public void testUnevenAssignment() {
181-
182182
for (char c : "abcdefghijklmnopqrstuvwxyz".toCharArray()) {
183183
String cString = Character.toString(c);
184184
TabletServerId tsid = new TabletServerIdImpl("127.0.0.1", c, cString);
@@ -204,7 +204,7 @@ public void testUnevenAssignment() {
204204
while (true) {
205205
List<TabletMigration> migrationsOut = new ArrayList<>();
206206
balancer.balance(new BalanceParamsImpl(getAssignments(servers), migrations, migrationsOut,
207-
"USER", Map.of()));
207+
DataLevel.USER.name(), Map.of()));
208208
if (migrationsOut.isEmpty()) {
209209
break;
210210
}
@@ -247,7 +247,7 @@ public void testUnevenAssignment2() {
247247
while (true) {
248248
List<TabletMigration> migrationsOut = new ArrayList<>();
249249
balancer.balance(new BalanceParamsImpl(getAssignments(servers), migrations, migrationsOut,
250-
"USER", Map.of()));
250+
DataLevel.USER.name(), Map.of()));
251251
if (migrationsOut.isEmpty()) {
252252
break;
253253
}

core/src/test/java/org/apache/accumulo/core/spi/balancer/TableLoadBalancerTest.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.apache.accumulo.core.manager.balancer.TabletServerIdImpl;
4545
import org.apache.accumulo.core.manager.balancer.TabletStatisticsImpl;
4646
import org.apache.accumulo.core.master.thrift.TableInfo;
47+
import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
4748
import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
4849
import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
4950
import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
@@ -141,13 +142,15 @@ public void test() {
141142
List<TabletMigration> migrationsOut = new ArrayList<>();
142143
TableLoadBalancer tls = new TableLoadBalancer();
143144
tls.init(environment);
144-
tls.balance(new BalanceParamsImpl(state, migrations, migrationsOut, "USER", tableIdMap));
145+
tls.balance(
146+
new BalanceParamsImpl(state, migrations, migrationsOut, DataLevel.USER.name(), tableIdMap));
145147
assertEquals(0, migrationsOut.size());
146148

147149
state.put(mkts("10.0.0.2", 2345, "0x02030405"), status());
148150
tls = new TableLoadBalancer();
149151
tls.init(environment);
150-
tls.balance(new BalanceParamsImpl(state, migrations, migrationsOut, "USER", tableIdMap));
152+
tls.balance(
153+
new BalanceParamsImpl(state, migrations, migrationsOut, DataLevel.USER.name(), tableIdMap));
151154
int count = 0;
152155
Map<TableId,Integer> movedByTable = new HashMap<>();
153156
movedByTable.put(TableId.of(t1Id), 0);

server/manager/src/main/java/org/apache/accumulo/manager/Manager.java

-2
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ public static void main(String[] args) throws Exception {
416416

417417
protected Manager(ServerOpts opts, String[] args) throws IOException {
418418
super("manager", opts, args);
419-
420419
ServerContext context = super.getContext();
421420
balancerEnvironment = new BalancerEnvironmentImpl(context);
422421

@@ -1027,7 +1026,6 @@ private long balanceTablets() {
10271026
BalanceParamsImpl params = null;
10281027
long wait = 0;
10291028
long totalMigrationsOut = 0;
1030-
10311029
int levelsCompleted = 0;
10321030

10331031
for (DataLevel dl : DataLevel.values()) {

test/src/test/java/org/apache/accumulo/test/ChaoticLoadBalancerTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.apache.accumulo.core.manager.balancer.TabletServerIdImpl;
4141
import org.apache.accumulo.core.manager.balancer.TabletStatisticsImpl;
4242
import org.apache.accumulo.core.master.thrift.TableInfo;
43+
import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
4344
import org.apache.accumulo.core.spi.balancer.data.TServerStatus;
4445
import org.apache.accumulo.core.spi.balancer.data.TabletMigration;
4546
import org.apache.accumulo.core.spi.balancer.data.TabletServerId;
@@ -158,7 +159,7 @@ public void testUnevenAssignment() {
158159
List<TabletMigration> migrationsOut = new ArrayList<>();
159160
while (!migrationsOut.isEmpty()) {
160161
balancer.balance(new BalanceParamsImpl(getAssignments(servers), migrations, migrationsOut,
161-
"USER", Map.of()));
162+
DataLevel.USER.name(), Map.of()));
162163
}
163164
}
164165

0 commit comments

Comments
 (0)