Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public String getRootTabletLocation() {
return null;
}

return loc.getHostPort();
return loc.getServerInstance().getHostPort();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
import org.apache.accumulo.core.metadata.MetadataCachedTabletObtainer;
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.metadata.RootTable;
import org.apache.accumulo.core.metadata.TServerInstance;
import org.apache.accumulo.core.singletons.SingletonManager;
import org.apache.accumulo.core.singletons.SingletonService;
import org.apache.accumulo.core.util.Interner;
import org.apache.accumulo.core.util.UtilWaitThread;
import org.apache.hadoop.io.Text;

Expand Down Expand Up @@ -270,43 +270,37 @@ public List<CachedTablet> getCachedTablets() {
}

public static class CachedTablet {
private static final Interner<String> interner = new Interner<>();

private final KeyExtent tablet_extent;
private final String tserverLocation;
private final String tserverSession;
private final TServerInstance tsi;
private final TabletHostingGoal goal;
private final boolean hostingRequested;

private final Long creationTime = System.nanoTime();

public CachedTablet(KeyExtent tablet_extent, String tablet_location, String session,
TabletHostingGoal goal, boolean hostingRequested) {
public CachedTablet(KeyExtent tablet_extent, TServerInstance instance, TabletHostingGoal goal,
boolean hostingRequested) {
checkArgument(tablet_extent != null, "tablet_extent is null");
checkArgument(tablet_location != null, "tablet_location is null");
checkArgument(session != null, "session is null");
checkArgument(instance != null, "tablet_location is null");
this.tablet_extent = tablet_extent;
this.tserverLocation = interner.intern(tablet_location);
this.tserverSession = interner.intern(session);
this.tsi = instance;
this.goal = Objects.requireNonNull(goal);
this.hostingRequested = hostingRequested;
}

public CachedTablet(KeyExtent tablet_extent, Optional<String> tablet_location,
Optional<String> session, TabletHostingGoal goal, boolean hostingRequested) {
public CachedTablet(KeyExtent tablet_extent, Optional<TServerInstance> tablet_location,
TabletHostingGoal goal, boolean hostingRequested) {
checkArgument(tablet_extent != null, "tablet_extent is null");
this.tablet_extent = tablet_extent;
this.tserverLocation = tablet_location.map(interner::intern).orElse(null);
this.tserverSession = session.map(interner::intern).orElse(null);
this.tsi = tablet_location.orElse(null);
this.goal = Objects.requireNonNull(goal);
this.hostingRequested = hostingRequested;
}

public CachedTablet(KeyExtent tablet_extent, TabletHostingGoal goal, boolean hostingRequested) {
checkArgument(tablet_extent != null, "tablet_extent is null");
this.tablet_extent = tablet_extent;
this.tserverLocation = null;
this.tserverSession = null;
this.tsi = null;
this.goal = Objects.requireNonNull(goal);
this.hostingRequested = hostingRequested;
}
Expand All @@ -325,25 +319,33 @@ && getTserverSession().equals(otl.getTserverSession()) && getGoal() == otl.getGo

@Override
public int hashCode() {
return Objects.hash(getExtent(), tserverLocation, tserverSession, goal, hostingRequested);
return Objects.hash(getExtent(), tsi, goal, hostingRequested);
}

@Override
public String toString() {
return "(" + getExtent() + "," + getTserverLocation() + "," + getTserverSession() + ","
+ getGoal() + ")";
+ getResourceGroup() + "," + getGoal() + ")";
}

public KeyExtent getExtent() {
return tablet_extent;
}

public Optional<String> getTserverLocation() {
return Optional.ofNullable(tserverLocation);
return Optional.ofNullable(tsi == null ? null : tsi.getHostPort());
}

public Optional<String> getTserverSession() {
return Optional.ofNullable(tserverSession);
return Optional.ofNullable(tsi == null ? null : tsi.getSession());
}

public Optional<String> getResourceGroup() {
return Optional.ofNullable(tsi == null ? null : tsi.getGroup());
}

public Optional<TServerInstance> getServer() {
return Optional.ofNullable(tsi == null ? null : tsi);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@ public CachedTablet findTablet(ClientContext context, Text row, boolean skipRow,
OpTimer timer = null;

if (log.isTraceEnabled()) {
log.trace("tid={} Locating tablet table={} row={} skipRow={}",
Thread.currentThread().getId(), tableId, TextUtil.truncate(row), skipRow);
log.trace("tid={} Locating tablet table={} row={} skipRow={}", Thread.currentThread().getId(),
tableId, TextUtil.truncate(row), skipRow);
timer = new OpTimer().start();
}

Expand Down Expand Up @@ -686,17 +686,19 @@ private void lookupTablet(ClientContext context, Text row, boolean retry,
if ((lastEndRow != null) && (ke.prevEndRow() != null)
&& ke.prevEndRow().equals(lastEndRow)) {
locToCache = new CachedTablet(new KeyExtent(ke.tableId(), ke.endRow(), lastEndRow),
cachedTablet.getTserverLocation(), cachedTablet.getTserverSession(),
cachedTablet.getGoal(), cachedTablet.wasHostingRequested());
cachedTablet.getServer(), cachedTablet.getGoal(), cachedTablet.wasHostingRequested());
} else {
locToCache = cachedTablet;
}

// save endRow for next iteration
lastEndRow = locToCache.getExtent().endRow();

log.trace("Caching tablet location: {}", locToCache);
updateCache(locToCache, lcSession);
}
} else {
log.warn("Metadata tablet not found for row: {}", metadataRow);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case could happen when a metadata tablet is temporarily not hosted. Would not want to warn in that case.

Suggested change
log.warn("Metadata tablet not found for row: {}", metadataRow);
log.debug("Metadata tablet not found for row: {}", metadataRow);

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,17 @@ protected CachedTablet getRootTabletLocation(ClientContext context) {
}

if (loc == null || loc.getType() != LocationType.CURRENT) {
return new CachedTablet(RootTable.EXTENT, Optional.empty(), Optional.empty(),
TabletHostingGoal.ALWAYS, false);
return new CachedTablet(RootTable.EXTENT, Optional.empty(), TabletHostingGoal.ALWAYS, false);
}

String server = loc.getHostPort();
String server = loc.getServerInstance().getHostPort();
String session = loc.getServerInstance().getSession();

if (lockChecker.isLockHeld(server, loc.getSession())) {
return new CachedTablet(RootTable.EXTENT, server, loc.getSession(), TabletHostingGoal.ALWAYS,
if (lockChecker.isLockHeld(server, session)) {
return new CachedTablet(RootTable.EXTENT, loc.getServerInstance(), TabletHostingGoal.ALWAYS,
false);
} else {
return new CachedTablet(RootTable.EXTENT, Optional.empty(), Optional.empty(),
TabletHostingGoal.ALWAYS, false);
return new CachedTablet(RootTable.EXTENT, Optional.empty(), TabletHostingGoal.ALWAYS, false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ private void waitForTableStateTransition(TableId tableId, TableState expectedSta
lastRow = tablet.getExtent().toMetaRow();

if (loc != null) {
serverCounts.increment(loc.getHostPortSession(), 1);
serverCounts.increment(loc.getServerInstance().getHostPortSessionGroup(), 1);
}
}

Expand Down
14 changes: 13 additions & 1 deletion core/src/main/java/org/apache/accumulo/core/conf/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.accumulo.core.file.rfile.RFile;
import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
import org.apache.accumulo.core.iteratorsImpl.system.DeletingIterator;
import org.apache.accumulo.core.lock.ServiceLockData.ServiceDescriptor;
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.spi.compaction.DefaultCompactionPlanner;
import org.apache.accumulo.core.spi.compaction.SimpleCompactionDispatcher;
Expand Down Expand Up @@ -724,6 +725,11 @@ public enum Property {
PropertyType.TIMEDURATION,
"The interval at which the TabletServer will check if on-demand tablets can be unloaded",
"4.0.0"),
TSERV_GROUP_NAME("tserver.group", ServiceDescriptor.DEFAULT_GROUP_NAME, PropertyType.STRING,
"Optional group name that will be made available to the "
+ "TablerServer plugins. Groups can be used to dedicate resources "
+ " to specific tables (e.g. balancing tablets for table(s) within a group)",
"4.0.0"),

// accumulo garbage collector properties
GC_PREFIX("gc.", null, PropertyType.PREFIX,
Expand Down Expand Up @@ -808,6 +814,11 @@ public enum Property {
+ " global setting to take effect. However, you must use the API or the shell"
+ " to change properties in zookeeper that are set on a table.",
"1.3.5"),
TABLE_ASSIGNMENT_GROUP("table.assignment.group", ServiceDescriptor.DEFAULT_GROUP_NAME,
PropertyType.STRING,
"Tablets for this table will be assigned to TabletServers that have a corresponding"
Copy link
Copy Markdown
Contributor

@keith-turner keith-turner Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement may not be true, it depends on the behavior of the balancer? Unless the balancer is limited to only assigning to tserver within the group?

We could limit balancing choices to a group, so a balancer could only chose from tservers within this group. That may require some changes to the SPI, not sure. Or this could be provided as information to the balancer, but it does not have to honor it. If the balancer does not have to honor it then would need to change the description.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless the balancer is limited to only assigning to tserver within the group?

I think we should do this given that there is a default resource group and the ability to create others.

+ " tserver.group property value.",
"4.0.0"),
TABLE_ARBITRARY_PROP_PREFIX("table.custom.", null, PropertyType.PREFIX,
"Prefix to be used for user defined arbitrary properties.", "1.7.0"),
TABLE_MINC_OUTPUT_DROP_CACHE("table.compaction.minor.output.drop.cache", "false",
Expand Down Expand Up @@ -1095,7 +1106,8 @@ public enum Property {
COMPACTOR_MAX_MESSAGE_SIZE("compactor.message.size.max", "10M", PropertyType.BYTES,
"The maximum size of a message that can be sent to a tablet server.", "2.1.0"),
@Experimental
COMPACTOR_QUEUE_NAME("compactor.queue", "", PropertyType.STRING,
// ELASTICITY_TODO: rename to compactor.group
COMPACTOR_QUEUE_NAME("compactor.queue", ServiceDescriptor.DEFAULT_GROUP_NAME, PropertyType.STRING,
"The queue for which this Compactor will perform compactions", "3.0.0"),
// CompactionCoordinator properties
@Experimental
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ public static class ServiceDescriptor {
private final String address;
private final String group;

public ServiceDescriptor(UUID uuid, ThriftService service, String address) {
this(uuid, service, address, DEFAULT_GROUP_NAME);
}

public ServiceDescriptor(UUID uuid, ThriftService service, String address, String group) {
this.uuid = requireNonNull(uuid);
this.service = requireNonNull(service);
Expand Down Expand Up @@ -159,11 +155,6 @@ public ServiceLockData(UUID uuid, String address, ThriftService service, String
Collections.singleton(new ServiceDescriptor(uuid, service, address, group)))));
}

public ServiceLockData(UUID uuid, String address, ThriftService service) {
this(new ServiceDescriptors(
new HashSet<>(Collections.singleton(new ServiceDescriptor(uuid, service, address)))));
}

public String getAddressString(ThriftService service) {
ServiceDescriptor sd = services.get(service);
if (sd == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public static TabletServerIdImpl fromThrift(TServerInstance tsi) {
return (tsi == null) ? null : new TabletServerIdImpl(tsi);
}

public TabletServerIdImpl(String host, int port, String session) {
public TabletServerIdImpl(String host, int port, String session, String group) {
requireNonNull(host);
this.tServerInstance = new TServerInstance(HostAndPort.fromParts(host, port), session);
this.tServerInstance = new TServerInstance(HostAndPort.fromParts(host, port), session, group);
}

public TabletServerIdImpl(TServerInstance tServerInstance) {
Expand All @@ -59,6 +59,11 @@ public String getSession() {
return tServerInstance.getSession();
}

@Override
public String getGroup() {
return tServerInstance.getGroup();
}

@Override
public int compareTo(TabletServerId o) {
return tServerInstance.compareTo(((TabletServerIdImpl) o).tServerInstance);
Expand Down Expand Up @@ -96,7 +101,7 @@ public static TServerInstance toThrift(TabletServerId tabletServerId) {
} else {
return new TServerInstance(
HostAndPort.fromParts(tabletServerId.getHost(), tabletServerId.getPort()),
tabletServerId.getSession());
tabletServerId.getSession(), tabletServerId.getGroup());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ public List<CachedTablet> lookupTablets(ClientContext context, String tserver,
}

public static CachedTablets getMetadataLocationEntries(SortedMap<Key,Value> entries) {
Text location = null;
Text session = null;
TServerInstance tsi = null;
TabletHostingGoal goal = null;
boolean hostingRequested = false;

Expand All @@ -238,8 +237,7 @@ public static CachedTablets getMetadataLocationEntries(SortedMap<Key,Value> entr
Value val = entry.getValue();

if (key.compareRow(lastRowFromKey) != 0) {
location = null;
session = null;
tsi = null;
goal = null;
hostingRequested = false;
key.getRow(lastRowFromKey);
Expand All @@ -251,11 +249,10 @@ public static CachedTablets getMetadataLocationEntries(SortedMap<Key,Value> entr
// interpret the row id as a key extent
if (colf.equals(CurrentLocationColumnFamily.NAME)
|| colf.equals(FutureLocationColumnFamily.NAME)) {
if (location != null) {
if (tsi != null) {
throw new IllegalStateException("Tablet has multiple locations : " + lastRowFromKey);
}
location = new Text(val.toString());
session = new Text(colq);
tsi = TServerInstance.fromString(val.toString());
} else if (HostingColumnFamily.GOAL_COLUMN.equals(colf, colq)) {
goal = TabletHostingGoalUtil.fromValue(val);
} else if (HostingColumnFamily.REQUESTED_COLUMN.equals(colf, colq)) {
Expand All @@ -265,13 +262,12 @@ public static CachedTablets getMetadataLocationEntries(SortedMap<Key,Value> entr
if (ke.isMeta()) {
goal = TabletHostingGoal.ALWAYS;
}
if (location != null) {
results.add(new CachedTablet(ke, location.toString(), session.toString(), goal,
hostingRequested));
if (tsi != null) {
results.add(new CachedTablet(ke, tsi, goal, hostingRequested));
} else {
results.add(new CachedTablet(ke, goal, hostingRequested));
}
location = null;
tsi = null;
}
}

Expand Down
Loading