当前位置: 首页>>代码示例>>Java>>正文


Java LeaseExpiredException类代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException的典型用法代码示例。如果您正苦于以下问题:Java LeaseExpiredException类的具体用法?Java LeaseExpiredException怎么用?Java LeaseExpiredException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LeaseExpiredException类属于org.apache.hadoop.hdfs.server.namenode包,在下文中一共展示了LeaseExpiredException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: recoverLease

import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException; //导入依赖的package包/类
/**
 * Try to recover the lease.
 * @param dfs
 * @param nbAttempt
 * @param p
 * @param startWaiting
 * @return True if dfs#recoverLease came by true.
 * @throws FileNotFoundException
 */
boolean recoverLease(final DistributedFileSystem dfs, final int nbAttempt, final Path p,
    final long startWaiting)
throws FileNotFoundException {
  boolean recovered = false;
  try {
    recovered = dfs.recoverLease(p);
    LOG.info((recovered? "Recovered lease, ": "Failed to recover lease, ") +
      getLogMessageDetail(nbAttempt, p, startWaiting));
  } catch (IOException e) {
    if (e instanceof LeaseExpiredException && e.getMessage().contains("File does not exist")) {
      // This exception comes out instead of FNFE, fix it
      throw new FileNotFoundException("The given WAL wasn't found at " + p);
    } else if (e instanceof FileNotFoundException) {
      throw (FileNotFoundException)e;
    }
    LOG.warn(getLogMessageDetail(nbAttempt, p, startWaiting), e);
  }
  return recovered;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:FSHDFSUtils.java

示例2: recoverLease

import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException; //导入依赖的package包/类
/**
 * Try to recover the lease.
 * @param dfs The filesystem instance.
 * @param nbAttempt Count number of this attempt.
 * @param p Path of the file to recover.
 * @param startWaiting Timestamp of when we started attempting to recover the file lease.
 * @return True if dfs#recoverLease came by true.
 * @throws java.io.FileNotFoundException
 */
boolean recoverLease(final DistributedFileSystem dfs, final int nbAttempt, final Path p,
                     final long startWaiting)
  throws FileNotFoundException {
  boolean recovered = false;
  try {
    recovered = dfs.recoverLease(p);
    LOG.info("recoverLease=" + recovered + ", " +
               getLogMessageDetail(nbAttempt, p, startWaiting));
  } catch (IOException e) {
    if (e instanceof LeaseExpiredException && e.getMessage().contains("File does not exist")) {
      // This exception comes out instead of FNFE, fix it
      throw new FileNotFoundException("The given file wasn't found at " + p);
    } else if (e instanceof FileNotFoundException) {
      throw (FileNotFoundException) e;
    }
    LOG.warn(getLogMessageDetail(nbAttempt, p, startWaiting), e);
  }
  return recovered;
}
 
开发者ID:apache,项目名称:incubator-tephra,代码行数:29,代码来源:HDFSUtil.java

示例3: recoverLease

import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException; //导入依赖的package包/类
/**
 * Try to recover the lease.
 * @param dfs
 * @param nbAttempt
 * @param p
 * @param startWaiting
 * @return True if dfs#recoverLease came by true.
 * @throws FileNotFoundException
 */
boolean recoverLease(final DistributedFileSystem dfs, final int nbAttempt, final Path p,
    final long startWaiting)
throws FileNotFoundException {
  boolean recovered = false;
  try {
    recovered = dfs.recoverLease(p);
    LOG.info("recoverLease=" + recovered + ", " +
      getLogMessageDetail(nbAttempt, p, startWaiting));
  } catch (IOException e) {
    if (e instanceof LeaseExpiredException && e.getMessage().contains("File does not exist")) {
      // This exception comes out instead of FNFE, fix it
      throw new FileNotFoundException("The given HLog wasn't found at " + p);
    } else if (e instanceof FileNotFoundException) {
      throw (FileNotFoundException)e;
    }
    LOG.warn(getLogMessageDetail(nbAttempt, p, startWaiting), e);
  }
  return recovered;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:29,代码来源:FSHDFSUtils.java

示例4: testMovedHLogDuringRecovery

import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException; //导入依赖的package包/类
@Test
public void testMovedHLogDuringRecovery() throws Exception {
  generateHLogs(-1);

  fs.initialize(fs.getUri(), conf);

  // This partial mock will throw LEE for every file simulating
  // files that were moved
  FileSystem spiedFs = Mockito.spy(fs);
  // The "File does not exist" part is very important,
  // that's how it comes out of HDFS
  Mockito.doThrow(new LeaseExpiredException("Injected: File does not exist")).
      when(spiedFs).append(Mockito.<Path>any());

  HLogSplitter logSplitter = new HLogSplitter(
      conf, hbaseDir, hlogDir, oldLogDir, spiedFs);

  try {
    logSplitter.splitLog();
    assertEquals(NUM_WRITERS, fs.listStatus(oldLogDir).length);
    assertFalse(fs.exists(hlogDir));
  } catch (IOException e) {
    fail("There shouldn't be any exception but: " + e.toString());
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:26,代码来源:TestHLogSplit.java

示例5: recoverLease

import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException; //导入依赖的package包/类
/**
 * Try to recover the lease.
 * @param dfs
 * @param nbAttempt
 * @param p
 * @param startWaiting
 * @return True if dfs#recoverLease came by true.
 * @throws FileNotFoundException
 */
boolean recoverLease(final DistributedFileSystem dfs, final int nbAttempt, final Path p,
    final long startWaiting)
throws FileNotFoundException {
  boolean recovered = false;
  try {
    recovered = dfs.recoverLease(p);
    LOG.info("recoverLease=" + recovered + ", " +
      getLogMessageDetail(nbAttempt, p, startWaiting));
  } catch (IOException e) {
    if (e instanceof LeaseExpiredException && e.getMessage().contains("File does not exist")) {
      // This exception comes out instead of FNFE, fix it
      throw new FileNotFoundException("The given WAL wasn't found at " + p);
    } else if (e instanceof FileNotFoundException) {
      throw (FileNotFoundException)e;
    }
    LOG.warn(getLogMessageDetail(nbAttempt, p, startWaiting), e);
  }
  return recovered;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:29,代码来源:FSHDFSUtils.java

示例6: testMovedHLogDuringRecovery

import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException; //导入依赖的package包/类
@Test (timeout=300000)
public void testMovedHLogDuringRecovery() throws Exception {
  generateHLogs(-1);

  fs.initialize(fs.getUri(), conf);

  // This partial mock will throw LEE for every file simulating
  // files that were moved
  FileSystem spiedFs = Mockito.spy(fs);
  // The "File does not exist" part is very important,
  // that's how it comes out of HDFS
  Mockito.doThrow(new LeaseExpiredException("Injected: File does not exist")).
      when(spiedFs).append(Mockito.<Path>any());

  try {
    HLogSplitter.split(HBASEDIR, HLOGDIR, OLDLOGDIR, spiedFs, conf);
    assertEquals(NUM_WRITERS, fs.listStatus(OLDLOGDIR).length);
    assertFalse(fs.exists(HLOGDIR));
  } catch (IOException e) {
    fail("There shouldn't be any exception but: " + e.toString());
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:23,代码来源:TestHLogSplit.java

示例7: testMovedHLogDuringRecovery

import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException; //导入依赖的package包/类
@Test
public void testMovedHLogDuringRecovery() throws Exception {
  generateHLogs(-1);

  fs.initialize(fs.getUri(), conf);

  // This partial mock will throw LEE for every file simulating
  // files that were moved
  FileSystem spiedFs = Mockito.spy(fs);
  // The "File does not exist" part is very important,
  // that's how it comes out of HDFS
  Mockito.doThrow(new LeaseExpiredException("Injected: File does not exist")).
      when(spiedFs).append(Mockito.<Path>any());

  HLogSplitter logSplitter = new HLogSplitter(
      conf, HBASEDIR, HLOGDIR, OLDLOGDIR, spiedFs, null);

  try {
    logSplitter.splitLog();
    assertEquals(NUM_WRITERS, fs.listStatus(OLDLOGDIR).length);
    assertFalse(fs.exists(HLOGDIR));
  } catch (IOException e) {
    fail("There shouldn't be any exception but: " + e.toString());
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:26,代码来源:TestHLogSplit.java

示例8: testFileIdMismatch

import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException; //导入依赖的package包/类
/**
 * Test complete(..) - verifies that the fileId in the request
 * matches that of the Inode.
 * This test checks that FileNotFoundException exception is thrown in case
 * the fileId does not match.
 */
@Test
public void testFileIdMismatch() throws IOException {
  Configuration conf = new HdfsConfiguration();
  MiniDFSCluster cluster =
      new MiniDFSCluster.Builder(conf).numDataNodes(3).build();
  DistributedFileSystem dfs = null;
  try {
    cluster.waitActive();
    dfs = cluster.getFileSystem();
    DFSClient client = dfs.dfs;

    final Path f = new Path("/testFileIdMismatch.txt");
    createFile(dfs, f, 3);
    long someOtherFileId = -1;
    try {
      cluster.getNameNodeRpc()
          .complete(f.toString(), client.clientName, null, someOtherFileId);
      fail();
    } catch(LeaseExpiredException e) {
      FileSystem.LOG.info("Caught Expected LeaseExpiredException: ", e);
    }
  } finally {
    IOUtils.closeStream(dfs);
    cluster.shutdown();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:TestFileCreation.java

示例9: testMovedWALDuringRecovery

import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException; //导入依赖的package包/类
@Test (timeout=300000)
public void testMovedWALDuringRecovery() throws Exception {
  // This partial mock will throw LEE for every file simulating
  // files that were moved
  FileSystem spiedFs = Mockito.spy(fs);
  // The "File does not exist" part is very important,
  // that's how it comes out of HDFS
  Mockito.doThrow(new LeaseExpiredException("Injected: File does not exist")).
      when(spiedFs).append(Mockito.<Path>any());
  retryOverHdfsProblem(spiedFs);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:12,代码来源:TestWALSplit.java

示例10: transferFile

import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException; //导入依赖的package包/类
@Override
protected void transferFile(boolean deleteSource, String destination, String filename, String localDirectory) throws IOException {
	Path source = new Path(localDirectory + BaseESReducer.DIR_SEPARATOR + filename);
	ensurePathExists(destination);

	try{
		hdfsFileSystem.copyFromLocalFile(deleteSource, true, source, new Path(destination + BaseESReducer.DIR_SEPARATOR + filename));	
	}
	catch(LeaseExpiredException | RemoteException e) {
		// This is an expected race condition where 2 reducers are trying to write the manifest files at the same time. That's okay, it only has to succeed once. 
		logger.warn("Exception from 2 reducers writing the same file concurrently. One writer failed to obtain a lease. Destination " + destination + " filename " + filename + " localDirectory " + localDirectory, e);
	}
}
 
开发者ID:MyPureCloud,项目名称:elasticsearch-lambda,代码行数:14,代码来源:HDFSSnapshotTransport.java

示例11: create

import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException; //导入依赖的package包/类
/**
 * Create a new dfs file with the specified block replication
 * with write-progress reporting and return an output stream for writing
 * into the file.
 *
 * @param src stream name
 * @param permission The permission of the directory being created.
 * If permission == null, use {@link FsPermission#getDefault()}.
 * @param overwrite do not check for file existence if true
 * @param replication block replication
 * @param forceSync a hdfs sync() operation invokes local filesystem sync
 * 				on datanodes.
 * @param doParallelWrites write replicas in parallel
 * @param favoredNodes nodes on which to place replicas if possible
 * @return output stream
 * @throws IOException
 * @see ClientProtocol#create(String, FsPermission, String, boolean, short, long)
 */
public OutputStream create(String src,
                           FsPermission permission,
                           boolean overwrite,
                           boolean createParent,
                           short replication,
                           long blockSize,
                           Progressable progress,
                           int buffersize,
                           int bytesPerChecksum,
                           boolean forceSync,
                           boolean doParallelWrites,
                           InetSocketAddress[] favoredNodes)
throws IOException {
  checkOpen();
  if (permission == null) {
    permission = FsPermission.getDefault();
  }
  boolean success = false;
  try {
    FsPermission masked = permission.applyUMask(FsPermission.getUMask(conf));
    LOG.debug(src + ": masked=" + masked);

    // For each of the favored nodes, mock up a DatanodeInfo with the IP
    // address and port of that node.
    DatanodeInfo[] favoredNodeInfos = null;
    if (favoredNodes != null) {
      favoredNodeInfos = new DatanodeInfo[favoredNodes.length];
      for (int i = 0; i < favoredNodes.length; i++) {
        favoredNodeInfos[i] = new DatanodeInfo(new DatanodeID(
            favoredNodes[i].getAddress().getHostAddress() + ":" +
            favoredNodes[i].getPort()));
      }
    }

    OutputStream result = new DFSOutputStream(this, src, masked,
        overwrite, createParent, replication, blockSize, progress, buffersize,
        bytesPerChecksum, forceSync, doParallelWrites, favoredNodeInfos);
    leasechecker.put(src, result);
    metrics.incNumCreateFileOps();
    if (stats != null) {
      stats.incrementFilesCreated();
    }
    success = true;
    return result;
  } finally {
    if (!success  && namenodeProtocolProxy.isMethodSupported(
        "abandonFile", String.class, String.class)) {
      try {
        namenode.abandonFile(src, clientName);
      } catch (RemoteException e) {
        if (e.unwrapRemoteException() instanceof LeaseExpiredException) {
          LOG.debug(String.format(
            "client %s attempting to abandon file %s which it does not own",
            clientName, src),
            e
          );
        } else {
          throw e;
        }
      }
    }
  }
}
 
开发者ID:iVCE,项目名称:RDFS,代码行数:82,代码来源:DFSClient.java

示例12: append

import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException; //导入依赖的package包/类
/**
 * Append to an existing HDFS file.
 *
 * @param src file name
 * @param buffersize buffer size
 * @param progress for reporting write-progress
 * @return an output stream for writing into the file
 * @throws IOException
 * @see ClientProtocol#append(String, String)
 */
OutputStream append(String src, int buffersize, Progressable progress
    ) throws IOException {
  checkOpen();
  FileStatus stat = null;
  LocatedBlock lastBlock = null;
  boolean success = false;
  int namespaceId = 0;
  
  try {
    stat = getFileInfo(src);
    if (namenodeProtocolProxy != null
        && namenodeProtocolProxy.isMethodSupported(
            "appendAndFetchMetaInfo", String.class, String.class)) {
      LocatedBlockWithMetaInfo loc = namenode.appendAndFetchMetaInfo(src,
          clientName);
      lastBlock = loc;
      if (loc != null) {
        namespaceId = loc.getNamespaceID();
        updateDataTransferProtocolVersionIfNeeded(loc.getDataProtocolVersion());
        getNewNameNodeIfNeeded(loc.getMethodFingerPrint());
      }
    } else {
      lastBlock = namenode.append(src, clientName);
    }

    OutputStream result = new DFSOutputStream(this, src, buffersize, progress,
        lastBlock, stat, conf.getInt("io.bytes.per.checksum", 512), namespaceId);
    leasechecker.put(src, result);
    success = true;

    return result;
  } catch(RemoteException re) {
    throw re.unwrapRemoteException(FileNotFoundException.class,
                                   AccessControlException.class,
                                   NSQuotaExceededException.class,
                                   DSQuotaExceededException.class);
  } finally {
    if (!success) {
      try {
        namenode.abandonFile(src, clientName);
      } catch (RemoteException e) {
        if (e.unwrapRemoteException() instanceof LeaseExpiredException) {
          LOG.debug(String.format(
            "client %s attempting to abandon file %s which it does not own",
            clientName, src), 
            e
          );
        } else {
          throw e;
        }
      }
    }
  }
}
 
开发者ID:iVCE,项目名称:RDFS,代码行数:65,代码来源:DFSClient.java


注:本文中的org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。