Java Code Examples for java.io.IOException#initCause()
The following examples show how to use
java.io.IOException#initCause() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputFormatGrakn.java From grakn with GNU Affero General Public License v3.0 | 6 votes |
public boolean nextKeyValue() throws IOException { if (!rowIterator.hasNext()) { LOG.trace("Finished scanning {} rows (estimate was: {})", rowIterator.totalRead, totalRowCount); return false; } try { currentRow = rowIterator.next(); } catch (Exception e) { // throw it as IOException, so client can catch it and handle it at client side IOException ioe = new IOException(e.getMessage()); ioe.initCause(ioe.getCause()); throw ioe; } return true; }
Example 2
Source File: DOMConvertor.java From netbeans with Apache License 2.0 | 6 votes |
/** Write object described by DOM document filled by {@link #writeElement} * @param w stream into which inst is written * @param inst the setting object to be written * @exception IOException if the object cannot be written * @since 1.1 */ public final void write(java.io.Writer w, Object inst) throws java.io.IOException { Document doc = null; try { doc = XMLUtil.createDocument(rootElement, null, publicID, systemID); setDocumentContext(doc, findContext(w)); writeElement(doc, doc.getDocumentElement(), inst); java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(1024); XMLUtil.write(doc, baos, "UTF-8"); // NOI18N w.write(baos.toString("UTF-8")); // NOI18N } catch (org.w3c.dom.DOMException ex) { IOException e = new IOException(ex.getLocalizedMessage()); e.initCause(ex); throw e; } finally { if (doc != null) { clearCashesForDocument(doc); } } }
Example 3
Source File: CqlRecordReader.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public boolean nextKeyValue() throws IOException { if (!rowIterator.hasNext()) { logger.debug("Finished scanning {} rows (estimate was: {})", rowIterator.totalRead, totalRowCount); return false; } try { currentRow = rowIterator.next(); } catch (Exception e) { // throw it as IOException, so client can catch it and handle it at client side IOException ioe = new IOException(e.getMessage()); ioe.initCause(ioe.getCause()); throw ioe; } return true; }
Example 4
Source File: MaxTupleBy1stField.java From spork with Apache License 2.0 | 6 votes |
@Override public Tuple exec(Tuple input) throws IOException { try { // input is a bag with one tuple containing // the column we are trying to max on DataBag bg = (DataBag) input.get(0); Tuple tp = bg.iterator().next(); return tp; //TODO: copy? } catch(ExecException ee) { IOException oughtToBeEE = new IOException(); oughtToBeEE.initCause(ee); throw oughtToBeEE; } }
Example 5
Source File: TestMapReduce.java From spork with Apache License 2.0 | 6 votes |
@Override public DataBag exec(Tuple input) throws IOException { try { DataBag output = BagFactory.getInstance().newDefaultBag(); Iterator<Tuple> it = (DataType.toBag(input.get(0))).iterator(); while(it.hasNext()) { Tuple t = it.next(); Tuple newT = TupleFactory.getInstance().newTuple(2); newT.set(0, field0); newT.set(1, t.get(0).toString()); output.add(newT); } return output; } catch (ExecException ee) { IOException ioe = new IOException(ee.getMessage()); ioe.initCause(ee); throw ioe; } }
Example 6
Source File: IIOPInputStream.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public final int readUnsignedShort() throws IOException{ try{ readObjectState.readData(this); return (orbStream.read_ushort() << 0) & 0x0000FFFF; } catch (MARSHAL marshalException) { handleOptionalDataMarshalException(marshalException, false); throw marshalException; } catch(Error e) { IOException exc = new IOException(e.getMessage()); exc.initCause(e); throw exc ; } }
Example 7
Source File: ZipArchive.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected void initMap() throws IOException { for (Enumeration<? extends ZipEntry> e = zfile.entries(); e.hasMoreElements(); ) { ZipEntry entry; try { entry = e.nextElement(); } catch (InternalError ex) { IOException io = new IOException(); io.initCause(ex); // convenience constructors added in Mustang :-( throw io; } addZipEntry(entry); } }
Example 8
Source File: IoSessionInputStream.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private boolean waitForData() throws IOException { if (released) { return false; } synchronized (mutex) { while (!released && buf.remaining() == 0 && exception == null) { try { mutex.wait(); } catch (InterruptedException e) { IOException ioe = new IOException("Interrupted while waiting for more data"); ioe.initCause(e); throw ioe; } } } if (exception != null) { releaseBuffer(); throw exception; } if (closed && buf.remaining() == 0) { releaseBuffer(); return false; } return true; }
Example 9
Source File: RemoteException.java From big-c with Apache License 2.0 | 5 votes |
private IOException instantiateException(Class<? extends IOException> cls) throws Exception { Constructor<? extends IOException> cn = cls.getConstructor(String.class); cn.setAccessible(true); IOException ex = cn.newInstance(this.getMessage()); ex.initCause(this); return ex; }
Example 10
Source File: NegotiatorImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Return the rest tokens of GSS, in SPNEGO, it's called NegTokenTarg * @param token the token received from server * @return the next token * @throws java.io.IOException if the token cannot be created successfully */ @Override public byte[] nextToken(byte[] token) throws IOException { try { return context.initSecContext(token, 0, token.length); } catch (GSSException e) { if (DEBUG) { System.out.println("Negotiate support cannot continue. Reason:"); e.printStackTrace(); } IOException ioe = new IOException("Negotiate support cannot continue"); ioe.initCause(e); throw ioe; } }
Example 11
Source File: DOMInputCapsule.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public String readString(String name, String defVal) throws IOException { String tmpString = currentElem.getAttribute(name); if (tmpString == null || tmpString.length() < 1) return defVal; try { return decodeString(tmpString); } catch (DOMException de) { IOException io = new IOException(de.toString()); io.initCause(de); throw io; } }
Example 12
Source File: ClobLocatorReader.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Read the next <code>len</code> characters of the <code>Clob</code> * value from the server. * * @param len number of characters to read. * @throws java.io.IOException Wrapped SqlException if reading * from server fails. * @return <code>char[]</code> containing the read characters. */ private char[] readCharacters(int len) throws IOException { try { //stores the actual length that can be read //based on the value of the current position //in the stream(currentPos) and the length of //the stream. int actualLength = -1; //check if maxPos has been set and calculate actualLength //based on that. if(maxPos != -1) { //maxPos has been set. use maxPos to calculate the //actual length based on the value set for maxPos. actualLength = (int )Math.min(len, maxPos - currentPos + 1); } else { //The subset of the Blob was not requested for //hence maxPos is -1. Here we use clob.sqllength //instead. actualLength = (int )Math.min(len, clob.sqlLength() - currentPos + 1); } // GemStone changes BEGIN String resultStr = clob.locatorProcs_. /* (original code) String resultStr = connection.locatorProcedureCall(). */ // GemStone changes END clobGetSubString(clob.getLocator(), currentPos, actualLength); char[] result = resultStr.toCharArray(); currentPos += result.length; return result; } catch (SqlException ex) { IOException ioEx = new IOException(); ioEx.initCause(ex); throw ioEx; } }
Example 13
Source File: IIOPInputStream.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public final short readShort() throws IOException{ try{ readObjectState.readData(this); return orbStream.read_short(); } catch (MARSHAL marshalException) { handleOptionalDataMarshalException(marshalException, false); throw marshalException; } catch(Error e) { IOException exc = new IOException(e.getMessage()); exc.initCause(e); throw exc ; } }
Example 14
Source File: MapTask.java From big-c with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private <T> T getSplitDetails(Path file, long offset) throws IOException { FileSystem fs = file.getFileSystem(conf); FSDataInputStream inFile = fs.open(file); inFile.seek(offset); String className = StringInterner.weakIntern(Text.readString(inFile)); Class<T> cls; try { cls = (Class<T>) conf.getClassByName(className); } catch (ClassNotFoundException ce) { IOException wrap = new IOException("Split class " + className + " not found"); wrap.initCause(ce); throw wrap; } SerializationFactory factory = new SerializationFactory(conf); Deserializer<T> deserializer = (Deserializer<T>) factory.getDeserializer(cls); deserializer.open(inFile); T split = deserializer.deserialize(null); long pos = inFile.getPos(); getCounters().findCounter( TaskCounter.SPLIT_RAW_BYTES).increment(pos - offset); inFile.close(); return split; }
Example 15
Source File: IIOPInputStream.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public final String readUTF() throws IOException{ try{ readObjectState.readData(this); return internalReadUTF(orbStream); } catch (MARSHAL marshalException) { handleOptionalDataMarshalException(marshalException, false); throw marshalException; } catch(Error e) { IOException exc = new IOException(e.getMessage()); exc.initCause(e); throw exc ; } }
Example 16
Source File: IIOPOutputStream.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public final void writeInt(int data) throws IOException{ try{ writeObjectState.writeData(this); orbStream.write_long(data); } catch(Error e) { IOException ioexc = new IOException(e.getMessage()); ioexc.initCause(e) ; throw ioexc ; } }
Example 17
Source File: IIOPOutputStream.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public final void writeDouble(double data) throws IOException{ try{ writeObjectState.writeData(this); orbStream.write_double(data); } catch(Error e) { IOException ioexc = new IOException(e.getMessage()); ioexc.initCause(e) ; throw ioexc ; } }
Example 18
Source File: IIOPOutputStream.java From JDKSourceCode1.8 with MIT License | 5 votes |
public final void write(byte b[]) throws IOException{ try{ writeObjectState.writeData(this); orbStream.write_octet_array(b, 0, b.length); } catch(Error e) { IOException ioexc = new IOException(e.getMessage()); ioexc.initCause(e) ; throw ioexc ; } }
Example 19
Source File: MiniDFSCluster.java From hadoop-gpu with Apache License 2.0 | 4 votes |
/** * NOTE: if possible, the other constructors that don't have nameNode port * parameter should be used as they will ensure that the servers use free ports. * <p> * Modify the config and start up the servers. * * @param nameNodePort suggestion for which rpc port to use. caller should * use getNameNodePort() to get the actual port used. * @param conf the base configuration to use in starting the servers. This * will be modified as necessary. * @param numDataNodes Number of DataNodes to start; may be zero * @param format if true, format the NameNode and DataNodes before starting up * @param manageNameDfsDirs if true, the data directories for servers will be * created and dfs.name.dir and dfs.data.dir will be set in the conf * @param manageDataDfsDirs if true, the data directories for datanodes will * be created and dfs.data.dir set to same in the conf * @param operation the operation with which to start the servers. If null * or StartupOption.FORMAT, then StartupOption.REGULAR will be used. * @param racks array of strings indicating the rack that each DataNode is on * @param hosts array of strings indicating the hostnames of each DataNode * @param simulatedCapacities array of capacities of the simulated data nodes */ public MiniDFSCluster(int nameNodePort, Configuration conf, int numDataNodes, boolean format, boolean manageNameDfsDirs, boolean manageDataDfsDirs, StartupOption operation, String[] racks, String hosts[], long[] simulatedCapacities) throws IOException { this.conf = conf; try { UserGroupInformation.setCurrentUser(UnixUserGroupInformation.login(conf)); } catch (LoginException e) { IOException ioe = new IOException(); ioe.initCause(e); throw ioe; } base_dir = new File(System.getProperty("test.build.data", "build/test/data"), "dfs/"); data_dir = new File(base_dir, "data"); // Setup the NameNode configuration FileSystem.setDefaultUri(conf, "hdfs://localhost:"+ Integer.toString(nameNodePort)); conf.set("dfs.http.address", "127.0.0.1:0"); if (manageNameDfsDirs) { conf.set("dfs.name.dir", new File(base_dir, "name1").getPath()+","+ new File(base_dir, "name2").getPath()); conf.set("fs.checkpoint.dir", new File(base_dir, "namesecondary1"). getPath()+"," + new File(base_dir, "namesecondary2").getPath()); } int replication = conf.getInt("dfs.replication", 3); conf.setInt("dfs.replication", Math.min(replication, numDataNodes)); conf.setInt("dfs.safemode.extension", 0); conf.setInt("dfs.namenode.decommission.interval", 3); // 3 second // Format and clean out DataNode directories if (format) { if (data_dir.exists() && !FileUtil.fullyDelete(data_dir)) { throw new IOException("Cannot remove data directory: " + data_dir); } NameNode.format(conf); } // Start the NameNode String[] args = (operation == null || operation == StartupOption.FORMAT || operation == StartupOption.REGULAR) ? new String[] {} : new String[] {operation.getName()}; conf.setClass("topology.node.switch.mapping.impl", StaticMapping.class, DNSToSwitchMapping.class); nameNode = NameNode.createNameNode(args, conf); // Start the DataNodes startDataNodes(conf, numDataNodes, manageDataDfsDirs, operation, racks, hosts, simulatedCapacities); waitClusterUp(); }
Example 20
Source File: IoUtility.java From geofence with GNU General Public License v2.0 | 4 votes |
/** * Decompress. * * @param prefix * the prefix * @param inputFile * the input file * @param tempFile * the temp file * @return the file * @throws IOException * Signals that an I/O exception has occurred. */ public static File decompress(final String prefix, final File inputFile, final File tempFile) throws IOException { final File tmpDestDir = createTodayPrefixedDirectory(prefix, new File(tempFile.getParent())); ZipFile zipFile = new ZipFile(inputFile); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = (ZipEntry) entries.nextElement(); InputStream stream = zipFile.getInputStream(entry); if (entry.isDirectory()) { // Assume directories are stored parents first then // children. (new File(tmpDestDir, entry.getName())).mkdir(); continue; } File newFile = new File(tmpDestDir, entry.getName()); FileOutputStream fos = new FileOutputStream(newFile); try { byte[] buf = new byte[1024]; int len; while ((len = stream.read(buf)) >= 0) { saveCompressedStream(buf, fos, len); } } catch (IOException e) { zipFile.close(); IOException ioe = new IOException("Not valid ZIP archive file type."); ioe.initCause(e); throw ioe; } finally { fos.flush(); fos.close(); stream.close(); } } zipFile.close(); if ((tmpDestDir.listFiles().length == 1) && (tmpDestDir.listFiles()[0].isDirectory())) { return getShpFile(tmpDestDir.listFiles()[0]); } // File[] files = tmpDestDir.listFiles(new FilenameFilter() { // // public boolean accept(File dir, String name) { // return FilenameUtils.getExtension(name).equalsIgnoreCase("shp"); // } // }); // // return files.length > 0 ? files[0] : null; return getShpFile(tmpDestDir); }