hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Dufrêne <dufr...@argia.fr>
Subject Re: How to initialize a test environment ?
Date Tue, 13 Oct 2009 13:13:52 GMT

Hi there,

I'm currently trying to set up a test environment launched during my 
unit tests.
I succeed in lauching hbase from the bin scripts provided with hbase and 
test on my local server,
but i was unable to run it from Java.
I wrote a class inspired from the Mini*Server located in Hbase Tests.

(I use Hbase 0.20)

Here my class :

public class StandaloneServer {

   private static Log log = LogFactory.getLog(StandaloneServer.class);

   private MiniZooKeeperCluster zookeeper;
   private MiniHBaseCluster hbase;
   private MiniDFSCluster dfs;

   private HBaseConfiguration conf;

   public void startup() throws Exception {
       conf = new HBaseConfiguration();

       log.info("Start DFS ...");
       dfs = new MiniDFSCluster(conf, 2, true, (String[]) null);
       // set file system to the mini dfs just started up
       FileSystem fs = dfs.getFileSystem();
       conf.set("fs.default.name", fs.getUri().toString());
       Path parentdir = fs.getHomeDirectory();
       conf.set(HConstants.HBASE_DIR, parentdir.toString());
       fs.mkdirs(parentdir);
       FSUtils.setVersion(fs, parentdir);

       log.info("Start Zookeeper ...");
       zookeeper = new MiniZooKeeperCluster();
       int clientPort = zookeeper.startup(new File(parentdir.toString(), 
"zookeeper"));
       conf.set("hbase.zookeeper.property.clientPort", Integer
               .toString(clientPort));

       // Disable regionserver info.
       conf.set("hbase.regionserver.info.port", "-1");
       conf.set("hbase.master.info.port", "-1");

       log.info("Start HBase ...");
       hbase = new MiniHBaseCluster(conf, 1);

       log.info("Check ROOT metatable connexion ...");
       new HTable(conf, HConstants.META_TABLE_NAME);

   }

   public void shutdown() {
       hbase.shutdown();
       if (dfs != null) {
           try {
               FileSystem fs = dfs.getFileSystem();
               if (fs != null)
                   fs.close();
           } catch (IOException e) {
               System.err.println("error closing file system: " + e);
           }
           try {
               dfs.shutdown();
           } catch (Exception e) { /* ignore */
           }
       }
   }

   public static void main(String[] args) throws Exception {
       final StandaloneServer server = new StandaloneServer();
       server.startup();

       // add close hook
       Runtime.getRuntime().addShutdownHook(new Thread() {
           public void run() {
               server.shutdown();
           }
       });

   }
}

I first wrote a main operation to easily test the behaviour ...
The idea is to start the server when my unit test is set up.

I got the following error :
09/10/13 14:12:13 INFO hbase.StandaloneServer: Check ROOT metatable 
connexion ...
Exception in thread "main" 
org.apache.hadoop.hbase.client.NoServerForRegionException: No server 
address listed in -ROOT- for region .META.,,1
   at 
[oahh.client]HConnectionManager$TableServers.locateRegionInMeta(HConnectionManager.java:660)


   at 
[oahh.client].HConnectionManager$TableServers.locateRegion(HConnectionManager.java:582) 

   at 
[oahh.client].client.HConnectionManager$TableServers.locateRegion(HConnectionManager.java:549)


   at [oahh.client].HTable.<init>(HTable.java:125)
   at (...) StandaloneServer.startup(StandaloneServer.java:53)
   at (...) StandaloneServer.main(StandaloneServer.java:76)

And some errors about "NO JSP Support" (but I think that I can ignore 
them, no ?)

So my question are :
- Is it the good way to start a test environment ?

And, If I succeed in starting up my server :
- Should I stop and restart the servers between each test ? (it seems to 
take a long time)
- May I just delete data from tables ? (it seems to take less time)


Thanks for your feedback,
-- 
Guillaume Dufrêne.





Ce message et toutes les pièces jointes sont établis à l'attention exclusive de leurs destinataires
et sont confidentiels. Si vous recevez ce message par erreur, merci de le détruire et d'en
avertir immédiatement l'expéditeur. L'internet ne permettant pas d'assurer l'intégrité
de ce message, le contenu de ce message ne représente en aucun cas un engagement de la part
de Leroy Merlin.

Mime
View raw message