Return-Path: X-Original-To: apmail-hbase-dev-archive@www.apache.org Delivered-To: apmail-hbase-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A4DEC17D06 for ; Sat, 7 Nov 2015 19:47:45 +0000 (UTC) Received: (qmail 59488 invoked by uid 500); 7 Nov 2015 19:47:45 -0000 Delivered-To: apmail-hbase-dev-archive@hbase.apache.org Received: (qmail 59389 invoked by uid 500); 7 Nov 2015 19:47:45 -0000 Mailing-List: contact dev-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list dev@hbase.apache.org Received: (qmail 59377 invoked by uid 99); 7 Nov 2015 19:47:44 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Nov 2015 19:47:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 56B1718034C for ; Sat, 7 Nov 2015 19:47:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.88 X-Spam-Level: ** X-Spam-Status: No, score=2.88 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id dWCp6MsFuciw for ; Sat, 7 Nov 2015 19:47:34 +0000 (UTC) Received: from mail-yk0-f174.google.com (mail-yk0-f174.google.com [209.85.160.174]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id D34CB21277 for ; Sat, 7 Nov 2015 19:47:33 +0000 (UTC) Received: by ykek133 with SMTP id k133so217278488yke.2 for ; Sat, 07 Nov 2015 11:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=6mB+4gvtSskVmYORTYHNn57+XYgr70EeIyl03kVXgZQ=; b=adBLpJXCZ1jOLjtqdpN7p93QIxXV2Sw07dfaD7aZX7G5FbJpkfAbr7rvpxeSEFyFpj yql8mApH/tJwCSjlsuZdjYs+wT8O5XHcLC838wHXILz6tP8XFKi7nqSuW+MiYoQeFt6u szC2mE/easamIISIKmI1Hxs1JRWbTLRD5xUtFxdkPn3RcL/yMBb+qV4WPWmtEHVuVM3X CqRdDG8hOSjr36JyLbWWuGMVveED1QPmHqfm1wc/350E+ldlY/xXKtIx/oXILiHASVmJ VJ8gozdr57yFfGGtkj9NYp6IxcbhhJLi32xnjhIxzmpxjzGso93uGuXUZPZ3RcN6DuHi GHGQ== MIME-Version: 1.0 X-Received: by 10.129.125.212 with SMTP id y203mr16441364ywc.182.1446925646568; Sat, 07 Nov 2015 11:47:26 -0800 (PST) Received: by 10.37.216.145 with HTTP; Sat, 7 Nov 2015 11:47:26 -0800 (PST) In-Reply-To: <2737c77b.47a.150e32ebdd7.Coremail.wangyongqiang0617@163.com> References: <2bd50b93.499d.150e092cde6.Coremail.wangyongqiang0617@163.com> <2737c77b.47a.150e32ebdd7.Coremail.wangyongqiang0617@163.com> Date: Sat, 7 Nov 2015 11:47:26 -0800 Message-ID: Subject: Re: Re: improvements on snapshot From: Ted Yu To: "dev@hbase.apache.org" Content-Type: multipart/alternative; boundary=001a1149262c2e241a0523f8a171 --001a1149262c2e241a0523f8a171 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Current behavior for creating duplicate snapshot is: hbase(main):005:0> snapshot 'IntegrationTestBigLinkedList', 'snap1' ERROR: org.apache.hadoop.hbase.snapshot.SnapshotExistsException: Snapshot 'snap1' already stored on the filesystem. at org.apache.hadoop.hbase.master.snapshot.SnapshotManager.takeSnapshot(Snapsh= otManager.java:530) at org.apache.hadoop.hbase.master.MasterRpcServices.snapshot(MasterRpcServices= .java:1275) at org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$2.cal= lBlockingMethod(MasterProtos.java:51123) at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2114) bq. before we create a snopshot of a table, we can check if there is a snopshot with same name Suppose snapshot name has been taken, are you going to try with different name blindly ? The second attempt may receive SnapshotExistsException, right ? Better approach is to use list_snapshots command to obtain existing snapshots so that your attempt is more guided. Cheers On Sat, Nov 7, 2015 at 10:21 AM, WangYQ wrote: > 1. i download the src code from: > http://mirrors.hust.edu.cn/apache/hbase/0.98.15/ > class: org.apache.hadoop.hbase.master.snapshot.SnapshotManager > method: public void restoreSnapshot(SnapshotDescription reqSnapshot) > throws IOException > line: 725 > code: > > > if (cpHost !=3D null) { > cpHost.postRestoreSnapshot(reqSnapshot, snapshotTableDesc); > } > } else { > HTableDescriptor htd =3D > RestoreSnapshotHelper.cloneTableSchema(snapshotTableDesc, tableName); > if (cpHost !=3D null) { > cpHost.preCloneSnapshot(reqSnapshot, htd); > } > cloneSnapshot(fsSnapshot, htd); > LOG.info("Clone snapshot=3D" + fsSnapshot.getName() + " as table=3D= " + > tableName); > > > if (cpHost !=3D null) { > cpHost.postCloneSnapshot(reqSnapshot, htd); > } > > i think the clone: > HTableDescriptor htd =3D > RestoreSnapshotHelper.cloneTableSchema(snapshotTableDesc, tableName); > can be removed. > > > 2. this one is similar to the one in HBaseAdmin.getTableDecsriptor > 3. add method 'isSnapShotExists' in HBaseAdmin to help us to know if > there is a snopshot on HDFS, just like HBaseAdmin.tableExists, > before we create a snopshot of a table, we can check if there is a > snopshot with same name > 4. simplify the code > version: hbase 0.98.15 > class: org.apache.hadoop.hbase.master.cleaner.CleanerChore > method:private boolean checkAndDeleteFiles(List files) > line: 235-243 > code: > > > // trace which cleaner is holding on to each file > if (LOG.isTraceEnabled()) { > ImmutableSet filteredFileSet =3D > ImmutableSet.copyOf(filteredFiles); > for (FileStatus file : deletableValidFiles) { > if (!filteredFileSet.contains(file)) { > LOG.trace(file.getPath() + " is not deletable according to:" = + > cleaner); > } > } > } > i think these code can use set's difference operation instead, which > is more straightforward > > > At 2015-11-07 21:10:21, "Ted Yu" wrote: > >For #1, I took a look at current 0.98 code but didn't find it. > >Can you double check and tell us the updated line number ? > > > >For #2, I think it makes sense - considering there may be large number o= f > >snapshots in the cluster. > > > >For #3, can you tell us the use case for the new API ? > > > >Cheers > > > >On Fri, Nov 6, 2015 at 10:12 PM, =E7=8E=8B=E5=8B=87=E5=BC=BA wrote: > > > >> the version is hbase0.98.10, find some improvements on snapshot: > >> 1. in class SnapshotManager, line 725, we make a clone of > >> HTableDescriptor, the clone is not so need to make > >> 2 class HBaseAdmin, method > >> public void restoreSnapshot(final String snapshotName, boolean > >> takeFailSafeSnapshot) > >> { > >> TableName tableName =3D null; > >> for (SnapshotDescription snapshotInfo: listSnapshots()) { > >> if (snapshotInfo.getName().equals(snapshotName)) { > >> tableName =3D TableName.valueOf(snapshotInfo.getTable()); > >> break; > >> } > >> } > >> ...... > >> } > >> must get all snapshot from master and then get the one we need, can > >> improve this, master just return the snapshot client needed > >> > >> > >> 3. there should better has a method 'isSnapShotExists' in HBaseAdmin > >> > >> > >> > >> > >> > >> > >> > >> > --001a1149262c2e241a0523f8a171--