Example usage for java.lang InterruptedException toString

List of usage examples for java.lang InterruptedException toString

Introduction

In this page you can find the example usage for java.lang InterruptedException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.mellanox.r4h.R4HDatanodePlugin.java

/**
 * Stop R4H server/*from   w  w w  .jav a  2 s  .  c  o  m*/
 * 
 * @param waitForDaemon
 *            milliseconds to wait for resources to be closed or -1 for infinate wait
 */
public void stop(int waitForDaemon) {
    if (waitForDaemon < -1) {
        throw new IllegalArgumentException(
                "Illegal (begative) number of milliseconds argument to wait for deamon to stop");
    }

    LOG.debug("Stopping R4H Datanode plugin");
    Daemon dm = new Daemon(new Runnable() {

        @Override
        public void run() {
            dxs.stop();
        }
    });
    dm.start();

    try {
        if (waitForDaemon == -1) {
            daemon.join();
        } else {
            daemon.join(waitForDaemon);
        }
    } catch (InterruptedException e) {
        LOG.debug("daemon join interrupted. Exception: " + e.toString());
    }

    if (dm.isAlive()) {
        LOG.error("timeout waiting for R4H plugin to stop");
    } else {
        LOG.info("R4H Datanode plugin stopped");
    }
}

From source file:de.dal33t.powerfolder.test.transfer.BandwidthLimitText.java

public void testUnlimited() {
    BandwidthLimiter bl = BandwidthLimiter.LAN_INPUT_BANDWIDTH_LIMITER;
    try {/*from w w w .  j a va 2 s .  c  o m*/
        assertEquals(bl.requestBandwidth(Long.MAX_VALUE), Long.MAX_VALUE);
    } catch (InterruptedException e) {
        fail(e.toString());
    }
    provider.setLimitBPS(bl, 0);
    long amount = 70000000;
    while (amount > 0) {
        long rem = 0;
        try {
            rem = bl.requestBandwidth(amount);
        } catch (InterruptedException e) {
            fail(e.toString());
        }
        amount -= rem;
        assertTrue("Short on amount", rem > 0);
    }
    assertTrue("Exceeded amount", amount == 0);
}

From source file:de.dal33t.powerfolder.test.transfer.BandwidthLimitText.java

public void testLimiter() {
    System.out.println("BandwidthLimitTest.testLimiter");
    BandwidthLimiter bl = BandwidthLimiter.LAN_INPUT_BANDWIDTH_LIMITER;
    try {/*from w w  w  .  ja  v  a  2 s .  c o  m*/
        assertEquals(bl.requestBandwidth(Long.MAX_VALUE), Long.MAX_VALUE);
    } catch (InterruptedException e) {
        fail(e.toString());
    }
    bl.setAvailable(2500);
    long amount = 700;
    while (amount > 0) {
        long rem = 0;
        try {
            rem = bl.requestBandwidth(amount);
        } catch (InterruptedException e) {
            fail(e.toString());
        }
        amount -= rem;
        assertTrue("Short on amount", rem > 0);
    }
    assertTrue("Exceeded amount", amount == 0);
}

From source file:com.datatorrent.demos.yahoofinance.StockTickInput.java

@Override
public void emitTuples() {

    try {//from  ww w.  jav a  2 s . co  m
        int statusCode = client.executeMethod(method);
        if (statusCode != HttpStatus.SC_OK) {
            logger.error("Method failed: " + method.getStatusLine());
        } else {
            InputStream istream = method.getResponseBodyAsStream();
            // Process response
            InputStreamReader isr = new InputStreamReader(istream);
            CSVReader reader = new CSVReader(isr);
            List<String[]> myEntries = reader.readAll();
            for (String[] stringArr : myEntries) {
                ArrayList<String> tuple = new ArrayList<String>(Arrays.asList(stringArr));
                if (tuple.size() != 4) {
                    return;
                }
                // input csv is <Symbol>,<Price>,<Volume>,<Time>
                String symbol = tuple.get(0);
                double currentPrice = Double.valueOf(tuple.get(1));
                long currentVolume = Long.valueOf(tuple.get(2));
                String timeStamp = tuple.get(3);
                long vol = currentVolume;
                // Sends total volume in first tick, and incremental volume afterwards.
                if (lastVolume.containsKey(symbol)) {
                    vol -= lastVolume.get(symbol);
                }

                if (vol > 0 || outputEvenIfZeroVolume) {
                    price.emit(new KeyValPair<String, Double>(symbol, currentPrice));
                    volume.emit(new KeyValPair<String, Long>(symbol, vol));
                    time.emit(new KeyValPair<String, String>(symbol, timeStamp));
                    lastVolume.put(symbol, currentVolume);
                }
            }
        }
        Thread.sleep(readIntervalMillis);
    } catch (InterruptedException ex) {
        logger.debug(ex.toString());
    } catch (IOException ex) {
        logger.debug(ex.toString());
    }
}

From source file:de.dal33t.powerfolder.test.transfer.BandwidthLimitText.java

public void testBandwidthStats() {
    BandwidthLimiter bl = BandwidthLimiter.LAN_INPUT_BANDWIDTH_LIMITER;
    bl.setAvailable(0);//from  w ww.ja  v  a2  s  . c  o  m
    provider.start();
    provider.setLimitBPS(bl, 1000);
    final AtomicBoolean gotStat = new AtomicBoolean();
    BandwidthStatsListener listener = new BandwidthStatsListener() {
        public void handleBandwidthStat(BandwidthStat stat) {
            System.out.println("Got a stat...");
            gotStat.set(true);
        }

        public boolean fireInEventDispatchThread() {
            return false;
        }
    };
    provider.addBandwidthStatListener(listener);
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        fail(e.toString());
    }
    provider.removeLimiter(bl);
    provider.shutdown();
    assertTrue("Failed to get any stats?", gotStat.get());
}

From source file:com.google.appengine.tck.logservice.LoggingTestBase.java

protected void pause(long sleepTime) {
    try {/*from ww w . j av a2s .  c  o  m*/
        Thread.sleep(sleepTime);
    } catch (InterruptedException e) {
        throw new IllegalStateException(e.toString());
    }
}

From source file:de.dal33t.powerfolder.test.transfer.BandwidthLimitText.java

public void testHeavyLoad() {
    BandwidthLimiter bl = BandwidthLimiter.LAN_INPUT_BANDWIDTH_LIMITER;
    bl.setAvailable(0);/*  w  w w .j  av  a  2s . c  o m*/
    provider.start();
    provider.setLimitBPS(bl, 1024 * 100);
    LimitedInputStream in = new LimitedInputStream(bl, new InputStream() {
        @Override
        public int read() throws IOException {
            return 0;
        }
    });
    Thread pool[] = new Thread[400];
    for (int i = 0; i < pool.length; i++)
        pool[i] = new Thread(new ReaderThread(in, 1000));

    for (int i = 0; i < pool.length; i++)
        pool[i].start();

    try {
        Thread.sleep(6000);
        pool[0].join(1);
    } catch (InterruptedException e) {
        fail(e.toString());
    }

    provider.shutdown();
    assertEquals(Thread.State.TERMINATED, pool[0].getState());
    for (int i = 0; i < pool.length; i++) {
        try {
            pool[i].join(1);
        } catch (InterruptedException e) {
            fail(e.toString());
        }
        assertEquals(Thread.State.TERMINATED, pool[i].getState());
    }
}

From source file:com.archivas.clienttools.arcutils.impl.adapter.HCAPNullAdapter.java

public void writeObjectFromStream(final String targetPath, final InputStream is,
        final FileMetadata ingestionMetadata) throws StorageAdapterException {
    try {//from ww  w. j  a v  a  2s  . c  om
        Thread.sleep(sleepTimeMs);
    } catch (InterruptedException e) {
        LOG.log(Level.WARNING, e.toString(), e);
    }
}

From source file:com.microsoft.azure.servicebus.samples.managingentity.ManagingEntity.java

private void createQueue(String queueName) {

    // Name of the queue is a required parameter.
    // All other queue properties have defaults, and hence optional.
    QueueDescription queueDescription = new QueueDescription(queueName);

    // The duration of a peek lock; that is, the amount of time that a message is locked from other receivers.
    queueDescription.setLockDuration(Duration.ofSeconds(45));

    // Size of the Queue. For non-partitioned entity, this would be the size of the queue.
    // For partitioned entity, this would be the size of each partition.
    queueDescription.setMaxSizeInMB(2048);

    // This value indicates if the queue requires guard against duplicate messages.
    // Find out more in DuplicateDetection sample.
    queueDescription.setRequiresDuplicateDetection(false);

    // Since RequiresDuplicateDetection is false, the following need not be specified and will be ignored.
    // queueDescription.setDuplicationDetectionHistoryTimeWindow(Duration.ofMinutes(2));

    // This indicates whether the queue supports the concept of session.
    queueDescription.setRequiresSession(false);

    // The default time to live value for the messages.
    // Find out more in "TimeToLive" sample.
    queueDescription.setDefaultMessageTimeToLive(Duration.ofDays(7));

    // Duration of idle interval after which the queue is automatically deleted.
    queueDescription.setAutoDeleteOnIdle(ManagementClientConstants.MAX_DURATION);

    // Decides whether an expired message due to TTL should be dead-lettered.
    // Find out more in "TimeToLive" sample.
    queueDescription.setEnableDeadLetteringOnMessageExpiration(false);

    // The maximum delivery count of a message before it is dead-lettered.
    // Find out more in "DeadletterQueue" sample.
    queueDescription.setMaxDeliveryCount(8);

    // Creating only one partition.
    // Find out more in PartitionedQueues sample.
    queueDescription.setEnablePartitioning(false);

    try {/*w w w. j a  v  a2 s. c  o m*/
        this.managementClient.createQueueAsync(queueDescription).get();
    } catch (InterruptedException e) {
        System.out.println("Encountered exception while creating Queue - \n" + e.toString());
    } catch (ExecutionException e) {
        if (e.getCause() instanceof ServiceBusException) {
            System.out.println("Encountered ServiceBusException while creating Queue - \n" + e.toString());
        }
        System.out.println("Encountered exception while creating Queue - \n" + e.toString());
    }
}

From source file:org.apache.zeppelin.lens.LensJLineShellComponent.java

/**
 * wait the shell command to complete by typing "quit" or "exit" 
 * /* ww  w  . j  a v a2  s.  c om*/
 */
public void waitForComplete() {
    try {
        shellThread.join();
    } catch (InterruptedException e) {
        LOGGER.error(e.toString(), e);
    }
}