/** * Called when some journals experience an error in some operation. */ private void disableAndReportErrorOnJournals(List<JournalAndStream> badJournals) { if (badJournals == null || badJournals.isEmpty()) { return; // nothing to do } for (JournalAndStream j : badJournals) { LOG.error("Disabling journal " + j); j.abort(); j.setDisabled(true); } }
/** * Add sync times to the buffer. */ String getSyncTimes() { StringBuilder buf = new StringBuilder(); for (JournalAndStream jas : journals) { if (jas.isActive()) { buf.append(jas.getCurrentStream().getTotalSyncTime()); buf.append(" "); } } return buf.toString(); }
if (j.getManager() instanceof FileJournalManager) { FileJournalManager fjm = (FileJournalManager)j.getManager(); try { allLogs.addAll(fjm.getRemoteEditLogs(fromTxId, false));
spy((EditLogFileOutputStream)jas.getCurrentStream()); jas.setCurrentStreamForTests(spyElos);
&& aborts.get(0).roll == (i+1)) { AbortSpec spec = aborts.remove(0); editlog.getJournals().get(spec.logindex).abort();
closure.apply(jas); } catch (Throwable t) { if (jas.isRequired()) { final String msg = "Error: " + status + " failed for required journal (" + jas + ")";
closure.apply(jas); } catch (Throwable t) { if (jas.isRequired()) { final String msg = "Error: " + status + " failed for required journal (" + jas + ")";
/** * invalidate storage by removing the second and third storage directories */ public void invalidateStorage(FSImage fi, Set<File> filesToInvalidate) throws IOException { ArrayList<StorageDirectory> al = new ArrayList<StorageDirectory>(2); Iterator<StorageDirectory> it = fi.getStorage().dirIterator(); while(it.hasNext()) { StorageDirectory sd = it.next(); if(filesToInvalidate.contains(sd.getRoot())) { LOG.info("causing IO error on " + sd.getRoot()); al.add(sd); } } // simulate an error fi.getStorage().reportErrorsOnDirectories(al); for (JournalAndStream j : fi.getEditLog().getJournals()) { if (j.getManager() instanceof FileJournalManager) { FileJournalManager fm = (FileJournalManager)j.getManager(); if (fm.getStorageDirectory().getRoot().equals(path2) || fm.getStorageDirectory().getRoot().equals(path3)) { EditLogOutputStream mockStream = spy(j.getCurrentStream()); j.setCurrentStreamForTests(mockStream); doThrow(new IOException("Injected fault: write")). when(mockStream).write(Mockito.<FSEditLogOp>anyObject()); } } } }
for (JournalAndStream jas : log.getJournals()) { final Map<String, String> jasMap = new HashMap<String, String>(); String manager = jas.getManager().toString(); jasMap.put("required", String.valueOf(jas.isRequired())); jasMap.put("disabled", String.valueOf(jas.isDisabled())); jasMap.put("manager", manager); if (jas.isDisabled()) { jasMap.put("stream", "Failed"); } else if (openForWrite) { EditLogOutputStream elos = jas.getCurrentStream(); if (elos != null) { jasMap.put("stream", elos.generateReport());
/** * In this function, we get a bunch of streams from all of our JournalManager * objects. Then we add these to the collection one by one. * * @param streams The collection to add the streams to. It may or * may not be sorted-- this is up to the caller. * @param fromTxId The transaction ID to start looking for streams at * @param inProgressOk Should we consider unfinalized streams? */ @Override public void selectInputStreams(Collection<EditLogInputStream> streams, long fromTxId, boolean inProgressOk) throws IOException { final PriorityQueue<EditLogInputStream> allStreams = new PriorityQueue<EditLogInputStream>(64, EDIT_LOG_INPUT_STREAM_COMPARATOR); for (JournalAndStream jas : journals) { if (jas.isDisabled()) { LOG.info("Skipping jas " + jas + " since it's disabled"); continue; } try { jas.getManager().selectInputStreams(allStreams, fromTxId, inProgressOk); } catch (IOException ioe) { LOG.warn("Unable to determine input streams from " + jas.getManager() + ". Skipping.", ioe); } } chainAndMakeRedundantStreams(streams, allStreams, fromTxId); }
/** * In this function, we get a bunch of streams from all of our JournalManager * objects. Then we add these to the collection one by one. * * @param streams The collection to add the streams to. It may or * may not be sorted-- this is up to the caller. * @param fromTxId The transaction ID to start looking for streams at * @param inProgressOk Should we consider unfinalized streams? */ @Override public void selectInputStreams(Collection<EditLogInputStream> streams, long fromTxId, boolean inProgressOk) throws IOException { final PriorityQueue<EditLogInputStream> allStreams = new PriorityQueue<EditLogInputStream>(64, EDIT_LOG_INPUT_STREAM_COMPARATOR); for (JournalAndStream jas : journals) { if (jas.isDisabled()) { LOG.info("Skipping jas " + jas + " since it's disabled"); continue; } try { jas.getManager().selectInputStreams(allStreams, fromTxId, inProgressOk); } catch (IOException ioe) { LOG.warn("Unable to determine input streams from " + jas.getManager() + ". Skipping.", ioe); } } chainAndMakeRedundantStreams(streams, allStreams, fromTxId); }
for (JournalAndStream jas : log.getJournals()) { final Map<String, String> jasMap = new HashMap<String, String>(); String manager = jas.getManager().toString(); jasMap.put("required", String.valueOf(jas.isRequired())); jasMap.put("disabled", String.valueOf(jas.isDisabled())); jasMap.put("manager", manager); if (jas.isDisabled()) { jasMap.put("stream", "Failed"); } else if (openForWrite) { EditLogOutputStream elos = jas.getCurrentStream(); if (elos != null) { jasMap.put("stream", elos.generateReport());
@Override public boolean isResourceAvailable() { return !isDisabled(); }
void remove(JournalManager j) { JournalAndStream jasToRemove = null; for (JournalAndStream jas: journals) { if (jas.getManager().equals(j)) { jasToRemove = jas; break; } } if (jasToRemove != null) { jasToRemove.abort(); journals.remove(jasToRemove); } }
/** * Called when some journals experience an error in some operation. */ private void disableAndReportErrorOnJournals(List<JournalAndStream> badJournals) { if (badJournals == null || badJournals.isEmpty()) { return; // nothing to do } for (JournalAndStream j : badJournals) { LOG.error("Disabling journal " + j); j.abort(); j.setDisabled(true); } }
void add(JournalManager j, boolean required, boolean shared) { JournalAndStream jas = new JournalAndStream(j, required, shared); journals.add(jas); }
void add(JournalManager j, boolean required, boolean shared) { JournalAndStream jas = new JournalAndStream(j, required, shared); journals.add(jas); }
void remove(JournalManager j) { JournalAndStream jasToRemove = null; for (JournalAndStream jas: journals) { if (jas.getManager().equals(j)) { jasToRemove = jas; break; } } if (jasToRemove != null) { jasToRemove.abort(); journals.remove(jasToRemove); } }
/** * Close the Journal and Stream */ public void close() throws IOException { closeStream(); journal.close(); }
@Override public void apply(JournalAndStream jas) throws IOException { jas.closeStream(); } }, "close");