keith-turner commented on code in PR #3294:
URL: https://github.com/apache/accumulo/pull/3294#discussion_r1167226173
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java:
##########
@@ -1379,8 +1383,10 @@ private void waitForTableStateTransition(TableId
tableId, TableState expectedSta
for (TabletMetadata tablet : tablets) {
total++;
Location loc = tablet.getLocation();
+ TabletHostingGoal goal = tablet.getHostingGoal();
if ((expectedState == TableState.ONLINE
+ && (goal == TabletHostingGoal.ALWAYS || goal ==
TabletHostingGoal.ONDEMAND)
Review Comment:
This may wait for an ondemand tablet to have a location, which may never
happen. If so could add a qualification
```suggestion
&& (goal == TabletHostingGoal.ALWAYS || (goal ==
TabletHostingGoal.ONDEMAND && tablet.getHostingRequested()))
```
of remove the check of ondemand
```suggestion
&& goal == TabletHostingGoal.ALWAYS
```
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java:
##########
@@ -542,70 +556,95 @@ public TabletLocation locateTablet(ClientContext context,
Text row, boolean skip
}
@Override
- public long onDemandTabletsOnlined() {
- return onDemandTabletsOnlinedCount.get();
+ public long getTabletHostingRequestCount() {
+ return tabletHostingRequestCount.get();
}
- private void bringOnDemandTabletsOnline(ClientContext context, Range range)
- throws AccumuloException, AccumuloSecurityException {
+ @VisibleForTesting
+ public void resetTabletHostingRequestCount() {
+ tabletHostingRequestCount.set(0);
+ }
- // Confirm that table is in an on-demand state. Don't throw an exception
- // if the table is not found, calling code will already handle it.
- try {
- String tableName = context.getTableName(tableId);
- if (!context.tableOperations().isOnDemand(tableName)) {
- log.trace("bringOnDemandTabletsOnline: table {} is not in ondemand
state", tableId);
- return;
- }
- } catch (TableNotFoundException e) {
- log.trace("bringOnDemandTabletsOnline: table not found: {}", tableId);
+ @VisibleForTesting
+ public void enableTabletHostingRequests(boolean enabled) {
+ HOSTING_ENABLED.set(enabled);
+ }
+
+ private void requestTabletHosting(ClientContext context, Range range)
+ throws AccumuloException, AccumuloSecurityException,
TableNotFoundException {
+
+ if (!HOSTING_ENABLED.get()) {
+ return;
+ }
+
+ // System tables should always be hosted
+ if (RootTable.ID == tableId || MetadataTable.ID == tableId) {
+ return;
+ }
+
+ String tableName = context.getTableName(tableId);
+ if (!context.tableOperations().isOnline(tableName)) {
+ log.trace("requestTabletHosting: table {} is not online", tableId);
return;
}
- final Text scanRangeStart = range.getStartKey().getRow();
- final Text scanRangeEnd = range.getEndKey().getRow();
- // Turn the scan range into a KeyExtent and bring online all ondemand
tablets
+ List<TKeyExtent> extentsToBringOnline =
+ findExtentsForRange(context, tableId, range,
Set.of(TabletHostingGoal.NEVER), true);
+ if (extentsToBringOnline.isEmpty()) {
+ return;
+ }
+ log.debug("Requesting tablets be hosted: {}", extentsToBringOnline);
+ ThriftClientTypes.TABLET_MGMT.executeVoid(context,
+ client -> client.requestTabletHosting(TraceUtil.traceInfo(),
context.rpcCreds(),
+ tableId.canonical(), extentsToBringOnline));
+ tabletHostingRequestCount.addAndGet(extentsToBringOnline.size());
+ }
+
+ public static List<TKeyExtent> findExtentsForRange(ClientContext context,
TableId tableId,
+ Range range, Set<TabletHostingGoal> disallowedStates, boolean
excludeHostedTablets)
+ throws AccumuloException {
+
+ final Text scanRangeStart = (range.getStartKey() == null) ? null :
range.getStartKey().getRow();
+ final Text scanRangeEnd = (range.getEndKey() == null) ? null :
range.getEndKey().getRow();
+ // Turn the scan range into a KeyExtent and return all tablets
// that are overlapped by the scan range
final KeyExtent scanRangeKE = new KeyExtent(tableId, scanRangeEnd,
scanRangeStart);
- List<TKeyExtent> extentsToBringOnline = new ArrayList<>();
+ List<TKeyExtent> extents = new ArrayList<>();
TabletsMetadata m = context.getAmple().readTablets().forTable(tableId)
.overlapping(scanRangeStart, true, null).build();
for (TabletMetadata tm : m) {
+ if (disallowedStates.contains(tm.getHostingGoal())) {
+ throw new AccumuloException("Range: " + range + " includes tablet: " +
tm.getExtent()
+ + " that is not in an allowable state for hosting");
+ }
final KeyExtent tabletExtent = tm.getExtent();
log.trace("Evaluating tablet {} against range {}", tabletExtent,
scanRangeKE);
- if (tm.getEndRow() != null && tm.getEndRow().compareTo(scanRangeStart) <
0) {
+ if (scanRangeStart != null && tm.getEndRow() != null
+ && tm.getEndRow().compareTo(scanRangeStart) < 0) {
// the end row of this tablet is before the start row, skip it
log.trace("tablet {} is before scan start range: {}", tabletExtent,
scanRangeStart);
continue;
}
- if (tm.getPrevEndRow() != null &&
tm.getPrevEndRow().compareTo(scanRangeEnd) > 0) {
+ if (scanRangeEnd != null && tm.getPrevEndRow() != null
+ && tm.getPrevEndRow().compareTo(scanRangeEnd) > 0) {
// the start row of this tablet is after the scan range end row, skip
it
log.trace("tablet {} is after scan end range: {}", tabletExtent,
scanRangeEnd);
continue;
Review Comment:
Could this break out of the loop? Maybe be able to set an end row on the
overlapping call to ample above.
```suggestion
break;
```
##########
server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java:
##########
@@ -201,7 +203,9 @@ public List<Short> check(Environment env, Mutation
mutation) {
}
if (columnUpdate.getValue().length == 0 &&
!columnFamily.equals(ScanFileColumnFamily.NAME)
- && !columnFamily.equals(OnDemandAssignmentStateColumnFamily.NAME)) {
+ &&
!(columnFamily.equals(HostingColumnFamily.REQUESTED_COLUMN.getColumnFamily())
+ && columnQualifier
+
.equals(HostingColumnFamily.REQUESTED_COLUMN.getColumnQualifier()))) {
Review Comment:
This can be shortened.
```suggestion
&&
!HostingColumnFamily.REQUESTED_COLUMN.equals(columnFamily,columnQualifier)) {
```
##########
test/src/main/java/org/apache/accumulo/test/functional/ManagerAssignmentIT.java:
##########
@@ -73,26 +77,43 @@ public static void beforeAll() throws Exception {
cfg.setNumTservers(1);
cfg.setProperty(Property.TSERV_ASSIGNMENT_MAXCONCURRENT, "10");
cfg.setProperty(Property.GENERAL_THREADPOOL_SIZE, "10");
- cfg.setProperty(Property.MANAGER_TABLET_GROUP_WATCHER_INTERVAL, "5");
+ cfg.setProperty(Property.MANAGER_TABLET_GROUP_WATCHER_INTERVAL, "5s");
+ cfg.setProperty(Property.TSERV_ONDEMAND_UNLOADER_INTERVAL, "10s");
+
cfg.setProperty("table.custom.ondemand.unloader.inactivity.threshold.seconds",
"15");
});
}
@Test
public void test() throws Exception {
try (AccumuloClient c =
Accumulo.newClient().from(getClientProps()).build()) {
+
+ // Confirm that the root and metadata tables are hosted
+ Locations locs =
+ c.tableOperations().locate(RootTable.NAME,
Collections.singletonList(new Range()));
+ locs.groupByTablet().keySet().forEach(tid ->
assertNotNull(locs.getTabletLocation(tid)));
+
+ Locations locs2 =
+ c.tableOperations().locate(MetadataTable.NAME,
Collections.singletonList(new Range()));
+ locs2.groupByTablet().keySet().forEach(tid ->
assertNotNull(locs2.getTabletLocation(tid)));
+
String tableName = super.getUniqueNames(1)[0];
c.tableOperations().create(tableName);
+
String tableId = c.tableOperations().tableIdMap().get(tableName);
- // wait for the table to be online
+
+ // wait for the tablet to exist in the metadata table. The tablet
+ // will not be hosted so the current location will be empty.
TabletLocationState newTablet;
do {
UtilWaitThread.sleep(250);
newTablet = getTabletLocationState(c, tableId);
- } while (newTablet.current == null);
+ } while (newTablet.extent == null);
Review Comment:
It would be a follow on issue. These loops could be shortened using the new
o.a.a.test.util.Wait class.
##########
core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletsMetadata.java:
##########
@@ -283,6 +283,9 @@ public Options fetch(ColumnType... colsToFetch) {
case FLUSH_ID:
qualifiers.add(FLUSH_COLUMN);
break;
+ case HOSTING_GOAL:
+ families.add(HostingColumnFamily.NAME);
+ break;
Review Comment:
```suggestion
case HOSTING_GOAL:
qualifiers.add(HostingColumnFamily.GOAL_COLUMN);
break;
case HOSTING_REQUESTED:
qualifiers.add(HostingColumnFamily.REQUESTED_COLUMN);
break;
```
##########
server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java:
##########
@@ -100,7 +101,7 @@ public class MetadataConstraints implements Constraint {
ChoppedColumnFamily.NAME,
ClonedColumnFamily.NAME,
ExternalCompactionColumnFamily.NAME,
- OnDemandAssignmentStateColumnFamily.NAME);
+ HostingColumnFamily.NAME);
Review Comment:
Instead of adding this, could add HostingColumnFamily.GOAL_COLUMN and
HostingColumnFamily.REQUESTED_COLUMN to the Set validColumnQuals above.
##########
server/base/src/main/java/org/apache/accumulo/server/metadata/TabletMutatorBase.java:
##########
@@ -269,18 +273,28 @@ protected Mutation getMutation() {
}
@Override
- public T putOnDemand() {
- mutation.put(OnDemandAssignmentStateColumnFamily.STR_NAME, "", "");
+ public T setHostingGoal(TabletHostingGoal goal) {
+ mutation.put(HostingColumnFamily.GOAL_COLUMN.getColumnFamily(),
+ HostingColumnFamily.GOAL_COLUMN.getColumnQualifier(),
TabletHostingGoalUtil.toValue(goal));
Review Comment:
```suggestion
HostingColumnFamily.GOAL_COLUMN.put(mutation,
TabletHostingGoalUtil.toValue(goal));
```
##########
core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataSchema.java:
##########
@@ -357,10 +358,18 @@ public static class ExternalCompactionColumnFamily {
public static final Text NAME = new Text(STR_NAME);
}
- public static class OnDemandAssignmentStateColumnFamily {
- public static final String STR_NAME = "ondemand";
+ public static class HostingColumnFamily {
+ public static final String STR_NAME = "hosting";
public static final Text NAME = new Text(STR_NAME);
+ public static final String GOAL_QUAL = "goal";
+ public static final ColumnFQ GOAL_COLUMN = new ColumnFQ(NAME, new
Text(GOAL_QUAL));
+ public static final String ALWAYS_GOAL = TabletHostingGoal.ALWAYS.name();
+ public static final String ONDEMAND_GOAL =
TabletHostingGoal.ONDEMAND.name();
+ public static final String NEVER_GOAL = TabletHostingGoal.NEVER.name();
Review Comment:
The way the are used I think they could be inlined
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java:
##########
@@ -1399,7 +1405,8 @@ private void waitForTableStateTransition(TableId tableId,
TableState expectedSta
"Saw unexpected table Id " + tableId + " " + tablet.getExtent());
}
- if (lastExtent != null &&
!tablet.getExtent().isPreviousExtent(lastExtent)) {
+ if (expectedState == TableState.OFFLINE && lastExtent != null
Review Comment:
Why was the check for offline added? I think this code is trying to detect
holes in the metadata table to know that maybe it did not see every tablet.
Would be another PR, but may be able to add checkConsistency() call when
building ample that should avoid holes.
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java:
##########
@@ -542,70 +556,95 @@ public TabletLocation locateTablet(ClientContext context,
Text row, boolean skip
}
@Override
- public long onDemandTabletsOnlined() {
- return onDemandTabletsOnlinedCount.get();
+ public long getTabletHostingRequestCount() {
+ return tabletHostingRequestCount.get();
}
- private void bringOnDemandTabletsOnline(ClientContext context, Range range)
- throws AccumuloException, AccumuloSecurityException {
+ @VisibleForTesting
+ public void resetTabletHostingRequestCount() {
+ tabletHostingRequestCount.set(0);
+ }
- // Confirm that table is in an on-demand state. Don't throw an exception
- // if the table is not found, calling code will already handle it.
- try {
- String tableName = context.getTableName(tableId);
- if (!context.tableOperations().isOnDemand(tableName)) {
- log.trace("bringOnDemandTabletsOnline: table {} is not in ondemand
state", tableId);
- return;
- }
- } catch (TableNotFoundException e) {
- log.trace("bringOnDemandTabletsOnline: table not found: {}", tableId);
+ @VisibleForTesting
+ public void enableTabletHostingRequests(boolean enabled) {
+ HOSTING_ENABLED.set(enabled);
+ }
+
+ private void requestTabletHosting(ClientContext context, Range range)
+ throws AccumuloException, AccumuloSecurityException,
TableNotFoundException {
+
+ if (!HOSTING_ENABLED.get()) {
+ return;
+ }
+
+ // System tables should always be hosted
+ if (RootTable.ID == tableId || MetadataTable.ID == tableId) {
+ return;
+ }
+
+ String tableName = context.getTableName(tableId);
+ if (!context.tableOperations().isOnline(tableName)) {
+ log.trace("requestTabletHosting: table {} is not online", tableId);
return;
}
- final Text scanRangeStart = range.getStartKey().getRow();
- final Text scanRangeEnd = range.getEndKey().getRow();
- // Turn the scan range into a KeyExtent and bring online all ondemand
tablets
+ List<TKeyExtent> extentsToBringOnline =
+ findExtentsForRange(context, tableId, range,
Set.of(TabletHostingGoal.NEVER), true);
+ if (extentsToBringOnline.isEmpty()) {
+ return;
+ }
+ log.debug("Requesting tablets be hosted: {}", extentsToBringOnline);
+ ThriftClientTypes.TABLET_MGMT.executeVoid(context,
+ client -> client.requestTabletHosting(TraceUtil.traceInfo(),
context.rpcCreds(),
+ tableId.canonical(), extentsToBringOnline));
+ tabletHostingRequestCount.addAndGet(extentsToBringOnline.size());
+ }
+
+ public static List<TKeyExtent> findExtentsForRange(ClientContext context,
TableId tableId,
+ Range range, Set<TabletHostingGoal> disallowedStates, boolean
excludeHostedTablets)
+ throws AccumuloException {
+
+ final Text scanRangeStart = (range.getStartKey() == null) ? null :
range.getStartKey().getRow();
+ final Text scanRangeEnd = (range.getEndKey() == null) ? null :
range.getEndKey().getRow();
Review Comment:
When a range is [created for
rows](https://github.com/apache/accumulo/blob/30d823def879234b4f390f7b816cef670d477f88/core/src/main/java/org/apache/accumulo/core/data/Range.java#L115-L124),
it seems the end row will always exclusive. However when a ranges is created
from a key this may not be the case. Determining inclusive vs exclusive of the
end row coming from a range seems a bit tricky, it could be determined with
custom code.
##########
server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java:
##########
@@ -231,7 +232,9 @@ enum CompactionState {
private final ConcurrentHashMap<Long,List<TabletFile>> bulkImported = new
ConcurrentHashMap<>();
private final int logId;
- private final boolean onDemand;
+
+ // TODO: User can change this, how does it get updated?
Review Comment:
Need to create a follow on issue before merging.
##########
server/base/src/main/java/org/apache/accumulo/server/metadata/TabletMutatorBase.java:
##########
@@ -269,18 +273,28 @@ protected Mutation getMutation() {
}
@Override
- public T putOnDemand() {
- mutation.put(OnDemandAssignmentStateColumnFamily.STR_NAME, "", "");
+ public T setHostingGoal(TabletHostingGoal goal) {
+ mutation.put(HostingColumnFamily.GOAL_COLUMN.getColumnFamily(),
+ HostingColumnFamily.GOAL_COLUMN.getColumnQualifier(),
TabletHostingGoalUtil.toValue(goal));
+ return getThis();
+ }
+
+ @Override
+ public T setHostingRequested() {
+ mutation.put(HostingColumnFamily.REQUESTED_COLUMN.getColumnFamily(),
+ HostingColumnFamily.REQUESTED_COLUMN.getColumnQualifier(),
EMPTY_VALUE);
Review Comment:
```suggestion
HostingColumnFamily.REQUESTED_COLUMN.put(mutation, EMPTY_VALUE);
```
##########
server/base/src/main/java/org/apache/accumulo/server/metadata/TabletMutatorBase.java:
##########
@@ -269,18 +273,28 @@ protected Mutation getMutation() {
}
@Override
- public T putOnDemand() {
- mutation.put(OnDemandAssignmentStateColumnFamily.STR_NAME, "", "");
+ public T setHostingGoal(TabletHostingGoal goal) {
+ mutation.put(HostingColumnFamily.GOAL_COLUMN.getColumnFamily(),
+ HostingColumnFamily.GOAL_COLUMN.getColumnQualifier(),
TabletHostingGoalUtil.toValue(goal));
+ return getThis();
+ }
+
+ @Override
+ public T setHostingRequested() {
+ mutation.put(HostingColumnFamily.REQUESTED_COLUMN.getColumnFamily(),
+ HostingColumnFamily.REQUESTED_COLUMN.getColumnQualifier(),
EMPTY_VALUE);
return getThis();
}
@Override
- public T deleteOnDemand() {
- mutation.putDelete(OnDemandAssignmentStateColumnFamily.STR_NAME, "");
+ public T deleteHostingRequested() {
+ mutation.putDelete(HostingColumnFamily.REQUESTED_COLUMN.getColumnFamily(),
+ HostingColumnFamily.REQUESTED_COLUMN.getColumnQualifier());
Review Comment:
```suggestion
HostingColumnFamily.REQUESTED_COLUMN.putDelete(mutation);
```
##########
server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java:
##########
@@ -215,9 +219,16 @@ public List<Short> check(Environment env, Mutation
mutation) {
} catch (NumberFormatException | ArrayIndexOutOfBoundsException nfe) {
violations = addViolation(violations, 1);
}
- } else if (columnFamily.equals(ScanFileColumnFamily.NAME)) {} else if
(columnFamily
- .equals(OnDemandAssignmentStateColumnFamily.NAME)) {} else if
(columnFamily
- .equals(BulkFileColumnFamily.NAME)) {
+ } else if (columnFamily.equals(ScanFileColumnFamily.NAME)) {
+
+ } else if
(columnFamily.equals(HostingColumnFamily.GOAL_COLUMN.getColumnFamily())
+ &&
columnQualifier.equals(HostingColumnFamily.GOAL_COLUMN.getColumnQualifier())) {
Review Comment:
This can be shortened
```suggestion
} else if
(HostingColumnFamily.GOAL_COLUMN.equals(columnFamily,columnQualifier)) {
```
##########
server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java:
##########
@@ -1450,7 +1453,7 @@ public void evaluateOnDemandTabletsForUnload() {
unloaders.get(tid).evaluate(params);
onDemandTabletsToUnload.forEach(ke -> {
log.debug("Unloading on-demand tablet: {} for table: {}", ke, tid);
- getContext().getAmple().mutateTablet(ke).deleteOnDemand().mutate();
+
getContext().getAmple().mutateTablet(ke).deleteHostingRequested().mutate();
Review Comment:
Can use one batchwriter for all updates.
```java
try(var tabletsMutator = getContext().getAmple().mutateTablets()) {
onDemandTabletsToUnload.forEach(ke -> {
log.debug("Unloading on-demand tablet: {} for table: {}", ke, tid);
tabletsMutator.mutateTablet(ke).deleteHostingRequested().mutate();
});
}
```
##########
test/src/main/java/org/apache/accumulo/test/functional/ManagerAssignmentIT.java:
##########
@@ -102,86 +123,140 @@ public void test() throws Exception {
c.tableOperations().flush(tableName, null, null, true);
TabletLocationState flushed = getTabletLocationState(c, tableId);
- assertEquals(newTablet.current, flushed.current);
+ assertNotNull(flushed.current);
assertEquals(flushed.getCurrentServer(), flushed.getLastServer());
assertNull(newTablet.future);
+ assertEquals(TabletHostingGoal.ONDEMAND, flushed.goal);
// take the tablet offline
c.tableOperations().offline(tableName, true);
TabletLocationState offline = getTabletLocationState(c, tableId);
assertNull(offline.future);
assertNull(offline.current);
assertEquals(flushed.getCurrentServer(), offline.getLastServer());
+ assertEquals(TabletHostingGoal.ONDEMAND, offline.goal);
// put it back online
c.tableOperations().online(tableName, true);
TabletLocationState online = getTabletLocationState(c, tableId);
assertNull(online.future);
assertNotNull(online.current);
assertEquals(online.getCurrentServer(), online.getLastServer());
+ assertEquals(TabletHostingGoal.ONDEMAND, online.goal);
- // take the tablet offline
- c.tableOperations().offline(tableName, true);
- offline = getTabletLocationState(c, tableId);
- assertNull(offline.future);
- assertNull(offline.current);
- assertEquals(flushed.getCurrentServer(), offline.getLastServer());
+ // set the hosting goal to always
+ c.tableOperations().setTabletHostingGoal(tableName, new Range(),
TabletHostingGoal.ALWAYS);
+ TabletLocationState always;
+ do {
+ UtilWaitThread.sleep(250);
+ always = getTabletLocationState(c, tableId);
+ } while (always.goal == TabletHostingGoal.ONDEMAND);
+
+ assertNull(always.future);
+ assertNotNull(always.current);
+ assertEquals(flushed.getCurrentServer(), always.getLastServer());
+ assertEquals(TabletHostingGoal.ALWAYS, always.goal);
+
+ // set the hosting goal to never
+ c.tableOperations().setTabletHostingGoal(tableName, new Range(),
TabletHostingGoal.NEVER);
+ TabletLocationState never;
+ do {
+ UtilWaitThread.sleep(250);
+ never = getTabletLocationState(c, tableId);
+ } while (never.goal == TabletHostingGoal.ALWAYS);
Review Comment:
```suggestion
} while (never.goal != TabletHostingGoal.NEVER);
```
##########
test/src/main/java/org/apache/accumulo/test/functional/ManagerAssignmentIT.java:
##########
@@ -102,86 +123,140 @@ public void test() throws Exception {
c.tableOperations().flush(tableName, null, null, true);
TabletLocationState flushed = getTabletLocationState(c, tableId);
- assertEquals(newTablet.current, flushed.current);
+ assertNotNull(flushed.current);
assertEquals(flushed.getCurrentServer(), flushed.getLastServer());
assertNull(newTablet.future);
+ assertEquals(TabletHostingGoal.ONDEMAND, flushed.goal);
// take the tablet offline
c.tableOperations().offline(tableName, true);
TabletLocationState offline = getTabletLocationState(c, tableId);
assertNull(offline.future);
assertNull(offline.current);
assertEquals(flushed.getCurrentServer(), offline.getLastServer());
+ assertEquals(TabletHostingGoal.ONDEMAND, offline.goal);
// put it back online
c.tableOperations().online(tableName, true);
TabletLocationState online = getTabletLocationState(c, tableId);
assertNull(online.future);
assertNotNull(online.current);
assertEquals(online.getCurrentServer(), online.getLastServer());
+ assertEquals(TabletHostingGoal.ONDEMAND, online.goal);
- // take the tablet offline
- c.tableOperations().offline(tableName, true);
- offline = getTabletLocationState(c, tableId);
- assertNull(offline.future);
- assertNull(offline.current);
- assertEquals(flushed.getCurrentServer(), offline.getLastServer());
+ // set the hosting goal to always
+ c.tableOperations().setTabletHostingGoal(tableName, new Range(),
TabletHostingGoal.ALWAYS);
+ TabletLocationState always;
+ do {
+ UtilWaitThread.sleep(250);
+ always = getTabletLocationState(c, tableId);
+ } while (always.goal == TabletHostingGoal.ONDEMAND);
Review Comment:
```suggestion
} while (always.goal != TabletHostingGoal.ALWAYS);
```
##########
test/src/main/java/org/apache/accumulo/test/functional/ManagerAssignmentIT.java:
##########
@@ -102,86 +123,140 @@ public void test() throws Exception {
c.tableOperations().flush(tableName, null, null, true);
TabletLocationState flushed = getTabletLocationState(c, tableId);
- assertEquals(newTablet.current, flushed.current);
+ assertNotNull(flushed.current);
assertEquals(flushed.getCurrentServer(), flushed.getLastServer());
assertNull(newTablet.future);
+ assertEquals(TabletHostingGoal.ONDEMAND, flushed.goal);
// take the tablet offline
c.tableOperations().offline(tableName, true);
TabletLocationState offline = getTabletLocationState(c, tableId);
assertNull(offline.future);
assertNull(offline.current);
assertEquals(flushed.getCurrentServer(), offline.getLastServer());
+ assertEquals(TabletHostingGoal.ONDEMAND, offline.goal);
// put it back online
c.tableOperations().online(tableName, true);
TabletLocationState online = getTabletLocationState(c, tableId);
assertNull(online.future);
assertNotNull(online.current);
assertEquals(online.getCurrentServer(), online.getLastServer());
+ assertEquals(TabletHostingGoal.ONDEMAND, online.goal);
- // take the tablet offline
- c.tableOperations().offline(tableName, true);
- offline = getTabletLocationState(c, tableId);
- assertNull(offline.future);
- assertNull(offline.current);
- assertEquals(flushed.getCurrentServer(), offline.getLastServer());
+ // set the hosting goal to always
+ c.tableOperations().setTabletHostingGoal(tableName, new Range(),
TabletHostingGoal.ALWAYS);
+ TabletLocationState always;
+ do {
+ UtilWaitThread.sleep(250);
+ always = getTabletLocationState(c, tableId);
+ } while (always.goal == TabletHostingGoal.ONDEMAND);
+
+ assertNull(always.future);
+ assertNotNull(always.current);
+ assertEquals(flushed.getCurrentServer(), always.getLastServer());
+ assertEquals(TabletHostingGoal.ALWAYS, always.goal);
+
+ // set the hosting goal to never
+ c.tableOperations().setTabletHostingGoal(tableName, new Range(),
TabletHostingGoal.NEVER);
+ TabletLocationState never;
+ do {
+ UtilWaitThread.sleep(250);
+ never = getTabletLocationState(c, tableId);
+ } while (never.goal == TabletHostingGoal.ALWAYS);
+
+ assertNull(never.future);
+ assertNotNull(never.current);
+ assertEquals(flushed.getCurrentServer(), never.getLastServer());
+ assertEquals(TabletHostingGoal.NEVER, never.goal);
+
+ // set the hosting goal to ondemand
+ c.tableOperations().setTabletHostingGoal(tableName, new Range(),
TabletHostingGoal.ONDEMAND);
+ TabletLocationState ondemand;
+ do {
+ UtilWaitThread.sleep(250);
+ ondemand = getTabletLocationState(c, tableId);
+ } while (ondemand.goal == TabletHostingGoal.NEVER);
Review Comment:
```suggestion
} while (ondemand.goal != TabletHostingGoal.ONDEMAND);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]