com.codahale.metrics.annotation.Metered Java Examples
The following examples show how to use
com.codahale.metrics.annotation.Metered.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProjectController.java From Kylin with Apache License 2.0 | 6 votes |
@RequestMapping(value = "", method = { RequestMethod.PUT }) @ResponseBody @Metered(name = "updateProject") public ProjectInstance updateProject(@RequestBody UpdateProjectRequest projectRequest) { if (StringUtils.isEmpty(projectRequest.getFormerProjectName())) { throw new InternalErrorException("A project name must be given to update a project"); } ProjectInstance updatedProj = null; try { updatedProj = projectService.updateProject(projectRequest); } catch (Exception e) { logger.error("Failed to deal with the request.", e); throw new InternalErrorException(e.getLocalizedMessage()); } return updatedProj; }
Example #2
Source File: SsoService.java From codenvy with Eclipse Public License 1.0 | 6 votes |
@Metered(name = "auth.sso.service_delete_token") @Path("{token}") @DELETE public void unregisterToken( @PathParam("token") String token, @QueryParam("clienturl") String clientUrl) throws AuthenticationException { LOG.debug("Un-register token {} and client {} ", token, clientUrl); if (clientUrl == null || clientUrl.isEmpty()) { ticketManager.removeTicket(token); } else { AccessTicket accessTicket = ticketManager.getAccessTicket(token); if (accessTicket != null) { accessTicket.unRegisterClientUrl(clientUrl); } } }
Example #3
Source File: TableController.java From Kylin with Apache License 2.0 | 6 votes |
/** * Get available table list of the input database * * @return Table metadata array * @throws IOException */ @RequestMapping(value = "", method = {RequestMethod.GET}) @ResponseBody @Metered(name = "listSourceTables") public List<TableDesc> getHiveTables(@RequestParam(value = "ext", required = false) boolean withExt, @RequestParam(value = "project", required = false) String project) { long start = System.currentTimeMillis(); List<TableDesc> tables = null; try { tables = cubeMgmtService.getProjectManager().listDefinedTables(project); } catch (Exception e) { logger.error("Failed to deal with the request.", e); throw new InternalErrorException(e.getLocalizedMessage()); } if (withExt) { tables = cloneTableDesc(tables); } long end = System.currentTimeMillis(); logger.info("Return all table metadata in " + (end - start) + " seconds"); return tables; }
Example #4
Source File: CubeController.java From Kylin with Apache License 2.0 | 6 votes |
@RequestMapping(value = "/{cubeName}", method = {RequestMethod.DELETE}) @ResponseBody @Metered(name = "deleteCube") public void deleteCube(@PathVariable String cubeName) { CubeInstance cube = cubeService.getCubeManager().getCube(cubeName); if (null == cube) { throw new NotFoundException("Cube with name " + cubeName + " not found.."); } try { cubeService.deleteCube(cube); } catch (Exception e) { logger.error(e.getLocalizedMessage(), e); throw new InternalErrorException("Failed to delete cube. " + " Caused by: " + e.getMessage(), e); } }
Example #5
Source File: CentralAuthenticationServiceImpl.java From taoshop with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * Destroy a TicketGrantingTicket and perform back channel logout. This has the effect of invalidating any * Ticket that was derived from the TicketGrantingTicket being destroyed. May throw an * {@link IllegalArgumentException} if the TicketGrantingTicket ID is null. * * @param ticketGrantingTicketId the id of the ticket we want to destroy * @return the logout requests. */ @Audit( action = "TICKET_GRANTING_TICKET_DESTROYED", actionResolverName = "DESTROY_TICKET_GRANTING_TICKET_RESOLVER", resourceResolverName = "DESTROY_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER") @Timed(name = "DESTROY_TICKET_GRANTING_TICKET_TIMER") @Metered(name = "DESTROY_TICKET_GRANTING_TICKET_METER") @Counted(name = "DESTROY_TICKET_GRANTING_TICKET_COUNTER", monotonic = true) @Override public List<LogoutRequest> destroyTicketGrantingTicket(@NotNull final String ticketGrantingTicketId) { try { logger.debug("Removing ticket [{}] from registry...", ticketGrantingTicketId); final TicketGrantingTicket ticket = getTicket(ticketGrantingTicketId, TicketGrantingTicket.class); logger.debug("Ticket found. Processing logout requests and then deleting the ticket..."); final List<LogoutRequest> logoutRequests = logoutManager.performLogout(ticket); this.ticketRegistry.deleteTicket(ticketGrantingTicketId); doPublishEvent(new CasTicketGrantingTicketDestroyedEvent(this, ticket)); return logoutRequests; } catch (final InvalidTicketException e) { logger.debug("TicketGrantingTicket [{}] cannot be found in the ticket registry.", ticketGrantingTicketId); } return Collections.emptyList(); }
Example #6
Source File: MainController.java From cfg4j-sample-apps with Apache License 2.0 | 6 votes |
@Metered(name = "hello.run") public void run(String... args) throws Exception { Boolean wasAwake = false; ReksioConfig reksioConfig = configurationProvider.bind("reksio", ReksioConfig.class); while (true) { if (wasAwake != reksioConfig.awake()) { System.out.println("Reksio is now " + (reksioConfig.awake() ? "awake" : "asleep")); wasAwake = reksioConfig.awake(); } Thread.sleep(500); } }
Example #7
Source File: MetricsInterceptor.java From metrics-cdi with Apache License 2.0 | 6 votes |
private void registerMetrics(Class<?> bean, Executable executable) { MetricResolver.Of<Counted> counted = resolver.counted(bean, executable); if (counted.isPresent()) registry.counter(counted.metricName()); MetricResolver.Of<ExceptionMetered> exceptionMetered = resolver.exceptionMetered(bean, executable); if (exceptionMetered.isPresent()) registry.meter(exceptionMetered.metricName()); MetricResolver.Of<Metered> metered = resolver.metered(bean, executable); if (metered.isPresent()) registry.meter(metered.metricName()); MetricResolver.Of<Timed> timed = resolver.timed(bean, executable); if (timed.isPresent()) { extension.<BiFunction<String, Class<? extends Metric>, Optional<Reservoir>>>getParameter(ReservoirFunction) .flatMap(function -> function.apply(timed.metricName(), Timer.class)) .map(reservoir -> registry.timer(timed.metricName(), () -> new Timer(reservoir))) .orElseGet(() -> registry.timer(timed.metricName())); } }
Example #8
Source File: EventDriverMetrics.java From dropwizard-websockets with MIT License | 6 votes |
public EventDriverMetrics(final Class<?> endpointClass, MetricRegistry metrics) { final Class<?> klass = endpointClass; Metered metered = klass.getAnnotation(Metered.class); Timed timed = klass.getAnnotation(Timed.class); ExceptionMetered em = klass.getAnnotation(ExceptionMetered.class); this.onTextMeter = metered != null ? Optional.of(metrics.meter(MetricRegistry.name(metered.name(), klass.getName(), OnMessage.class.getSimpleName()))) : Optional.empty(); this.countOpened = metered != null ? Optional.of(metrics.counter(MetricRegistry.name(metered.name(), klass.getName(), OPEN_CONNECTIONS))) : Optional.empty(); this.timer = timed != null ? Optional.of(metrics.timer(MetricRegistry.name(timed.name(), klass.getName()))) : Optional.empty(); this.exceptionMetered = em != null ? Optional.of(metrics.meter(MetricRegistry.name(em.name(), klass.getName(), OnError.class.getSimpleName()))) : Optional.empty(); }
Example #9
Source File: CentralAuthenticationServiceImpl.java From springboot-shiro-cas-mybatis with MIT License | 6 votes |
/** * {@inheritDoc} */ @Timed(name = "GET_TICKET_TIMER") @Metered(name = "GET_TICKET_METER") @Counted(name="GET_TICKET_COUNTER", monotonic=true) @Override public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz) throws InvalidTicketException { Assert.notNull(ticketId, "ticketId cannot be null"); final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz); if (ticket == null) { logger.debug("Ticket [{}] by type [{}] cannot be found in the ticket registry.", ticketId, clazz.getSimpleName()); throw new InvalidTicketException(ticketId); } if (ticket instanceof TicketGrantingTicket) { synchronized (ticket) { if (ticket.isExpired()) { this.ticketRegistry.deleteTicket(ticketId); logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId); throw new InvalidTicketException(ticketId); } } } return (T) ticket; }
Example #10
Source File: CubeController.java From Kylin with Apache License 2.0 | 6 votes |
@RequestMapping(value = "/{cubeName}/enable", method = {RequestMethod.PUT}) @ResponseBody @Metered(name = "enableCube") public CubeInstance enableCube(@PathVariable String cubeName) { try { CubeInstance cube = cubeService.getCubeManager().getCube(cubeName); if (null == cube) { throw new InternalErrorException("Cannot find cube " + cubeName); } return cubeService.enableCube(cube); } catch (Exception e) { String message = "Failed to enable cube: " + cubeName; logger.error(message, e); throw new InternalErrorException(message + " Caused by: " + e.getMessage(), e); } }
Example #11
Source File: ProjectController.java From Kylin with Apache License 2.0 | 6 votes |
@RequestMapping(value = "", method = { RequestMethod.POST }) @ResponseBody @Metered(name = "saveProject") public ProjectInstance saveProject(@RequestBody CreateProjectRequest projectRequest) { if (StringUtils.isEmpty(projectRequest.getName())) { throw new InternalErrorException("A project name must be given to create a project"); } ProjectInstance createdProj = null; try { createdProj = projectService.createProject(projectRequest); } catch (Exception e) { logger.error("Failed to deal with the request.", e); throw new InternalErrorException(e.getLocalizedMessage()); } return createdProj; }
Example #12
Source File: CentralAuthenticationServiceImpl.java From springboot-shiro-cas-mybatis with MIT License | 6 votes |
@Audit( action="SERVICE_TICKET", actionResolverName="GRANT_SERVICE_TICKET_RESOLVER", resourceResolverName="GRANT_SERVICE_TICKET_RESOURCE_RESOLVER") @Timed(name = "GRANT_SERVICE_TICKET_TIMER") @Metered(name="GRANT_SERVICE_TICKET_METER") @Counted(name="GRANT_SERVICE_TICKET_COUNTER", monotonic=true) @Override public ServiceTicket grantServiceTicket(final String ticketGrantingTicketId, final Service service) throws TicketException { try { return this.grantServiceTicket(ticketGrantingTicketId, service, (Credential[]) null); } catch (final AuthenticationException e) { throw new IllegalStateException("Unexpected authentication exception", e); } }
Example #13
Source File: MetricResolver.java From metrics-cdi with Apache License 2.0 | 6 votes |
private String metricName(Annotation annotation) { if (CachedGauge.class.isInstance(annotation)) return ((CachedGauge) annotation).name(); else if (Counted.class.isInstance(annotation)) return ((Counted) annotation).name(); else if (ExceptionMetered.class.isInstance(annotation)) return ((ExceptionMetered) annotation).name(); else if (Gauge.class.isInstance(annotation)) return ((Gauge) annotation).name(); else if (Metered.class.isInstance(annotation)) return ((Metered) annotation).name(); else if (Timed.class.isInstance(annotation)) return ((Timed) annotation).name(); else throw new IllegalArgumentException("Unsupported Metrics forMethod [" + annotation.getClass().getName() + "]"); }
Example #14
Source File: CentralAuthenticationServiceImpl.java From springboot-shiro-cas-mybatis with MIT License | 6 votes |
/** * {@inheritDoc} * Destroy a TicketGrantingTicket and perform back channel logout. This has the effect of invalidating any * Ticket that was derived from the TicketGrantingTicket being destroyed. May throw an * {@link IllegalArgumentException} if the TicketGrantingTicket ID is null. * * @param ticketGrantingTicketId the id of the ticket we want to destroy * @return the logout requests. */ @Audit( action="TICKET_GRANTING_TICKET_DESTROYED", actionResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOLVER", resourceResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER") @Timed(name = "DESTROY_TICKET_GRANTING_TICKET_TIMER") @Metered(name="DESTROY_TICKET_GRANTING_TICKET_METER") @Counted(name="DESTROY_TICKET_GRANTING_TICKET_COUNTER", monotonic=true) @Override public List<LogoutRequest> destroyTicketGrantingTicket(@NotNull final String ticketGrantingTicketId) { try { logger.debug("Removing ticket [{}] from registry...", ticketGrantingTicketId); final TicketGrantingTicket ticket = getTicket(ticketGrantingTicketId, TicketGrantingTicket.class); logger.debug("Ticket found. Processing logout requests and then deleting the ticket..."); final List<LogoutRequest> logoutRequests = logoutManager.performLogout(ticket); this.ticketRegistry.deleteTicket(ticketGrantingTicketId); return logoutRequests; } catch (final InvalidTicketException e) { logger.debug("TicketGrantingTicket [{}] cannot be found in the ticket registry.", ticketGrantingTicketId); } return Collections.emptyList(); }
Example #15
Source File: CubeController.java From Kylin with Apache License 2.0 | 6 votes |
@RequestMapping(value = "/{cubeName}/purge", method = {RequestMethod.PUT}) @ResponseBody @Metered(name = "purgeCube") public CubeInstance purgeCube(@PathVariable String cubeName) { try { CubeInstance cube = cubeService.getCubeManager().getCube(cubeName); if (cube == null) { throw new InternalErrorException("Cannot find cube " + cubeName); } return cubeService.purgeCube(cube); } catch (Exception e) { String message = "Failed to purge cube: " + cubeName; logger.error(message, e); throw new InternalErrorException(message + " Caused by: " + e.getMessage(), e); } }
Example #16
Source File: CentralAuthenticationServiceImpl.java From taoshop with Apache License 2.0 | 6 votes |
@Audit( action = "TICKET_GRANTING_TICKET", actionResolverName = "CREATE_TICKET_GRANTING_TICKET_RESOLVER", resourceResolverName = "CREATE_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER") @Timed(name = "CREATE_TICKET_GRANTING_TICKET_TIMER") @Metered(name = "CREATE_TICKET_GRANTING_TICKET_METER") @Counted(name = "CREATE_TICKET_GRANTING_TICKET_COUNTER", monotonic = true) @Override public TicketGrantingTicket createTicketGrantingTicket(final AuthenticationContext context) throws AuthenticationException, AbstractTicketException { final Authentication authentication = context.getAuthentication(); final TicketGrantingTicketFactory factory = this.ticketFactory.get(TicketGrantingTicket.class); final TicketGrantingTicket ticketGrantingTicket = factory.create(authentication); this.ticketRegistry.addTicket(ticketGrantingTicket); doPublishEvent(new CasTicketGrantingTicketCreatedEvent(this, ticketGrantingTicket)); return ticketGrantingTicket; }
Example #17
Source File: MetricResolver.java From metrics-cdi with Apache License 2.0 | 6 votes |
private boolean isMetricAbsolute(Annotation annotation) { if (extension.<Boolean>getParameter(UseAbsoluteName).orElse(false)) return true; if (CachedGauge.class.isInstance(annotation)) return ((CachedGauge) annotation).absolute(); else if (Counted.class.isInstance(annotation)) return ((Counted) annotation).absolute(); else if (ExceptionMetered.class.isInstance(annotation)) return ((ExceptionMetered) annotation).absolute(); else if (Gauge.class.isInstance(annotation)) return ((Gauge) annotation).absolute(); else if (Metered.class.isInstance(annotation)) return ((Metered) annotation).absolute(); else if (Timed.class.isInstance(annotation)) return ((Timed) annotation).absolute(); else throw new IllegalArgumentException("Unsupported Metrics forMethod [" + annotation.getClass().getName() + "]"); }
Example #18
Source File: CubeController.java From Kylin with Apache License 2.0 | 6 votes |
@RequestMapping(value = "/{cubeName}/disable", method = {RequestMethod.PUT}) @ResponseBody @Metered(name = "disableCube") public CubeInstance disableCube(@PathVariable String cubeName) { try { CubeInstance cube = cubeService.getCubeManager().getCube(cubeName); if (cube == null) { throw new InternalErrorException("Cannot find cube " + cubeName); } return cubeService.disableCube(cube); } catch (Exception e) { String message = "Failed to disable cube: " + cubeName; logger.error(message, e); throw new InternalErrorException(message + " Caused by: " + e.getMessage(), e); } }
Example #19
Source File: MultiFactorAwareCentralAuthenticationService.java From cas-mfa with Apache License 2.0 | 6 votes |
@Override @Audit( action="TICKET_GRANTING_TICKET", actionResolverName="CREATE_TICKET_GRANTING_TICKET_RESOLVER", resourceResolverName="CREATE_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER") @Timed(name = "CREATE_TICKET_GRANTING_TICKET_TIMER") @Metered(name = "CREATE_TICKET_GRANTING_TICKET_METER") @Counted(name="CREATE_TICKET_GRANTING_TICKET_COUNTER", monotonic=true) public TicketGrantingTicket createTicketGrantingTicket(final Credential... credentials) throws TicketException { final MultiFactorCredentials mfaCredentials = (MultiFactorCredentials) credentials[0]; final Authentication authentication = mfaCredentials.getAuthentication(); if (authentication == null) { throw new TicketCreationException(new RuntimeException("Authentication cannot be null")); } final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl( this.ticketGrantingTicketUniqueTicketIdGenerator.getNewTicketId(TicketGrantingTicket.PREFIX), authentication, this.ticketGrantingTicketExpirationPolicy); this.ticketRegistry.addTicket(ticketGrantingTicket); return ticketGrantingTicket; }
Example #20
Source File: CentralAuthenticationServiceImpl.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Audit( action="TICKET_GRANTING_TICKET", actionResolverName="CREATE_TICKET_GRANTING_TICKET_RESOLVER", resourceResolverName="CREATE_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER") @Timed(name = "CREATE_TICKET_GRANTING_TICKET_TIMER") @Metered(name = "CREATE_TICKET_GRANTING_TICKET_METER") @Counted(name="CREATE_TICKET_GRANTING_TICKET_COUNTER", monotonic=true) @Override public TicketGrantingTicket createTicketGrantingTicket(final Credential... credentials) throws AuthenticationException, TicketException { final Set<Credential> sanitizedCredentials = sanitizeCredentials(credentials); if (sanitizedCredentials.size() > 0) { final Authentication authentication = this.authenticationManager.authenticate(credentials); final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl( this.ticketGrantingTicketUniqueTicketIdGenerator .getNewTicketId(TicketGrantingTicket.PREFIX), authentication, this.ticketGrantingTicketExpirationPolicy); this.ticketRegistry.addTicket(ticketGrantingTicket); return ticketGrantingTicket; } final String msg = "No credentials were specified in the request for creating a new ticket-granting ticket"; logger.warn(msg); throw new TicketCreationException(new IllegalArgumentException(msg)); }
Example #21
Source File: MultiFactorAwareCentralAuthenticationService.java From cas-mfa with Apache License 2.0 | 5 votes |
@Timed(name = "GET_TICKETS_TIMER") @Metered(name = "GET_TICKETS_METER") @Counted(name="GET_TICKETS_COUNTER", monotonic=true) @Override public Collection<Ticket> getTickets(final Predicate predicate) { return this.delegate.getTickets(predicate); }
Example #22
Source File: MultipleMetricsStaticMethod.java From metrics-aspectj with Apache License 2.0 | 5 votes |
@ExceptionMetered(name = "exception") @Gauge(name = "gauge") @Metered(name = "meter") @Timed(name = "timer") public static String metricsMethod() { return "value"; }
Example #23
Source File: MultiFactorAwareCentralAuthenticationService.java From cas-mfa with Apache License 2.0 | 5 votes |
@Audit( action="SERVICE_TICKET_VALIDATE", actionResolverName="VALIDATE_SERVICE_TICKET_RESOLVER", resourceResolverName="VALIDATE_SERVICE_TICKET_RESOURCE_RESOLVER") @Timed(name="VALIDATE_SERVICE_TICKET_TIMER") @Metered(name="VALIDATE_SERVICE_TICKET_METER") @Counted(name="VALIDATE_SERVICE_TICKET_COUNTER", monotonic=true) @Override public Assertion validateServiceTicket(final String serviceTicketId, final Service service) throws TicketException { return this.delegate.validateServiceTicket(serviceTicketId, service); }
Example #24
Source File: MultipleMetricsMethodBean.java From metrics-cdi with Apache License 2.0 | 5 votes |
@Counted(name = "counter", monotonic = true) @ExceptionMetered(name = "exception") @Gauge(name = "gauge") @Metered(name = "meter") @Timed(name = "timer") public String metricsMethod() { return "value"; }
Example #25
Source File: MultipleMetricsMethod.java From metrics-aspectj with Apache License 2.0 | 5 votes |
@ExceptionMetered(name = "exception") @Gauge(name = "gauge") @Metered(name = "meter") @Timed(name = "timer") public String metricsMethod() { return "value"; }
Example #26
Source File: MultiFactorAwareCentralAuthenticationService.java From cas-mfa with Apache License 2.0 | 5 votes |
@Audit( action="SERVICE_TICKET", actionResolverName="GRANT_SERVICE_TICKET_RESOLVER", resourceResolverName="GRANT_SERVICE_TICKET_RESOURCE_RESOLVER") @Timed(name="GRANT_SERVICE_TICKET_TIMER") @Metered(name="GRANT_SERVICE_TICKET_METER") @Counted(name="GRANT_SERVICE_TICKET_COUNTER", monotonic=true) @Override public ServiceTicket grantServiceTicket( final String ticketGrantingTicketId, final Service service, final Credential... credentials) throws org.jasig.cas.authentication.AuthenticationException, TicketException { return this.delegate.grantServiceTicket(ticketGrantingTicketId, service, credentials); }
Example #27
Source File: JavaFirstServiceImpl.java From dropwizard-jaxws with Apache License 2.0 | 5 votes |
@Override @Metered @ExceptionMetered public String echo(String in) throws JavaFirstServiceException { if (in == null || in.trim().length() == 0) { throw new JavaFirstServiceException("Invalid parameter"); } Principal user = (Principal)wsContext.getMessageContext().get("dropwizard.jaxws.principal"); return in + "; principal: " + user.getName(); }
Example #28
Source File: MultiFactorAwareCentralAuthenticationService.java From cas-mfa with Apache License 2.0 | 5 votes |
@Audit( action="SERVICE_TICKET", actionResolverName="GRANT_SERVICE_TICKET_RESOLVER", resourceResolverName="GRANT_SERVICE_TICKET_RESOURCE_RESOLVER") @Timed(name = "GRANT_SERVICE_TICKET_TIMER") @Metered(name="GRANT_SERVICE_TICKET_METER") @Counted(name="GRANT_SERVICE_TICKET_COUNTER", monotonic=true) @Override public ServiceTicket grantServiceTicket(final String ticketGrantingTicketId, final Service service) throws TicketException { return this.delegate.grantServiceTicket(ticketGrantingTicketId, service); }
Example #29
Source File: MultipleMetricsMethodWithRegistryFromBeanProperty.java From metrics-aspectj with Apache License 2.0 | 5 votes |
@ExceptionMetered(name = "exception") @Gauge(name = "gauge") @Metered(name = "meter") @Timed(name = "timer") public String metricsMethod() { return "value"; }
Example #30
Source File: MultiFactorAwareCentralAuthenticationService.java From cas-mfa with Apache License 2.0 | 5 votes |
@Timed(name = "GET_TICKET_TIMER") @Metered(name = "GET_TICKET_METER") @Counted(name="GET_TICKET_COUNTER", monotonic=true) @Override public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz) throws InvalidTicketException { return delegate.getTicket(ticketId, clazz); }