Search in sources :

Example 1 with DistributedStoreException

use of org.apache.accumulo.server.manager.state.DistributedStoreException in project accumulo by apache.

the class UnloadTabletHandler method run.

@Override
public void run() {
    Tablet t = null;
    synchronized (server.unopenedTablets) {
        if (server.unopenedTablets.contains(extent)) {
            server.unopenedTablets.remove(extent);
            // enqueueManagerMessage(new TabletUnloadedMessage(extent));
            return;
        }
    }
    synchronized (server.openingTablets) {
        while (server.openingTablets.contains(extent)) {
            try {
                log.info("Waiting for tablet {} to finish opening before unloading.", extent);
                server.openingTablets.wait();
            } catch (InterruptedException e) {
            }
        }
    }
    synchronized (server.onlineTablets) {
        if (server.onlineTablets.snapshot().containsKey(extent)) {
            t = server.onlineTablets.snapshot().get(extent);
        }
    }
    if (t == null) {
        // unload request is crossing the successful unloaded message
        if (!server.recentlyUnloadedCache.containsKey(extent)) {
            log.info("told to unload tablet that was not being served {}", extent);
            server.enqueueManagerMessage(new TabletStatusMessage(TabletLoadState.UNLOAD_FAILURE_NOT_SERVING, extent));
        }
        return;
    }
    try {
        t.close(!goalState.equals(TUnloadTabletGoal.DELETED));
    } catch (Exception e) {
        if ((t.isClosing() || t.isClosed()) && e instanceof IllegalStateException) {
            log.debug("Failed to unload tablet {}... it was already closing or closed : {}", extent, e.getMessage());
        } else {
            log.error("Failed to close tablet {}... Aborting migration", extent, e);
            server.enqueueManagerMessage(new TabletStatusMessage(TabletLoadState.UNLOAD_ERROR, extent));
        }
        return;
    }
    // stop serving tablet - client will get not serving tablet
    // exceptions
    server.recentlyUnloadedCache.put(extent, System.currentTimeMillis());
    server.onlineTablets.remove(extent);
    try {
        TServerInstance instance = new TServerInstance(server.clientAddress, server.getLock().getSessionId());
        TabletLocationState tls = null;
        try {
            tls = new TabletLocationState(extent, null, instance, null, null, null, false);
        } catch (BadLocationStateException e) {
            log.error("Unexpected error", e);
        }
        if (!goalState.equals(TUnloadTabletGoal.SUSPENDED) || extent.isRootTablet() || (extent.isMeta() && !server.getConfiguration().getBoolean(Property.MANAGER_METADATA_SUSPENDABLE))) {
            TabletStateStore.unassign(server.getContext(), tls, null);
        } else {
            TabletStateStore.suspend(server.getContext(), tls, null, requestTimeSkew + NANOSECONDS.toMillis(System.nanoTime()));
        }
    } catch (DistributedStoreException ex) {
        log.warn("Unable to update storage", ex);
    } catch (KeeperException e) {
        log.warn("Unable determine our zookeeper session information", e);
    } catch (InterruptedException e) {
        log.warn("Interrupted while getting our zookeeper session information", e);
    }
    // tell the manager how it went
    server.enqueueManagerMessage(new TabletStatusMessage(TabletLoadState.UNLOADED, extent));
    // roll tablet stats over into tablet server's statsKeeper object as
    // historical data
    server.statsKeeper.saveMajorMinorTimes(t.getTabletStats());
}
Also used : TabletStatusMessage(org.apache.accumulo.tserver.managermessage.TabletStatusMessage) TabletLocationState(org.apache.accumulo.core.metadata.TabletLocationState) DistributedStoreException(org.apache.accumulo.server.manager.state.DistributedStoreException) Tablet(org.apache.accumulo.tserver.tablet.Tablet) BadLocationStateException(org.apache.accumulo.core.metadata.TabletLocationState.BadLocationStateException) KeeperException(org.apache.zookeeper.KeeperException) DistributedStoreException(org.apache.accumulo.server.manager.state.DistributedStoreException) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) BadLocationStateException(org.apache.accumulo.core.metadata.TabletLocationState.BadLocationStateException) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

TServerInstance (org.apache.accumulo.core.metadata.TServerInstance)1 TabletLocationState (org.apache.accumulo.core.metadata.TabletLocationState)1 BadLocationStateException (org.apache.accumulo.core.metadata.TabletLocationState.BadLocationStateException)1 DistributedStoreException (org.apache.accumulo.server.manager.state.DistributedStoreException)1 TabletStatusMessage (org.apache.accumulo.tserver.managermessage.TabletStatusMessage)1 Tablet (org.apache.accumulo.tserver.tablet.Tablet)1 KeeperException (org.apache.zookeeper.KeeperException)1