本文整理汇总了Java中org.apache.hadoop.hdfs.qjournal.client.QuorumJournalManager.checkJournalId方法的典型用法代码示例。如果您正苦于以下问题:Java QuorumJournalManager.checkJournalId方法的具体用法?Java QuorumJournalManager.checkJournalId怎么用?Java QuorumJournalManager.checkJournalId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hdfs.qjournal.client.QuorumJournalManager
的用法示例。
在下文中一共展示了QuorumJournalManager.checkJournalId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrCreateJournal
import org.apache.hadoop.hdfs.qjournal.client.QuorumJournalManager; //导入方法依赖的package包/类
synchronized Journal getOrCreateJournal(String jid, StartupOption startOpt)
throws IOException {
QuorumJournalManager.checkJournalId(jid);
Journal journal = journalsById.get(jid);
if (journal == null) {
File logDir = getLogDir(jid);
LOG.info("Initializing journal in directory " + logDir);
journal = new Journal(conf, logDir, jid, startOpt, new ErrorReporter());
journalsById.put(jid, journal);
}
return journal;
}
示例2: getOrCreateJournal
import org.apache.hadoop.hdfs.qjournal.client.QuorumJournalManager; //导入方法依赖的package包/类
synchronized Journal getOrCreateJournal(String jid) throws IOException {
QuorumJournalManager.checkJournalId(jid);
Journal journal = journalsById.get(jid);
if (journal == null) {
File logDir = getLogDir(jid);
LOG.info("Initializing journal in directory " + logDir);
journal = new Journal(conf, logDir, jid, new ErrorReporter());
journalsById.put(jid, journal);
}
return journal;
}
示例3: doGet
import org.apache.hadoop.hdfs.qjournal.client.QuorumJournalManager; //导入方法依赖的package包/类
@Override
public void doGet(final HttpServletRequest request,
final HttpServletResponse response) throws ServletException, IOException {
FileInputStream editFileIn = null;
try {
final ServletContext context = getServletContext();
final Configuration conf = (Configuration) getServletContext()
.getAttribute(JspHelper.CURRENT_CONF);
final String journalId = request.getParameter(JOURNAL_ID_PARAM);
QuorumJournalManager.checkJournalId(journalId);
final JNStorage storage = JournalNodeHttpServer
.getJournalFromContext(context, journalId).getStorage();
// Check security
if (!checkRequestorOrSendError(conf, request, response)) {
return;
}
// Check that the namespace info is correct
if (!checkStorageInfoOrSendError(storage, request, response)) {
return;
}
long segmentTxId = ServletUtil.parseLongParam(request,
SEGMENT_TXID_PARAM);
FileJournalManager fjm = storage.getJournalManager();
File editFile;
synchronized (fjm) {
// Synchronize on the FJM so that the file doesn't get finalized
// out from underneath us while we're in the process of opening
// it up.
EditLogFile elf = fjm.getLogFile(
segmentTxId);
if (elf == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND,
"No edit log found starting at txid " + segmentTxId);
return;
}
editFile = elf.getFile();
ImageServlet.setVerificationHeadersForGet(response, editFile);
ImageServlet.setFileNameHeaders(response, editFile);
editFileIn = new FileInputStream(editFile);
}
DataTransferThrottler throttler = ImageServlet.getThrottler(conf);
// send edits
TransferFsImage.copyFileToStream(response.getOutputStream(), editFile,
editFileIn, throttler);
} catch (Throwable t) {
String errMsg = "getedit failed. " + StringUtils.stringifyException(t);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, errMsg);
throw new IOException(errMsg);
} finally {
IOUtils.closeStream(editFileIn);
}
}
示例4: doGet
import org.apache.hadoop.hdfs.qjournal.client.QuorumJournalManager; //导入方法依赖的package包/类
@Override
public void doGet(final HttpServletRequest request,
final HttpServletResponse response) throws ServletException, IOException {
try {
final GetImageParams parsedParams = new GetImageParams(request, response);
// here we only support getImage
if (!parsedParams.isGetImage()) {
throw new IOException("Only getImage requests are supported");
}
// get access to journal node storage
final ServletContext context = getServletContext();
final Configuration conf = (Configuration) getServletContext()
.getAttribute(JspHelper.CURRENT_CONF);
final String journalId = request.getParameter(JOURNAL_ID_PARAM);
QuorumJournalManager.checkJournalId(journalId);
final Journal journal = JournalNodeHttpServer.getJournalFromContext(
context, journalId);
final JNStorage imageStorage = journal.getImageStorage();
final JournalMetrics metrics = journal.getMetrics();
if (metrics != null) {
metrics.numGetImageDoGet.inc();
}
// Check that the namespace info is correct
if (!GetJournalEditServlet.checkStorageInfoOrSendError(imageStorage,
request, response)) {
return;
}
// we will serve image at txid
long txid = parsedParams.getTxId();
File imageFile = imageStorage.getImageFile(txid);
// no such image in the storage
if (imageFile == null) {
throw new IOException("Could not find image with txid " + txid);
}
// set verification headers
setVerificationHeaders(response, imageFile);
// send fsImage
TransferFsImage.getFileServer(response.getOutputStream(), imageFile,
GetImageServlet.getThrottler(conf, parsedParams.isThrottlerDisabled()));
} catch (Throwable t) {
GetJournalEditServlet.handleFailure(t, response, "getImage");
}
}
示例5: doGet
import org.apache.hadoop.hdfs.qjournal.client.QuorumJournalManager; //导入方法依赖的package包/类
@Override
public void doGet(final HttpServletRequest request,
final HttpServletResponse response) throws ServletException, IOException {
try {
final ServletContext context = getServletContext();
final String journalId = request
.getParameter(GetJournalEditServlet.JOURNAL_ID_PARAM);
QuorumJournalManager.checkJournalId(journalId);
final Journal journal = JournalNodeHttpServer.getJournalFromContext(
context, journalId);
final JNStorage storage = journal.getJournalStorage();
// Check that the namespace info is correct
if (!GetJournalEditServlet.checkStorageInfoOrSendError(storage, request,
response)) {
return;
}
long startTxId = ServletUtil.parseLongParam(request, START_TXID_PARAM);
FileJournalManager fjm = journal.getJournalManager();
LOG.info("getJournalManifest request: journalId " + journalId
+ ", start txid: " + startTxId + ", storage: "
+ storage.toColonSeparatedString());
String output = JSON.toString(new ArrayList<String>());
synchronized (journal) {
// Synchronize on the journal so that the files do not change
// get all log segments
List<EditLogFile> logFiles = fjm.getLogFiles(startTxId, false);
List<String> manifest = new ArrayList<String>();
for (EditLogFile elf : logFiles) {
manifest.add(elf.toColonSeparatedString());
}
output = JSON.toString(manifest);
}
JournalNodeHttpServer.sendResponse(output, response);
} catch (Throwable t) {
GetJournalEditServlet.handleFailure(t, response, "getJournalManifest");
}
}
示例6: doGet
import org.apache.hadoop.hdfs.qjournal.client.QuorumJournalManager; //导入方法依赖的package包/类
@Override
public void doGet(final HttpServletRequest request,
final HttpServletResponse response) throws ServletException, IOException {
FileInputStream editFileIn = null;
try {
final ServletContext context = getServletContext();
final Configuration conf = (Configuration) getServletContext()
.getAttribute(JspHelper.CURRENT_CONF);
final String journalId = request.getParameter(JOURNAL_ID_PARAM);
QuorumJournalManager.checkJournalId(journalId);
final JNStorage storage = JournalNodeHttpServer
.getJournalFromContext(context, journalId).getStorage();
// Check security
if (!checkRequestorOrSendError(conf, request, response)) {
return;
}
// Check that the namespace info is correct
if (!checkStorageInfoOrSendError(storage, request, response)) {
return;
}
long segmentTxId = ServletUtil.parseLongParam(request,
SEGMENT_TXID_PARAM);
FileJournalManager fjm = storage.getJournalManager();
File editFile;
synchronized (fjm) {
// Synchronize on the FJM so that the file doesn't get finalized
// out from underneath us while we're in the process of opening
// it up.
EditLogFile elf = fjm.getLogFile(
segmentTxId);
if (elf == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND,
"No edit log found starting at txid " + segmentTxId);
return;
}
editFile = elf.getFile();
GetImageServlet.setVerificationHeaders(response, editFile);
GetImageServlet.setFileNameHeaders(response, editFile);
editFileIn = new FileInputStream(editFile);
}
DataTransferThrottler throttler = GetImageServlet.getThrottler(conf);
// send edits
TransferFsImage.getFileServer(response, editFile, editFileIn, throttler);
} catch (Throwable t) {
String errMsg = "getedit failed. " + StringUtils.stringifyException(t);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, errMsg);
throw new IOException(errMsg);
} finally {
IOUtils.closeStream(editFileIn);
}
}