List of usage examples for java.io IOError IOError
public IOError(Throwable cause)
From source file:com.bigdata.dastor.gms.FailureDetector.java
/** * We dump the arrival window for any endpoint only if the * local Failure Detector module has been up for more than a * minute./*from w ww . j av a2 s .co m*/ * * @param ep for which the arrival window needs to be dumped. */ private void dumpInterArrivalTimes(InetAddress ep) { long now = System.currentTimeMillis(); if ((now - FailureDetector.creationTime_) <= FailureDetector.uptimeThreshold_) return; try { FileOutputStream fos = new FileOutputStream( "/var/tmp/output-" + System.currentTimeMillis() + "-" + ep + ".dat", true); ArrivalWindow hWnd = arrivalSamples_.get(ep); fos.write(hWnd.toString().getBytes()); fos.close(); } catch (IOException e) { throw new IOError(e); } }
From source file:com.github.springtestdbunit.TestExecutionListenerChainTest.java
@Test(expected = Exception.class) public void shouldChainAfterTestMethodEvenOnException() throws Exception { doThrow(new IOError(null)).when(this.l2).afterTestMethod(this.testContext); this.chain.afterTestMethod(this.testContext); this.ordered.verify(this.l2).afterTestMethod(this.testContext); this.ordered.verify(this.l1).afterTestMethod(this.testContext); }
From source file:com.bigdata.dastor.streaming.StreamInitiateVerbHandler.java
public void doVerb(Message message) { byte[] body = message.getMessageBody(); ByteArrayInputStream bufIn = new ByteArrayInputStream(body); if (logger.isDebugEnabled()) logger.debug(String.format("StreamInitiateVerbeHandler.doVerb %s %s %s", message.getVerb(), message.getMessageId(), message.getMessageType())); try {/*from w w w .ja v a 2 s. c o m*/ StreamInitiateMessage biMsg = StreamInitiateMessage.serializer() .deserialize(new DataInputStream(bufIn)); PendingFile[] pendingFiles = biMsg.getStreamContext(); if (pendingFiles.length == 0) { if (logger.isDebugEnabled()) logger.debug("no data needed from " + message.getFrom()); if (StorageService.instance.isBootstrapMode()) StorageService.instance.removeBootstrapSource(message.getFrom(), new String(message.getHeader(StreamOut.TABLE_NAME))); return; } Map<String, String> fileNames = getNewNames(pendingFiles); Map<String, String> pathNames = new HashMap<String, String>(); for (String ssName : fileNames.keySet()) pathNames.put(ssName, DatabaseDescriptor.getNextAvailableDataLocation()); /* * For each of stream context's in the incoming message * generate the new file names and store the new file names * in the StreamContextManager. */ for (PendingFile pendingFile : pendingFiles) { CompletedFileStatus streamStatus = new CompletedFileStatus(pendingFile.getTargetFile(), pendingFile.getExpectedBytes()); String file = getNewFileNameFromOldContextAndNames(fileNames, pathNames, pendingFile); if (logger.isDebugEnabled()) logger.debug("Received Data from : " + message.getFrom() + " " + pendingFile.getTargetFile() + " " + file); pendingFile.setTargetFile(file); addStreamContext(message.getFrom(), pendingFile, streamStatus); } StreamInManager.registerStreamCompletionHandler(message.getFrom(), new StreamCompletionHandler()); if (logger.isDebugEnabled()) logger.debug("Sending a stream initiate done message ..."); Message doneMessage = new Message(FBUtilities.getLocalAddress(), "", StorageService.Verb.STREAM_INITIATE_DONE, new byte[0]); MessagingService.instance.sendOneWay(doneMessage, message.getFrom()); } catch (IOException ex) { throw new IOError(ex); } }
From source file:org.apache.cassandra.db.commitlog.CommitLog.java
/** * param @ table - name of table for which we are maintaining * this commit log.//w ww .j av a 2s. c om * param @ recoverymode - is commit log being instantiated in * in recovery mode. */ private CommitLog() { try { DatabaseDescriptor.createAllDirectories(); segmentSize = DatabaseDescriptor.getCommitLogSegmentSize(); } catch (IOException e) { throw new IOError(e); } // all old segments are recovered and deleted before CommitLog is instantiated. // All we need to do is create a new one. segments.add(new CommitLogSegment()); executor = DatabaseDescriptor.getCommitLogSync() == Config.CommitLogSync.batch ? new BatchCommitLogExecutorService() : new PeriodicCommitLogExecutorService(this); }
From source file:com.bigdata.dastor.io.CompactionIterator.java
protected CompactedRow getReduced() { assert rows.size() > 0; DataOutputBuffer headerBuffer = new DataOutputBuffer(); // BIGDATA DataOutputBuffer buffer = new DataOutputBuffer(); DecoratedKey key = rows.get(0).getKey(); Set<SSTable> sstables = new HashSet<SSTable>(); for (IteratingRow row : rows) sstables.add(row.sstable);/*from w w w .ja v a 2s . c om*/ boolean shouldPurge = major || !cfs.isKeyInRemainingSSTables(key, sstables); try { if (rows.size() > 1 || shouldPurge) { ColumnFamily cf = null; for (IteratingRow row : rows) { ColumnFamily thisCF; try { thisCF = row.getColumnFamily(); } catch (IOException e) { logger.error("Skipping row " + key + " in " + row.getPath(), e); continue; } if (cf == null) { cf = thisCF; } else { cf.addAll(thisCF); } } ColumnFamily cfPurged = shouldPurge ? ColumnFamilyStore.removeDeleted(cf, gcBefore) : cf; if (cfPurged == null) return null; ColumnFamily.serializer().serializeWithIndexes(cfPurged, headerBuffer, buffer, cfs.getCFMetaData().compressAlgo); // BIGDATA } else { assert rows.size() == 1; try { rows.get(0).echoData(buffer); } catch (IOException e) { throw new IOError(e); } } } finally { rows.clear(); if ((row++ % 1000) == 0) { bytesRead = 0; for (SSTableScanner scanner : getScanners()) { bytesRead += scanner.getFilePointer(); } } } return new CompactedRow(key, headerBuffer, buffer); }
From source file:ca.mcgill.cs.crown.data.WiktionaryReader.java
private static List<LexicalEntry> convertToEntries(List<JSONObject> rawEntries) { // Avoid the potential for duplicates in the entries Set<String> alreadyIncluded = new HashSet<String>(); int excluded = 0; List<LexicalEntry> entries = new ArrayList<LexicalEntry>(); for (JSONObject jo : rawEntries) { try {//from w w w .ja v a 2s . c o m String posStr = jo.getString("pos").toUpperCase(); String lemma = jo.getString("lemma"); String id = jo.getString("id"); // Check for duplicates if (alreadyIncluded.contains(lemma + "." + posStr + ":" + id)) { excluded++; continue; } alreadyIncluded.add(lemma + ":" + id); LexicalEntry e = new LexicalEntryImpl(lemma, id, POS.valueOf(posStr)); Set<String> glosses = new LinkedHashSet<String>(); Map<String, String> rawGlossToCleaned = new LinkedHashMap<String, String>(); JSONArray glossArr = jo.getJSONArray("glosses"); for (int i = 0; i < glossArr.length(); ++i) { String rawGloss = glossArr.getString(i); String cleaned = WiktionaryUtils.cleanGloss(rawGloss); glosses.add(cleaned); rawGlossToCleaned.put(rawGloss, cleaned); } String combinedGloss = String.join(" ", glosses); List<Relation> relations = new ArrayList<Relation>(); JSONArray relationsArr = jo.getJSONArray("relations"); for (int i = 0; i < relationsArr.length(); ++i) { JSONObject relObj = relationsArr.getJSONObject(i); Relation rel = new RelationImpl(relObj.getString("targetLemma"), relObj.optString("targetSense"), Relation.RelationType.valueOf(relObj.getString("type"))); relations.add(rel); } CoreMap m = e.getAnnotations(); m.set(CrownAnnotations.Gloss.class, combinedGloss); m.set(CrownAnnotations.Glosses.class, glosses); m.set(CrownAnnotations.RawGlosses.class, rawGlossToCleaned); m.set(CrownAnnotations.Relations.class, relations); entries.add(e); } catch (JSONException je) { throw new IOError(je); } } CrownLogger.verbose("Excluded %d duplicate entries", excluded); return entries; }
From source file:org.apache.cassandra.db.compaction.LazilyCompactedRow.java
public void update(MessageDigest digest) { // no special-case for rows.size == 1, we're actually skipping some bytes here so just // blindly updating everything wouldn't be correct DataOutputBuffer out = new DataOutputBuffer(); try {// w w w . j a v a 2s . co m ColumnFamily.serializer().serializeCFInfo(emptyColumnFamily, out); out.writeInt(columnCount); digest.update(out.getData(), 0, out.getLength()); } catch (IOException e) { throw new IOError(e); } Iterator<IColumn> iter = iterator(); while (iter.hasNext()) { iter.next().updateDigest(digest); } }
From source file:org.codice.ddf.configuration.migration.PathUtils.java
/** * Creates a new path utility.//w ww .jav a 2 s . c om * * @throws IOError if unable to determine ${ddf.home} */ public PathUtils() { try { this.ddfHome = Paths.get(System.getProperty("ddf.home")).toRealPath(LinkOption.NOFOLLOW_LINKS); } catch (IOException e) { throw new IOError(e); } }
From source file:fr.lirmm.graphik.graal.store.test.TestUtil.java
private static void rm(File file) { if (file.exists()) { if (file.isDirectory()) { try { FileUtils.deleteDirectory(file); } catch (IOException e) { throw new IOError(new Error("I can't delete the file " + file.getAbsolutePath(), e)); }// w w w .j a va 2 s .c om } else { if (!file.delete()) { throw new IOError(new Error("I can't delete the file " + file.getAbsolutePath())); } } } }
From source file:org.apache.cassandra.io.sstable.SSTableWriter.java
static Descriptor rename(Descriptor tmpdesc) { Descriptor newdesc = tmpdesc.asTemporary(false); try {/* ww w.ja va2 s . c o m*/ for (String component : components) FBUtilities.renameWithConfirm(tmpdesc.filenameFor(component), newdesc.filenameFor(component)); } catch (IOException e) { throw new IOError(e); } return newdesc; }