Search in sources :

Example 1 with SnapshotCreationException

use of org.apache.hadoop.hbase.snapshot.SnapshotCreationException in project hbase by apache.

the class HBaseAdmin method snapshot.

@Override
public void snapshot(SnapshotDescription snapshotDesc) throws IOException, SnapshotCreationException, IllegalArgumentException {
    // actually take the snapshot
    HBaseProtos.SnapshotDescription snapshot = ProtobufUtil.createHBaseProtosSnapshotDesc(snapshotDesc);
    SnapshotResponse response = asyncSnapshot(snapshot);
    final IsSnapshotDoneRequest request = IsSnapshotDoneRequest.newBuilder().setSnapshot(snapshot).build();
    IsSnapshotDoneResponse done = null;
    long start = EnvironmentEdgeManager.currentTime();
    long max = response.getExpectedTimeout();
    long maxPauseTime = max / this.numRetries;
    int tries = 0;
    LOG.debug("Waiting a max of " + max + " ms for snapshot '" + ClientSnapshotDescriptionUtils.toString(snapshot) + "'' to complete. (max " + maxPauseTime + " ms per retry)");
    while (tries == 0 || ((EnvironmentEdgeManager.currentTime() - start) < max && !done.getDone())) {
        try {
            // sleep a backoff <= pauseTime amount
            long sleep = getPauseTime(tries++);
            sleep = sleep > maxPauseTime ? maxPauseTime : sleep;
            LOG.debug("(#" + tries + ") Sleeping: " + sleep + "ms while waiting for snapshot completion.");
            Thread.sleep(sleep);
        } catch (InterruptedException e) {
            throw (InterruptedIOException) new InterruptedIOException("Interrupted").initCause(e);
        }
        LOG.debug("Getting current status of snapshot from master...");
        done = executeCallable(new MasterCallable<IsSnapshotDoneResponse>(getConnection(), getRpcControllerFactory()) {

            @Override
            protected IsSnapshotDoneResponse rpcCall() throws Exception {
                return master.isSnapshotDone(getRpcController(), request);
            }
        });
    }
    if (!done.getDone()) {
        throw new SnapshotCreationException("Snapshot '" + snapshot.getName() + "' wasn't completed in expectedTime:" + max + " ms", snapshotDesc);
    }
}
Also used : InterruptedIOException(java.io.InterruptedIOException) SnapshotResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SnapshotResponse) RestoreSnapshotResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotResponse) SnapshotCreationException(org.apache.hadoop.hbase.snapshot.SnapshotCreationException) IsSnapshotDoneResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneResponse) IsSnapshotDoneRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneRequest) HBaseProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)

Example 2 with SnapshotCreationException

use of org.apache.hadoop.hbase.snapshot.SnapshotCreationException in project hbase by apache.

the class RawAsyncHBaseAdmin method snapshot.

@Override
public CompletableFuture<Void> snapshot(SnapshotDescription snapshotDesc) {
    SnapshotProtos.SnapshotDescription snapshot = ProtobufUtil.createHBaseProtosSnapshotDesc(snapshotDesc);
    try {
        ClientSnapshotDescriptionUtils.assertSnapshotRequestIsValid(snapshot);
    } catch (IllegalArgumentException e) {
        return failedFuture(e);
    }
    CompletableFuture<Void> future = new CompletableFuture<>();
    final SnapshotRequest request = SnapshotRequest.newBuilder().setSnapshot(snapshot).build();
    addListener(this.<Long>newMasterCaller().action((controller, stub) -> this.<SnapshotRequest, SnapshotResponse, Long>call(controller, stub, request, (s, c, req, done) -> s.snapshot(c, req, done), resp -> resp.getExpectedTimeout())).call(), (expectedTimeout, err) -> {
        if (err != null) {
            future.completeExceptionally(err);
            return;
        }
        TimerTask pollingTask = new TimerTask() {

            int tries = 0;

            long startTime = EnvironmentEdgeManager.currentTime();

            long endTime = startTime + expectedTimeout;

            long maxPauseTime = expectedTimeout / maxAttempts;

            @Override
            public void run(Timeout timeout) throws Exception {
                if (EnvironmentEdgeManager.currentTime() < endTime) {
                    addListener(isSnapshotFinished(snapshotDesc), (done, err2) -> {
                        if (err2 != null) {
                            future.completeExceptionally(err2);
                        } else if (done) {
                            future.complete(null);
                        } else {
                            // retry again after pauseTime.
                            long pauseTime = ConnectionUtils.getPauseTime(TimeUnit.NANOSECONDS.toMillis(pauseNs), ++tries);
                            pauseTime = Math.min(pauseTime, maxPauseTime);
                            AsyncConnectionImpl.RETRY_TIMER.newTimeout(this, pauseTime, TimeUnit.MILLISECONDS);
                        }
                    });
                } else {
                    future.completeExceptionally(new SnapshotCreationException("Snapshot '" + snapshot.getName() + "' wasn't completed in expectedTime:" + expectedTimeout + " ms", snapshotDesc));
                }
            }
        };
        AsyncConnectionImpl.RETRY_TIMER.newTimeout(pollingTask, 1, TimeUnit.MILLISECONDS);
    });
    return future;
}
Also used : RegionMetricsBuilder(org.apache.hadoop.hbase.RegionMetricsBuilder) CreateTableResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.CreateTableResponse) RunCleanerChoreRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RunCleanerChoreRequest) MoveServersRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.MoveServersRequest) GetRegionInfoResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse) FutureUtils.unwrapCompletionException(org.apache.hadoop.hbase.util.FutureUtils.unwrapCompletionException) SplitTableRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SplitTableRegionResponse) ClusterMetrics(org.apache.hadoop.hbase.ClusterMetrics) RestoreSnapshotException(org.apache.hadoop.hbase.snapshot.RestoreSnapshotException) IsBalancerEnabledRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsBalancerEnabledRequest) GetQuotaStatesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetQuotaStatesResponse) RSGroupInfo(org.apache.hadoop.hbase.rsgroup.RSGroupInfo) GetNamespaceDescriptorRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetNamespaceDescriptorRequest) CompactionSwitchRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CompactionSwitchRequest) Map(java.util.Map) Configuration(org.apache.hadoop.conf.Configuration) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException) DeleteNamespaceRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteNamespaceRequest) EnumSet(java.util.EnumSet) SetCleanerChoreRunningRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetCleanerChoreRunningRequest) Pair(org.apache.hadoop.hbase.util.Pair) Address(org.apache.hadoop.hbase.net.Address) StopMasterRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.StopMasterRequest) IsNormalizerEnabledResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsNormalizerEnabledResponse) CompactRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CompactRegionRequest) MajorCompactionTimestampForRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MajorCompactionTimestampForRegionRequest) CacheEvictionStats(org.apache.hadoop.hbase.CacheEvictionStats) GetLocksResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetLocksResponse) AddColumnResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.AddColumnResponse) EnableCatalogJanitorRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.EnableCatalogJanitorRequest) ModifyColumnStoreFileTrackerResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyColumnStoreFileTrackerResponse) RpcCallback(org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback) DecommissionRegionServersRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DecommissionRegionServersRequest) Stream(java.util.stream.Stream) RegionSpecifierType(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType) UpdateConfigurationResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateConfigurationResponse) ReplicationPeerDescription(org.apache.hadoop.hbase.replication.ReplicationPeerDescription) NameStringPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair) ListTableDescriptorsByNamespaceRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListTableDescriptorsByNamespaceRequest) SnapshotCreationException(org.apache.hadoop.hbase.snapshot.SnapshotCreationException) GetProcedureResultRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProcedureResultRequest) GrantRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AccessControlProtos.GrantRequest) DeleteTableRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteTableRequest) GetReplicationPeerConfigResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.GetReplicationPeerConfigResponse) Supplier(java.util.function.Supplier) UpdateConfigurationRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateConfigurationRequest) GetNamespaceDescriptorResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetNamespaceDescriptorResponse) GetLocksRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetLocksRequest) DisableTableRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DisableTableRequest) ClearRegionBlockCacheRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearRegionBlockCacheRequest) IsInMaintenanceModeResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsInMaintenanceModeResponse) StopServerResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.StopServerResponse) ListNamespacesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListNamespacesRequest) GetRSGroupInfoOfServerRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfServerRequest) DecommissionRegionServersResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DecommissionRegionServersResponse) ShutdownRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ShutdownRequest) NormalizeResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.NormalizeResponse) Option(org.apache.hadoop.hbase.ClusterMetrics.Option) GetUserPermissionsResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AccessControlProtos.GetUserPermissionsResponse) TableName(org.apache.hadoop.hbase.TableName) UpdateReplicationPeerConfigRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.UpdateReplicationPeerConfigRequest) IsInMaintenanceModeRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsInMaintenanceModeRequest) AdminService(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService) IOException(java.io.IOException) AddRSGroupResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.AddRSGroupResponse) RpcChannel(org.apache.hbase.thirdparty.com.google.protobuf.RpcChannel) EnableReplicationPeerRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.EnableReplicationPeerRequest) CompactRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CompactRegionResponse) DeleteColumnRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteColumnRequest) GetConfiguredNamespacesAndTablesInRSGroupResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetConfiguredNamespacesAndTablesInRSGroupResponse) RenameRSGroupResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RenameRSGroupResponse) TableNotDisabledException(org.apache.hadoop.hbase.TableNotDisabledException) SetQuotaResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaResponse) Nullable(edu.umd.cs.findbugs.annotations.Nullable) IsSnapshotDoneRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneRequest) ListTableNamesByNamespaceResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListTableNamesByNamespaceResponse) ClearDeadServersResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ClearDeadServersResponse) DeleteTableResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteTableResponse) GetProceduresRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProceduresRequest) GetSpaceQuotaRegionSizesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesRequest) Message(org.apache.hbase.thirdparty.com.google.protobuf.Message) GetTableDescriptorsResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetTableDescriptorsResponse) DeleteSnapshotResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteSnapshotResponse) ProcedureDescription(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ProcedureDescription) RunCatalogScanResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RunCatalogScanResponse) ListNamespacesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListNamespacesResponse) GetQuotaStatesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetQuotaStatesRequest) SecurityCapability(org.apache.hadoop.hbase.client.security.SecurityCapability) ReplicationException(org.apache.hadoop.hbase.replication.ReplicationException) BalanceRSGroupRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.BalanceRSGroupRequest) RollWALWriterRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.RollWALWriterRequest) ProtobufUtil(org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil) GetRegionLoadResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionLoadResponse) RenameRSGroupRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RenameRSGroupRequest) EnableTableRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.EnableTableRequest) TimerTask(org.apache.hbase.thirdparty.io.netty.util.TimerTask) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) RevokeResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AccessControlProtos.RevokeResponse) ListTablesInRSGroupRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListTablesInRSGroupRequest) AddReplicationPeerRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerRequest) ListReplicationPeersRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.ListReplicationPeersRequest) Collectors(java.util.stream.Collectors) AbortProcedureResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.AbortProcedureResponse) GetSpaceQuotaRegionSizesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesResponse) CollectionUtils(org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUtils) SetBalancerRunningResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetBalancerRunningResponse) ModifyColumnStoreFileTrackerRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyColumnStoreFileTrackerRequest) ListRSGroupInfosRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosRequest) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) NormalizeRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.NormalizeRequest) SwitchExceedThrottleQuotaRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SwitchExceedThrottleQuotaRequest) AdminRequestCallerBuilder(org.apache.hadoop.hbase.client.AsyncRpcRetryingCallerFactory.AdminRequestCallerBuilder) IsProcedureDoneRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsProcedureDoneRequest) SetSplitOrMergeEnabledRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetSplitOrMergeEnabledRequest) ListRSGroupInfosResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosResponse) GetTableDescriptorsRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetTableDescriptorsRequest) SetSnapshotCleanupResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetSnapshotCleanupResponse) CacheEvictionStatsAggregator(org.apache.hadoop.hbase.CacheEvictionStatsAggregator) HasUserPermissionsRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AccessControlProtos.HasUserPermissionsRequest) AssignRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.AssignRegionRequest) TableNotEnabledException(org.apache.hadoop.hbase.TableNotEnabledException) ListNamespaceDescriptorsResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListNamespaceDescriptorsResponse) AddRSGroupRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.AddRSGroupRequest) CompletableFuture(java.util.concurrent.CompletableFuture) RestoreSnapshotResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotResponse) TransitReplicationPeerSyncReplicationStateResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.TransitReplicationPeerSyncReplicationStateResponse) SetQuotaRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetQuotaRequest) RunCatalogScanRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RunCatalogScanRequest) Function(java.util.function.Function) GetRSGroupInfoOfTableResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfTableResponse) HConstants(org.apache.hadoop.hbase.HConstants) QuotaTableUtil(org.apache.hadoop.hbase.quotas.QuotaTableUtil) ClearCompactionQueuesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearCompactionQueuesRequest) GetSpaceQuotaSnapshotsRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaSnapshotsRequest) SnapshotRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SnapshotRequest) DisableReplicationPeerRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.DisableReplicationPeerRequest) RemoveServersRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RemoveServersRequest) MoveRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MoveRegionRequest) Bytes(org.apache.hadoop.hbase.util.Bytes) ListReplicationPeersResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.ListReplicationPeersResponse) Logger(org.slf4j.Logger) HBaseProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos) TableExistsException(org.apache.hadoop.hbase.TableExistsException) HashedWheelTimer(org.apache.hbase.thirdparty.io.netty.util.HashedWheelTimer) MajorCompactionTimestampRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MajorCompactionTimestampRequest) RemoveReplicationPeerResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.RemoveReplicationPeerResponse) SetNormalizerRunningRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetNormalizerRunningRequest) AccessControlProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.AccessControlProtos) GetClusterStatusResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetClusterStatusResponse) SecurityCapabilitiesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCapabilitiesRequest) MasterRequestCallerBuilder(org.apache.hadoop.hbase.client.AsyncRpcRetryingCallerFactory.MasterRequestCallerBuilder) ListNamespaceDescriptorsRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListNamespaceDescriptorsRequest) RequestConverter(org.apache.hadoop.hbase.shaded.protobuf.RequestConverter) RegionMetrics(org.apache.hadoop.hbase.RegionMetrics) DeleteNamespaceResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteNamespaceResponse) Consumer(java.util.function.Consumer) UpdateRSGroupConfigRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.UpdateRSGroupConfigRequest) MergeTableRegionsRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MergeTableRegionsRequest) InterfaceAudience(org.apache.yetus.audience.InterfaceAudience) GetReplicationPeerConfigRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.GetReplicationPeerConfigRequest) HRegionLocation(org.apache.hadoop.hbase.HRegionLocation) QuotaSettings(org.apache.hadoop.hbase.quotas.QuotaSettings) RecommissionRegionServerRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RecommissionRegionServerRequest) DeleteColumnResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteColumnResponse) ModifyTableStoreFileTrackerResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableStoreFileTrackerResponse) UpdateReplicationPeerConfigResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.UpdateReplicationPeerConfigResponse) GetRSGroupInfoResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoResponse) CompactionSwitchResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CompactionSwitchResponse) ShadedAccessControlUtil(org.apache.hadoop.hbase.security.access.ShadedAccessControlUtil) RunCleanerChoreResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RunCleanerChoreResponse) Arrays(java.util.Arrays) ExecProcedureResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureResponse) GetClusterStatusRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetClusterStatusRequest) BalanceRSGroupResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.BalanceRSGroupResponse) QuotaFilter(org.apache.hadoop.hbase.quotas.QuotaFilter) HasUserPermissionsResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AccessControlProtos.HasUserPermissionsResponse) IsCatalogJanitorEnabledRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsCatalogJanitorEnabledRequest) DisableTableResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DisableTableResponse) UpdateRSGroupConfigResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.UpdateRSGroupConfigResponse) MasterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos) IsBalancerEnabledResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsBalancerEnabledResponse) SplitTableRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SplitTableRegionRequest) ForeignExceptionUtil(org.apache.hadoop.hbase.util.ForeignExceptionUtil) IsCatalogJanitorEnabledResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsCatalogJanitorEnabledResponse) SpaceQuotaSnapshot(org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot) GetOnlineRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetOnlineRegionRequest) FlushRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.FlushRegionRequest) ExecProcedureRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureRequest) Set(java.util.Set) IsNormalizerEnabledRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsNormalizerEnabledRequest) ListTableNamesByNamespaceRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListTableNamesByNamespaceRequest) StopServerRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.StopServerRequest) ModifyTableResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableResponse) MoveRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MoveRegionResponse) SetSplitOrMergeEnabledResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetSplitOrMergeEnabledResponse) RegionSizes(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaRegionSizesResponse.RegionSizes) MasterService(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MasterService) IsRpcThrottleEnabledResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsRpcThrottleEnabledResponse) ClusterMetricsBuilder(org.apache.hadoop.hbase.ClusterMetricsBuilder) RevokeRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AccessControlProtos.RevokeRequest) GetTableNamesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetTableNamesRequest) IsProcedureDoneResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsProcedureDoneResponse) IsSplitOrMergeEnabledRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSplitOrMergeEnabledRequest) ModifyTableStoreFileTrackerRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableStoreFileTrackerRequest) ClientSnapshotDescriptionUtils(org.apache.hadoop.hbase.snapshot.ClientSnapshotDescriptionUtils) RemoveRSGroupResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RemoveRSGroupResponse) ListTableDescriptorsByNamespaceResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListTableDescriptorsByNamespaceResponse) AddColumnRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.AddColumnRequest) IsCleanerChoreEnabledRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsCleanerChoreEnabledRequest) RestoreSnapshotRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotRequest) ArrayList(java.util.ArrayList) GetConfiguredNamespacesAndTablesInRSGroupRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetConfiguredNamespacesAndTablesInRSGroupRequest) RollWALWriterResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.RollWALWriterResponse) RemoveServersResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RemoveServersResponse) AddReplicationPeerResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerResponse) SnapshotProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos) UnassignRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.UnassignRegionRequest) BiConsumer(java.util.function.BiConsumer) ClearRegionBlockCacheResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearRegionBlockCacheResponse) ModifyColumnResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyColumnResponse) ServerName(org.apache.hadoop.hbase.ServerName) SwitchRpcThrottleRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SwitchRpcThrottleRequest) ModifyNamespaceResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyNamespaceResponse) SecurityCapabilitiesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SecurityCapabilitiesResponse) SetNormalizerRunningResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetNormalizerRunningResponse) SyncReplicationState(org.apache.hadoop.hbase.replication.SyncReplicationState) GetProcedureResultResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProcedureResultResponse) ReplicationPeerConfig(org.apache.hadoop.hbase.replication.ReplicationPeerConfig) FlushRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.FlushRegionResponse) IsSplitOrMergeEnabledResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSplitOrMergeEnabledResponse) ShutdownResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ShutdownResponse) GetCompletedSnapshotsRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetCompletedSnapshotsRequest) TruncateTableResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.TruncateTableResponse) AssignRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.AssignRegionResponse) CatalogFamilyFormat(org.apache.hadoop.hbase.CatalogFamilyFormat) TableNotFoundException(org.apache.hadoop.hbase.TableNotFoundException) FutureUtils.addListener(org.apache.hadoop.hbase.util.FutureUtils.addListener) GetRegionLoadRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionLoadRequest) RegionLocations(org.apache.hadoop.hbase.RegionLocations) LoggerFactory(org.slf4j.LoggerFactory) ServerRequestCallerBuilder(org.apache.hadoop.hbase.client.AsyncRpcRetryingCallerFactory.ServerRequestCallerBuilder) Timeout(org.apache.hbase.thirdparty.io.netty.util.Timeout) GetSpaceQuotaSnapshotsResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaSnapshotsResponse) GetProceduresResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetProceduresResponse) MoveServersResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.MoveServersResponse) TransitReplicationPeerSyncReplicationStateRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.TransitReplicationPeerSyncReplicationStateRequest) StopMasterResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.StopMasterResponse) UnassignRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.UnassignRegionResponse) TableCFs(org.apache.hadoop.hbase.client.replication.TableCFs) RemoveRSGroupRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RemoveRSGroupRequest) EnableReplicationPeerResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.EnableReplicationPeerResponse) CreateNamespaceResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.CreateNamespaceResponse) CreateTableRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.CreateTableRequest) IsCleanerChoreEnabledResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsCleanerChoreEnabledResponse) TruncateTableRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.TruncateTableRequest) IsSnapshotCleanupEnabledResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotCleanupEnabledResponse) HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) ClearCompactionQueuesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearCompactionQueuesResponse) GetRegionInfoRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoRequest) GetRSGroupInfoOfTableRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfTableRequest) List(java.util.List) ReplicationPeerConfigUtil(org.apache.hadoop.hbase.client.replication.ReplicationPeerConfigUtil) IsSnapshotDoneResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneResponse) HIGH_QOS(org.apache.hadoop.hbase.HConstants.HIGH_QOS) ModifyNamespaceRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyNamespaceRequest) GetRSGroupInfoOfServerResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfServerResponse) EnvironmentEdgeManager(org.apache.hadoop.hbase.util.EnvironmentEdgeManager) Optional(java.util.Optional) MergeTableRegionsResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MergeTableRegionsResponse) SetCleanerChoreRunningResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetCleanerChoreRunningResponse) Pattern(java.util.regex.Pattern) META_TABLE_NAME(org.apache.hadoop.hbase.TableName.META_TABLE_NAME) Permission(org.apache.hadoop.hbase.security.access.Permission) EnableCatalogJanitorResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.EnableCatalogJanitorResponse) ModifyColumnRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyColumnRequest) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) EnableTableResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.EnableTableResponse) MajorCompactionTimestampResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MajorCompactionTimestampResponse) GetUserPermissionsRequest(org.apache.hadoop.hbase.security.access.GetUserPermissionsRequest) RecommissionRegionServerResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RecommissionRegionServerResponse) SnapshotResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SnapshotResponse) Preconditions(org.apache.hbase.thirdparty.com.google.common.base.Preconditions) GetCompletedSnapshotsResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetCompletedSnapshotsResponse) NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) ListTablesInRSGroupResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListTablesInRSGroupResponse) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) ListDecommissionedRegionServersResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDecommissionedRegionServersResponse) DisableReplicationPeerResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.DisableReplicationPeerResponse) GrantResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AccessControlProtos.GrantResponse) GetRSGroupInfoRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoRequest) RemoveReplicationPeerRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.RemoveReplicationPeerRequest) SwitchExceedThrottleQuotaResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SwitchExceedThrottleQuotaResponse) ReadType(org.apache.hadoop.hbase.client.Scan.ReadType) ClearDeadServersRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ClearDeadServersRequest) CreateNamespaceRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.CreateNamespaceRequest) SetBalancerRunningRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetBalancerRunningRequest) TableSchema(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.TableSchema) AbortProcedureRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.AbortProcedureRequest) DeleteSnapshotRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteSnapshotRequest) ModifyTableRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ModifyTableRequest) UserPermission(org.apache.hadoop.hbase.security.access.UserPermission) IsRpcThrottleEnabledRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsRpcThrottleEnabledRequest) GetTableNamesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.GetTableNamesResponse) OfflineRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.OfflineRegionRequest) ClientMetaTableAccessor(org.apache.hadoop.hbase.ClientMetaTableAccessor) OfflineRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.OfflineRegionResponse) TimeUnit(java.util.concurrent.TimeUnit) GetOnlineRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetOnlineRegionResponse) ListDecommissionedRegionServersRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ListDecommissionedRegionServersRequest) SwitchRpcThrottleResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SwitchRpcThrottleResponse) Collections(java.util.Collections) CompletableFuture(java.util.concurrent.CompletableFuture) TimerTask(org.apache.hbase.thirdparty.io.netty.util.TimerTask) Timeout(org.apache.hbase.thirdparty.io.netty.util.Timeout) SnapshotRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SnapshotRequest) RestoreSnapshotRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotRequest) DeleteSnapshotRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.DeleteSnapshotRequest) SnapshotCreationException(org.apache.hadoop.hbase.snapshot.SnapshotCreationException) SnapshotProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos)

Example 3 with SnapshotCreationException

use of org.apache.hadoop.hbase.snapshot.SnapshotCreationException in project hbase by apache.

the class SnapshotManager method prepareToTakeSnapshot.

/**
 * Check to make sure that we are OK to run the passed snapshot. Checks to make sure that we
 * aren't already running a snapshot or restore on the requested table.
 * @param snapshot description of the snapshot we want to start
 * @throws HBaseSnapshotException if the filesystem could not be prepared to start the snapshot
 */
private synchronized void prepareToTakeSnapshot(SnapshotDescription snapshot) throws HBaseSnapshotException {
    Path workingDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(snapshot, rootDir, master.getConfiguration());
    TableName snapshotTable = TableName.valueOf(snapshot.getTable());
    // make sure we aren't already running a snapshot
    if (isTakingSnapshot(snapshot)) {
        SnapshotSentinel handler = this.snapshotHandlers.get(snapshotTable);
        throw new SnapshotCreationException("Rejected taking " + ClientSnapshotDescriptionUtils.toString(snapshot) + " because we are already running another snapshot " + (handler != null ? ("on the same table " + ClientSnapshotDescriptionUtils.toString(handler.getSnapshot())) : "with the same name"), ProtobufUtil.createSnapshotDesc(snapshot));
    }
    // make sure we aren't running a restore on the same table
    if (isRestoringTable(snapshotTable)) {
        throw new SnapshotCreationException("Rejected taking " + ClientSnapshotDescriptionUtils.toString(snapshot) + " because we are already have a restore in progress on the same snapshot.");
    }
    try {
        FileSystem workingDirFS = workingDir.getFileSystem(master.getConfiguration());
        // delete the working directory, since we aren't running the snapshot. Likely leftovers
        // from a failed attempt.
        workingDirFS.delete(workingDir, true);
        // recreate the working directory for the snapshot
        if (!workingDirFS.mkdirs(workingDir)) {
            throw new SnapshotCreationException("Couldn't create working directory (" + workingDir + ") for snapshot", ProtobufUtil.createSnapshotDesc(snapshot));
        }
    } catch (HBaseSnapshotException e) {
        throw e;
    } catch (IOException e) {
        throw new SnapshotCreationException("Exception while checking to see if snapshot could be started.", e, ProtobufUtil.createSnapshotDesc(snapshot));
    }
}
Also used : Path(org.apache.hadoop.fs.Path) TableName(org.apache.hadoop.hbase.TableName) SnapshotSentinel(org.apache.hadoop.hbase.master.SnapshotSentinel) SnapshotCreationException(org.apache.hadoop.hbase.snapshot.SnapshotCreationException) FileSystem(org.apache.hadoop.fs.FileSystem) MasterFileSystem(org.apache.hadoop.hbase.master.MasterFileSystem) HBaseSnapshotException(org.apache.hadoop.hbase.snapshot.HBaseSnapshotException) IOException(java.io.IOException)

Example 4 with SnapshotCreationException

use of org.apache.hadoop.hbase.snapshot.SnapshotCreationException in project hbase by apache.

the class SnapshotManager method snapshotTable.

/**
 * Take a snapshot using the specified handler.
 * On failure the snapshot temporary working directory is removed.
 * NOTE: prepareToTakeSnapshot() called before this one takes care of the rejecting the
 *       snapshot request if the table is busy with another snapshot/restore operation.
 * @param snapshot the snapshot description
 * @param handler the snapshot handler
 */
private synchronized void snapshotTable(SnapshotDescription snapshot, final TakeSnapshotHandler handler) throws IOException {
    try {
        handler.prepare();
        this.executorService.submit(handler);
        this.snapshotHandlers.put(TableName.valueOf(snapshot.getTable()), handler);
    } catch (Exception e) {
        // cleanup the working directory by trying to delete it from the fs.
        Path workingDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(snapshot, rootDir, master.getConfiguration());
        FileSystem workingDirFs = workingDir.getFileSystem(master.getConfiguration());
        try {
            if (!workingDirFs.delete(workingDir, true)) {
                LOG.error("Couldn't delete working directory (" + workingDir + " for snapshot:" + ClientSnapshotDescriptionUtils.toString(snapshot));
            }
        } catch (IOException e1) {
            LOG.error("Couldn't delete working directory (" + workingDir + " for snapshot:" + ClientSnapshotDescriptionUtils.toString(snapshot));
        }
        // fail the snapshot
        throw new SnapshotCreationException("Could not build snapshot handler", e, ProtobufUtil.createSnapshotDesc(snapshot));
    }
}
Also used : Path(org.apache.hadoop.fs.Path) FileSystem(org.apache.hadoop.fs.FileSystem) MasterFileSystem(org.apache.hadoop.hbase.master.MasterFileSystem) SnapshotCreationException(org.apache.hadoop.hbase.snapshot.SnapshotCreationException) IOException(java.io.IOException) SnapshotExistsException(org.apache.hadoop.hbase.snapshot.SnapshotExistsException) HBaseSnapshotException(org.apache.hadoop.hbase.snapshot.HBaseSnapshotException) RestoreSnapshotException(org.apache.hadoop.hbase.snapshot.RestoreSnapshotException) AccessDeniedException(org.apache.hadoop.hbase.security.AccessDeniedException) FileNotFoundException(java.io.FileNotFoundException) TablePartiallyOpenException(org.apache.hadoop.hbase.snapshot.TablePartiallyOpenException) SnapshotCreationException(org.apache.hadoop.hbase.snapshot.SnapshotCreationException) ForeignException(org.apache.hadoop.hbase.errorhandling.ForeignException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) UnknownSnapshotException(org.apache.hadoop.hbase.snapshot.UnknownSnapshotException) SnapshotDoesNotExistException(org.apache.hadoop.hbase.snapshot.SnapshotDoesNotExistException)

Example 5 with SnapshotCreationException

use of org.apache.hadoop.hbase.snapshot.SnapshotCreationException in project hbase by apache.

the class SnapshotManager method takeSnapshot.

/**
   * Take a snapshot based on the enabled/disabled state of the table.
   *
   * @param snapshot
   * @throws HBaseSnapshotException when a snapshot specific exception occurs.
   * @throws IOException when some sort of generic IO exception occurs.
   */
public void takeSnapshot(SnapshotDescription snapshot) throws IOException {
    // check to see if we already completed the snapshot
    if (isSnapshotCompleted(snapshot)) {
        throw new SnapshotExistsException("Snapshot '" + snapshot.getName() + "' already stored on the filesystem.", ProtobufUtil.createSnapshotDesc(snapshot));
    }
    LOG.debug("No existing snapshot, attempting snapshot...");
    // stop tracking "abandoned" handlers
    cleanupSentinels();
    // check to see if the table exists
    HTableDescriptor desc = null;
    try {
        desc = master.getTableDescriptors().get(TableName.valueOf(snapshot.getTable()));
    } catch (FileNotFoundException e) {
        String msg = "Table:" + snapshot.getTable() + " info doesn't exist!";
        LOG.error(msg);
        throw new SnapshotCreationException(msg, e, ProtobufUtil.createSnapshotDesc(snapshot));
    } catch (IOException e) {
        throw new SnapshotCreationException("Error while geting table description for table " + snapshot.getTable(), e, ProtobufUtil.createSnapshotDesc(snapshot));
    }
    if (desc == null) {
        throw new SnapshotCreationException("Table '" + snapshot.getTable() + "' doesn't exist, can't take snapshot.", ProtobufUtil.createSnapshotDesc(snapshot));
    }
    SnapshotDescription.Builder builder = snapshot.toBuilder();
    // if not specified, set the snapshot format
    if (!snapshot.hasVersion()) {
        builder.setVersion(SnapshotDescriptionUtils.SNAPSHOT_LAYOUT_VERSION);
    }
    User user = RpcServer.getRequestUser();
    if (User.isHBaseSecurityEnabled(master.getConfiguration()) && user != null) {
        builder.setOwner(user.getShortName());
    }
    snapshot = builder.build();
    // call pre coproc hook
    MasterCoprocessorHost cpHost = master.getMasterCoprocessorHost();
    if (cpHost != null) {
        cpHost.preSnapshot(snapshot, desc);
    }
    // if the table is enabled, then have the RS run actually the snapshot work
    TableName snapshotTable = TableName.valueOf(snapshot.getTable());
    if (master.getTableStateManager().isTableState(snapshotTable, TableState.State.ENABLED)) {
        LOG.debug("Table enabled, starting distributed snapshot.");
        snapshotEnabledTable(snapshot);
        LOG.debug("Started snapshot: " + ClientSnapshotDescriptionUtils.toString(snapshot));
    } else // For disabled table, snapshot is created by the master
    if (master.getTableStateManager().isTableState(snapshotTable, TableState.State.DISABLED)) {
        LOG.debug("Table is disabled, running snapshot entirely on master.");
        snapshotDisabledTable(snapshot);
        LOG.debug("Started snapshot: " + ClientSnapshotDescriptionUtils.toString(snapshot));
    } else {
        LOG.error("Can't snapshot table '" + snapshot.getTable() + "', isn't open or closed, we don't know what to do!");
        TablePartiallyOpenException tpoe = new TablePartiallyOpenException(snapshot.getTable() + " isn't fully open.");
        throw new SnapshotCreationException("Table is not entirely open or closed", tpoe, ProtobufUtil.createSnapshotDesc(snapshot));
    }
    // call post coproc hook
    if (cpHost != null) {
        cpHost.postSnapshot(snapshot, desc);
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) MasterCoprocessorHost(org.apache.hadoop.hbase.master.MasterCoprocessorHost) User(org.apache.hadoop.hbase.security.User) SnapshotCreationException(org.apache.hadoop.hbase.snapshot.SnapshotCreationException) TablePartiallyOpenException(org.apache.hadoop.hbase.snapshot.TablePartiallyOpenException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) SnapshotDescription(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.SnapshotDescription) SnapshotExistsException(org.apache.hadoop.hbase.snapshot.SnapshotExistsException) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Aggregations

SnapshotCreationException (org.apache.hadoop.hbase.snapshot.SnapshotCreationException)6 IOException (java.io.IOException)5 TableName (org.apache.hadoop.hbase.TableName)4 FileNotFoundException (java.io.FileNotFoundException)3 FileSystem (org.apache.hadoop.fs.FileSystem)2 Path (org.apache.hadoop.fs.Path)2 MasterCoprocessorHost (org.apache.hadoop.hbase.master.MasterCoprocessorHost)2 MasterFileSystem (org.apache.hadoop.hbase.master.MasterFileSystem)2 HBaseProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)2 IsSnapshotDoneRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneRequest)2 IsSnapshotDoneResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneResponse)2 RestoreSnapshotResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.RestoreSnapshotResponse)2 SnapshotResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SnapshotResponse)2 HBaseSnapshotException (org.apache.hadoop.hbase.snapshot.HBaseSnapshotException)2 RestoreSnapshotException (org.apache.hadoop.hbase.snapshot.RestoreSnapshotException)2 SnapshotExistsException (org.apache.hadoop.hbase.snapshot.SnapshotExistsException)2 TablePartiallyOpenException (org.apache.hadoop.hbase.snapshot.TablePartiallyOpenException)2 Nullable (edu.umd.cs.findbugs.annotations.Nullable)1 InterruptedIOException (java.io.InterruptedIOException)1 ArrayList (java.util.ArrayList)1