當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。