protected Table.ID getTableId(ClientContext context, String tableName) throws ThriftTableOperationException { return ClientServiceHandler.checkTableId(context, tableName, null); }
public static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager fs, TabletLocator locator, Path file) throws Exception { return findOverlappingTablets(context, fs, locator, file, null, null); }
void attemptingAssignments(Map<Path,List<TabletLocation>> assignments) { for (Entry<Path,List<TabletLocation>> entry : assignments.entrySet()) { for (TabletLocation tl : entry.getValue()) { Integer count = getCount(tl.tablet_extent); counts.put(tl.tablet_extent, count + 1); } } }
private Map<Path,List<KeyExtent>> assignMapFiles(VolumeManager fs, Map<Path,List<TabletLocation>> assignments, Collection<Path> paths, int numThreads, int numMapThreads) { timer.start(Timers.EXAMINE_MAP_FILES); Map<Path,List<AssignmentInfo>> assignInfo = estimateSizes(fs, assignments, paths, numMapThreads); timer.stop(Timers.EXAMINE_MAP_FILES); Map<Path,List<KeyExtent>> ret; timer.start(Timers.IMPORT_MAP_FILES); ret = assignMapFiles(assignInfo, locationsOf(assignments), numThreads); timer.stop(Timers.IMPORT_MAP_FILES); return ret; }
@Override public Map<String,String> getTableConfiguration(TInfo tinfo, TCredentials credentials, String tableName) throws TException, ThriftTableOperationException { Table.ID tableId = checkTableId(context, tableName, null); AccumuloConfiguration config = context.getServerConfFactory().getTableConfiguration(tableId); return conf(credentials, config); }
public static List<String> bulkLoad(ServerContext context, long tid, String tableId, List<String> files, boolean setTime) throws IOException { AssignmentStats stats = new BulkImporter(context, tid, tableId, setTime).importFiles(files); List<String> result = new ArrayList<>(); for (Path p : stats.completeFailures.keySet()) { result.add(p.toString()); } return result; }
public static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager fs, TabletLocator locator, Path file, KeyExtent failed) throws Exception { locator.invalidateCache(failed); Text start = getStartRowForExtent(failed); return findOverlappingTablets(context, fs, locator, file, start, failed.getEndRow()); }
@Override public void grantNamespacePermission(TInfo tinfo, TCredentials credentials, String user, String ns, byte permission) throws ThriftSecurityException, ThriftTableOperationException { Namespace.ID namespaceId = checkNamespaceId(context, ns, TableOperation.PERMISSION); security.grantNamespacePermission(credentials, user, namespaceId, NamespacePermission.getPermissionById(permission)); }
@Override public Map<String,String> getConfiguration(TInfo tinfo, TCredentials credentials, ConfigurationType type) throws TException { ServerConfigurationFactory factory = context.getServerConfFactory(); switch (type) { case CURRENT: return conf(credentials, factory.getSystemConfiguration()); case SITE: return conf(credentials, factory.getSiteConfiguration()); case DEFAULT: return conf(credentials, factory.getDefaultConfiguration()); } throw new RuntimeException("Unexpected configuration type " + type); }
@Override public void run() { HashSet<Path> uniqMapFiles = new HashSet<>(); for (List<PathSize> mapFiles : assignmentsPerTablet.values()) for (PathSize ps : mapFiles) uniqMapFiles.add(ps.path); log.debug("Assigning {} map files to {} tablets at {}", uniqMapFiles.size(), assignmentsPerTablet.size(), location); try { List<KeyExtent> failures = assignMapFiles(context, location, assignmentsPerTablet); handleFailures(failures, "Not Serving Tablet"); } catch (AccumuloException | AccumuloSecurityException e) { handleFailures(assignmentsPerTablet.keySet(), e.getMessage()); } }
@Override public void run() { Map<KeyExtent,Long> estimatedSizes = null; try { estimatedSizes = FileUtil.estimateSizes(context, entry.getKey(), mapFileSizes.get(entry.getKey()), extentsOf(entry.getValue())); } catch (IOException e) { log.warn("Failed to estimate map file sizes {}", e.getMessage()); } if (estimatedSizes == null) { // estimation failed, do a simple estimation estimatedSizes = new TreeMap<>(); long estSize = (long) (mapFileSizes.get(entry.getKey()) / (double) entry.getValue().size()); for (TabletLocation tl : entry.getValue()) estimatedSizes.put(tl.tablet_extent, estSize); } List<AssignmentInfo> assignmentInfoList = new ArrayList<>(estimatedSizes.size()); for (Entry<KeyExtent,Long> entry2 : estimatedSizes.entrySet()) assignmentInfoList.add(new AssignmentInfo(entry2.getKey(), entry2.getValue())); ais.put(entry.getKey(), assignmentInfoList); } };
@Override public List<String> bulkImportFiles(TInfo tinfo, final TCredentials credentials, final long tid, final String tableId, final List<String> files, final String errorDir, final boolean setTime) throws ThriftSecurityException, ThriftTableOperationException, TException { try { if (!security.canPerformSystemActions(credentials)) throw new AccumuloSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED); bulkImportStatus.updateBulkImportStatus(files, BulkImportState.INITIAL); log.debug("Got request to bulk import files to table({}): {}", tableId, files); bulkImportStatus.updateBulkImportStatus(files, BulkImportState.PROCESSING); try { return BulkImporter.bulkLoad(context, tid, tableId, files, setTime); } finally { bulkImportStatus.removeBulkImportStatus(files); } } catch (AccumuloSecurityException e) { throw e.asThriftException(); } catch (Exception ex) { throw new TException(ex); } }
@Override public boolean hasTablePermission(TInfo tinfo, TCredentials credentials, String user, String tableName, byte tblPerm) throws ThriftSecurityException, ThriftTableOperationException { Table.ID tableId = checkTableId(context, tableName, TableOperation.PERMISSION); return security.hasTablePermission(credentials, user, tableId, TablePermission.getPermissionById(tblPerm)); }
@Override public boolean hasNamespacePermission(TInfo tinfo, TCredentials credentials, String user, String ns, byte perm) throws ThriftSecurityException, ThriftTableOperationException { Namespace.ID namespaceId = checkNamespaceId(context, ns, TableOperation.PERMISSION); return security.hasNamespacePermission(credentials, user, namespaceId, NamespacePermission.getPermissionById(perm)); }
@Override public void run() { List<TabletLocation> tabletsToAssignMapFileTo = Collections.emptyList(); try { tabletsToAssignMapFileTo = findOverlappingTablets(context, fs, locator, mapFile); } catch (Exception ex) { log.warn("Unable to find tablets that overlap file " + mapFile, ex); } log.debug("Map file {} found to overlap {} tablets", mapFile, tabletsToAssignMapFileTo.size()); if (tabletsToAssignMapFileTo.size() == 0) { List<KeyExtent> empty = Collections.emptyList(); completeFailures.put(mapFile, empty); } else assignments.put(mapFile, tabletsToAssignMapFileTo); } };
void assignmentsFailed(Map<Path,List<KeyExtent>> assignmentFailures) { for (Entry<Path,List<KeyExtent>> entry : assignmentFailures.entrySet()) { for (KeyExtent ke : entry.getValue()) { Integer count = getCount(ke); counts.put(ke, count - 1); } } }
@Override public Map<String,String> getNamespaceConfiguration(TInfo tinfo, TCredentials credentials, String ns) throws ThriftTableOperationException, TException { Namespace.ID namespaceId; try { namespaceId = Namespaces.getNamespaceId(context, ns); } catch (NamespaceNotFoundException e) { String why = "Could not find namespace while getting configuration."; throw new ThriftTableOperationException(null, ns, null, TableOperationExceptionType.NAMESPACE_NOTFOUND, why); } AccumuloConfiguration config = context.getServerConfFactory() .getNamespaceConfiguration(namespaceId); return conf(credentials, config); }
@Override public void grantTablePermission(TInfo tinfo, TCredentials credentials, String user, String tableName, byte permission) throws TException { Table.ID tableId = checkTableId(context, tableName, TableOperation.PERMISSION); Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(context, tableId); } catch (TableNotFoundException e) { throw new TException(e); } security.grantTablePermission(credentials, user, tableId, TablePermission.getPermissionById(permission), namespaceId); }
@Override public void revokeNamespacePermission(TInfo tinfo, TCredentials credentials, String user, String ns, byte permission) throws ThriftSecurityException, ThriftTableOperationException { Namespace.ID namespaceId = checkNamespaceId(context, ns, TableOperation.PERMISSION); security.revokeNamespacePermission(credentials, user, namespaceId, NamespacePermission.getPermissionById(permission)); }
@Override public void revokeTablePermission(TInfo tinfo, TCredentials credentials, String user, String tableName, byte permission) throws TException { Table.ID tableId = checkTableId(context, tableName, TableOperation.PERMISSION); Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(context, tableId); } catch (TableNotFoundException e) { throw new TException(e); } security.revokeTablePermission(credentials, user, tableId, TablePermission.getPermissionById(permission), namespaceId); }