Example usage for java.io IOError IOError

List of usage examples for java.io IOError IOError

Introduction

In this page you can find the example usage for java.io IOError IOError.

Prototype

public IOError(Throwable cause) 

Source Link

Document

Constructs a new instance of IOError with the specified cause.

Usage

From source file:gov.llnl.ontology.mapreduce.table.WordNetEvidenceTable.java

public void close() {
    try {/*from w ww.j a v  a2s.c o m*/
        table.flushCommits();
        table.close();
    } catch (IOException ioe) {
        throw new IOError(ioe);
    }
}

From source file:gov.llnl.ontology.mapreduce.table.WordNetEvidenceTable.java

private void put(Put put) {
    try {//from www  . j  a  v a  2s  .c om
        table.put(put);
    } catch (IOException ioe) {
        throw new IOError(ioe);
    }
}

From source file:org.apache.cassandra.db.Directories.java

/**
 * Returns a non-blacklisted data directory that _currently_ has {@code writeSize} bytes as usable space.
 *
 * @throws IOError if all directories are blacklisted.
 *///  w w  w . ja  v  a  2  s .c om
public DataDirectory getWriteableLocation(long writeSize) {
    List<DataDirectoryCandidate> candidates = new ArrayList<>();

    long totalAvailable = 0L;

    // pick directories with enough space and so that resulting sstable dirs aren't blacklisted for writes.
    boolean tooBig = false;
    for (DataDirectory dataDir : dataDirectories) {
        if (BlacklistedDirectories.isUnwritable(getLocationForDisk(dataDir))) {
            logger.trace("removing blacklisted candidate {}", dataDir.location);
            continue;
        }
        DataDirectoryCandidate candidate = new DataDirectoryCandidate(dataDir);
        // exclude directory if its total writeSize does not fit to data directory
        if (candidate.availableSpace < writeSize) {
            logger.trace("removing candidate {}, usable={}, requested={}", candidate.dataDirectory.location,
                    candidate.availableSpace, writeSize);
            tooBig = true;
            continue;
        }
        candidates.add(candidate);
        totalAvailable += candidate.availableSpace;
    }

    if (candidates.isEmpty())
        if (tooBig)
            return null;
        else
            throw new IOError(new IOException(
                    "All configured data directories have been blacklisted as unwritable for erroring out"));

    // shortcut for single data directory systems
    if (candidates.size() == 1)
        return candidates.get(0).dataDirectory;

    sortWriteableCandidates(candidates, totalAvailable);

    return pickWriteableDirectory(candidates);
}

From source file:gov.llnl.ontology.mapreduce.table.TrinidadTable.java

/**
 * Stores the {@code put} into the {@link HTable}.  This helper method just
 * encapsulates the error handling code.
 *//* w  w w  .ja  va  2 s.  c o m*/
private void put(Put put) {
    try {
        table.put(put);
    } catch (IOException ioe) {
        throw new IOError(ioe);
    }
}

From source file:gov.llnl.ontology.mapreduce.table.TrinidadTable.java

/**
 * {@inheritDoc}//from   ww  w  .j  av  a  2s .  c o m
 */
public void close() {
    try {
        table.flushCommits();
        table.close();
    } catch (IOException ioe) {
        throw new IOError(ioe);
    }
}

From source file:org.asoem.greyfish.cli.GreyfishCLIApplication.java

private static Optional<String> getCommitHash(final Class<?> clazz) {
    try {//from   ww w  .jav a 2  s  .  co  m
        final JarFile jarFile = Resources.getJarFile(clazz);
        final Manifest manifest = jarFile.getManifest();
        final Attributes attr = manifest.getMainAttributes();
        return Optional.of(attr.getValue("Git-Commit-Hash"));
    } catch (IOException e) {
        throw new IOError(e);
    } catch (UnsupportedOperationException e) {
        return Optional.absent();
    }
}

From source file:org.apache.cassandra.service.StorageService.java

public synchronized void initClient() throws IOException, ConfigurationException {
    if (initialized) {
        if (!isClientMode)
            throw new UnsupportedOperationException("StorageService does not support switching modes.");
        return;/* ww  w.  ja v  a 2  s.c  om*/
    }
    initialized = true;
    isClientMode = true;
    logger_.info("Starting up client gossip");
    setMode("Client", false);
    Gossiper.instance.register(this);
    Gossiper.instance.start((int) (System.currentTimeMillis() / 1000)); // needed for node-ring gathering.
    MessagingService.instance().listen(FBUtilities.getLocalAddress());

    // sleep a while to allow gossip to warm up (the other nodes need to know about this one before they can reply).
    try {
        Thread.sleep(5000L);
    } catch (Exception ex) {
        throw new IOError(ex);
    }
    MigrationManager.announce(DatabaseDescriptor.getDefsVersion(), DatabaseDescriptor.getSeeds());
}

From source file:org.opentestsystem.airose.sspace.TrainEssayScorerLSA.java

/**
 * {@inheritDoc}//from   w w  w  . j  a  v  a2s .  c o m
 * 
 * @param properties
 *          {@inheritDoc} See this class's {@link LatentSemanticAnalysis
 *          javadoc} for the full list of supported properties.
 */
public void processSpace() throws UninitializedException {

    Transform transform = new LogEntropyTransform();
    // lets get the number of dimensions we want to reduce the space to from
    // the configuration.
    int dimensions = 50; // default
    SVD.Algorithm alg = SVD.Algorithm.ANY;

    if (ConfigurationFactory.getConfigurationType() == ConfigurationType.TRAINER) {
        TrainerConfiguration configuration = (TrainerConfiguration) ConfigurationFactory.getConfiguration();
        dimensions = configuration.getNumberOfDimensions();

        String svdProp = configuration.getSVDAlgorithm();
        alg = (svdProp == null) ? SVD.Algorithm.ANY : SVD.Algorithm.valueOf(svdProp);

        String transformClass = configuration.getTransformClass();
        if (transformClass != null) {
            transform = ReflectionUtil.getObjectInstance(transformClass);
        }
    }

    try {
        MatrixFile processedSpace = processSpace(transform);

        LoggerUtil.info(LOG, "reducing to %d dimensions", dimensions);

        // Compute SVD on the pre-processed matrix.
        @SuppressWarnings("deprecation")
        Matrix[] usv = SVD.svd(processedSpace.getFile(), alg, processedSpace.getFormat(), dimensions);

        mUSV = new org.opentestsystem.airose.linear.Matrix[] { convetTo(usv[0], MatrixTypeEnum.REAL2D),
                convetTo(usv[1], MatrixTypeEnum.DIAGONAL), convetTo(usv[2], MatrixTypeEnum.REAL2D) };

        // Load the left factor matrix, which is the word semantic space
        mWordSpace = convetTo(usv[0], MatrixTypeEnum.REAL2D);

        // Weight the values in the word space by the singular values.
        Matrix singularValues = usv[1];
        for (int r = 0; r < mWordSpace.rows(); ++r) {
            for (int c = 0; c < mWordSpace.columns(); ++c) {
                mWordSpace.set(r, c, mWordSpace.get(r, c) * singularValues.get(c, c));
            }
        }

        // set the property to keep track of the number of dimensions in the
        // reduced space.
        mDimensionInReducedSpace = dimensions;

    } catch (IOException ioe) {
        // rethrow as Error
        throw new IOError(ioe);
    }
}

From source file:org.apache.cassandra.db.ColumnFamilyStore.java

/**
 * Removes unnecessary files from the cf directory at startup: these include temp files, orphans, zero-length files
 * and compacted sstables. Files that cannot be recognized will be ignored.
 * @return A list of Descriptors that were removed.
 *//*from  w w  w . j  a  v a  2s .c o  m*/
public static void scrubDataDirectories(String table, String columnFamily) {
    for (Map.Entry<Descriptor, Set<Component>> sstableFiles : files(table, columnFamily, true).entrySet()) {
        Descriptor desc = sstableFiles.getKey();
        Set<Component> components = sstableFiles.getValue();

        if (components.contains(Component.COMPACTED_MARKER) || desc.temporary) {
            SSTable.delete(desc, components);
            continue;
        }

        File dataFile = new File(desc.filenameFor(Component.DATA));
        if (components.contains(Component.DATA) && dataFile.length() > 0)
            // everything appears to be in order... moving on.
            continue;

        // missing the DATA file! all components are orphaned
        logger.warn("Removing orphans for {}: {}", desc, components);
        for (Component component : components) {
            try {
                FileUtils.deleteWithConfirm(desc.filenameFor(component));
            } catch (IOException e) {
                throw new IOError(e);
            }
        }
    }

    // cleanup incomplete saved caches
    Pattern tmpCacheFilePattern = Pattern.compile(table + "-" + columnFamily + "-(Key|Row)Cache.*\\.tmp$");
    File dir = new File(DatabaseDescriptor.getSavedCachesLocation());

    if (dir.exists()) {
        assert dir.isDirectory();
        for (File file : dir.listFiles())
            if (tmpCacheFilePattern.matcher(file.getName()).matches())
                if (!file.delete())
                    logger.warn("could not delete " + file.getAbsolutePath());
    }

    // also clean out any index leftovers.
    CFMetaData cfm = DatabaseDescriptor.getCFMetaData(table, columnFamily);
    if (cfm != null) // secondary indexes aren't stored in DD.
    {
        for (ColumnDefinition def : cfm.getColumn_metadata().values())
            scrubDataDirectories(table, CFMetaData.indexName(cfm.cfName, def));
    }
}

From source file:com.puppycrawl.tools.checkstyle.CheckerTest.java

@Test
public void testCatchErrorInProcessFilesMethod() throws Exception {
    // The idea of the test is to satisfy coverage rate.
    // An Error indicates serious problems that a reasonable application should not try to
    // catch, but due to issue https://github.com/checkstyle/checkstyle/issues/2285
    // we catch errors in 'processFiles' method. Most such errors are abnormal conditions,
    // that is why we use PowerMockito to reproduse them.
    final File mock = PowerMockito.mock(File.class);
    // Assume that I/O error is happened when we try to invoke 'lastModified()' method.
    final String errorMessage = "Java Virtual Machine is broken"
            + " or has run out of resources necessary for it to continue operating.";
    final Error expectedError = new IOError(new InternalError(errorMessage));
    when(mock.lastModified()).thenThrow(expectedError);
    final Checker checker = new Checker();
    final List<File> filesToProcess = Lists.newArrayList();
    filesToProcess.add(mock);//from w w  w. j  a  v  a2 s .co m
    try {
        checker.process(filesToProcess);
        fail("IOError is expected!");
    } catch (Error error) {
        assertThat(error.getCause(), instanceOf(IOError.class));
        assertThat(error.getCause().getCause(), instanceOf(InternalError.class));
        assertEquals(errorMessage, error.getCause().getCause().getMessage());
    }
}