Java 类org.apache.commons.lang.time.StopWatch 实例源码

项目:loom    文件:BasicQueryOperations.java   
static List<QueryResult> queryAllThreads(final LoomClient client, final TapestryDefinition tapestryDefinition) {
    List<QueryResult> queryResults = new ArrayList<QueryResult>(tapestryDefinition.getThreads().size());
    StopWatch watch = new StopWatch();
    watch.start();
    List<ThreadDefinition> threads = tapestryDefinition.getThreads();
    for (ThreadDefinition thread : threads) {
        String threadId = thread.getId();
        QueryResult qr =
                getThreadWithWait(client, tapestryDefinition.getId(), threadId, IntegrationTestBase.greaterThan0);
        assertFalse("Result of a query did not contain elements for " + threadId, qr.getElements().isEmpty());
        queryResults.add(qr);
    }
    watch.stop();
    log.info("Getting all threads time=" + watch);
    assertFalse("Loom stuck in performance black hole", watch.getTime() > (60 * 1000));
    RelationshipsHandling.checkCrossThreadRelationships(queryResults);
    return queryResults;
}
项目:GitHub    文件:TestFastJson.java   
@Test
public void testSerializePerformance() throws IOException {
    Object obj = createTest();

    for (int x = 0; x < 20; ++x) {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        for (int i = 0; i < TIMES; ++i) {
            jsonSerialize(obj);
        }
        stopWatch.stop();

        System.out.println("JSON serialize:" + stopWatch.getTime());

        stopWatch.reset();
        stopWatch.start();
        for (int i = 0; i < TIMES; ++i) {
            javaSerialize(obj);
        }
        stopWatch.stop();
        System.out.println("JAVA serialize:" + stopWatch.getTime());
        System.out.println();
    }
}
项目:soundwave    文件:EsServiceMappingStore.java   
public List<EsServiceMapping> getServiceMappings() throws Exception {
  StopWatch sw = new StopWatch();
  sw.start();
  List<EsServiceMapping> ret = new ArrayList<>();
  SearchResponse result = getByDocType(10000);
  for (SearchHit hit : result.getHits()) {
    try {
      EsServiceMapping
          serviceMapping =
          mapper.readValue(hit.getSourceAsString(), EsServiceMapping.class);
      serviceMapping.buildMatchPatterns();
      ret.add(serviceMapping);
    } catch (Exception ex) {
      logger.error("Cannot create Service mapping from {}", hit.getSourceAsString());
    }
  }
  sw.stop();
  logger.info("Refresh all service mappings in {} ms", sw.getTime());
  return ret;
}
项目:jsf-core    文件:CallbackLogWorker.java   
@Override
public boolean run() {
    if (!CheckDBWorker.isDBOK) {
        return true;
    }
    logger.info("callback-log delete worker is starting ...");
    StopWatch clock = new StopWatch();
    try {
        clock.start();     // 计时开始
        callbackLogServiceImpl.deleteByTime();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return false;
    } finally {
        clock.stop();      // 计时结束
    }
    logger.info("callback-log delete worker is finished ...... it elapse time: " + clock.getTime() + " ms");
    return true;
}
项目:jsf-core    文件:ServiceTraceLogWorker.java   
@Override
public boolean run() {
    if (!CheckDBWorker.isDBOK) {
        return true;
    }
    logger.info("servicetrace-log delete worker is starting ...");
    StopWatch clock = new StopWatch();
    try {
        clock.start();     // 计时开始
        serviceTraceLogServiceImpl.deleteByTime();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return false;
    } finally {
        clock.stop();      // 计时结束
    }
    logger.info("servicetrace-log delete worker is finished ...... it elapse time: " + clock.getTime() + " ms");
    return true;
}
项目:loom    文件:TestStitcherSession.java   
@Override
public void removeStitchedItems(final String typeId, final String providerId) {

    if (!allowStitching) {
        return;
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("Remove all stitched items typeId=" + typeId + " providerId=" + providerId);
    }

    if (ruleManager.rulesExistForItemTypeId(typeId)) {
        StopWatch watch = new StopWatch();
        watch.start();
        // There may be stitches for this item type, which are removed by this call to
        // itemIndexer.
        itemIndexer.removeAllItemsForTypeIdAndProviderId(typeId, providerId);
        itemAttributeIndexer.removeAllItemsForTypeIdAndProviderId(typeId, providerId);
        watch.stop();
        LOG.info("removeStitchedItems " + typeId + " " + providerId + " time=" + watch);
    }
}
项目:loom    文件:RestClient.java   
private <T> T get(final String url, final java.lang.Class<T> tClass, final Object... uriVariables) {
    setErrorHandler();
    StopWatch watch = new StopWatch();
    watch.start();
    // T object = restTemplate.getForObject(url, tClass, uriVariables);

    ResponseEntity<T> response = restTemplate.getForEntity(url, tClass, uriVariables);
    HttpHeaders headers = response.getHeaders();

    List<String> cookies = headers.get("Set-Cookie");
    if (cookies != null && cookies.size() > 0) {
        for (String cookie : cookies) {
            if (cookie.substring(0, cookie.indexOf("=")).equals(LoomClient.SESSION_COOKIE)) {
                sessionId = cookie.substring(cookie.indexOf("=") + 1, cookie.indexOf(";"));
                if (sessionId.equals("")) {
                    sessionId = null;
                }
                break;
            }
        }
    }

    watch.stop();
    if (log.isTraceEnabled()) {
        String args = "";
        for (Object arg : uriVariables) {
            args += " " + arg;
        }
        if (watch.getTime() > timewarning) {
            log.trace("GET " + url + " " + args + " WARNING: Operation took " + watch);
        } else {
            log.trace("GET " + url + " " + args + " Operation took " + watch);
        }
    }

    return response.getBody();
    // return object;
}
项目:loom    文件:QueryExecutorImplTest.java   
@Test
public void testGetSameQuery()
        throws NoSuchSessionException, NoSuchTapestryDefinitionException, IllegalAccessException,
        UnsupportedOperationException, OperationException, NoSuchAggregationException, InvalidQueryInputException,
        LogicalIdAlreadyExistsException, NoSuchQueryDefinitionException, NoSuchThreadDefinitionException,
        OperationNotSupportedException, InvalidQueryParametersException, PendingQueryResultsException,
        ItemPropertyNotFound, RelationPropertyNotFound, IllegalArgumentException, ThreadDeletedByDynAdapterUnload {

    tap = new TapestryDefinition();
    tap.setThreads(identityThreads);
    tapestryManager.setTapestryDefinition(session, tap);

    StopWatch watch = new StopWatch();
    LOG.info("testing Get Same Query process");
    watch.start();
    QueryResult results = queryExec.processQuery(session, tap.getThreads().get(0));
    QueryResult sameResults = queryExec.processQuery(session, tap.getThreads().get(0));

    assertTrue(results.getLogicalId().equals(sameResults.getLogicalId()));
    assertTrue(results.getElements().size() == sameResults.getElements().size());

    watch.stop();
    LOG.info("tested Get Same Query process --> " + watch);
}
项目:loom    文件:OsItemTest.java   
@Test
public void testVolumeJson() throws Exception {
    StopWatch watch = new StopWatch();
    LOG.info("testing VolumeJson");
    watch.start();
    // create a volume Item
    ItemType type = new OsVolumeType(provider);
    type.setId("os-" + type.getLocalId());
    OsVolume volume = new OsVolume("/os/fake/volumes/v1", type);
    OsVolumeAttributes ova =
            new OsVolumeAttributes("v1", "vId1", 40, "AVAILABLE", "zone", new Date().toString(), "None", "1234");
    ova.setItemDescription("A description");
    volume.setCore(ova);
    LOG.info("created JSON is\n" + toJson(volume));
    watch.stop();
    LOG.info("tested VolumeJson --> " + watch);
}
项目:loom    文件:QueryExecutorImplTest.java   
@Test(expected = NoSuchSessionException.class)
public void nonExistentSession()
        throws NoSuchSessionException, NoSuchTapestryDefinitionException, LogicalIdAlreadyExistsException,
        NoSuchAggregationException, IllegalAccessException, OperationException, UnsupportedOperationException,
        InvalidQueryInputException, NoSuchQueryDefinitionException, NoSuchThreadDefinitionException,
        OperationNotSupportedException, InvalidQueryParametersException, PendingQueryResultsException,
        ItemPropertyNotFound, RelationPropertyNotFound, IllegalArgumentException, ThreadDeletedByDynAdapterUnload {
    tap = new TapestryDefinition();
    tap.setThreads(groupBraidThreads);
    tapestryManager.setTapestryDefinition(session, tap);

    StopWatch watch = new StopWatch();
    LOG.info("testing bad session process");
    watch.start();
    queryExec.processQuery(new SessionImpl(UUID.randomUUID().toString(), sessionManager.getInterval()),
            tap.getThreads().get(0));

    watch.stop();
    LOG.info("tested bad session process --> " + watch);
}
项目:loom    文件:QueryExecutorImplTest.java   
@Test(expected = NoSuchAggregationException.class)
public void nonExistentAggregation()
        throws NoSuchSessionException, NoSuchTapestryDefinitionException, LogicalIdAlreadyExistsException,
        NoSuchAggregationException, IllegalAccessException, OperationException, UnsupportedOperationException,
        InvalidQueryInputException, NoSuchQueryDefinitionException, NoSuchThreadDefinitionException,
        OperationNotSupportedException, InvalidQueryParametersException, PendingQueryResultsException,
        ItemPropertyNotFound, RelationPropertyNotFound, IllegalArgumentException, ThreadDeletedByDynAdapterUnload {
    tap = new TapestryDefinition();
    tap.setThreads(groupBraidThreads);
    tapestryManager.setTapestryDefinition(session, tap);

    StopWatch watch = new StopWatch();
    LOG.info("testing bad aggregation process");
    List<String> badSources = new ArrayList<>(1);
    badSources.add("/bad/sources");

    watch.start();
    groupBraidQuery.setInputs(badSources);
    queryExec.processQuery(session, tap.getThreads().get(0));

    watch.stop();
    LOG.info("tested bad aggregation process --> " + watch);
}
项目:loom    文件:OperationManagerImplTest.java   
@Test
public void testWrongUUIDRegister() {
    StopWatch watch = new StopWatch();
    LOG.info("testing OpMgrRegistration");
    watch.start();

    List<String> opList = opMgr.listOperations(UUID.randomUUID());
    assertTrue(opList.size() == 0);

    opMgr.registerOperation("FAKEOP", firstMeta, UUID.randomUUID());
    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    opMgr.registerOperation("", firstMeta, OperationManagerImpl.LOOM_UUID);
    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    opMgr.registerOperation("FAKEOP", null, OperationManagerImpl.LOOM_UUID);
    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    watch.stop();
    LOG.info("tested OpMgrRegistration --> " + watch);

}
项目:loom    文件:OperationManagerImplTest.java   
@Test
public void testWrongProviderRegister() {
    StopWatch watch = new StopWatch();
    LOG.info("testing OpMgrRegistration");
    watch.start();

    opMgr.registerOperation4Provider("FAKEOP", firstMeta, null);
    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    opMgr.registerOperation4Provider("", firstMeta, new ProviderImpl("test", "test", "none", "test", "com"));
    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    opMgr.registerOperation4Provider("FAKEOP", null, new ProviderImpl("test", "test", "none", "test", "com"));
    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    watch.stop();
    LOG.info("tested OpMgrRegistration --> " + watch);
}
项目:loom    文件:OsItemTest.java   
@Test
public void testRegionCreation() {
    StopWatch watch = new StopWatch();
    LOG.info("testing RegionCreation");
    watch.start();
    // create an instance Item
    String logicalId = "/os/fake/regions/r1";
    String name = "r1";
    String provId = "fake";
    ItemType type = new OsRegionType();
    type.setId("os-" + type.getLocalId());
    OsRegion item = new OsRegion(logicalId, type);
    OsRegionAttributes ora = new OsRegionAttributes();
    ora.setItemId(name);
    ora.setItemName(name);
    ora.setProviderId(provId);
    item.setCore(ora);
    assertEquals("Incorrect logicalId after creation", logicalId, item.getLogicalId());
    assertEquals("Incorrect name after creation", name, item.getCore().getItemName());
    assertEquals("Incorrect id after creation", name, item.getCore().getItemId());
    assertEquals("Incorrect providerId after creation", provId, item.getCore().getProviderId());
    assertEquals("Incorrect type after creation", type, item.getItemType());
    watch.stop();
    LOG.info("tested RegionCreation --> " + watch);
}
项目:loom    文件:OperationManagerImplTest.java   
@Test
public void deleteAllOps4ProviderWrongly() {
    StopWatch watch = new StopWatch();
    LOG.info("testing OpMgrDelete");
    watch.start();

    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    opMgr.registerOperation4Provider("", firstMeta, new ProviderImpl("test", "test", "none", "test", "com"));
    assertEquals(DefaultOperations.values().length,
            opMgr.listOperations(new ProviderImpl("test", "test", "none", "test", "com")).size());

    opMgr.registerOperation4Provider("FAKEOP2", null, new ProviderImpl("test", "test", "none", "test", "com"));
    assertEquals(DefaultOperations.values().length,
            opMgr.listOperations(new ProviderImpl("test", "test", "none", "test", "com")).size());


}
项目:loom    文件:AdapterManagerTest.java   
@Test
public void testNewProviderType()
        throws NoSuchProviderException, DuplicateAdapterException, DuplicateItemTypeException,
        NullItemTypeIdException, DuplicatePatternException, NullPatternIdException, UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing NewProviderType");
    watch.start();
    // fakeAdapter.registerWithAdapterManager();
    assertTrue("provider is not registered", adapterManager.getProviders().contains(fakeAdapter.getProvider()));
    Provider dnp = new ProviderImpl("newProviderType", provider.getProviderId(), "newEndpoint", "newName", "com");
    DoNothingAdapter dna = new DoNothingAdapter(dnp);
    adapterManager.registerAdapter(dna);
    assertTrue("provider is not registered", adapterManager.getProviders().contains(dnp));
    adapterManager.deregisterAdapter(dna, new HashSet<>(0));
    watch.stop();
    LOG.info("tested NewProviderType --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test
public void testAdapterDeregistration()
        throws NoSuchProviderException, DuplicateAdapterException, DuplicateItemTypeException,
        NullItemTypeIdException, DuplicatePatternException, NullPatternIdException, UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing AdapterDeregistration");
    watch.start();
    Provider testProvider = new FakeProviderImpl("test", "test", "test", "test", "test", "com");
    DoNothingAdapter dna = new DoNothingAdapter(testProvider);

    dna.setAdapterManager(adapterManager, null);
    adapterManager.registerAdapter(dna);
    dna.onLoad();

    assertTrue("provider is not registered", adapterManager.getProviders().contains(testProvider));
    // now deregister

    dna.onUnload();
    assertFalse("provider is still registered", adapterManager.getProviders().contains(testProvider));
    watch.stop();
    LOG.info("tested AdapterDeregistration --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test
public void testItemTypeRegistrationWithAdapter() throws NoSuchProviderException, DuplicateAdapterException {
    StopWatch watch = new StopWatch();
    LOG.info("testing ItemRegistration");
    watch.start();
    // itemType can only be registered for a registered Provider/Adapter
    // fakeAdapter.registerWithAdapterManager();
    assertTrue("provider is not registered", adapterManager.getProviders().contains(provider));
    // register Pattern
    // itemType should be automatically registered by registering the adapter
    // check if tapestryManager has received it
    assertTrue("tapestryManager should have received the itemType",
            itemTypeManager.getItemTypes(provider).contains(fakeAdapter.getItemType(OsInstanceType.TYPE_LOCAL_ID)));
    assertTrue("adapterManager should prefix Id with providerType",
            fakeAdapter.getItemType(OsInstanceType.TYPE_LOCAL_ID).getId().startsWith(provider.getProviderType()));
    // now deregister
    // fakeAdapter.deregisterWithAdapterManager();
    watch.stop();
    LOG.info("tested PatternRegistration --> " + watch);
}
项目:loom    文件:OsItemTest.java   
@Test
public void testProjectJson() throws Exception {
    StopWatch watch = new StopWatch();
    LOG.info("testing ProjectJson");
    watch.start();
    // create a project Item
    ItemType type = new OsProjectType();
    type.setId("os-" + type.getLocalId());
    OsProject project = new OsProject("/os/fake/projects/p1", type);
    OsProjectAttributes opa = new OsProjectAttributes();
    opa.setItemName("p1");
    opa.setItemId("pId1");
    opa.setItemDescription("description");
    opa.setProviderId("fake");
    project.setCore(opa);
    LOG.info("created JSON is\n" + toJson(project));
    watch.stop();
    LOG.info("tested ProjectJson --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test
public void testUserDisconnected() throws NoSuchProviderException, DuplicateAdapterException,
        NoSuchSessionException, SessionAlreadyExistsException, UserAlreadyConnectedException, NoSuchUserException,
        DuplicateItemTypeException, NullItemTypeIdException, DuplicatePatternException, NullPatternIdException,
        UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing UserDisconnected");
    watch.start();
    Provider prov = createProvider();
    DoNothingAdapter dna = createUnregisteredDoNothingAdapter(prov);
    adapterManager.registerAdapter(dna);
    Session session = new SessionImpl("id1", sessionManager.getInterval());
    aggregationManager.createSession(session);
    stitcher.createSession(session);
    adapterManager.userConnected(session, dna.getProvider(), null);
    assertTrue("both sessions should be the same", session.equals(dna.getSession()));
    adapterManager.userDisconnected(session, dna.getProvider(), null);
    adapterManager.deregisterAdapter(dna, new HashSet<>(0));
    watch.stop();
    LOG.info("tested UserDisconnected --> " + watch);
}
项目:loom    文件:FakeAdapterTest.java   
@Test
public void testJustSleep() throws InterruptedException {
    StopWatch watch = new StopWatch();
    LOG.info("testing JustSleep");
    watch.start();
    Provider prov =
            new FakeProviderImpl("os", "private", "http://16.25.166.21:5000/v2.0", "Private", "test", "test");
    assertNotNull("adapter not created", fakeAdapter);
    LOG.info("prov: " + prov);
    LOG.info("faProv: " + fakeAdapter.getProvider());
    assertEquals(true, prov.equals(fakeAdapter.getProvider()));
    LOG.info("test just sleeping...");
    // sleep(1 * 60000);
    watch.stop();
    LOG.info("tested JustSleep --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test
public void testItemTypeDeRegistrationWithAdapter() throws NoSuchProviderException, DuplicateItemTypeException,
        NullItemTypeIdException, NoSuchItemTypeException, DuplicateAdapterException, DuplicatePatternException,
        NullPatternIdException, UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing ItemTypeDeRegistrationWithAdapter");
    watch.start();
    Provider prov = createProvider();
    DoNothingAdapter dna = createUnregisteredDoNothingAdapter(prov);
    adapterManager.registerAdapter(dna);
    ItemType fakeType = new FakeType();
    adapterManager.addItemType(prov, fakeType);
    adapterManager.removeAllItemTypes(prov);
    watch.stop();
    LOG.info("tested ItemTypeDeRegistrationWithAdapter --> " + watch);
}
项目:loom    文件:RestClient.java   
private <T> void put(final String url, final Object bodyObj, final java.lang.Class<T> tClass,
        final Object... uriVariables) {
    setErrorHandler();
    StopWatch watch = new StopWatch();
    watch.start();
    restTemplate.put(url, bodyObj, tClass, uriVariables);
    watch.stop();
    if (log.isTraceEnabled()) {
        // if (watch.getTime() > timeWarning) {
        // bodyStr += " WARNING:";
        // }
        String args = "";
        for (Object arg : uriVariables) {
            args += " " + arg;
        }
        log.trace("PUT " + url + " " + args + " " + bodyObj + " Operation took " + watch);
    }
}
项目:loom    文件:AdapterManagerTest.java   
@Test(expected = NoSuchProviderException.class)
public void testRegisterPatternsUnknownProvider() throws NoSuchProviderException, DuplicateAdapterException,
        DuplicatePatternException, NullPatternIdException, NoSuchPatternException, UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing RegisterPatternsUnknownProvider");
    watch.start();
    Provider prov = createProvider();
    createUnregisteredDoNothingAdapter(prov);
    PatternDefinition pat1 = new PatternDefinition("pat1");
    PatternDefinition pat2 = new PatternDefinition("pat2");
    HashSet<PatternDefinition> patternSet = new HashSet<PatternDefinition>();
    patternSet.add(pat1);
    patternSet.add(pat2);
    adapterManager.addPatternDefinitions(prov, patternSet);
    watch.stop();
    LOG.info("tested RegisterPatternsUnknownProvider --> " + watch);
}
项目:ditb    文件:TestIPCUtil.java   
private static void timerTests(final IPCUtil util, final int count, final int size,
    final Codec codec, final CompressionCodec compressor)
throws IOException {
  final int cycles = 1000;
  StopWatch timer = new StopWatch();
  timer.start();
  for (int i = 0; i < cycles; i++) {
    timerTest(util, timer, count, size, codec, compressor, false);
  }
  timer.stop();
  LOG.info("Codec=" + codec + ", compression=" + compressor + ", sized=" + false +
      ", count=" + count + ", size=" + size + ", + took=" + timer.getTime() + "ms");
  timer.reset();
  timer.start();
  for (int i = 0; i < cycles; i++) {
    timerTest(util, timer, count, size, codec, compressor, true);
  }
  timer.stop();
  LOG.info("Codec=" + codec + ", compression=" + compressor + ", sized=" + true +
    ", count=" + count + ", size=" + size + ", + took=" + timer.getTime() + "ms");
}
项目:loom    文件:AdapterManagerTest.java   
@Test(expected = NullPatternIdException.class)
public void testRegisterTwoPatternsOneNullId() throws NoSuchProviderException, DuplicateAdapterException,
        DuplicatePatternException, NullPatternIdException, NoSuchPatternException, UnsupportedOperationException,
        DuplicateItemTypeException, NullItemTypeIdException {
    LOG.info("testing RegisterTwoPatternsOneNullId");
    StopWatch watch = new StopWatch();
    watch.start();
    Provider prov = createProvider();
    DoNothingAdapter dna = createUnregisteredDoNothingAdapter(prov);
    adapterManager.registerAdapter(dna);
    PatternDefinition pat1 = new PatternDefinition("pat1");
    PatternDefinition pat2 = new PatternDefinition();
    HashSet<PatternDefinition> patternSet = new HashSet<PatternDefinition>();
    patternSet.add(pat1);
    patternSet.add(pat2);
    adapterManager.addPatternDefinitions(prov, patternSet);
    watch.stop();
    LOG.info("tested RegisterTwoPatternsOneNullId --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test
public void testGetItemLogicalId()
        throws NoSuchProviderException, DuplicateAdapterException, NoSuchSessionException,
        SessionAlreadyExistsException, LogicalIdAlreadyExistsException, DuplicateItemTypeException,
        NullItemTypeIdException, DuplicatePatternException, NullPatternIdException, UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing GetItemLogicalId");
    watch.start();
    Provider prov = createProvider();
    ItemType type = new FakeType();
    type.setId("fake-" + type.getLocalId());
    Session session = createSession();
    aggregationManager.createSession(session);
    Aggregation agg = adapterManager.createGroundedAggregation(session, prov, type, null, true, "vms",
            "List of virtual machines - fake", 44);
    adapterManager.registerAdapter(createUnregisteredDoNothingAdapter(prov));
    String itemId = "a123";
    assertTrue("item LogicalId should combine agg logicalId with itemId ",
            LoomUtils.getItemLogicalId(agg, itemId).equals(agg.getLogicalId() + "/" + itemId));
    watch.stop();
    LOG.info("tested GetItemLogicalId --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test(expected = IllegalArgumentException.class)
public void testGetItemLogicalIdNullId() throws NoSuchProviderException, NoSuchSessionException,
        SessionAlreadyExistsException, LogicalIdAlreadyExistsException {
    StopWatch watch = new StopWatch();
    LOG.info("testing GetItemLogicalIdNullId");
    watch.start();
    Provider prov = createProvider();
    ItemType type = new FakeType();
    type.setId("fake-" + type.getLocalId());
    Session session = createSession();
    aggregationManager.createSession(session);
    Aggregation agg = adapterManager.createGroundedAggregation(session, prov, type, null, true, "vms",
            "List of virtual machines - fake", 44);
    LoomUtils.getItemLogicalId(agg, null);
    watch.stop();
    LOG.info("tested GetItemLogicalIdNullId --> " + watch);
}
项目:SkyEye    文件:CacheService.java   
/**
 * 将数据库中的配置表进行缓存
 */
private void loadCache() {
    StopWatch sw = new StopWatch();
    sw.start();
    LOGGER.info("start load config to cache");

    Iterable<ServiceInfo> serviceInfos = this.serviceInfoRepository.findAll();

    for (Iterator<ServiceInfo> it = serviceInfos.iterator(); it.hasNext();) {
        ServiceInfo serviceInfo = it.next();
        this.setOps.add(SERVICE_INFO_PREFIX, serviceInfo.getSid());
    }

    sw.stop();
    LOGGER.info("load config to cache end, cost {} ms", sw.getTime());
}
项目:loom    文件:AdapterManagerTest.java   
@Test
public void testCreateOneAggregation()
        throws NoSuchSessionException, SessionAlreadyExistsException, DuplicateAdapterException,
        LogicalIdAlreadyExistsException, NoSuchProviderException, DuplicateItemTypeException,
        NullItemTypeIdException, DuplicatePatternException, NullPatternIdException, UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing CreateOneAggregation");
    watch.start();
    Provider prov = createProvider();
    adapterManager.registerAdapter(createUnregisteredDoNothingAdapter(prov));
    ItemType type = new FakeType();
    type.setId("fake-" + type.getLocalId());
    Session session = createSession();
    aggregationManager.createSession(session);
    adapterManager.createGroundedAggregation(session, prov, type, null, true, "vms",
            "List of virtual machines - fake", 44);
    assertTrue("aggregationManager should know this aggregation",
            aggregationManager.getAggregation(session, "os/testfake/testfakes") != null);
    watch.stop();
    LOG.info("tested CreateOneAggregation --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test(expected = IllegalArgumentException.class)
public void testCreateOneAggregationNullProvider()
        throws NoSuchSessionException, SessionAlreadyExistsException, DuplicateAdapterException,
        LogicalIdAlreadyExistsException, NoSuchProviderException, DuplicateItemTypeException,
        NullItemTypeIdException, DuplicatePatternException, NullPatternIdException, UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing CreateOneAggregationNullProvider");
    watch.start();
    Provider prov = createProvider();
    Adapter adapter = createUnregisteredDoNothingAdapter(prov);
    // adapterManager.deregisterAdapter(adapter, new HashSet<Session>());

    adapterManager.registerAdapter(adapter);
    ItemType type = new FakeType();
    adapterManager.addItemType(prov, type);
    Session session = createSession();
    aggregationManager.createSession(session);
    adapterManager.createGroundedAggregation(session, null, type, null, true, "vms",
            "List of virtual machines - fake", 44);
    watch.stop();
    LOG.info("tested CreateOneAggregationNullProvider --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test(expected = IllegalArgumentException.class)
public void testCreateOneAggregationNullSession()
        throws NoSuchSessionException, SessionAlreadyExistsException, DuplicateAdapterException,
        LogicalIdAlreadyExistsException, NoSuchProviderException, DuplicateItemTypeException,
        NullItemTypeIdException, DuplicatePatternException, NullPatternIdException, UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing CreateOneAggregationNullSession");
    watch.start();
    Provider prov = createProvider();
    adapterManager.registerAdapter(createUnregisteredDoNothingAdapter(prov));
    ItemType type = new FakeType();
    adapterManager.addItemType(prov, type);
    Session session = createSession();
    aggregationManager.createSession(session);
    adapterManager.createGroundedAggregation(null, prov, type, null, true, "vms", "List of virtual machines - fake",
            44);
    watch.stop();
    LOG.info("tested CreateOneAggregationNullSession --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test
public void testCreateOneAggregationNullLocalIdFalseMapped()
        throws NoSuchSessionException, SessionAlreadyExistsException, DuplicateAdapterException,
        LogicalIdAlreadyExistsException, NoSuchProviderException, DuplicateItemTypeException,
        NullItemTypeIdException, DuplicatePatternException, NullPatternIdException, UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing CreateOneAggregationNullLocalIdFalseMapped");
    watch.start();
    Provider prov = createProvider();
    adapterManager.registerAdapter(createUnregisteredDoNothingAdapter(prov));
    ItemType type = new FakeType();
    type.setId("fake-" + type.getLocalId());
    Session session = createSession();
    aggregationManager.createSession(session);
    adapterManager.createGroundedAggregation(session, prov, type, null, false, "vms",
            "List of virtual machines - fake", 44);
    watch.stop();
    LOG.info("tested CreateOneAggregationNullLocalIdFalseMapped --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test(expected = NoSuchSessionException.class)
public void testCreateOneAggregationUnknownSession()
        throws NoSuchSessionException, SessionAlreadyExistsException, DuplicateAdapterException,
        LogicalIdAlreadyExistsException, NoSuchProviderException, DuplicateItemTypeException,
        NullItemTypeIdException, DuplicatePatternException, NullPatternIdException, UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing CreateOneAggregationUnknownSession");
    watch.start();
    Provider prov = createProvider();
    adapterManager.registerAdapter(createUnregisteredDoNothingAdapter(prov));
    ItemType type = new FakeType();
    type.setId("fake-" + type.getLocalId());
    Session session = createSession();
    adapterManager.createGroundedAggregation(session, prov, type, null, true, "vms",
            "List of virtual machines - fake", 44);
    watch.stop();
    LOG.info("tested CreateOneAggregationUnknownSession --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test
public void testCreateTwoAggregations()
        throws NoSuchSessionException, SessionAlreadyExistsException, DuplicateAdapterException,
        LogicalIdAlreadyExistsException, NoSuchProviderException, DuplicateItemTypeException,
        NullItemTypeIdException, DuplicatePatternException, NullPatternIdException, UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing CreateTwoAggregations");
    watch.start();
    Provider prov = createProvider();
    adapterManager.registerAdapter(createUnregisteredDoNothingAdapter(prov));
    Session session = createSession();
    aggregationManager.createSession(session);
    ItemType type = new FakeType();
    type.setId("fake-" + type.getLocalId());
    adapterManager.createGroundedAggregation(session, prov, type, "fake-sfx", true, "vms",
            "List of virtual machines - fake", 44);
    adapterManager.createGroundedAggregation(session, prov, type, "fake-sfx2", true, "vms",
            "List of virtual machines - fake", 44);
    assertTrue("both aggregations should be in", aggregationManager.listAggregations(session).size() == 2);
    watch.stop();
    LOG.info("tested CreateTwoAggregations --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test(expected = LogicalIdAlreadyExistsException.class)
public void testCreateRepeatAggregations()
        throws NoSuchSessionException, SessionAlreadyExistsException, DuplicateAdapterException,
        LogicalIdAlreadyExistsException, NoSuchProviderException, DuplicateItemTypeException,
        NullItemTypeIdException, DuplicatePatternException, NullPatternIdException, UnsupportedOperationException {
    StopWatch watch = new StopWatch();
    LOG.info("testing CreateRepeatAggregations");
    watch.start();
    Provider prov = createProvider();
    adapterManager.registerAdapter(createUnregisteredDoNothingAdapter(prov));
    Session session = createSession();
    aggregationManager.createSession(session);
    ItemType type = new FakeType();
    type.setId("fake-" + type.getLocalId());
    adapterManager.createGroundedAggregation(session, prov, type, "fake-sfx", true, "vms",
            "List of virtual machines - fake", 44);
    adapterManager.createGroundedAggregation(session, prov, type, "fake-sfx", true, "vms",
            "List of virtual machines - fake", 44);
    assertTrue("both aggregations should be in", aggregationManager.listAggregations(session).size() == 2);
    watch.stop();
    LOG.info("tested CreateRepeatAggregations --> " + watch);
}
项目:loom    文件:AdapterManagerTest.java   
@Test
public void testGetAggregationForItem() throws CheckedLoomException {
    StopWatch watch = new StopWatch();
    LOG.info("testGetAggregationForItem start");
    watch.start();
    assertNotNull("Aggregation manager instance not set", aggregationManager);
    Provider prov = createProvider();
    adapterManager.registerAdapter(createUnregisteredDoNothingAdapter(prov));
    Session session = createSession();
    aggregationManager.createSession(session);
    ItemType type = new FakeType();
    type.setId("fake-" + type.getLocalId());
    Aggregation aggregation = adapterManager.createGroundedAggregation(session, prov, type, null, true, "vms",
            "List of virtual machines - fake", 44);
    String logicalId = aggregation.getLogicalId() + "/i-7e9675e2-c5c0-49e3-8b17-2cfaf14307e8";
    Aggregation retrievedAggregation = adapterManager.getAggregationForItem(session, logicalId);
    assertNotNull("Get Aggregation for Item returned null result", retrievedAggregation);
    assertEquals("Returned aggregation had incorrect logicalId", aggregation.getLogicalId(),
            retrievedAggregation.getLogicalId());
    watch.stop();
    LOG.info("testGetAggregationForItem end --> " + watch);
}
项目:loom    文件:TapestryHandling.java   
static String clientCreateTapestryDefinition(final LoomClient client, final TapestryDefinition tapestryDefinition) {
    if (predictableOrdering) {
        convertToPredictableOrdering(tapestryDefinition);
    }
    StopWatch watch = new StopWatch();
    watch.start();
    // String id = client.createTapestryDefinition(tapestryDefinition);
    String id = client.createTapestryDefinition(tapestryDefinition).getId();
    watch.stop();
    if (log.isDebugEnabled()) {
        log.debug("Create tapestry time=" + watch + " nthreads=" + tapestryDefinition.getThreads().size() + " id "
                + id);
    }

    return id;
}
项目:intellij-spring-assistant    文件:SuggestionIndexServiceImpl.java   
@Override
public void reIndex(Project project) {
  if (indexingInProgress) {
    currentExecution.cancel(false);
  }
  //noinspection CodeBlock2Expr
  currentExecution = getApplication().executeOnPooledThread(() -> {
    getApplication().runReadAction(() -> {
      indexingInProgress = true;
      StopWatch timer = new StopWatch();
      timer.start();
      try {
        debug(() -> log.debug("-> Indexing requested for project " + project.getName()));
        // OrderEnumerator.orderEntries(project) is returning everything from all modules including root level module(which is called project in gradle terms)
        // So, we should not be doing anything with this

        Module[] modules = ModuleManager.getInstance(project).getModules();
        for (Module module : modules) {
          reindexModule(emptyList(), emptyList(), module);
        }
      } finally {
        indexingInProgress = false;
        timer.stop();
        debug(() -> log
            .debug("<- Indexing took " + timer.toString() + " for project " + project.getName()));
      }
    });
  });
}
项目:intellij-spring-assistant    文件:SuggestionIndexServiceImpl.java   
@Override
public void reindex(Project project, Module[] modules) {
  if (indexingInProgress) {
    if (currentExecution != null) {
      currentExecution.cancel(false);
    }
  }
  //noinspection CodeBlock2Expr
  currentExecution = getApplication().executeOnPooledThread(() -> {
    getApplication().runReadAction(() -> {
      debug(() -> log.debug(
          "-> Indexing requested for a subset of modules of project " + project.getName()));
      indexingInProgress = true;
      StopWatch timer = new StopWatch();
      timer.start();
      try {
        for (Module module : modules) {
          debug(() -> log.debug("--> Indexing requested for module " + module.getName()));
          StopWatch moduleTimer = new StopWatch();
          moduleTimer.start();
          try {
            reindexModule(emptyList(), emptyList(), module);
          } finally {
            moduleTimer.stop();
            debug(() -> log.debug(
                "<-- Indexing took " + moduleTimer.toString() + " for module " + module
                    .getName()));
          }
        }
      } finally {
        indexingInProgress = false;
        timer.stop();
        debug(() -> log
            .debug("<- Indexing took " + timer.toString() + " for project " + project.getName()));
      }
    });
  });
}