Search in sources :

Example 6 with TKeyExtent

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;
}
Also used : TabletStats(org.apache.accumulo.core.tabletserver.thrift.TabletStats) ArrayList(java.util.ArrayList) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)

Example 7 with TKeyExtent

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);
        }
    }
}
Also used : Tablet(org.apache.accumulo.tserver.tablet.Tablet) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) HashSet(java.util.HashSet)

Example 8 with TKeyExtent

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);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MapFileInfo(org.apache.accumulo.core.dataImpl.thrift.MapFileInfo) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) IOException(java.io.IOException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TooManyFilesException(org.apache.accumulo.server.fs.TooManyFilesException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NoSuchScanIDException(org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException) CancellationException(java.util.concurrent.CancellationException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TSampleNotPresentException(org.apache.accumulo.core.tabletserver.thrift.TSampleNotPresentException) ConstraintViolationException(org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException) TException(org.apache.thrift.TException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) TimeoutException(java.util.concurrent.TimeoutException) TabletClosedException(org.apache.accumulo.tserver.tablet.TabletClosedException) IterationInterruptedException(org.apache.accumulo.core.iteratorsImpl.system.IterationInterruptedException) NotServingTabletException(org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) SampleNotPresentException(org.apache.accumulo.core.client.SampleNotPresentException) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) FileSystem(org.apache.hadoop.fs.FileSystem) TabletFile(org.apache.accumulo.core.metadata.TabletFile) Tablet(org.apache.accumulo.tserver.tablet.Tablet) Map(java.util.Map) HashMap(java.util.HashMap)

Example 9 with TKeyExtent

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));
}
Also used : ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent)

Example 10 with TKeyExtent

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;
}
Also used : TabletStats(org.apache.accumulo.core.tabletserver.thrift.TabletStats) ArrayList(java.util.ArrayList) TabletStatistics(org.apache.accumulo.core.spi.balancer.data.TabletStatistics) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) TabletStatisticsImpl(org.apache.accumulo.core.manager.balancer.TabletStatisticsImpl)

Aggregations

TKeyExtent (org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)23 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)15 ThriftSecurityException (org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)12 ArrayList (java.util.ArrayList)11 Tablet (org.apache.accumulo.tserver.tablet.Tablet)9 IOException (java.io.IOException)8 HashMap (java.util.HashMap)7 List (java.util.List)7 Map (java.util.Map)7 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)7 TableId (org.apache.accumulo.core.data.TableId)7 NoSuchScanIDException (org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException)7 TabletClientService (org.apache.accumulo.core.tabletserver.thrift.TabletClientService)7 HashSet (java.util.HashSet)6 SampleNotPresentException (org.apache.accumulo.core.client.SampleNotPresentException)6 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)6 Entry (java.util.Map.Entry)5 NamespaceId (org.apache.accumulo.core.data.NamespaceId)5 Range (org.apache.accumulo.core.data.Range)5 MultiScanResult (org.apache.accumulo.core.dataImpl.thrift.MultiScanResult)5