accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1324771 - in /accumulo/branches/1.4: src/server/src/main/java/org/apache/accumulo/server/test/functional/ src/server/src/main/java/org/apache/accumulo/server/test/performance/thrift/ test/system/auto/stress/
Date Wed, 11 Apr 2012 14:10:08 GMT
Author: ecn
Date: Wed Apr 11 14:10:07 2012
New Revision: 1324771

URL: http://svn.apache.org/viewvc?rev=1324771&view=rev
Log:
ACCUMULO-526 : create a zombie tserver the master can kill

Added:
    accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/test/functional/ZombieTServer.java
  (with props)
Modified:
    accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/test/performance/thrift/NullTserver.java
    accumulo/branches/1.4/test/system/auto/stress/weird.py

Added: accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/test/functional/ZombieTServer.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/test/functional/ZombieTServer.java?rev=1324771&view=auto
==============================================================================
--- accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/test/functional/ZombieTServer.java
(added)
+++ accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/test/functional/ZombieTServer.java
Wed Apr 11 14:10:07 2012
@@ -0,0 +1,132 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.server.test.functional;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.Random;
+
+import org.apache.accumulo.cloudtrace.thrift.TInfo;
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.master.thrift.TableInfo;
+import org.apache.accumulo.core.master.thrift.TabletServerStatus;
+import org.apache.accumulo.core.security.thrift.AuthInfo;
+import org.apache.accumulo.core.security.thrift.ThriftSecurityException;
+import org.apache.accumulo.core.tabletserver.thrift.TabletClientService;
+import org.apache.accumulo.core.util.AddressUtil;
+import org.apache.accumulo.core.util.ServerServices;
+import org.apache.accumulo.core.util.ServerServices.Service;
+import org.apache.accumulo.core.util.UtilWaitThread;
+import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.core.zookeeper.ZooUtil.NodeExistsPolicy;
+import org.apache.accumulo.server.client.HdfsZooInstance;
+import org.apache.accumulo.server.util.TServerUtils;
+import org.apache.accumulo.server.util.TServerUtils.ServerPort;
+import org.apache.accumulo.server.zookeeper.TransactionWatcher;
+import org.apache.accumulo.server.zookeeper.ZooLock;
+import org.apache.accumulo.server.zookeeper.ZooLock.LockLossReason;
+import org.apache.accumulo.server.zookeeper.ZooLock.LockWatcher;
+import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+
+/**
+ * Tablet server that creates a lock in zookeeper, responds to one status request, and then
hangs on subsequent requests. Exits with code zero if halted.
+ */
+public class ZombieTServer {
+  
+  public static class ThriftClientHandler extends org.apache.accumulo.server.test.performance.thrift.NullTserver.ThriftClientHandler
{
+    
+    int statusCount = 0;
+    
+    boolean halted = false;
+
+    ThriftClientHandler(TransactionWatcher watcher) {
+      super(watcher);
+    }
+    
+    @Override
+    synchronized public void fastHalt(TInfo tinfo, AuthInfo credentials, String lock) {
+      halted = true;
+      notifyAll();
+    }
+    
+    @Override
+    public TabletServerStatus getTabletServerStatus(TInfo tinfo, AuthInfo credentials) throws
ThriftSecurityException, TException {
+      synchronized (this) {
+        if (statusCount++ < 1) {
+          TabletServerStatus result = new TabletServerStatus();
+          result.tableMap = new HashMap<String,TableInfo>();
+          return result;
+        }
+      }
+      UtilWaitThread.sleep(Integer.MAX_VALUE);
+      return null;
+    }
+    
+    @Override
+    synchronized public void halt(TInfo tinfo, AuthInfo credentials, String lock) throws
ThriftSecurityException, TException {
+      halted = true;
+      notifyAll();
+    }
+    
+  }
+  
+  public static void main(String[] args) throws Exception {
+    final Logger log = Logger.getLogger(ZombieTServer.class);
+    Random random = new Random(System.currentTimeMillis() % 1000);
+    int port = random.nextInt(30000) + 2000;
+    
+    TransactionWatcher watcher = new TransactionWatcher();
+    final ThriftClientHandler tch = new ThriftClientHandler(watcher);
+    TabletClientService.Processor processor = new TabletClientService.Processor(tch);
+    ServerPort serverPort = TServerUtils.startTServer(port, processor, "ZombieTServer", "walking
dead", 2, 1000);
+    
+    InetSocketAddress addr = new InetSocketAddress(InetAddress.getLocalHost(), serverPort.port);
+    String addressString = AddressUtil.toString(addr);
+    String zPath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZTSERVERS +
"/" + addressString;
+    ZooReaderWriter zoo = ZooReaderWriter.getInstance();
+    zoo.putPersistentData(zPath, new byte[] {}, NodeExistsPolicy.SKIP);
+    
+    ZooLock zlock = new ZooLock(zPath);
+    
+    LockWatcher lw = new LockWatcher() {
+      @Override
+      public void lostLock(final LockLossReason reason) {
+        try {
+          tch.halt(null, null, null);
+        } catch (Exception ex) {
+          log.error(ex, ex);
+          System.exit(1);
+        }
+      }
+    };
+    
+    byte[] lockContent = new ServerServices(addressString, Service.TSERV_CLIENT).toString().getBytes();
+    if (zlock.tryLock(lw, lockContent)) {
+      log.debug("Obtained tablet server lock " + zlock.getLockPath());
+    }
+    // modify !METADATA
+    while (!tch.halted) {
+      synchronized (tch) {
+        tch.wait();
+      }
+    }
+    System.exit(0);
+  }
+}

Propchange: accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/test/functional/ZombieTServer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/test/performance/thrift/NullTserver.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/test/performance/thrift/NullTserver.java?rev=1324771&r1=1324770&r2=1324771&view=diff
==============================================================================
--- accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/test/performance/thrift/NullTserver.java
(original)
+++ accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/test/performance/thrift/NullTserver.java
Wed Apr 11 14:10:07 2012
@@ -70,11 +70,11 @@ import org.apache.thrift.TException;
 
 public class NullTserver {
   
-  private static class ThriftClientHandler extends ClientServiceHandler implements TabletClientService.Iface
{
+  public static class ThriftClientHandler extends ClientServiceHandler implements TabletClientService.Iface
{
     
     private long updateSession = 1;
     
-    ThriftClientHandler(TransactionWatcher watcher) {
+    public ThriftClientHandler(TransactionWatcher watcher) {
       super(watcher);
     }
     

Modified: accumulo/branches/1.4/test/system/auto/stress/weird.py
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/test/system/auto/stress/weird.py?rev=1324771&r1=1324770&r2=1324771&view=diff
==============================================================================
--- accumulo/branches/1.4/test/system/auto/stress/weird.py (original)
+++ accumulo/branches/1.4/test/system/auto/stress/weird.py Wed Apr 11 14:10:07 2012
@@ -17,62 +17,29 @@ import os
 
 import logging
 import unittest
-import time
-import sys
-import signal
-import socket
 
-from TestUtils import ACCUMULO_HOME, SITE, FUZZ
-
-from simple.readwrite import SunnyDayTest
+from TestUtils import TestUtilsMixin
 
 log = logging.getLogger('test.auto')
 
-class LateLastContact(SunnyDayTest):
+class LateLastContact(unittest.TestCase, TestUtilsMixin):
     """Fake the "tablet stops talking but holds its lock" problem we see when hard drives
and NFS fail.
-    Start a tabletserver, create a fake lock, start the master, kill the tablet server.
+       Start a ZombieTServer, and see that master stops it.
     """
 
     order = 80
 
-    settings = SunnyDayTest.settings.copy()
+    settings = TestUtilsMixin.settings.copy()
+    settings['general.rpc.timeout'] = '2s'
+
+    def setUp(self):
+        TestUtilsMixin.setUp(self);
     
     def runTest(self):
-        if not os.getenv("ZOOKEEPER_HOME"):
-            self.fail("ZOOKEEPER_HOME environment variable is not set please set the location
of ZOOKEEPER home in this environment variable")
-        self.waitForStop(self.ingester, self.waitTime())
-        cfg = os.path.join(ACCUMULO_HOME, 'conf', SITE)
-        import config
-        dir = config.parse(cfg)['instance.dfs.dir']
-
-        handle = self.runOn(self.masterHost(),
-                            ["hadoop","dfs","-ls", dir +"/instance_id"])
+        handle = self.runClassOn(self.masterHost(), 'org.apache.accumulo.server.test.functional.ZombieTServer',
[])
         out, err = handle.communicate()
-        out = out.strip()
-        instance_id = out.split("\n")[-1].split("/")[-1]
-        zkcli = os.path.join(os.getenv("ZOOKEEPER_HOME"), "bin", "zkCli.sh")
-        if not os.path.exists(zkcli):
-            zkcli = "/usr/share/zookeeper/bin/zkCli.sh"
-        myaddr = socket.getaddrinfo(socket.gethostname(), None)[0][-1][0]
-        self.wait(self.runOn(self.masterHost(),
-                             [zkcli, "-server", "localhost",
-                              "create", "-s",
-                              "/accumulo/%s/tservers/%s:%s/zlock-0" %
-                              (instance_id, myaddr, 42000),
-                              "tserver", "world:anyone:cdrw"]))
-        self.stop_tserver(self.masterHost(), signal=signal.SIGKILL)
-        log.info("Making sure the tablet server is still considered online")
-        handle = self.runClassOn(self.masterHost(), 'org.apache.accumulo.server.test.GetMasterStats',
[])
-        out, err = handle.communicate()
-        tServer = "%s:%s" % (myaddr, 39000 + FUZZ)
-        assert out.find(tServer) > 0
-        self.sleep(12)
-        log.info("Making sure the tablet server is now offline")
-        handle = self.runClassOn(self.masterHost(), 'org.apache.accumulo.server.test.GetMasterStats',
[])
-        out, err = handle.communicate()
-        assert (out.find(tServer) < 0) or (out.find(tServer) > out.find('Bad servers'))
-        
-        
+        assert handle.returncode == 0
+
 def suite():
     result = unittest.TestSuite()
     result.addTest(LateLastContact())



Mime
View raw message