Example usage for org.springframework.util StopWatch stop

List of usage examples for org.springframework.util StopWatch stop

Introduction

In this page you can find the example usage for org.springframework.util StopWatch stop.

Prototype

public void stop() throws IllegalStateException 

Source Link

Document

Stop the current task.

Usage

From source file:fr.acxio.tools.agia.alfresco.configuration.SimpleNodeFactoryTest.java

@Test
public void testConditionalTreeGetNodes() throws Exception {
    FolderDefinition aDefaultNodeDefinition = NodeFactoryUtils.createFolderDefinition("test", null, null, null);
    FolderDefinition aFolder1NodeDefinition = NodeFactoryUtils.createFolderDefinition("s1", null, "true", null);
    FolderDefinition aFolder2NodeDefinition = NodeFactoryUtils.createFolderDefinition("s2", null, "false",
            null);// w  ww.  j a v a  2  s. c o  m
    FolderDefinition aFolder3NodeDefinition = NodeFactoryUtils.createFolderDefinition("s3", null, "true", null);

    aDefaultNodeDefinition.addFolder(aFolder1NodeDefinition);
    aDefaultNodeDefinition.addFolder(aFolder2NodeDefinition);
    aDefaultNodeDefinition.addFolder(aFolder3NodeDefinition);

    DocumentDefinition aDocument1Definition = NodeFactoryUtils.createDocumentDefinition("doc1", null, null,
            null, null, null);
    DocumentDefinition aDocument2Definition = NodeFactoryUtils.createDocumentDefinition("doc2", null, null,
            null, null, null);
    DocumentDefinition aDocument3Definition = NodeFactoryUtils.createDocumentDefinition("doc3", null, null,
            null, null, null);

    aFolder1NodeDefinition.addDocument(aDocument1Definition);
    aFolder1NodeDefinition.addDocument(aDocument2Definition);
    aFolder2NodeDefinition.addDocument(aDocument3Definition);

    StopWatch aStopWatch = new StopWatch("testConditionalTreeGetNodes");
    aStopWatch.start("Create a node list");

    SimpleNodeFactory aNodeFactory = new SimpleNodeFactory();
    aNodeFactory.setNamespaceContext(namespaceContext);
    aNodeFactory.setNodeDefinition(aDefaultNodeDefinition);
    NodeList aNodeList = aNodeFactory.getNodes(evaluationContext);

    aStopWatch.stop();

    assertEquals(5, aNodeList.size());
    assertEquals("/cm:test", ((Folder) aNodeList.get(0)).getPath());
    assertEquals("/cm:test/cm:s1", ((Folder) aNodeList.get(1)).getPath());
    assertEquals("/cm:test/cm:s1/cm:doc1", ((Document) aNodeList.get(2)).getPath());
    assertEquals("/cm:test/cm:s1/cm:doc2", ((Document) aNodeList.get(3)).getPath());
    assertEquals("/cm:test/cm:s3", ((Folder) aNodeList.get(4)).getPath());

    System.out.println(aStopWatch.prettyPrint());
}

From source file:com.excilys.ebi.spring.dbunit.DbUnitDatabasePopulator.java

@Override
public void populate(Connection connection) throws SQLException {

    LOGGER.debug("populating");

    StopWatch sw = new StopWatch("DbUnitDatabasePopulator");

    DatabaseOperation operation = phase.getOperation(dataSetConfiguration);
    try {// w w  w . j ava  2 s. c  om
        IDataSet dataSet = decorateDataSetIfNeeded(dataSetConfiguration.getDataSet(),
                dataSetConfiguration.getDecorators());
        String schema = dataSetConfiguration.getSchema();
        DatabaseConnection databaseConnection = getDatabaseConnection(connection, schema, dataSetConfiguration);
        sw.start("populating");
        operation.execute(databaseConnection, dataSet);
        sw.stop();
        LOGGER.debug(sw.prettyPrint());

    } catch (BatchUpdateException e) {
        LOGGER.error("BatchUpdateException while loading dataset", e);
        LOGGER.error("Caused by : ", e.getNextException());
        throw e;

    } catch (DatabaseUnitException e) {
        throw new DbUnitException(e);
    } catch (IOException e) {
        throw new DbUnitException(e);
    }
}

From source file:com.todo.backend.config.SwaggerConfiguration.java

@Bean
public Docket swaggerSpringfoxDocket() {

    log.debug("Initializing swagger...");

    final StopWatch watch = new StopWatch();
    watch.start();//from   w  ww  .j a v a2s  .co  m

    final Docket docket = new Docket(DocumentationType.SWAGGER_2).forCodeGeneration(true)
            .genericModelSubstitutes(ResponseEntity.class).ignoredParameterTypes(Pageable.class)
            .ignoredParameterTypes(java.sql.Date.class)
            .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
            .directModelSubstitute(java.time.ZonedDateTime.class, Date.class)
            .directModelSubstitute(java.time.LocalTime.class, Date.class).select()
            .paths(PathSelectors.regex("/api/.*")).build();

    watch.stop();
    log.debug("Swagger started in {} ms", watch.getTotalTimeMillis());
    return docket;
}

From source file:com.persistent.cloudninja.scheduler.TenantDBBandwidthGenerator.java

@Override
public boolean execute() {
    StopWatch watch = new StopWatch();
    boolean retVal = true;
    try {/*from w  ww . j  av  a  2  s.  c  o  m*/
        watch.start();
        LOGGER.debug("In generator");
        TenantDBBandwidthQueue queue = (TenantDBBandwidthQueue) getWorkQueue();
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z");
        dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        String currentTime = dateFormat.format(calendar.getTime());
        queue.enqueue(currentTime);
        LOGGER.info("Generator : msg added is " + currentTime);
        watch.stop();
        taskCompletionDao.updateTaskCompletionDetails(watch.getTotalTimeSeconds(),
                "GenerateMeterTenantDBBandwidthWork", "");
    } catch (StorageException e) {
        retVal = false;
        LOGGER.error(e.getMessage(), e);
    }
    return retVal;
}

From source file:fr.acxio.tools.agia.alfresco.configuration.SimpleNodeFactoryTest.java

@Test
public void testEvaluationGetNodes() throws Exception {
    FolderDefinition aDefaultNodeDefinition = NodeFactoryUtils.createFolderDefinition("test", null, null, null);
    FolderDefinition aFolder1NodeDefinition = NodeFactoryUtils.createFolderDefinition("@{#in['level1']}", null,
            "@{#in['level1'].equals('s1')}", "@{#in['customfoldertype']}");
    FolderDefinition aFolder2NodeDefinition = NodeFactoryUtils.createFolderDefinition("@{#in['level2']}", null,
            "@{#in['level1'].equals('s2')}", null);
    FolderDefinition aFolder3NodeDefinition = NodeFactoryUtils.createFolderDefinition("@{#in['date']}", null,
            "@{#in['level2'].equals('s2')}", null);

    aDefaultNodeDefinition.addFolder(aFolder1NodeDefinition);
    aDefaultNodeDefinition.addFolder(aFolder2NodeDefinition);
    aDefaultNodeDefinition.addFolder(aFolder3NodeDefinition);

    DocumentDefinition aDocument1Definition = NodeFactoryUtils.createDocumentDefinition("my_@{#in['content1']}",
            "Some @{#in['content1']} title", "@{#in['path1']}", "@{#in['encoding']}", "@{#in['mimetype']}",
            "@{#in['customdoctype']}");
    DocumentDefinition aDocument2Definition = NodeFactoryUtils.createDocumentDefinition("my_@{#in['content2']}",
            "Some @{#in['content2']} title", "file:/otherpath/@{#in['filename2']}", null, null, null);
    DocumentDefinition aDocument3Definition = NodeFactoryUtils.createDocumentDefinition("doc3", null, null,
            null, null, null);/*from www.  j  a  v a2 s .c  o  m*/

    aFolder1NodeDefinition.addDocument(aDocument1Definition);
    aFolder1NodeDefinition.addDocument(aDocument2Definition);
    aFolder2NodeDefinition.addDocument(aDocument3Definition);

    StopWatch aStopWatch = new StopWatch("testEvaluationGetNodes");
    aStopWatch.start("Create a node list");

    SimpleNodeFactory aNodeFactory = new SimpleNodeFactory();
    aNodeFactory.setNamespaceContext(namespaceContext);
    aNodeFactory.setNodeDefinition(aDefaultNodeDefinition);
    NodeList aNodeList = aNodeFactory.getNodes(evaluationContext);

    aStopWatch.stop();

    assertEquals(5, aNodeList.size());
    assertEquals("/cm:test", ((Folder) aNodeList.get(0)).getPath());
    assertEquals("/cm:test/custom:s1", ((Folder) aNodeList.get(1)).getPath());
    assertEquals("/cm:test/custom:s1/custom:my_doc1", ((Document) aNodeList.get(2)).getPath());
    assertEquals("/cm:test/custom:s1/cm:my_doc2", ((Document) aNodeList.get(3)).getPath());
    assertEquals("/cm:test/cm:_x0032_012-07-05", ((Folder) aNodeList.get(4)).getPath()); // TODO : check the encoding

    assertEquals("Some doc1 title", NodeFactoryUtils
            .getPropertyValues(aNodeList.get(2), "{http://www.alfresco.org/model/content/1.0}title").get(0));
    assertEquals("Some doc2 title", NodeFactoryUtils
            .getPropertyValues(aNodeList.get(3), "{http://www.alfresco.org/model/content/1.0}title").get(0));
    assertEquals("file:/somepath/content1.pdf", ((Document) aNodeList.get(2)).getContentPath());
    assertEquals("file:/otherpath/content2.pdf", ((Document) aNodeList.get(3)).getContentPath());
    assertEquals("UTF-8", ((Document) aNodeList.get(2)).getEncoding());
    assertEquals("application/pdf", ((Document) aNodeList.get(2)).getMimeType());
    assertEquals("{http://custom}doc", ((Document) aNodeList.get(2)).getType().toString());
    assertEquals("{http://custom}folder", ((Folder) aNodeList.get(1)).getType().toString());

    System.out.println(aStopWatch.prettyPrint());
}

From source file:de.uniwue.dmir.heatmap.heatmaps.DefaultHeatmap.java

@Override
public TTile getTile(TileCoordinates tileCoordinates) {

    // initializing stop watch
    StopWatch stopWatch = new StopWatch();

    // tile coordinates to top-left reference system
    TileCoordinates projectedTileCoordinates = this.settings.getTileProjection()
            .fromCustomToTopLeft(tileCoordinates, this.settings.getZoomLevelMapper());

    // loading data seed 

    this.logger.debug("Loading data seed.");

    stopWatch.start("loading data seed");

    TTile tile = this.seed.getTile(projectedTileCoordinates);

    stopWatch.stop();
    if (tile == null) {
        this.logger.debug("No data seed available: {}", stopWatch.toString());
    } else {//from w  w  w .  ja  va 2 s  . com
        this.logger.debug("Done loading data seed: {}", stopWatch.toString());
    }

    // get data

    this.logger.debug("Loading data points.");

    stopWatch.start("loading data points");

    Iterator<TPoint> externalData = this.pointsource.getPoints(projectedTileCoordinates, this.filter);

    stopWatch.stop();
    this.logger.debug("Done loading data points: {}", stopWatch.toString());

    // return null if no data was found
    if (externalData == null || !externalData.hasNext()) {

        this.logger.debug("No external data found for this tile: {}", tileCoordinates);

        if (tile == null) {

            this.logger.debug("No data seed available for his tile: returnung null.");
            return null;

        } else if (!this.returnSeedTilesWithNoExternalData) {

            this.logger.debug("Data seed available, but no external data found: returning null.");
            return null;
        }

    }

    // initializing tile if no seed is available
    if (tile == null) {
        this.logger.debug("No data seed available; initializing empty tile.");
        tile = this.tileFactory.newInstance(this.settings.getTileSize(), projectedTileCoordinates);
    }

    // add external data to tile

    this.logger.debug("Adding data points to tile: {}", tileCoordinates);

    stopWatch.start("adding data points to tile");

    int externalDataPointCount = 0;
    while (externalData.hasNext()) {
        TPoint externalDataPoint = externalData.next();
        this.filter.filter(externalDataPoint, tile, this.settings.getTileSize(), tileCoordinates);
        externalDataPointCount++;
    }

    stopWatch.stop();
    this.logger.debug("Done adding {} data points to tile: {}", externalDataPointCount, stopWatch.toString());

    return tile;
}

From source file:com.github.totyumengr.minicubes.core.MiniCubeTest.java

@Test
public void test_5_2_DistinctCount_20140606() throws Throwable {

    StopWatch stopWatch = new StopWatch();
    stopWatch.start();//  w w  w  .  j av a  2 s. c om
    Map<String, List<Integer>> filter = new HashMap<String, List<Integer>>(1);
    filter.put("tradeId", Arrays.asList(
            new Integer[] { 3205, 3206, 3207, 3208, 3209, 3210, 3212, 3299, 3204, 3203, 3202, 3201, 3211 }));
    Map<Integer, RoaringBitmap> distinct = miniCube.distinct("postId", true, "tradeId", filter);
    stopWatch.stop();

    Assert.assertEquals(13, distinct.size());
    Assert.assertEquals(277, distinct.get(3209).getCardinality());
    Assert.assertEquals(186, distinct.get(3211).getCardinality());
    Assert.assertEquals(464, distinct.get(3206).getCardinality());
    LOGGER.info(stopWatch.getTotalTimeSeconds() + " used for distinct result {}", distinct.toString());

}

From source file:com.persistent.cloudninja.scheduler.TenantCreationTask.java

@Override
public boolean execute() {
    boolean retval = true;
    try {/*from   w w w.ja va2  s.co  m*/
        TenantCreationQueue tntCreationQueue = (TenantCreationQueue) getWorkQueue();
        String message = tntCreationQueue.dequeue(SchedulerSettings.MessageVisibilityTimeout);
        if (message == null) {
            LOGGER.debug("Msg is null");
            retval = false;
        } else {
            StopWatch watch = new StopWatch();
            watch.start();
            ProvisioningTenantDTO provisioningTenantDTO = createDTOfromMessage(message);
            boolean tenantCreationSuccess = provisioningService.provisionTenant(provisioningTenantDTO);
            if (tenantCreationSuccess) {
                LOGGER.debug("tenant created :" + provisioningTenantDTO.getTenantId());
            } else {
                LOGGER.debug(
                        "tenant creation for tenant ID :" + provisioningTenantDTO.getTenantId() + " failed.");
            }
            watch.stop();
            taskCompletionDao.updateTaskCompletionDetails(watch.getTotalTimeSeconds(), "ProvisionTenantWork",
                    "Tenant " + provisioningTenantDTO.getTenantId() + " is created.");
        }
    } catch (StorageException e) {
        retval = false;
        LOGGER.error(e.getMessage(), e);
    }
    return retval;
}

From source file:org.dd4t.core.filters.impl.RichTextResolverFilter.java

/**
 * Recursivly resolves all components links.
 * /*from  w  ww  .ja va2s.  com*/
 * @param item
 *            the to resolve the links
 * @param context
 *            the requestContext
 */
@Override
public void doFilter(Item item, RequestContext context) throws FilterException {

    StopWatch stopWatch = null;
    if (logger.isDebugEnabled()) {
        stopWatch = new StopWatch();
        stopWatch.start();
    }
    if (item instanceof GenericPage) {
        resolvePage((GenericPage) item);
    } else if (item instanceof GenericComponent) {
        resolveComponent((GenericComponent) item);
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug(
                    "RichTextResolverFilter. Item is not a GenericPage or GenericComponent so no component to resolve");
        }
    }
    if (logger.isDebugEnabled()) {
        stopWatch.stop();
        logger.debug("RichTextResolverFilter finished in " + stopWatch.getTotalTimeMillis() + " ms");
    }
}