当前位置: 首页>>代码示例>>Java>>正文


Java Monitor类代码示例

本文整理汇总了Java中com.jamonapi.Monitor的典型用法代码示例。如果您正苦于以下问题:Java Monitor类的具体用法?Java Monitor怎么用?Java Monitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Monitor类属于com.jamonapi包,在下文中一共展示了Monitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invokeUnderTrace

import com.jamonapi.Monitor; //导入依赖的package包/类
/**
 * Wraps the invocation with a JAMon Monitor and writes the current
 * performance statistics to the log (if enabled).
 * @see com.jamonapi.MonitorFactory#start
 * @see com.jamonapi.Monitor#stop
 */
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
	String name = createInvocationTraceName(invocation);
	MonKey key = new MonKeyImp(name, name, "ms.");

	Monitor monitor = MonitorFactory.start(key);
	try {
		return invocation.proceed();
	}
	catch (Throwable ex) {
		trackException(key, ex);
		throw ex;
	}
	finally {
		monitor.stop();
		if (!this.trackAllInvocations || isLogEnabled(logger)) {
			logger.trace("JAMon performance statistics for method [" + name + "]:\n" + monitor);
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:JamonPerformanceMonitorInterceptor.java

示例2: profileInvocation

import com.jamonapi.Monitor; //导入依赖的package包/类
public Object profileInvocation(ProceedingJoinPoint pjp) throws Throwable {
    if (logger.isDebugEnabled()) {
        logger.debug("profiling call for method" + pjp.toLongString());
    }
    Monitor mon = MonitorFactory.start(createMonitorName(pjp));
    try {
        return pjp.proceed();
    } finally {
        mon.stop();
        long now = System.currentTimeMillis();
        if (now - lastOutput > outputInterval) {
            lastOutput = now;
            try {
                outputStats();
            } catch (IOException ioe) {
                logger.warn("error writing to '" + getReportOutputLocation() + "'", ioe);
            }
        }
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:21,代码来源:JamonProfilingAspectAdvice.java

示例3: run

import com.jamonapi.Monitor; //导入依赖的package包/类
@Override
public void run(ExecutionContext ctx, DiagnosticTaskResult result) throws DiagnoseException {
    MonitorComposite monco = MonitorFactory.getRootMonitor();
    Monitor[] monitors = monco.getMonitors();
    if (monitors == null) {
        result.setPassedMessage("No monitor activity recorded");
        return;
    }
    // sort monitors by label lexicographically
    Arrays.sort(monitors,new Comparator<Monitor>() {
        public int compare(Monitor o1, Monitor o2) {
            return o1.getLabel().compareTo(o2.getLabel());
        }
    });

    CompositeDiagnosticTaskResult comResult = (CompositeDiagnosticTaskResult) result;
    for (Monitor each : monitors) {
        DiagnosticTaskResult localResult = new DiagnosticTaskResult(this);
        localResult.setComment(each.getLabel());
        localResult.setPassedMessage(this.composeRow(each));
        comResult.addResult(localResult);
    }
}
 
开发者ID:emicklei,项目名称:selfdiagnose,代码行数:24,代码来源:ReportJamonMonitors.java

示例4: invokeUnderTrace

import com.jamonapi.Monitor; //导入依赖的package包/类
/**
 * Wraps the invocation with a JAMon Monitor and writes the current
 * performance statistics to the log (if enabled).
 * @see com.jamonapi.MonitorFactory#start
 * @see com.jamonapi.Monitor#stop
 */
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
	String name = createInvocationTraceName(invocation);
	Monitor monitor = MonitorFactory.start(name);
	try {
		return invocation.proceed();
	}
	finally {
		monitor.stop();
		if (!this.trackAllInvocations || isLogEnabled(logger)) {
			logger.trace("JAMon performance statistics for method [" + name + "]:\n" + monitor);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:JamonPerformanceMonitorInterceptor.java

示例5: storeProfileInternal

import com.jamonapi.Monitor; //导入依赖的package包/类
private Response storeProfileInternal(String apiKey, String tenantID, String itemID, String itemType, String profile) {
    Monitor mon = MonitorFactory.start(JAMON_PROFILE_STORE);

    List<Message> errorMessages = new ArrayList<>();
    List<Message> responseObject = new ArrayList<>();

    try {
        if (checkParameters(apiKey, tenantID, itemID, itemType, errorMessages) &&
                checkParameterProfile(profile, errorMessages)) {
            Integer coreTenantID = operatorDAO.getTenantId(apiKey, tenantID);
            if (coreTenantID == null)
                errorMessages.add(MSG.TENANT_WRONG_TENANT_APIKEY);
            else {
                if (profileService.storeProfile(coreTenantID, itemID, itemType, profile))
                    responseObject.add(MSG.PROFILE_SAVED);
                else
                    errorMessages.add(MSG.PROFILE_NOT_SAVED);
            }
        }
    } catch (IllegalArgumentException illegalArgumentException) {
        if (illegalArgumentException.getMessage().contains("unknown item type")) {
            errorMessages.add(MSG.OPERATION_FAILED.append(
                    String.format(" itemType %s not found for tenant %s", itemType, tenantID)));
        } else
            errorMessages.add(MSG.PROFILE_NOT_SAVED);
    } catch (RuntimeException runtimeException) {
        errorMessages.add(MSG.PROFILE_NOT_SAVED);
    }

    Response response = formatResponse(responseObject, errorMessages,
            WS.PROFILE_STORE, null);
    mon.stop();
    return response;
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:35,代码来源:JSONProfileWebService.java

示例6: storeItemWithProfileInternal

import com.jamonapi.Monitor; //导入依赖的package包/类
private Response storeItemWithProfileInternal(String apiKey, String tenantID, String itemID, String itemType,
                             String itemDescription, String itemUrl, String itemImageUrl, String profile) {

    Monitor mon = MonitorFactory.start(JAMON_PROFILE_STORE);

    List<Message> errorMessages = new ArrayList<>();
    List<Message> responseObject = new ArrayList<>();

    try {
        Integer coreTenantId = operatorDAO.getTenantId(apiKey, tenantID);
        if (checkParameters(coreTenantId, itemID, itemDescription, itemUrl, errorMessages) && checkParameterProfile(profile, errorMessages)) {

            itemType = checkItemType(itemType, coreTenantId, Item.DEFAULT_STRING_ITEM_TYPE, errorMessages);
            if (itemType != null) {
                itemDAO.insertOrUpdate(coreTenantId, itemID, itemType, itemDescription, itemUrl, itemImageUrl);
        

                if (profileService.storeProfile(coreTenantId, itemID, itemType, profile))
                    responseObject.add(MSG.PROFILE_SAVED);
                else
                    errorMessages.add(MSG.PROFILE_NOT_SAVED);
            }
        
        }
    } catch (IllegalArgumentException illegalArgumentException) {
        if (illegalArgumentException.getMessage().contains("unknown item type")) {
            errorMessages.add(MSG.OPERATION_FAILED.append(
                    String.format(" itemType %s not found for tenant %s", itemType, tenantID)));
        } else
            errorMessages.add(MSG.PROFILE_NOT_SAVED);
    } catch (RuntimeException runtimeException) {
        errorMessages.add(MSG.PROFILE_NOT_SAVED);
    }

    Response response = formatResponse(responseObject, errorMessages,
            WS.PROFILE_STORE, null);
    mon.stop();
    return response;
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:40,代码来源:JSONProfileWebService.java

示例7: pushFieldInternal

import com.jamonapi.Monitor; //导入依赖的package包/类
private Response pushFieldInternal(String apiKey, String tenantID, String itemID, String itemType, String path, String value) {
    Monitor mon = MonitorFactory.start(JAMON_PROFILE_FIELD_STORE);

    List<Message> errorMessages = new ArrayList<>();
    List<Message> responseObject = new ArrayList<>();

    try {
        if (checkParameters(apiKey, tenantID, itemID, itemType, errorMessages) &&
                checkParameterValue(value, errorMessages)) {
            Integer coreTenantID = operatorDAO.getTenantId(apiKey, tenantID);
            if (coreTenantID == null)
                errorMessages.add(MSG.TENANT_WRONG_TENANT_APIKEY);
            else {
                if (profileService.pushToArrayField(
                        coreTenantID, itemID, itemType,
                        path, value))
                    responseObject.add(MSG.PROFILE_FIELD_SAVED);
                else
                    errorMessages.add(MSG.PROFILE_FIELD_NOT_SAVED);
            }
        }
    } catch (Exception e) {
        if (e instanceof IllegalArgumentException) {
            if (e.getMessage().contains("unknown item type")) {
            errorMessages.add(MSG.OPERATION_FAILED.append(
                    String.format(" itemType %s not found for tenant %s", itemType, tenantID)));
            } else {
                errorMessages.add(MSG.PROFILE_FIELD_NOT_SAVED.append(e.getMessage()));
            }
        } else {
            errorMessages.add(MSG.OPERATION_FAILED.append(
                "Exception: " + e.getMessage()));
        }

    } 
    Response response = formatResponse(responseObject, errorMessages,
            WS.PROFILE_FIELD_PUSH, null);
    mon.stop();
    return response; 
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:41,代码来源:JSONProfileWebService.java

示例8: getServiceMonitors

import com.jamonapi.Monitor; //导入依赖的package包/类
/**
 * Retrieves all the Service Monitor Values
 */
public ServiceMonitorVoCollection getServiceMonitors(String filter)
{
	MonitorComposite rootMonitor = MonitorFactory.getRootMonitor();
	Monitor[] allMonitors = rootMonitor.getMonitors();
	ServiceMonitorVoCollection ret = new ServiceMonitorVoCollection();
	Monitor currentMonitor = null;
	String serviceName = null;
	for (int i = 0; i < allMonitors.length; i++)
	{
		currentMonitor = allMonitors[i];
		ServiceMonitorVo vo = new ServiceMonitorVo();
		List list = new ArrayList();
		currentMonitor.getMonKey().getRowData(list);
		serviceName = list.get(0).toString();

		if (filter == null || filter.equals("") || (serviceName.indexOf(filter) != -1))
		{
			vo.setServiceName(serviceName);

			vo.setHits(new Integer((int) currentMonitor.getHits()));
			vo.setAvg(new Integer((int) currentMonitor.getAvg()));
			vo.setTotal(new Integer((int) currentMonitor.getTotal()));
			vo.setStdDev(new Float((float) currentMonitor.getStdDev()));
			vo.setLast(new Float((float) currentMonitor.getLastValue()));
			vo.setMin(new Float((float) currentMonitor.getMin()));
			vo.setMax(new Float((float) currentMonitor.getMax()));
			vo.setActive(new Integer((int) currentMonitor.getActive()));
			vo.setAvgActive(new Float((float) currentMonitor.getAvgActive()));
			vo.setMaxActive(new Integer((int) currentMonitor.getMaxActive()));
			vo.setFirstAccess(new DateTime(currentMonitor.getFirstAccess()));
			vo.setLastAccess(new DateTime(currentMonitor.getLastAccess()));
			ret.add(vo);
		}
	}

	return ret;
}
 
开发者ID:oopcell,项目名称:AvoinApotti,代码行数:41,代码来源:ServiceStatsImpl.java

示例9: stop

import com.jamonapi.Monitor; //导入依赖的package包/类
@Override
public void stop(Monitor mon, Throwable throwable) {
    mon.stop();
    put(throwable);
    // note the following 'get' always succeeds because of the above 'put'
    mon.getMonKey().setDetails(get(throwable));
}
 
开发者ID:stevensouza,项目名称:automon,代码行数:8,代码来源:Jamon.java

示例10: testStart

import com.jamonapi.Monitor; //导入依赖的package包/类
@Test
public void testStart() throws Exception {
    Monitor mon = openMon.start(staticPart);
    assertThat(mon.getLabel()).describedAs("The label should match passed in label").isEqualTo(SharedConstants.LABEL);
    assertThat(mon.getUnits()).describedAs("The units should be for time").isEqualTo("ms.");
    assertThat(mon.getActive()).describedAs("The monitor should have been started").isEqualTo(1);
}
 
开发者ID:stevensouza,项目名称:automon,代码行数:8,代码来源:JamonTest.java

示例11: testStop

import com.jamonapi.Monitor; //导入依赖的package包/类
@Test
public void testStop() throws Exception {
    Monitor mon = openMon.start(staticPart);
    openMon.stop(mon);
    assertThat(mon.getLabel()).describedAs("The label should match passed in label").isEqualTo(SharedConstants.LABEL);
    assertThat(mon.getActive()).describedAs("The monitor should not be running").isEqualTo(0);
    assertThat(mon.getHits()).describedAs("The monitor should have finished and recorded hits").isEqualTo(1);
}
 
开发者ID:stevensouza,项目名称:automon,代码行数:9,代码来源:JamonTest.java

示例12: testStopWithException

import com.jamonapi.Monitor; //导入依赖的package包/类
@Test
public void testStopWithException() throws Exception {
    Monitor mon = openMon.start(staticPart);
    openMon.stop(mon, new RuntimeException("my exception"));
    assertThat(mon.getLabel()).describedAs("The label should match passed in label").isEqualTo(SharedConstants.LABEL);
    assertThat(mon.getActive()).describedAs("The monitor should not be running").isEqualTo(0);
    assertThat(mon.getHits()).describedAs("The monitor should have finished and recorded hits").isEqualTo(1);
}
 
开发者ID:stevensouza,项目名称:automon,代码行数:9,代码来源:JamonTest.java

示例13: itemsBasedOnViewingHistory

import com.jamonapi.Monitor; //导入依赖的package包/类
@IOLog
@Profiled
@Override
public Recommendation itemsBasedOnViewingHistory(Integer tenantId, String userId, Session session,
                                                 String consideredItemType, Integer numberOfLastActionsConsidered,
                                                 String assocType, String requestedItemType,
                                                 Integer numberOfRecommendations) throws EasyRecRestException {
    Recommendation rec;
    RemoteTenant remoteTenant = remoteTenantDAO.get(tenantId);

    Monitor monCore = MonitorFactory.start(JAMON_REST_RECS_FOR_USER);
    RecommendationVO<Integer, String> recommendation =
            domainRecommenderService.itemsBasedOnViewingHistory(
                    tenantId, idMappingDAO.lookup(userId), null, // no sessionId needed
                    consideredItemType, numberOfLastActionsConsidered, assocType, requestedItemType);

    monCore.stop();
    List<Item> items = idMappingService.mapRecommendedItems(recommendation, remoteTenant,
            idMappingDAO.lookup(userId), session,
            numberOfRecommendations);  // session needed for building backtracking url (session.getRequest())


    rec = new Recommendation(remoteTenant.getStringId(), WS.ACTION_RECOMMENDATIONS_FOR_USER, userId, null,
            // no sessionId needed
            null, // no base item needed
            items);
    return rec;
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:29,代码来源:ShopRecommenderServiceImpl.java

示例14: actionHistory

import com.jamonapi.Monitor; //导入依赖的package包/类
@IOLog
@Profiled
@Override
public Recommendation actionHistory(Integer tenantId, String userId, Session session,
                                                String consideredActionType, String consideredItemType, 
                                                Integer numberOfLastActionsConsidered,
                                                Integer numberOfRecommendations) throws EasyRecRestException {
    Recommendation rec;
    RemoteTenant remoteTenant = remoteTenantDAO.get(tenantId);

    Monitor monCore = MonitorFactory.start(JAMON_REST_ACTION_HISTORY_CORE);
    List<ItemVO<Integer, String>> recommendation =
            domainRecommenderService.getActionHistory(tenantId, 
                                                      idMappingDAO.lookup(userId),
                                                      null, 
                                                      consideredActionType, 
                                                      consideredItemType, 
                                                      null, 
                                                      numberOfLastActionsConsidered);

    monCore.stop();
    List<Item> items = idMappingService.mapListOfItemVOs(recommendation, 
                                                        remoteTenant, 
                                                        idMappingDAO.lookup(userId), 
                                                        session, 
                                                        numberOfRecommendations);

    rec = new Recommendation(remoteTenant.getStringId(), WS.ACTION_HISTORY, userId, 
            null, // no sessionId needed
            null, // no base item needed
            items);
    return rec;
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:34,代码来源:ShopRecommenderServiceImpl.java

示例15: itemsBasedOnActionHistory

import com.jamonapi.Monitor; //导入依赖的package包/类
@IOLog
@Profiled
@Override
public Recommendation itemsBasedOnActionHistory(Integer tenantId, String userId, Session session,
                                                String consideredActionType, String consideredItemType, 
                                                Integer numberOfLastActionsConsidered,
                                                String assocType, String requestedItemType,
                                                Integer numberOfRecommendations) throws EasyRecRestException {
    Recommendation rec;
    RemoteTenant remoteTenant = remoteTenantDAO.get(tenantId);

    Double ratingThreshold = null;
    if (consideredActionType.equals(TypeMappingService.ACTION_TYPE_RATE)) {
        ratingThreshold = tenantService.getTenantById(tenantId).getRatingRangeNeutral();
    }
    Monitor monCore = MonitorFactory.start(JAMON_REST_RECS_FOR_USER);
    RecommendationVO<Integer, String> recommendation =
            domainRecommenderService.getItemsBasedOnActionHistory(
                    tenantId, idMappingDAO.lookup(userId), null, // no sessionId needed
                    consideredActionType, consideredItemType, ratingThreshold, numberOfLastActionsConsidered, assocType, requestedItemType);

    monCore.stop();
    List<Item> items = idMappingService.mapRecommendedItems(recommendation, remoteTenant,
            idMappingDAO.lookup(userId), session,
            numberOfRecommendations);  // session needed for building backtracking url (session.getRequest())


    rec = new Recommendation(remoteTenant.getStringId(), WS.ACTION_RECOMMENDATIONS_FOR_USER, userId, null,
            // no sessionId needed
            null, // no base item needed
            items);
    return rec;
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:34,代码来源:ShopRecommenderServiceImpl.java


注:本文中的com.jamonapi.Monitor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。