Example usage for java.util.concurrent TimeUnit MINUTES

List of usage examples for java.util.concurrent TimeUnit MINUTES

Introduction

In this page you can find the example usage for java.util.concurrent TimeUnit MINUTES.

Prototype

TimeUnit MINUTES

To view the source code for java.util.concurrent TimeUnit MINUTES.

Click Source Link

Document

Time unit representing sixty seconds.

Usage

From source file:ms1quant.MS1TargetQuantThread.java

@Override
public void run() {
    try {//  w w  w. ja  va2s.  com

        Logger.getRootLogger().info("Processing file " + mzxmlfile.getAbsolutePath() + "....");

        long time = System.currentTimeMillis();
        LCMSPeakMS1 LCMS1 = new LCMSPeakMS1(mzxmlfile.getAbsolutePath(), NoCPUs);
        LCMS1.SetParameter(param);

        LCMS1.Resume = false;
        if (!param.TargetIDOnly) {
            LCMS1.CreatePeakFolder();
        }
        LCMS1.ExportPeakClusterTable = false;

        if (id.PSMList.isEmpty()) {
            Logger.getRootLogger()
                    .warn("There is no PSM mapped to the file:" + mzxmlfile.getName() + ", skipping the file.");
            return;
        }
        LCMS1.IDsummary = id;
        LCMS1.IDsummary.mzXMLFileName = mzxmlfile.getAbsolutePath();

        if (param.TargetIDOnly) {
            LCMS1.SaveSerializationFile = false;
        }

        if (param.TargetIDOnly || !LCMS1.ReadPeakCluster()) {
            LCMS1.PeakClusterDetection();
        }

        LCMS1.AssignQuant(false);
        LCMS1.IDsummary.ExportPepID(outputfolder);

        time = System.currentTimeMillis() - time;
        //logger.info(LCMS1.ParentmzXMLName + " processed time:" + String.format("%d hour, %d min, %d sec", TimeUnit.MILLISECONDS.toHours(time), TimeUnit.MILLISECONDS.toMinutes(time) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time)), TimeUnit.MILLISECONDS.toSeconds(time) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time))));
        Logger.getRootLogger()
                .info(LCMS1.ParentmzXMLName + " processed time:"
                        + String.format("%d hour, %d min, %d sec", TimeUnit.MILLISECONDS.toHours(time),
                                TimeUnit.MILLISECONDS.toMinutes(time)
                                        - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time)),
                                TimeUnit.MILLISECONDS.toSeconds(time)
                                        - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time))));
        LCMS1.BaseClearAllPeaks();
        LCMS1.SetSpectrumParser(null);
        LCMS1.IDsummary = null;
        LCMS1 = null;
        id.ReleaseIDs();
        id = null;
        System.gc();
    } catch (Exception ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
    }
}

From source file:com.wattzap.view.graphs.MMPGraph.java

public MMPGraph(XYSeries series) {
    super();//from  w  w w.j  a v  a2s .c  o m

    NumberAxis yAxis = new NumberAxis(userPrefs.messages.getString("poWtt"));
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    double maxY = series.getMaxY();
    yAxis.setRange(0, maxY + 20);
    yAxis.setTickLabelPaint(Color.white);
    yAxis.setLabelPaint(Color.white);

    LogAxis xAxis = new LogAxis(userPrefs.messages.getString("time"));
    xAxis.setTickLabelPaint(Color.white);
    xAxis.setBase(4);
    xAxis.setAutoRange(false);

    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    xAxis.setRange(1, series.getMaxX() + 500);
    xAxis.setNumberFormatOverride(new NumberFormat() {

        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {

            long millis = (long) number * 1000;

            if (millis >= 60000) {
                return new StringBuffer(String.format("%d m %d s",
                        TimeUnit.MILLISECONDS.toMinutes((long) millis),
                        TimeUnit.MILLISECONDS.toSeconds((long) millis)
                                - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            } else {
                return new StringBuffer(String.format("%d s",

                        TimeUnit.MILLISECONDS.toSeconds((long) millis)
                                - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            }
        }

        @Override
        public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
            return new StringBuffer(String.format("%s", number));
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    });

    XYPlot plot = new XYPlot(new XYSeriesCollection(series), xAxis, yAxis,
            new XYLineAndShapeRenderer(true, false));

    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    chart.setBackgroundPaint(Color.gray);
    plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.darkGray);
    /*plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);*/

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelPaint(Color.white);
    domainAxis.setLabelPaint(Color.white);

    chartPanel = new ChartPanel(chart);
    chartPanel.setSize(100, 800);
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setBackground(Color.gray);

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);
    setBackground(Color.black);
    chartPanel.revalidate();
    setVisible(true);
}

From source file:ddf.test.itests.catalog.TestSecurityAuditPlugin.java

@Test
public void testSecurityAuditPlugin() throws Exception {
    Configuration config = configAdmin
            .getConfiguration("org.codice.ddf.catalog.plugin.security.audit.SecurityAuditPlugin", null);
    List attributes = new ArrayList<>();
    attributes.add("description");
    Dictionary properties = new Hashtable<>();
    properties.put("auditAttributes", attributes);
    config.update(properties);/*from  www . j a  v  a 2s  . co m*/

    String logFilePath = System.getProperty("karaf.data") + "/log/security.log";

    File securityLog = new File(logFilePath);
    WaitCondition.expect("Securitylog exists").within(2, TimeUnit.MINUTES).checkEvery(2, TimeUnit.SECONDS)
            .until(securityLog::exists);

    WaitCondition.expect("Securitylog has log message: " + configUpdateMessage).within(2, TimeUnit.MINUTES)
            .checkEvery(2, TimeUnit.SECONDS)
            .until(() -> getFileContent(securityLog).contains(configUpdateMessage));

    String id = ingestXmlFromResourceAndWait("metacard1.xml");

    update(id, getResourceAsString("metacard2.xml"), "text/xml");

    String expectedLogMessage = String.format(auditMessageFormat, "description", id, "My Description",
            "My Description (Updated)");
    WaitCondition.expect("Securitylog has log message: " + expectedLogMessage).within(2, TimeUnit.MINUTES)
            .checkEvery(2, TimeUnit.SECONDS)
            .until(() -> getFileContent(securityLog).contains(expectedLogMessage));

    delete(id);
}

From source file:com.graphaware.common.ping.GoogleAnalyticsStatsCollector.java

private void post(final String body) {
    executor.scheduleAtFixedRate(new Runnable() {
        @Override//from   w  w w.j  a va  2 s . c om
        public void run() {
            HttpPost httpPost = new HttpPost("http://www.google-analytics.com/collect");
            httpPost.setEntity(new StringEntity(body, ContentType.TEXT_PLAIN));

            try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
                httpClient.execute(httpPost);
            } catch (IOException e1) {
                LOG.warn("Unable to collect stats", e1);
            }
        }
    }, 5, 5, TimeUnit.MINUTES);
}

From source file:bes.injector.InjectorBurnTest.java

@Test
public void testPromptnessOfExecution() throws InterruptedException, ExecutionException, TimeoutException {
    testPromptnessOfExecution(TimeUnit.MINUTES.toNanos(2L), 0.5f);
}

From source file:io.cloudslang.lang.logging.LoggingServiceImpl.java

@Override
public void waitForAllLogTasksToFinish() {
    try {/*from  w  ww. j  a v  a  2  s  . co  m*/
        singleThreadExecutor.shutdown();
        singleThreadExecutor.awaitTermination(1, TimeUnit.MINUTES);
    } catch (InterruptedException ignore) {
    }
}

From source file:com.epam.ta.reportportal.TestConfig.java

@Bean
@Primary/*from  w w w.  ja va 2s .co m*/
public CacheManager getGlobalCacheManager() {
    SimpleCacheManager cacheManager = new SimpleCacheManager();

    GuavaCache tickets = new GuavaCache(EXTERNAL_SYSTEM_TICKET_CACHE,
            CacheBuilder.newBuilder().maximumSize(ticketCacheSize).softValues()
                    .expireAfterAccess(ticketCacheExpiration, TimeUnit.MINUTES).build());
    GuavaCache projects = new GuavaCache(JIRA_PROJECT_CACHE,
            CacheBuilder.newBuilder().maximumSize(projectCacheSize).softValues()
                    .expireAfterAccess(projectCacheExpiration, TimeUnit.DAYS).build());
    GuavaCache users = new GuavaCache(USERS_CACHE, CacheBuilder.newBuilder().maximumSize(userCacheSize)
            .expireAfterWrite(userCacheExpiration, TimeUnit.MINUTES).build());
    GuavaCache projectInfo = new GuavaCache(PROJECT_INFO_CACHE,
            CacheBuilder.newBuilder().maximumSize(projectCacheSize).softValues()
                    .expireAfterWrite(projectInfoCacheExpiration, TimeUnit.MINUTES).build());
    GuavaCache assignedUsers = new GuavaCache(ASSIGNED_USERS_CACHE,
            CacheBuilder.newBuilder().maximumSize(userCacheSize).weakKeys()
                    .expireAfterWrite(userCacheExpiration, TimeUnit.MINUTES).build());

    //@formatter:off
    cacheManager.setCaches(ImmutableList.<GuavaCache>builder().add(tickets).add(projects).add(users)
            .add(projectInfo).add(assignedUsers).build());
    //@formatter:on
    return cacheManager;
}

From source file:com.ning.metrics.eventtracker.ScribeSender.java

public ScribeSender(ScribeClient scribeClient, int messagesToSendBeforeReconnecting, int maxIdleTimeInMinutes) {
    this.scribeClient = scribeClient;
    this.messagesToSendBeforeReconnecting = messagesToSendBeforeReconnecting;

    // Setup a watchdog for the Scribe connection. We don't want to keep it open forever. For instance, SLB VIP
    // may trigger a RST if idle more than a few minutes.
    final ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1,
            Executors.defaultThreadFactory());
    executor.scheduleAtFixedRate(new Runnable() {
        @Override//from  w w  w. ja  va  2s.  co m
        public void run() {
            if (sleeping.get()) {
                log.info("Idle connection to Scribe, re-opening it");
                createConnection();
            }
            sleeping.set(true);
        }
    }, maxIdleTimeInMinutes, maxIdleTimeInMinutes, TimeUnit.MINUTES);
}

From source file:org.jdal.text.PeriodFormatter.java

/**
 * convert period and unit to millis/* w w w  .j  a  v  a  2 s  .c  om*/
 * @param value period value
 * @param unit time unit
 * @return value in millis.
 */
private long parse(long value, String unit) {
    if (DAYS.equalsIgnoreCase(unit))
        return TimeUnit.DAYS.toMillis(value);
    else if (HOURS.equalsIgnoreCase(unit))
        return TimeUnit.HOURS.toMillis(value);
    else if (MINUTES.equalsIgnoreCase(unit))
        return TimeUnit.MINUTES.toMillis(value);
    else if (SECONDS.equalsIgnoreCase(unit))
        return TimeUnit.SECONDS.toMillis(value);

    return 0;
}

From source file:gobblin.metrics.kafka.KafkaSchemaRegistry.java

protected KafkaSchemaRegistry(Properties props) {
    this.props = props;
    int maxCacheSize = Integer.parseInt(props.getProperty(KAFKA_SCHEMA_REGISTRY_MAX_CACHE_SIZE,
            DEFAULT_KAFKA_SCHEMA_REGISTRY_MAX_CACHE_SIZE));
    int expireAfterWriteMin = Integer
            .parseInt(props.getProperty(KAFKA_SCHEMA_REGISTRY_CACHE_EXPIRE_AFTER_WRITE_MIN,
                    DEFAULT_KAFKA_SCHEMA_REGISTRY_CACHE_EXPIRE_AFTER_WRITE_MIN));
    this.cachedSchemasByKeys = CacheBuilder.newBuilder().maximumSize(maxCacheSize)
            .expireAfterWrite(expireAfterWriteMin, TimeUnit.MINUTES).build(new KafkaSchemaCacheLoader());
}