use of org.apache.accumulo.core.dataImpl.thrift.TKeyExtent in project accumulo by apache.
the class HostRegexTableLoadBalancerTest method getOnlineTabletsForTable.
@Override
public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, TableId tableId) {
// Report incorrect information so that balance will create an assignment
List<TabletStats> tablets = new ArrayList<>();
if (tableId.equals(BAR.getId()) && tserver.getHost().equals("192.168.0.1")) {
// Report that we have a bar tablet on this server
TKeyExtent tke = new TKeyExtent();
tke.setTable(BAR.getId().canonical().getBytes(UTF_8));
tke.setEndRow("11".getBytes());
tke.setPrevEndRow("10".getBytes());
TabletStats ts = new TabletStats();
ts.setExtent(tke);
tablets.add(ts);
} else if (tableId.equals(FOO.getId()) && tserver.getHost().equals("192.168.0.6")) {
// Report that we have a foo tablet on this server
TKeyExtent tke = new TKeyExtent();
tke.setTable(FOO.getId().canonical().getBytes(UTF_8));
tke.setEndRow("1".getBytes());
tke.setPrevEndRow("0".getBytes());
TabletStats ts = new TabletStats();
ts.setExtent(tke);
tablets.add(ts);
}
return tablets;
}
use of org.apache.accumulo.core.dataImpl.thrift.TKeyExtent in project accumulo by apache.
the class ThriftClientHandler method loadTablet.
@Override
public void loadTablet(TInfo tinfo, TCredentials credentials, String lock, final TKeyExtent textent) {
try {
checkPermission(credentials, lock, "loadTablet");
} catch (ThriftSecurityException e) {
log.error("Caller doesn't have permission to load a tablet", e);
throw new RuntimeException(e);
}
final KeyExtent extent = KeyExtent.fromThrift(textent);
synchronized (server.unopenedTablets) {
synchronized (server.openingTablets) {
synchronized (server.onlineTablets) {
// Checking if the current tablet is in any of the sets
// below is not a strong enough check to catch all overlapping tablets
// when splits and fix splits are occurring
Set<KeyExtent> unopenedOverlapping = KeyExtent.findOverlapping(extent, server.unopenedTablets);
Set<KeyExtent> openingOverlapping = KeyExtent.findOverlapping(extent, server.openingTablets);
Set<KeyExtent> onlineOverlapping = KeyExtent.findOverlapping(extent, server.getOnlineTablets());
Set<KeyExtent> all = new HashSet<>();
all.addAll(unopenedOverlapping);
all.addAll(openingOverlapping);
all.addAll(onlineOverlapping);
if (!all.isEmpty()) {
// ignore any tablets that have recently split, for error logging
for (KeyExtent e2 : onlineOverlapping) {
Tablet tablet = server.getOnlineTablet(e2);
if (System.currentTimeMillis() - tablet.getSplitCreationTime() < RECENTLY_SPLIT_MILLIES) {
all.remove(e2);
}
}
// ignore self, for error logging
all.remove(extent);
if (!all.isEmpty()) {
log.error("Tablet {} overlaps a previously assigned tablet, possibly due to a recent split. " + "Overlapping tablets: Unopened: {}, Opening: {}, Online: {}", extent, unopenedOverlapping, openingOverlapping, onlineOverlapping);
}
return;
}
server.unopenedTablets.add(extent);
}
}
}
TabletLogger.loading(extent, server.getTabletSession());
final AssignmentHandler ah = new AssignmentHandler(server, extent);
if (extent.isRootTablet()) {
Threads.createThread("Root Tablet Assignment", () -> {
ah.run();
if (server.getOnlineTablets().containsKey(extent)) {
log.info("Root tablet loaded: {}", extent);
} else {
log.info("Root tablet failed to load");
}
}).start();
} else {
if (extent.isMeta()) {
server.resourceManager.addMetaDataAssignment(extent, log, ah);
} else {
server.resourceManager.addAssignment(extent, log, ah);
}
}
}
use of org.apache.accumulo.core.dataImpl.thrift.TKeyExtent in project accumulo by apache.
the class ThriftClientHandler method bulkImport.
@Override
public List<TKeyExtent> bulkImport(TInfo tinfo, TCredentials credentials, final long tid, final Map<TKeyExtent, Map<String, MapFileInfo>> files, final boolean setTime) throws ThriftSecurityException {
if (!security.canPerformSystemActions(credentials)) {
throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
}
try {
return transactionWatcher.run(Constants.BULK_ARBITRATOR_TYPE, tid, () -> {
List<TKeyExtent> failures = new ArrayList<>();
for (Entry<TKeyExtent, Map<String, MapFileInfo>> entry : files.entrySet()) {
TKeyExtent tke = entry.getKey();
Map<String, MapFileInfo> fileMap = entry.getValue();
Map<TabletFile, MapFileInfo> fileRefMap = new HashMap<>();
for (Entry<String, MapFileInfo> mapping : fileMap.entrySet()) {
Path path = new Path(mapping.getKey());
FileSystem ns = context.getVolumeManager().getFileSystemByPath(path);
path = ns.makeQualified(path);
fileRefMap.put(new TabletFile(path), mapping.getValue());
}
Tablet importTablet = server.getOnlineTablet(KeyExtent.fromThrift(tke));
if (importTablet == null) {
failures.add(tke);
} else {
try {
importTablet.importMapFiles(tid, fileRefMap, setTime);
} catch (IOException ioe) {
log.info("files {} not imported to {}: {}", fileMap.keySet(), KeyExtent.fromThrift(tke), ioe.getMessage());
failures.add(tke);
}
}
}
return failures;
});
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.apache.accumulo.core.dataImpl.thrift.TKeyExtent in project accumulo by apache.
the class ThriftClientHandler method unloadTablet.
@Override
public void unloadTablet(TInfo tinfo, TCredentials credentials, String lock, TKeyExtent textent, TUnloadTabletGoal goal, long requestTime) {
try {
checkPermission(credentials, lock, "unloadTablet");
} catch (ThriftSecurityException e) {
log.error("Caller doesn't have permission to unload a tablet", e);
throw new RuntimeException(e);
}
KeyExtent extent = KeyExtent.fromThrift(textent);
server.resourceManager.addMigration(extent, new UnloadTabletHandler(server, extent, goal, requestTime));
}
use of org.apache.accumulo.core.dataImpl.thrift.TKeyExtent in project accumulo by apache.
the class HostRegexTableLoadBalancerTest method getOnlineTabletsForTable.
@Override
public List<TabletStatistics> getOnlineTabletsForTable(TabletServerId tserver, TableId tableId) {
// Report incorrect information so that balance will create an assignment
List<TabletStatistics> tablets = new ArrayList<>();
if (tableId.equals(BAR.getId()) && tserver.getHost().equals("192.168.0.1")) {
// Report that we have a bar tablet on this server
TKeyExtent tke = new TKeyExtent();
tke.setTable(BAR.getId().canonical().getBytes(UTF_8));
tke.setEndRow("11".getBytes());
tke.setPrevEndRow("10".getBytes());
TabletStats tstats = new TabletStats();
tstats.setExtent(tke);
TabletStatistics ts = new TabletStatisticsImpl(tstats);
tablets.add(ts);
} else if (tableId.equals(FOO.getId()) && tserver.getHost().equals("192.168.0.6")) {
// Report that we have a foo tablet on this server
TKeyExtent tke = new TKeyExtent();
tke.setTable(FOO.getId().canonical().getBytes(UTF_8));
tke.setEndRow("1".getBytes());
tke.setPrevEndRow("0".getBytes());
TabletStats tstats = new TabletStats();
tstats.setExtent(tke);
TabletStatistics ts = new TabletStatisticsImpl(tstats);
tablets.add(ts);
}
return tablets;
}
Aggregations