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


Java IOException.setStackTrace方法代码示例

本文整理汇总了Java中java.io.IOException.setStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java IOException.setStackTrace方法的具体用法?Java IOException.setStackTrace怎么用?Java IOException.setStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.IOException的用法示例。


在下文中一共展示了IOException.setStackTrace方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: distributedConfigureServers

import java.io.IOException; //导入方法依赖的package包/类
private void distributedConfigureServers(int count) throws IOException {
    StringBuilder sbClient = new StringBuilder();
    StringBuilder sbServer = new StringBuilder();
    try {
        for(int i = 0; i < count; i++) {
            String r[] = QuorumPeerInstance.createServer(im, i);
            if (i > 0) {
                sbClient.append(',');
                sbServer.append(',');
            }
            sbClient.append(r[0]);
            sbServer.append(r[1]);
        }
        serverHostPort = sbClient.toString();
        quorumHostPort = sbServer.toString();
    } catch(Exception e) {
        IOException ioe = new IOException(e.getMessage());
        ioe.setStackTrace(e.getStackTrace());
        throw ioe;
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:22,代码来源:BaseSysTest.java

示例2: distributedConfigureServers

import java.io.IOException; //导入方法依赖的package包/类
private void distributedConfigureServers(int count) throws IOException {
    StringBuilder sbClient = new StringBuilder();
    StringBuilder sbServer = new StringBuilder();
    try {
        for(int i = 0; i < count; i++) {
            String r[] = QuorumPeerInstance.createServer(im, i);
            if (i > 0) {
                sbClient.append(',');
                sbServer.append(',');
            }
            sbClient.append(r[0]); // r[0] == "host:clientPort"
            sbServer.append(r[1]); // r[1] == "host:leaderPort:leaderElectionPort"
            sbServer.append(";"+(r[0].split(":"))[1]); // Appending ";clientPort"
        }
        serverHostPort = sbClient.toString();
        quorumHostPort = sbServer.toString();
    } catch(Exception e) {
        IOException ioe = new IOException(e.getMessage());
        ioe.setStackTrace(e.getStackTrace());
        throw ioe;
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:23,代码来源:BaseSysTest.java

示例3: startServer

import java.io.IOException; //导入方法依赖的package包/类
public void startServer(int index) throws IOException {
    int port = fakeBasePort+10+index;
    if (fakeMachines) {
        qps[index] = new QuorumPeer(peers, qpsDirs[index], qpsDirs[index], port, 0, index+1, tickTime, initLimit, syncLimit);
        qps[index].start();
    } else {
        try {
            QuorumPeerInstance.startInstance(im, quorumHostPort, index);
        } catch(Exception e) {
            IOException ioe = new IOException(e.getClass().getName() + ": " + e.getMessage());
            ioe.setStackTrace(e.getStackTrace());
            throw ioe;
        }
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:16,代码来源:BaseSysTest.java

示例4: stopServer

import java.io.IOException; //导入方法依赖的package包/类
public void stopServer(int index) throws IOException {
    if (fakeMachines) {
        qps[index].shutdown();
    } else {
        try {
            QuorumPeerInstance.stopInstance(im, index);
        } catch(Exception e) {
            IOException ioe = new IOException(e.getMessage());
            ioe.setStackTrace(e.getStackTrace());
            throw ioe;
        }
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:14,代码来源:BaseSysTest.java

示例5: convertMapFailedIOException

import java.io.IOException; //导入方法依赖的package包/类
private IOException convertMapFailedIOException(IOException ioe, String resourceDescription, int bufSize) {
  final String originalMessage;
  final Throwable originalCause;
  if (ioe.getCause() instanceof OutOfMemoryError) {
    // nested OOM confuses users, because its "incorrect", just print a plain message:
    originalMessage = "Map failed";
    originalCause = null;
  } else {
    originalMessage = ioe.getMessage();
    originalCause = ioe.getCause();
  }
  final String moreInfo;
  if (!Constants.JRE_IS_64BIT) {
    moreInfo = "MMapDirectory should only be used on 64bit platforms, because the address space on 32bit operating systems is too small. ";
  } else if (Constants.WINDOWS) {
    moreInfo = "Windows is unfortunately very limited on virtual address space. If your index size is several hundred Gigabytes, consider changing to Linux. ";
  } else if (Constants.LINUX) {
    moreInfo = "Please review 'ulimit -v', 'ulimit -m' (both should return 'unlimited'), and 'sysctl vm.max_map_count'. ";
  } else {
    moreInfo = "Please review 'ulimit -v', 'ulimit -m' (both should return 'unlimited'). ";
  }
  final IOException newIoe = new IOException(String.format(Locale.ENGLISH,
      "%s: %s [this may be caused by lack of enough unfragmented virtual address space "+
      "or too restrictive virtual memory limits enforced by the operating system, "+
      "preventing us to map a chunk of %d bytes. %sMore information: "+
      "http://blog.thetaphi.de/2012/07/use-lucenes-mmapdirectory-on-64bit.html]",
      originalMessage, resourceDescription, bufSize, moreInfo), originalCause);
  newIoe.setStackTrace(ioe.getStackTrace());
  return newIoe;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:MMapDirectory.java

示例6: startServer

import java.io.IOException; //导入方法依赖的package包/类
public void startServer(int index) throws IOException {
    int port = fakeBasePort+10+index;
    if (fakeMachines) {
        qps[index] = new QuorumPeer(peers, qpsDirs[index], qpsDirs[index], port, 3, index+1, tickTime, initLimit, syncLimit);
        qps[index].start();
    } else {
        try {
            QuorumPeerInstance.startInstance(im, quorumHostPort, index);
        } catch(Exception e) {
            IOException ioe = new IOException(e.getClass().getName() + ": " + e.getMessage());
            ioe.setStackTrace(e.getStackTrace());
            throw ioe;
        }
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:16,代码来源:BaseSysTest.java

示例7: encodeJobHistoryFileName

import java.io.IOException; //导入方法依赖的package包/类
/**
 * Helper function to encode the URL of the filename of the job-history 
 * log file.
 * 
 * @param logFileName file name of the job-history file
 * @return URL encoded filename
 * @throws IOException
 */
public static String encodeJobHistoryFileName(String logFileName)
throws IOException {
  String replacementDelimiterEscape = null;

  // Temporarily protect the escape delimiters from encoding
  if (logFileName.contains(DELIMITER_ESCAPE)) {
    replacementDelimiterEscape = nonOccursString(logFileName);

    logFileName = logFileName.replaceAll(DELIMITER_ESCAPE, replacementDelimiterEscape);
  }

  String encodedFileName = null;
  try {
    encodedFileName = URLEncoder.encode(logFileName, "UTF-8");
  } catch (UnsupportedEncodingException uee) {
    IOException ioe = new IOException();
    ioe.initCause(uee);
    ioe.setStackTrace(uee.getStackTrace());
    throw ioe;
  }

  // Restore protected escape delimiters after encoding
  if (replacementDelimiterEscape != null) {
    encodedFileName = encodedFileName.replaceAll(replacementDelimiterEscape, DELIMITER_ESCAPE);
  }

  return encodedFileName;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:FileNameIndexUtils.java

示例8: decodeJobHistoryFileName

import java.io.IOException; //导入方法依赖的package包/类
/**
 * Helper function to decode the URL of the filename of the job-history 
 * log file.
 * 
 * @param logFileName file name of the job-history file
 * @return URL decoded filename
 * @throws IOException
 */
public static String decodeJobHistoryFileName(String logFileName)
throws IOException {
  String decodedFileName = null;
  try {
    decodedFileName = URLDecoder.decode(logFileName, "UTF-8");
  } catch (UnsupportedEncodingException uee) {
    IOException ioe = new IOException();
    ioe.initCause(uee);
    ioe.setStackTrace(uee.getStackTrace());
    throw ioe;
  }
  return decodedFileName;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:FileNameIndexUtils.java

示例9: ioeToSocketException

import java.io.IOException; //导入方法依赖的package包/类
/**
 * Converts an IOExcpetion (not subclasses) to SocketException.
 * This is typically done to indicate to upper layers that the error 
 * was a socket error rather than often more serious exceptions like 
 * disk errors.
 */
private static IOException ioeToSocketException(IOException ioe) {
  if (ioe.getClass().equals(IOException.class)) {
    // "se" could be a new class in stead of SocketException.
    IOException se = new SocketException("Original Exception : " + ioe);
    se.initCause(ioe);
    /* Change the stacktrace so that original trace is not truncated
     * when printed.*/ 
    se.setStackTrace(ioe.getStackTrace());
    return se;
  }
  // otherwise just return the same exception.
  return ioe;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:BlockSender.java

示例10: NetworkBehavior

import java.io.IOException; //导入方法依赖的package包/类
private NetworkBehavior(Random random) {
  this.random = random;

  failureException = new IOException("Mock failure!");
  failureException.setStackTrace(new StackTraceElement[0]);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:NetworkBehavior.java

示例11: NetworkBehavior

import java.io.IOException; //导入方法依赖的package包/类
private NetworkBehavior(Random random) {
    this.random = random;

    failureException = new IOException("Mock failure!");
    failureException.setStackTrace(new StackTraceElement[0]);
}
 
开发者ID:octaware,项目名称:super-volley,代码行数:7,代码来源:NetworkBehavior.java


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