Skip to content

Commit f9e4c92

Browse files
committed
Merge remote-tracking branch 'upstream/elasticity' into importWithHostingGoal
# Conflicts: # server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java # server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/PopulateMetadataTable.java
2 parents 9179326 + 4eff735 commit f9e4c92

File tree

106 files changed

+1559
-1352
lines changed

Some content is hidden

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

106 files changed

+1559
-1352
lines changed

core/src/main/java/org/apache/accumulo/core/client/admin/HostingGoalForTablet.java core/src/main/java/org/apache/accumulo/core/client/admin/AvailabilityForTablet.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@
2323
import org.apache.accumulo.core.data.TabletId;
2424

2525
/**
26-
* This class contains information that defines the tablet hosting data for a table. The class
27-
* contains the TabletId and associated goal for each tablet in a table or a subset of tablets if a
28-
* range is provided.
26+
* This class contains information that defines the tablet availability data for a table. The class
27+
* contains the TabletId and associated availability for each tablet in a table or a subset of
28+
* tablets if a range is provided.
2929
*
3030
* @since 4.0.0
3131
*/
32-
public class HostingGoalForTablet {
32+
public class AvailabilityForTablet {
3333
private final TabletId tabletId;
34-
private final TabletHostingGoal hostingGoal;
34+
private final TabletAvailability tabletAvailability;
3535

36-
public HostingGoalForTablet(TabletId tabletId, TabletHostingGoal hostingGoal) {
36+
public AvailabilityForTablet(TabletId tabletId, TabletAvailability tabletAvailability) {
3737
this.tabletId = tabletId;
38-
this.hostingGoal = hostingGoal;
38+
this.tabletAvailability = tabletAvailability;
3939
}
4040

41-
public TabletHostingGoal getHostingGoal() {
42-
return hostingGoal;
41+
public TabletAvailability getTabletAvailability() {
42+
return tabletAvailability;
4343
}
4444

4545
public TabletId getTabletId() {
@@ -54,12 +54,12 @@ public boolean equals(Object o) {
5454
if (o == null || getClass() != o.getClass()) {
5555
return false;
5656
}
57-
HostingGoalForTablet that = (HostingGoalForTablet) o;
58-
return Objects.equals(tabletId, that.tabletId) && hostingGoal == that.hostingGoal;
57+
AvailabilityForTablet that = (AvailabilityForTablet) o;
58+
return Objects.equals(tabletId, that.tabletId) && tabletAvailability == that.tabletAvailability;
5959
}
6060

6161
@Override
6262
public int hashCode() {
63-
return Objects.hash(tabletId, hostingGoal);
63+
return Objects.hash(tabletId, tabletAvailability);
6464
}
6565
}

core/src/main/java/org/apache/accumulo/core/client/admin/NewTableConfiguration.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class NewTableConfiguration {
7272
private Map<String,String> localityProps = Collections.emptyMap();
7373
private final Map<String,String> iteratorProps = new HashMap<>();
7474
private SortedSet<Text> splitProps = Collections.emptySortedSet();
75-
private TabletHostingGoal initialHostingGoal = TabletHostingGoal.ONDEMAND;
75+
private TabletAvailability initialTabletAvailability = TabletAvailability.ONDEMAND;
7676

7777
private void checkDisjoint(Map<String,String> props, Map<String,String> derivedProps,
7878
String kind) {
@@ -317,21 +317,22 @@ public NewTableConfiguration attachIterator(IteratorSetting setting,
317317
}
318318

319319
/**
320-
* Sets the initial tablet hosting goal for all tablets. If not set, the default is
321-
* {@link TabletHostingGoal#ONDEMAND}
320+
* Sets the initial tablet availability for all tablets. If not set, the default is
321+
* {@link TabletAvailability#ONDEMAND}
322322
*
323323
* @since 4.0.0
324324
*/
325-
public NewTableConfiguration withInitialHostingGoal(final TabletHostingGoal goal) {
326-
this.initialHostingGoal = goal;
325+
public NewTableConfiguration
326+
withInitialTabletAvailability(final TabletAvailability tabletAvailability) {
327+
this.initialTabletAvailability = tabletAvailability;
327328
return this;
328329
}
329330

330331
/**
331332
* @since 4.0.0
332333
*/
333-
public TabletHostingGoal getInitialHostingGoal() {
334-
return this.initialHostingGoal;
334+
public TabletAvailability getInitialTabletAvailability() {
335+
return this.initialTabletAvailability;
335336
}
336337

337338
/**

core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -1009,17 +1009,18 @@ default TimeType getTimeType(String tableName) throws TableNotFoundException {
10091009
}
10101010

10111011
/**
1012-
* Sets the hosting goal for a range of Tablets in the specified table, but does not wait for the
1013-
* tablets to reach this goal state. For the Range parameter, note that the Row portion of the
1014-
* start and end Keys and the inclusivity parameters are used when determining the range of
1015-
* affected tablets. The other portions of the start and end Keys are not used.
1012+
* Sets the tablet availability for a range of Tablets in the specified table, but does not wait
1013+
* for the tablets to reach this availability state. For the Range parameter, note that the Row
1014+
* portion of the start and end Keys and the inclusivity parameters are used when determining the
1015+
* range of affected tablets. The other portions of the start and end Keys are not used.
10161016
*
10171017
* @param tableName table name
10181018
* @param range tablet range
1019-
* @param goal hosting goal
1019+
* @param tabletAvailability tablet availability
10201020
* @since 4.0.0
10211021
*/
1022-
default void setTabletHostingGoal(String tableName, Range range, TabletHostingGoal goal)
1022+
default void setTabletAvailability(String tableName, Range range,
1023+
TabletAvailability tabletAvailability)
10231024
throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
10241025
throw new UnsupportedOperationException();
10251026
}

core/src/main/java/org/apache/accumulo/core/client/admin/TabletHostingGoal.java core/src/main/java/org/apache/accumulo/core/client/admin/TabletAvailability.java

+14-8
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,25 @@
1919
package org.apache.accumulo.core.client.admin;
2020

2121
/**
22-
* @see TableOperations#setTabletHostingGoal(String, org.apache.accumulo.core.data.Range,
23-
* TabletHostingGoal)
22+
* @see TableOperations#setTabletAvailability(String, org.apache.accumulo.core.data.Range,
23+
* TabletAvailability)
2424
* @since 4.0.0
2525
*/
26-
public enum TabletHostingGoal {
26+
public enum TabletAvailability {
2727

28-
// Signifies that a Tablet should always be hosted
29-
ALWAYS,
28+
/**
29+
* Signifies that a Tablet should always be hosted on a tablet server.
30+
*/
31+
HOSTED,
3032

31-
// Signifies that a Tablet should be hosted on client request
33+
/**
34+
* Signifies that a Tablet should be hosted on a tablet server when a client needs it.
35+
*/
3236
ONDEMAND,
3337

34-
// Signifies that a Tablet should never be hosted
35-
NEVER;
38+
/**
39+
* Signifies that a Tablet should never be hosted on a tablet server.
40+
*/
41+
UNHOSTED;
3642

3743
}

core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public interface TabletInformation {
6969
String getTabletDir();
7070

7171
/**
72-
* @return the tablet hosting goal.
72+
* @return the TabletAvailability object.
7373
*/
74-
TabletHostingGoal getHostingGoal();
74+
TabletAvailability getTabletAvailability();
7575

7676
}

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

+20-17
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.apache.accumulo.core.client.AccumuloSecurityException;
3535
import org.apache.accumulo.core.client.InvalidTabletHostingRequestException;
3636
import org.apache.accumulo.core.client.TableNotFoundException;
37-
import org.apache.accumulo.core.client.admin.TabletHostingGoal;
37+
import org.apache.accumulo.core.client.admin.TabletAvailability;
3838
import org.apache.accumulo.core.data.InstanceId;
3939
import org.apache.accumulo.core.data.Mutation;
4040
import org.apache.accumulo.core.data.Range;
@@ -52,7 +52,7 @@
5252

5353
/**
5454
* Client side cache of information about Tablets. Currently, a tablet prev end row is cached and
55-
* locations are cached if they exists.
55+
* locations are cached if they exist.
5656
*/
5757
public abstract class ClientTabletCache {
5858

@@ -308,39 +308,40 @@ public static class CachedTablet {
308308
private final KeyExtent tablet_extent;
309309
private final String tserverLocation;
310310
private final String tserverSession;
311-
private final TabletHostingGoal goal;
311+
private final TabletAvailability availability;
312312
private final boolean hostingRequested;
313313

314314
private final Long creationTime = System.nanoTime();
315315

316316
public CachedTablet(KeyExtent tablet_extent, String tablet_location, String session,
317-
TabletHostingGoal goal, boolean hostingRequested) {
317+
TabletAvailability availability, boolean hostingRequested) {
318318
checkArgument(tablet_extent != null, "tablet_extent is null");
319319
checkArgument(tablet_location != null, "tablet_location is null");
320320
checkArgument(session != null, "session is null");
321321
this.tablet_extent = tablet_extent;
322322
this.tserverLocation = interner.intern(tablet_location);
323323
this.tserverSession = interner.intern(session);
324-
this.goal = Objects.requireNonNull(goal);
324+
this.availability = Objects.requireNonNull(availability);
325325
this.hostingRequested = hostingRequested;
326326
}
327327

328328
public CachedTablet(KeyExtent tablet_extent, Optional<String> tablet_location,
329-
Optional<String> session, TabletHostingGoal goal, boolean hostingRequested) {
329+
Optional<String> session, TabletAvailability availability, boolean hostingRequested) {
330330
checkArgument(tablet_extent != null, "tablet_extent is null");
331331
this.tablet_extent = tablet_extent;
332332
this.tserverLocation = tablet_location.map(interner::intern).orElse(null);
333333
this.tserverSession = session.map(interner::intern).orElse(null);
334-
this.goal = Objects.requireNonNull(goal);
334+
this.availability = Objects.requireNonNull(availability);
335335
this.hostingRequested = hostingRequested;
336336
}
337337

338-
public CachedTablet(KeyExtent tablet_extent, TabletHostingGoal goal, boolean hostingRequested) {
338+
public CachedTablet(KeyExtent tablet_extent, TabletAvailability availability,
339+
boolean hostingRequested) {
339340
checkArgument(tablet_extent != null, "tablet_extent is null");
340341
this.tablet_extent = tablet_extent;
341342
this.tserverLocation = null;
342343
this.tserverSession = null;
343-
this.goal = Objects.requireNonNull(goal);
344+
this.availability = Objects.requireNonNull(availability);
344345
this.hostingRequested = hostingRequested;
345346
}
346347

@@ -350,21 +351,23 @@ public boolean equals(Object o) {
350351
CachedTablet otl = (CachedTablet) o;
351352
return getExtent().equals(otl.getExtent())
352353
&& getTserverLocation().equals(otl.getTserverLocation())
353-
&& getTserverSession().equals(otl.getTserverSession()) && getGoal() == otl.getGoal()
354+
&& getTserverSession().equals(otl.getTserverSession())
355+
&& getAvailability() == otl.getAvailability()
354356
&& hostingRequested == otl.hostingRequested;
355357
}
356358
return false;
357359
}
358360

359361
@Override
360362
public int hashCode() {
361-
return Objects.hash(getExtent(), tserverLocation, tserverSession, goal, hostingRequested);
363+
return Objects.hash(getExtent(), tserverLocation, tserverSession, availability,
364+
hostingRequested);
362365
}
363366

364367
@Override
365368
public String toString() {
366369
return "(" + getExtent() + "," + getTserverLocation() + "," + getTserverSession() + ","
367-
+ getGoal() + ")";
370+
+ getAvailability() + ")";
368371
}
369372

370373
public KeyExtent getExtent() {
@@ -381,12 +384,12 @@ public Optional<String> getTserverSession() {
381384

382385
/**
383386
* The ClientTabletCache will remove and replace a CachedTablet when the location is no longer
384-
* valid. However, it will not do the same when the goal is no longer valid. The goal returned
385-
* by this method may be out of date. If this information is needed to be fresh, then you may
386-
* want to consider clearing the cache first.
387+
* valid. However, it will not do the same when the availability is no longer valid. The
388+
* availability returned by this method may be out of date. If this information is needed to be
389+
* fresh, then you may want to consider clearing the cache first.
387390
*/
388-
public TabletHostingGoal getGoal() {
389-
return this.goal;
391+
public TabletAvailability getAvailability() {
392+
return this.availability;
390393
}
391394

392395
public Duration getAge() {

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

+9-8
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
import org.apache.accumulo.core.client.AccumuloSecurityException;
4646
import org.apache.accumulo.core.client.InvalidTabletHostingRequestException;
4747
import org.apache.accumulo.core.client.TableNotFoundException;
48-
import org.apache.accumulo.core.client.admin.TabletHostingGoal;
48+
import org.apache.accumulo.core.client.admin.TabletAvailability;
4949
import org.apache.accumulo.core.data.Key;
5050
import org.apache.accumulo.core.data.Mutation;
5151
import org.apache.accumulo.core.data.PartialKey;
@@ -130,9 +130,10 @@ private class LockCheckerSession {
130130
private final HashSet<Pair<String,String>> invalidLocks = new HashSet<>();
131131

132132
private CachedTablet checkLock(CachedTablet tl) {
133-
// the goal of this class is to minimize calls out to lockChecker under that assumption that
134-
// its a resource synchronized among many threads... want to
135-
// avoid fine grained synchronization when binning lots of mutations or ranges... remember
133+
// the goal of this class is to minimize calls out to lockChecker under that
134+
// assumption that
135+
// it is a resource synchronized among many threads... want to
136+
// avoid fine-grained synchronization when binning lots of mutations or ranges... remember
136137
// decisions from the lockChecker in thread local unsynchronized
137138
// memory
138139

@@ -668,17 +669,17 @@ private void requestTabletHosting(ClientContext context,
668669
List<TKeyExtent> extentsToBringOnline = new ArrayList<>();
669670
for (var cachedTablet : tabletsWithNoLocation) {
670671
if (cachedTablet.getAge().compareTo(STALE_DURATION) < 0) {
671-
if (cachedTablet.getGoal() == TabletHostingGoal.ONDEMAND) {
672+
if (cachedTablet.getAvailability() == TabletAvailability.ONDEMAND) {
672673
if (!cachedTablet.wasHostingRequested()) {
673674
extentsToBringOnline.add(cachedTablet.getExtent().toThrift());
674675
log.trace("requesting ondemand tablet to be hosted {}", cachedTablet.getExtent());
675676
} else {
676677
log.trace("ignoring ondemand tablet that already has a hosting request in place {} {}",
677678
cachedTablet.getExtent(), cachedTablet.getAge());
678679
}
679-
} else if (cachedTablet.getGoal() == TabletHostingGoal.NEVER) {
680+
} else if (cachedTablet.getAvailability() == TabletAvailability.UNHOSTED) {
680681
throw new InvalidTabletHostingRequestException("Extent " + cachedTablet.getExtent()
681-
+ " has a tablet hosting goal state " + TabletHostingGoal.NEVER);
682+
+ " has a tablet availability " + TabletAvailability.UNHOSTED);
682683
}
683684
} else {
684685
// When a tablet does not have a location it is reread from the metadata table before this
@@ -748,7 +749,7 @@ private void lookupTablet(ClientContext context, Text row, boolean retry,
748749
&& ke.prevEndRow().equals(lastEndRow)) {
749750
locToCache = new CachedTablet(new KeyExtent(ke.tableId(), ke.endRow(), lastEndRow),
750751
cachedTablet.getTserverLocation(), cachedTablet.getTserverSession(),
751-
cachedTablet.getGoal(), cachedTablet.wasHostingRequested());
752+
cachedTablet.getAvailability(), cachedTablet.wasHostingRequested());
752753
} else {
753754
locToCache = cachedTablet;
754755
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import java.util.function.BiConsumer;
3232

3333
import org.apache.accumulo.core.Constants;
34-
import org.apache.accumulo.core.client.admin.TabletHostingGoal;
34+
import org.apache.accumulo.core.client.admin.TabletAvailability;
3535
import org.apache.accumulo.core.clientImpl.ClientTabletCacheImpl.TabletServerLockChecker;
3636
import org.apache.accumulo.core.data.Mutation;
3737
import org.apache.accumulo.core.data.Range;
@@ -124,17 +124,17 @@ protected CachedTablet getRootTabletLocation(ClientContext context) {
124124

125125
if (loc == null || loc.getType() != LocationType.CURRENT) {
126126
return new CachedTablet(RootTable.EXTENT, Optional.empty(), Optional.empty(),
127-
TabletHostingGoal.ALWAYS, false);
127+
TabletAvailability.HOSTED, false);
128128
}
129129

130130
String server = loc.getHostPort();
131131

132132
if (lockChecker.isLockHeld(server, loc.getSession())) {
133-
return new CachedTablet(RootTable.EXTENT, server, loc.getSession(), TabletHostingGoal.ALWAYS,
133+
return new CachedTablet(RootTable.EXTENT, server, loc.getSession(), TabletAvailability.HOSTED,
134134
false);
135135
} else {
136136
return new CachedTablet(RootTable.EXTENT, Optional.empty(), Optional.empty(),
137-
TabletHostingGoal.ALWAYS, false);
137+
TabletAvailability.HOSTED, false);
138138
}
139139
}
140140

0 commit comments

Comments
 (0)