• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Timed类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: update

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@PUT
@Timed	@Path("{id}")
@UnitOfWork
public Response update(
		@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
		@SessionUser User user, @SessionCurProj Project currentProject,
		@PathParam("id") Long id, @Valid UserProject userProject) {
	Project p = pd.findById(currentProject.getId());
	if (p == null)
		throw new WebApplicationException(Response.Status.FORBIDDEN);
	User u = this.ud.findById(userProject.getIdForUser());
	userProject.setUser(u);
	userProject.setProject(p);
	
	UserProject newUserProject = upd.save(userProject);
	//
	URI uri = UriBuilder.fromResource(UserProjectResource.class).build(
			newUserProject.getId());
	log.info("the response uri will be " + uri);
	sro.reloadSessionForUser(u);
	return Response.created(uri).build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:23,代码来源:UserProjectResource.java


示例2: delete

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@DELETE
@Timed
@Path("{id}")
@Consumes(MediaType.TEXT_PLAIN)
@UnitOfWork
public Response delete(
		@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
		@SessionUser User user, @SessionCurProj Project currentProject,
		@PathParam("id") Long id) {
	Project p = pd.findById(currentProject.getId());

	UserProject deleteableUserProject = upd.findById(id);
	if(p.getId() != deleteableUserProject.getProject().getId()) throw new WebApplicationException(Response.Status.FORBIDDEN);
	upd.delete(id);
	sro.reloadSessionForUser(deleteableUserProject.getUser());
	return Response.ok().build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:18,代码来源:UserProjectResource.java


示例3: update

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@PUT
@Timed
@Path("{id}")
@UnitOfWork
public Response update(
		@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
		@SessionUser User user, @SessionCurProj Project currentProject,
		@PathParam("id") Long id, @Valid Project project) {
	Project p = projectDAO.findById(id);
	if (p == null)
		throw new WebApplicationException(Response.Status.FORBIDDEN);
	if (!p.getId().equals(project.getId()))
		throw new WebApplicationException(Response.Status.FORBIDDEN);
	if(!p.getPrimaryAdmin().getId().equals(user.getId())) throw new WebApplicationException(Response.Status.FORBIDDEN);
	project.setPrimaryAdmin(user);
	
	Project newProject = projectDAO.save(project);
	//
	URI uri = UriBuilder.fromResource(ProjectResource.class).build(
			newProject.getId());
	log.info("the response uri will be " + uri);
	return Response.created(uri).build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:24,代码来源:ProjectResource.java


示例4: accept

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
@UnitOfWork
@Path("accept")
public Response accept(  @QueryParam("code") String code) {
	log.info("redeeming invite code "+code);
	Invite i = this.inviteDAO.findByCode(code);
	Map<String,String> m = new HashMap<String,String>();
	m.put("email",i.getEmail());
	m.put("projectName", i.getProject().getName());
	m.put("projectDesc", i.getProject().getName());
	m.put("fromUser",i.getInviter().getUsername());
	m.put("fromUserEmail",i.getInviter().getEmail());
	return Response.ok(m).build();

}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:17,代码来源:ProjectResource.java


示例5: joinProject

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
	@Timed
	@UnitOfWork
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	@Path("join")
	public Response joinProject(@SessionUser User user,JoinProjectRequest request) {
		log.info("GOT an new project "+request);
//TODO  setup a permissions sort of things.
		String name = request.getSelectedProject();
		Project p = this.projectDAO.findByName(name);
		if(p != null) {
			UserProject up = new UserProject();
			User u = this.userDAO.findById(user.getId());
			
			up.setProject(p);
			up.setUser(u);
			this.upDAO.save(up);
		} else {
			
		}
		return Response.ok().build();
	}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:24,代码来源:ProjectResource.java


示例6: getNextEvent

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
@Produces(MediaType.APPLICATION_JSON)
@UnitOfWork
@Path("nextEvent")
public NextEventRecord getNextEvent(@SessionAuth(required={Priv.CATEGORIZE}) SessionFilteredAuthorization auths,@SessionCurProj Project currentProject,@SessionUser User user, @QueryParam("lastEvent") String lastEventIdStr) {
	Long lastEventId = null;
	try {
		lastEventId = Long.parseLong(lastEventIdStr);
	} catch (NumberFormatException e) {
		// stupid API ignore this exception
	}
	NextEventRecord ner = this.ds.makeNextEventRecord(user,currentProject,lastEventId);
	if(ner.getImageEvent() != null) {
		for(ImageRecord ir: ner.getImageEvent().getImageRecords()) {
			ir.getDatetime();
		}
		ImageEvent upie = initializeAndUnproxy(ner.getImageEvent());
		ner.setImageEvent(upie);
	}
	return ner;
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:23,代码来源:ImageResource.java


示例7: add

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
@Timed
@UnitOfWork
public Response add(
		@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
		@SessionUser User user, @SessionCurProj Project currentProject,
		@Valid Camera camera) {
	log.info("Ok we have the following session user " + user);
	Project p = pd.findById(currentProject.getId());
	if (p == null)
		throw new WebApplicationException(Response.Status.FORBIDDEN);
	camera.setProject(p);
	Camera newCamera = cd.save(camera);

	URI uri = UriBuilder.fromResource(CameraResource.class).build(
			newCamera.getId());
	log.info("the response uri will be " + uri);
	return Response.created(uri).build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:20,代码来源:CameraResource.java


示例8: update

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@PUT
@Timed
@Path("{id}")
@UnitOfWork
public Response update(
		@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
		@SessionUser User user, @SessionCurProj Project currentProject,
		@PathParam("id") Long id, @Valid Camera camera) {
	Project p = pd.findById(currentProject.getId());
	if (p == null)
		throw new WebApplicationException(Response.Status.FORBIDDEN);
	if (!p.getId().equals(camera.getProject().getId()))
		throw new WebApplicationException(Response.Status.FORBIDDEN);

	Camera newCamera = cd.save(camera);
	//
	URI uri = UriBuilder.fromResource(CameraResource.class).build(
			newCamera.getId());
	log.info("the response uri will be " + uri);
	return Response.created(uri).build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:22,代码来源:CameraResource.java


示例9: delete

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@DELETE
@Timed
@Path("{id}")
@Consumes(MediaType.TEXT_PLAIN)
@UnitOfWork
public Response delete(
		@SessionAuth(required = { Priv.ADMIN }) SessionFilteredAuthorization auths,
		@SessionUser User user, @SessionCurProj Project currentProject,
		@PathParam("id") Long id) {
	Project p = pd.findById(currentProject.getId());

	Camera deleteableCamera = cd.findById(id);
	if(p.getId() != deleteableCamera.getProject().getId()) throw new WebApplicationException(Response.Status.FORBIDDEN);
	cd.delete(id);
	return Response.ok().build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:17,代码来源:CameraResource.java


示例10: lookupToo

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
@Path("lookup")
@UnitOfWork
public List<UserTO> lookupToo(@SessionUser User user, @QueryParam("text") String snippet,@QueryParam("p") String projectIdStr) {
	if(snippet == null) throw new NotFoundException();
	if(snippet.length() < 3) throw new NotFoundException();
	Project project = null;
	try {
		Long projectId = null;
		projectId = Long.parseLong(projectIdStr);
		project = this.projectDAO.findById(projectId);
	} catch(NumberFormatException nfe) {}
	User u = this.ud.findByPortionOfEmailUsername(snippet);
	if(u == null) return null;
	// now remove it, if it's already in existence.
	List<UserProject> current= this.upDAO.findByUserIdProjectId(u, project);
	if(current.size() > 0) throw new NotFoundException();
	ArrayList<UserTO> l = new ArrayList<UserTO>();
	l.add(new UserTO(u));
	return l;
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:23,代码来源:UserResource.java


示例11: userupdate

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
	@Timed
	@Path("userupdate")
	@UnitOfWork
	public Response userupdate(@SessionUser User user, @Context HttpServletRequest request, UserUpdate updatedCurUser) {
		int userId = user.getId();
		User editUser = this.ud.findById(userId);
		
//		email  -- this should require a REVERIFICATION
		
		
		this.ud.save(editUser);

		clearSession(request);
		loadAssociatedAndSetSessionWith(request, editUser);
		loadStartingProject(request,editUser);

		
		// there is an implicit SAVE on editUser
		return Response.status(Response.Status.OK).build();
	}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:22,代码来源:UserResource.java


示例12: lostpw

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
@Timed
@Path("lostpw")
@UnitOfWork
public Response lostpw(String resetemail) {
	log.info("starting reset password on "+resetemail);
	// now create and send via email a token which will return to a page on which a new PW can be chosen.
	// that page should simple reset the password IF  the token is valid and matches the email.
	// token should live for a fixed amount of time. 10 minutes ?
	User p = this.ud.findByEmail(resetemail);
	if(p != null) {
		String token = tokendao.createToken(p);
		try {
			emailService.sendPasswordResetEmail(p, token);
		} catch (MessagingException e) {

		}
	}
	// return OK regardless so that we don't "leak" data about membership.
	return Response.status(Response.Status.OK).build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:22,代码来源:UserResource.java


示例13: verify

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@POST
@Timed
@Path("verify")
@UnitOfWork
public Response verify(@Context HttpServletRequest request,VerifyRequest req) {
	String code = req.getVerifyCode();
	User p = ud.findByVerifyCode(code);
	if(p == null) {
		return Response.status(Response.Status.NOT_FOUND).build();
	}
	p.setVerified(true);
	try {
		this.emailService.sendUsANotification(p);
	} catch (MessagingException e) {
		// do nothing here
	}
	if(autoLoginOnVerify) {
		loadAssociatedAndSetSessionWith(request,p);
		loadStartingProject(request,p);
	}
	VerifyResponse vr = new VerifyResponse(p);
	return Response.ok(vr, MediaType.APPLICATION_JSON).build();
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:24,代码来源:UserResource.java


示例14: getEventData

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed
@UnitOfWork
@Path("event/{eventId}")
public Response getEventData(@SessionAuth(required={Priv.REPORT}) SessionFilteredAuthorization auths,@SessionUser User user, @SessionCurProj Project currentProject, @PathParam("eventId") Long eventId) {
	if(eventId == null) return Response.status(Status.NOT_FOUND).build();
	ImageEvent e = eventDAO.findById(eventId);
	if(e == null) return Response.status(Status.NOT_FOUND).build();
	// load data about categorization
	List<SpeciesCount> lsc = this.rd.findCategorizationData(e);
	// load flagging data
	Integer reviewCount = this.reviewDao.getReviewFlagCount(e,user);
	
	Map<String, Integer> m = new HashMap<String,Integer>();
	// load images data included "good" images data
	for(ImageRecord ir :e.getImageRecords()) {
		Integer good = this.goodDao.getGoodFlagCount(ir,user);
		m.put(ir.getId(),good);
	}
	CurrentEventInfo cei = new CurrentEventInfo(lsc,reviewCount,m);
	return Response.ok(cei).build();		
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:23,代码来源:ReportResource.java


示例15: getFieldMappings

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@Override
@Timed
public TableFieldMapping getFieldMappings(String table) throws FoxtrotException {
    table = ElasticsearchUtils.getValidTableName(table);

    if (!tableMetadataManager.exists(table)) {
        throw FoxtrotExceptions.createTableMissingException(table);
    }
    try {
        ElasticsearchMappingParser mappingParser = new ElasticsearchMappingParser(mapper);
        Set<FieldTypeMapping> mappings = new HashSet<>();
        GetMappingsResponse mappingsResponse = connection.getClient().admin()
                .indices().prepareGetMappings(ElasticsearchUtils.getIndices(table)).execute().actionGet();

        for (ObjectCursor<String> index : mappingsResponse.getMappings().keys()) {
            MappingMetaData mappingData = mappingsResponse.mappings().get(index.value).get(ElasticsearchUtils.DOCUMENT_TYPE_NAME);
            mappings.addAll(mappingParser.getFieldMappings(mappingData));
        }
        return new TableFieldMapping(table, mappings);
    } catch (IOException e) {
        throw FoxtrotExceptions.createExecutionException(table, e);
    }
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:24,代码来源:ElasticsearchQueryStore.java


示例16: servePage

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
@GET
@Timed(name = "Dashboard rendertime", group = "Web", type = "")
@Transactional
public String servePage() {
	User me = securityProvider.getUser();
	List<Project> projects = projectDao.findByUser(me);
	List<ProjectInvitation> invitations = invitationDao.findByUser(me);

	return renderer
			.setValue("invitations", invitations)
			.setValue("projects", projects)
			.addJS("common.js")
			.addJS("dashboard.js")
			.addJS("invites.js")
			.render("dashboard.tpl");
}
 
开发者ID:devhub-tud,项目名称:devhub-prototype,代码行数:17,代码来源:DashboardPage.java


示例17: getInstanceMetadata

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
/**
 * GETs a list of instances that are available.
 * @param instance is the instance whose metadata is being requested.
 * @return the metadata about the instance.
 */
@GET
@Timed
@ApiStability.Experimental
public MetadataBackup getInstanceMetadata(@PathParam(INSTANCE_PARAMETER) String instance) {
  Kiji kiji = mKijiClient.getKiji(instance);
  try {
    MetadataBackup backup = MetadataBackup.newBuilder()
        .setLayoutVersion(kiji.getSystemTable().getDataVersion().toString())
        .setSystemTable(kiji.getSystemTable().toBackup())
        .setSchemaTable(kiji.getSchemaTable().toBackup())
        .setMetaTable(kiji.getMetaTable().toBackup()).build();
    return backup;
  } catch (Exception e) {
    throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
  }
}
 
开发者ID:kijiproject,项目名称:kiji-rest,代码行数:22,代码来源:InstanceResource.java


示例18: getTables

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
/**
 * GETs a list of tables in the specified instance.
 *
 * @param instance to list the contained tables.
 * @return a map of tables to their respective resource URIs for easier future access.
 */
@GET
@Timed
@ApiStability.Evolving
public List<GenericResourceRepresentation> getTables(
    @PathParam(INSTANCE_PARAMETER) String instance) {

  List<GenericResourceRepresentation> tables = Lists.newArrayList();
  Kiji kiji = mKijiClient.getKiji(instance);
  try {
    for (String table : kiji.getTableNames()) {
      String tableUri = TABLE_PATH.replace("{" + TABLE_PARAMETER + "}", table)
          .replace("{" + INSTANCE_PARAMETER + "}", instance);
      tables.add(new GenericResourceRepresentation(table, tableUri));
    }
  } catch (IOException e) {
    throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
  }
  return tables;
}
 
开发者ID:kijiproject,项目名称:kiji-rest,代码行数:26,代码来源:TablesResource.java


示例19: addTestRecords

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
/**
 * This method is very usefull for the testing , it fill the tc_users table
 * by {users_count} records , then it create {visits_per_user} for {days}.
 *
 * @param usersCount
 *            the users count
 * @param days
 *            the days
 * @param visits
 *            the visits
 * @return the string
 */
@GET
@Timed
@Path("create/users/{users_count}/{days}/{visits_per_user}")
public String addTestRecords(@PathParam("users_count") final int usersCount, @PathParam("days") final int days,
		@PathParam("visits_per_user") final int visits) {
	final UsersFacade facade = UsersFacade.getInstance();
	System.out.println("Creating records for :" + usersCount + " users");
	for (int i = 1; i <= usersCount; i++) {
		final User user = new User(i, "User " + i);
		facade.addUser(user);
	}
	// create {visits_per_user} visits to each user
	final Random rand = new Random();
	System.out.println("Creating " + visits + " records for all the users for :" + days + " days");
	for (int i = 1; i <= usersCount; i++) {
		System.out.println("Creating Random Visits for User :" + i);
		for (int j = 0; j < visits; j++) {
			DateTime time = new DateTime();
			final int randomDays = rand.nextInt(days) + 1;
			// shift time back by randomDays value
			time = time.minusDays(randomDays);

			// random visitor id
			final int randomVisitor = rand.nextInt(usersCount) + 1;

			// create log object
			final UserVisitLog log = new UserVisitLog(randomVisitor, i, new Timestamp(time.getMillis()));

			// save log object ASYNCH to the database
			facade.recordVisitLog(log);
		}
	}

	return Messages.get(usersCount + " Users added Succ");
}
 
开发者ID:kiswanij,项目名称:jk-drop-wizard-full-example,代码行数:48,代码来源:TestResource.java


示例20: getAllVisitors

import com.yammer.metrics.annotation.Timed; //导入依赖的package包/类
/**
 * Get list of all the user visits.
 *
 * @param userId
 *            the user id
 * @return the all visitors
 */
@GET
@Timed
@Path("all-visitors/{user}")
public String getAllVisitors(@PathParam("user") final int userId) {
	final List<UserVisitLog> allVisitors = this.facade.getAllVisitors(userId);
	return format(allVisitors);
}
 
开发者ID:kiswanij,项目名称:jk-drop-wizard-full-example,代码行数:15,代码来源:UserResource.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ReplyException类代码示例发布时间:2022-05-21
下一篇:
Java ElasticSearchException类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap