Skip to content

Commit ba0ea84

Browse files
committed
Remove option of setting null for init goal
1 parent 02a0357 commit ba0ea84

File tree

4 files changed

+17
-35
lines changed

4 files changed

+17
-35
lines changed

core/src/main/java/org/apache/accumulo/core/clientImpl/ImportConfigurationImpl.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class ImportConfigurationImpl implements ImportConfiguration, ImportConfi
2727
private boolean built = false;
2828
private boolean keepOffline = false;
2929
private boolean keepMappingsFile = false;
30-
private TabletHostingGoal initialHostingGoal = null;
30+
private TabletHostingGoal initialHostingGoal = TabletHostingGoal.ONDEMAND;
3131

3232
private final static String BUILT_ERROR_MSG = "ImportConfiguration was already built";
3333
private final static String NOT_BUILT_ERROR_MSG = "ImportConfiguration was not built yet";
@@ -48,6 +48,7 @@ public Builder setKeepMappings(boolean keepMappings) {
4848

4949
@Override
5050
public Builder setInitialHostingGoal(TabletHostingGoal initialTabletHostingGoal) {
51+
Preconditions.checkState(initialTabletHostingGoal != null, "initialTabletHostingGoal is null");
5152
Preconditions.checkState(!built, BUILT_ERROR_MSG);
5253
this.initialHostingGoal = initialTabletHostingGoal;
5354
return this;

core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1637,8 +1637,7 @@ public void importTable(String tableName, Set<String> importDirs, ImportConfigur
16371637
args.add(0, ByteBuffer.wrap(tableName.getBytes(UTF_8)));
16381638
args.add(1, ByteBuffer.wrap(Boolean.toString(keepOffline).getBytes(UTF_8)));
16391639
args.add(2, ByteBuffer.wrap(Boolean.toString(keepMapping).getBytes(UTF_8)));
1640-
args.add(3, ic.getInitialHostingGoal() == null ? EMPTY
1641-
: ByteBuffer.wrap(ic.getInitialHostingGoal().name().getBytes(UTF_8)));
1640+
args.add(3, ByteBuffer.wrap(ic.getInitialHostingGoal().name().getBytes(UTF_8)));
16421641
checkedImportDirs.stream().map(s -> s.getBytes(UTF_8)).map(ByteBuffer::wrap).forEach(args::add);
16431642

16441643
try {

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

+2-7
Original file line numberDiff line numberDiff line change
@@ -573,13 +573,8 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, Fate
573573
validateName(arguments.get(0), tableOp, NEW_TABLE_NAME.and(NOT_BUILTIN_TABLE));
574574
boolean keepOffline = Boolean.parseBoolean(ByteBufferUtil.toString(arguments.get(1)));
575575
boolean keepMappings = Boolean.parseBoolean(ByteBufferUtil.toString(arguments.get(2)));
576-
577-
TabletHostingGoal initialHostingGoal = null;
578-
String goalString = ByteBufferUtil.toString(arguments.get(3));
579-
goalString = StringUtils.defaultIfBlank(goalString, null);
580-
if (goalString != null) {
581-
initialHostingGoal = TabletHostingGoal.valueOf(goalString);
582-
}
576+
TabletHostingGoal initialHostingGoal =
577+
TabletHostingGoal.valueOf(ByteBufferUtil.toString(arguments.get(3)));
583578

584579
List<ByteBuffer> exportDirArgs =
585580
arguments.stream().skip(IMPORT_DIR_OFFSET + 1).collect(Collectors.toList());

server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/PopulateMetadataTable.java

+12-25
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ public Repo<Manager> call(long tid, Manager manager) throws Exception {
130130
int dirCount = 0;
131131

132132
TabletHostingGoal initialHostingGoal = tableInfo.initialHostingGoal;
133-
134-
boolean sawHostingGoal = false;
133+
if (initialHostingGoal == null) {
134+
log.error("Initial hosting goal is null and shouldn't be, defaulting to "
135+
+ TabletHostingGoal.ONDEMAND);
136+
initialHostingGoal = TabletHostingGoal.ONDEMAND;
137+
}
135138

136139
while (true) {
137140
key.readFields(in);
@@ -163,11 +166,8 @@ public Repo<Manager> call(long tid, Manager manager) throws Exception {
163166
if (m == null || !currentRow.equals(metadataRow)) {
164167

165168
if (m != null) {
166-
// if initial hosting goal was provided, use it, otherwise use ondemand
167-
TabletHostingGoal hostingGoal =
168-
(initialHostingGoal != null) ? initialHostingGoal : TabletHostingGoal.ONDEMAND;
169-
170-
HostingColumnFamily.GOAL_COLUMN.put(m, TabletHostingGoalUtil.toValue(hostingGoal));
169+
HostingColumnFamily.GOAL_COLUMN.put(m,
170+
TabletHostingGoalUtil.toValue(initialHostingGoal));
171171
mbw.addMutation(m);
172172
}
173173

@@ -180,30 +180,17 @@ public Repo<Manager> call(long tid, Manager manager) throws Exception {
180180
m = new Mutation(metadataRow);
181181
ServerColumnFamily.DIRECTORY_COLUMN.put(m, new Value(tabletDir));
182182
currentRow = metadataRow;
183-
sawHostingGoal = false;
184183
}
185184

186-
if (initialHostingGoal != null) {
187-
// add the initial hosting goal
188-
HostingColumnFamily.GOAL_COLUMN.put(m,
189-
TabletHostingGoalUtil.toValue(initialHostingGoal));
190-
sawHostingGoal = true;
191-
}
192-
if (HostingColumnFamily.GOAL_COLUMN.hasColumns(key)) {
193-
sawHostingGoal = true;
194-
}
185+
// add the initial hosting goal
186+
HostingColumnFamily.GOAL_COLUMN.put(m,
187+
TabletHostingGoalUtil.toValue(initialHostingGoal));
188+
195189
m.put(key.getColumnFamily(), cq, val);
196190

197191
if (endRow == null && TabletColumnFamily.PREV_ROW_COLUMN.hasColumns(key)) {
198-
199-
if (!sawHostingGoal) {
200-
// add a default hosting goal
201-
HostingColumnFamily.GOAL_COLUMN.put(m,
202-
TabletHostingGoalUtil.toValue(TabletHostingGoal.ONDEMAND));
203-
}
204-
205192
mbw.addMutation(m);
206-
break; // its the last column in the last row
193+
break; // it's the last column in the last row
207194
}
208195
}
209196
break;

0 commit comments

Comments
 (0)