Example usage for java.lang IllegalArgumentException getClass

List of usage examples for java.lang IllegalArgumentException getClass

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveTypeObjectStringClassint05() <br>
 * <br>/*from   w  w  w .j  a  v  a 2s . co  m*/
 * () <br>
 * G <br>
 * <br>
 * () bean:Map<String, Object> map0???????getter????<br>
 * () name:"map0"<br>
 * () genericClass:Map.class<br>
 * () index:0<br>
 * <br>
 * () :IllegalArgumentException<br>
 * <br>
 * ???????IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveTypeObjectStringClassint05() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveType(new GenericPropertyUtil_Stub01(), "map0", Map.class, 0);
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveTypeObjectStringClassint06() <br>
 * <br>//from  w  w w . j a v  a 2 s .com
 * () <br>
 * G <br>
 * <br>
 * () bean:Map<String, Object> map1????getter??<br>
 * () name:"map1"<br>
 * () genericClass:Map.class<br>
 * () index:-1<br>
 * <br>
 * () :IllegalArgumentException<br>
 * <br>
 * index??????IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveTypeObjectStringClassint06() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveType(new GenericPropertyUtil_Stub01(), "map1", Map.class, -1);
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveTypeObjectStringClassint09() <br>
 * <br>/*w w  w.java 2 s .  c  om*/
 *  <br>
 * G <br>
 * <br>
 * () bean:Map<String, Object> map1????getter??<br>
 * () name:"map1"<br>
 * () genericClass:Map.class<br>
 * () index:2<br>
 * <br>
 * () :IllegalArgumentException<br>
 * <br>
 * index??????IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveTypeObjectStringClassint09() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveType(new GenericPropertyUtil_Stub01(), "map1", Map.class, 2);
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveTypeObjectStringClassint10() <br>
 * <br>//  w  w w. j a  va 2s.c  o  m
 *  <br>
 * G <br>
 * <br>
 * () bean:Map<String, Object> map1????getter??<br>
 * () name:"map1"<br>
 * () genericClass:null<br>
 * () index:1<br>
 * <br>
 * () :IllegalArgumentException<br>
 * <br>
 * genericClass?null????IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveTypeObjectStringClassint10() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveType(new GenericPropertyUtil_Stub01(), "map1", null, 1);
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}

From source file:org.apache.tez.runtime.library.common.shuffle.orderedgrouped.FetcherOrderedGrouped.java

protected InputAttemptIdentifier[] copyMapOutput(MapHost host, DataInputStream input)
        throws FetcherReadTimeoutException {
    MapOutput mapOutput = null;//from  w  w  w  . ja v  a2  s.  co  m
    InputAttemptIdentifier srcAttemptId = null;
    long decompressedLength = -1;
    long compressedLength = -1;

    try {
        long startTime = System.currentTimeMillis();
        int forReduce = -1;
        //Read the shuffle header
        try {
            ShuffleHeader header = new ShuffleHeader();
            // TODO Review: Multiple header reads in case of status WAIT ? 
            header.readFields(input);
            if (!header.mapId.startsWith(InputAttemptIdentifier.PATH_PREFIX)) {
                if (!stopped) {
                    badIdErrs.increment(1);
                    LOG.warn("Invalid map id: " + header.mapId + ", expected to start with "
                            + InputAttemptIdentifier.PATH_PREFIX + ", partition: " + header.forReduce);
                    return new InputAttemptIdentifier[] { getNextRemainingAttempt() };
                } else {
                    LOG.info("Already shutdown. Ignoring invalid map id error");
                    return EMPTY_ATTEMPT_ID_ARRAY;
                }
            }
            srcAttemptId = scheduler.getIdentifierForFetchedOutput(header.mapId, header.forReduce);
            compressedLength = header.compressedLength;
            decompressedLength = header.uncompressedLength;
            forReduce = header.forReduce;
        } catch (IllegalArgumentException e) {
            if (!stopped) {
                badIdErrs.increment(1);
                LOG.warn("Invalid map id ", e);
                // Don't know which one was bad, so consider this one bad and dont read
                // the remaining because we dont know where to start reading from. YARN-1773
                return new InputAttemptIdentifier[] { getNextRemainingAttempt() };
            } else {
                LOG.info("Already shutdown. Ignoring invalid map id error. Exception: " + e.getClass().getName()
                        + ", Message: " + e.getMessage());
                return EMPTY_ATTEMPT_ID_ARRAY;
            }
        }

        // Do some basic sanity verification
        if (!verifySanity(compressedLength, decompressedLength, forReduce, remaining, srcAttemptId)) {
            if (!stopped) {
                if (srcAttemptId == null) {
                    LOG.warn("Was expecting " + getNextRemainingAttempt() + " but got null");
                    srcAttemptId = getNextRemainingAttempt();
                }
                assert (srcAttemptId != null);
                return new InputAttemptIdentifier[] { srcAttemptId };
            } else {
                LOG.info("Already stopped. Ignoring verification failure.");
                return EMPTY_ATTEMPT_ID_ARRAY;
            }
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug("header: " + srcAttemptId + ", len: " + compressedLength + ", decomp len: "
                    + decompressedLength);
        }

        // Get the location for the map output - either in-memory or on-disk
        try {
            mapOutput = merger.reserve(srcAttemptId, decompressedLength, compressedLength, id);
        } catch (IOException e) {
            if (!stopped) {
                // Kill the reduce attempt
                ioErrs.increment(1);
                scheduler.reportLocalError(e);
            } else {
                LOG.info("Already stopped. Ignoring error from merger.reserve");
            }
            return EMPTY_ATTEMPT_ID_ARRAY;
        }

        // Check if we can shuffle *now* ...
        if (mapOutput.getType() == Type.WAIT) {
            // TODO Review: Does this cause a tight loop ?
            LOG.info("fetcher#" + id + " - MergerManager returned Status.WAIT ...");
            //Not an error but wait to process data.
            return EMPTY_ATTEMPT_ID_ARRAY;
        }

        // Go!
        LOG.info("fetcher#" + id + " about to shuffle output of map " + mapOutput.getAttemptIdentifier()
                + " decomp: " + decompressedLength + " len: " + compressedLength + " to "
                + mapOutput.getType());
        if (mapOutput.getType() == Type.MEMORY) {
            ShuffleUtils.shuffleToMemory(mapOutput.getMemory(), input, (int) decompressedLength,
                    (int) compressedLength, codec, ifileReadAhead, ifileReadAheadLength, LOG,
                    mapOutput.getAttemptIdentifier().toString());
        } else if (mapOutput.getType() == Type.DISK) {
            ShuffleUtils.shuffleToDisk(mapOutput.getDisk(), host.getHostIdentifier(), input, compressedLength,
                    LOG, mapOutput.getAttemptIdentifier().toString());
        } else {
            throw new IOException("Unknown mapOutput type while fetching shuffle data:" + mapOutput.getType());
        }

        // Inform the shuffle scheduler
        long endTime = System.currentTimeMillis();
        // Reset retryStartTime as map task make progress if retried before.
        retryStartTime = 0;

        scheduler.copySucceeded(srcAttemptId, host, compressedLength, decompressedLength, endTime - startTime,
                mapOutput);
        // Note successful shuffle
        remaining.remove(srcAttemptId);
        metrics.successFetch();
        return null;
    } catch (IOException ioe) {
        if (stopped) {
            LOG.info("Not reporting fetch failure for exception during data copy: [" + ioe.getClass().getName()
                    + ", " + ioe.getMessage() + "]");
            cleanupCurrentConnection(true);
            if (mapOutput != null) {
                mapOutput.abort(); // Release resources
            }
            // Don't need to put back - since that's handled by the invoker
            return EMPTY_ATTEMPT_ID_ARRAY;
        }
        if (shouldRetry(host, ioe)) {
            //release mem/file handles
            if (mapOutput != null) {
                mapOutput.abort();
            }
            throw new FetcherReadTimeoutException(ioe);
        }
        ioErrs.increment(1);
        if (srcAttemptId == null || mapOutput == null) {
            LOG.info("fetcher#" + id + " failed to read map header" + srcAttemptId + " decomp: "
                    + decompressedLength + ", " + compressedLength, ioe);
            if (srcAttemptId == null) {
                return remaining.toArray(new InputAttemptIdentifier[remaining.size()]);
            } else {
                return new InputAttemptIdentifier[] { srcAttemptId };
            }
        }

        LOG.warn("Failed to shuffle output of " + srcAttemptId + " from " + host.getHostIdentifier(), ioe);

        // Inform the shuffle-scheduler
        mapOutput.abort();
        metrics.failedFetch();
        return new InputAttemptIdentifier[] { srcAttemptId };
    }

}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveTypeObjectStringClassint01() <br>
 * <br>// w w  w  . j av  a  2  s. co  m
 * () <br>
 * G <br>
 * <br>
 * () bean:null<br>
 * () index:0<br>
 * <br>
 * () :IllegalArgumentException<br>
 * "Argument 'bean' ("<br>
 * + Object.class.getName() + " is null"<br>
 * <br>
 * bean?null???IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveTypeObjectStringClassint01() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveType(null, (String) null, null, 0);
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        String message = "Argument 'bean' (" + Object.class.getName() + " is null";
        assertEquals(message, e.getMessage());
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveTypeObjectStringClassint02() <br>
 * <br>/*from  w ww .j  av  a 2 s .  c  o m*/
 * () <br>
 * G <br>
 * <br>
 * () bean:Object<br>
 * () name:null<br>
 * () index:0<br>
 * <br>
 * () :IllegalArgumentException<br>
 * "Argument 'name' ("<br>
 * + String.class.getName() + " is empty"<br>
 * <br>
 * name?null???IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveTypeObjectStringClassint02() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveType(new Object(), (String) null, null, 0);
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        String message = "Argument 'name' (" + String.class.getName() + " is empty";
        assertEquals(message, e.getMessage());
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveTypeObjectStringClassint03() <br>
 * <br>/*from  w w  w .j  a v  a  2 s  . c om*/
 * () <br>
 * G <br>
 * <br>
 * () bean:Object<br>
 * () name:""<br>
 * () index:0<br>
 * <br>
 * () :IllegalArgumentException<br>
 * "Argument 'name' ("<br>
 * + String.class.getName() + " is empty"<br>
 * <br>
 * name????IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveTypeObjectStringClassint03() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveType(new Object(), "", null, 0);
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        String message = "Argument 'name' (" + String.class.getName() + " is empty";
        assertEquals(message, e.getMessage());
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveTypeObjectStringClassint04() <br>
 * <br>/*  www.  j  a  v  a2 s.  com*/
 * () <br>
 * G <br>
 * <br>
 * () bean:Object<br>
 * () name:"   "<br>
 * () index:0<br>
 * <br>
 * () :IllegalArgumentException<br>
 * "Argument 'name' ("<br>
 * + String.class.getName() + " is empty"<br>
 * <br>
 * name????IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveTypeObjectStringClassint04() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveType(new Object(), "   ", null, 0);
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        String message = "Argument 'name' (" + String.class.getName() + " is empty";
        assertEquals(message, e.getMessage());
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}

From source file:jp.terasoluna.fw.util.GenericPropertyUtilTest.java

/**
 * testResolveTypeClassClassTypeint01() <br>
 * <br>//from w  ww  .  j  av  a  2 s.  co  m
 *  <br>
 * G <br>
 * <br>
 * () genericClass:null<br>
 * () index:0<br>
 * <br>
 * () :IllegalArgumentException<br>
 * "Argument 'genericsClass' ("<br>
 * + Class.class.getName() + ") is null"<br>
 * <br>
 * genericClass?null???IllegalArgumentException?????? <br>
 * @throws Exception ?????
 */
@Test
public void testResolveTypeClassClassTypeint01() throws Exception {
    try {
        // 
        GenericPropertyUtil.resolveType((Class<?>) null, (Class<?>) null, null, 0);
        // 
        fail("???????");
    } catch (IllegalArgumentException e) {
        String message = "Argument 'genericsClass' (" + Class.class.getName() + ") is null";
        assertEquals(message, e.getMessage());
        assertEquals(IllegalArgumentException.class.getName(), e.getClass().getName());
    }
}