Package org.apache.hadoop.hdfs.server.datanode

Examples of org.apache.hadoop.hdfs.server.datanode.DataNodeFaultInjector


      List<BlockLocation> allLocs = Lists.newArrayList();
      allLocs.addAll(Arrays.asList(blockLocs1));
      allLocs.addAll(Arrays.asList(blockLocs2));

      // Stall on the DN to test the timeout
      DataNodeFaultInjector injector = Mockito.mock(DataNodeFaultInjector.class);
      Mockito.doAnswer(new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
          Thread.sleep(3000);
          return null;
        }
      }).when(injector).getHdfsBlocksMetadata();
      DataNodeFaultInjector.instance = injector;

      BlockStorageLocation[] locs = fs.getFileBlockStorageLocations(allLocs);
      for (BlockStorageLocation loc: locs) {
        assertEquals(
            "Found more than 0 cached hosts although RPCs supposedly timed out",
            0, loc.getCachedHosts().length);
      }

      // Restore a default injector
      DataNodeFaultInjector.instance = new DataNodeFaultInjector();

      // Stop a datanode to simulate a failure.
      DataNodeProperties stoppedNode = cluster.stopDataNode(0);
     
      // Fetch VolumeBlockLocations
View Full Code Here


      List<BlockLocation> allLocs = Lists.newArrayList();
      allLocs.addAll(Arrays.asList(blockLocs1));
      allLocs.addAll(Arrays.asList(blockLocs2));

      // Stall on the DN to test the timeout
      DataNodeFaultInjector injector = Mockito.mock(DataNodeFaultInjector.class);
      Mockito.doAnswer(new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
          Thread.sleep(3000);
          return null;
        }
      }).when(injector).getHdfsBlocksMetadata();
      DataNodeFaultInjector.instance = injector;

      BlockStorageLocation[] locs = fs.getFileBlockStorageLocations(allLocs);
      for (BlockStorageLocation loc: locs) {
        assertEquals(
            "Found more than 0 cached hosts although RPCs supposedly timed out",
            0, loc.getCachedHosts().length);
      }

      // Restore a default injector
      DataNodeFaultInjector.instance = new DataNodeFaultInjector();

      // Stop a datanode to simulate a failure.
      DataNodeProperties stoppedNode = cluster.stopDataNode(0);
     
      // Fetch VolumeBlockLocations
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.server.datanode.DataNodeFaultInjector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.