Ejemplo n.º 1
0
 @AfterReturning(value = "allOperation()||athenaServiceOperation()||spartanServiceOperation()")
 public void afterReturning(JoinPoint join) throws IOException {
   counterService.increment(
       "counter.HttpStatus."
           + httpStatusCode.name()
           + "."
           + join.getSignature().getDeclaringType().getSimpleName()
           + "."
           + join.getSignature().getName()
           + ".calls");
   counterService.increment("counter.numberof.calls");
 }
  @Override
  public void delete(String id) {
    logger.info("> delete");

    counterService.increment("services.issueservice.delete.invoked");

    issueRepository.delete(id);

    logger.info("< delete");
  }
 public String incrementUricounter(String className, String methodName) {
   counterService.increment(className + "." + methodName);
   Metric metric = repository.findOne("gauge." + className + "." + methodName + "");
   if (metric != null) {
     gaugeservice.submit(className + "." + methodName, (Double) metric.getValue() + 1);
   } else {
     gaugeservice.submit(className + "." + methodName, 1);
   }
   return className + "." + methodName;
 }
  @Override
  public Issue update(Issue issue) {
    logger.info("> update");

    counterService.increment("services.issueservice.update.invoked");

    Issue updatedIssue = issueRepository.save(issue);

    logger.info("< update");
    return updatedIssue;
  }
  @Override
  public Issue find(String id) {
    logger.info("> find id:{}", id);

    counterService.increment("services.issueservice.find.invoked");

    Issue issue = issueRepository.findOne(id);

    logger.info("< find id:{}", id);
    return issue;
  }
  @Override
  public Iterable<Issue> findAll() {
    logger.info("> findAll");

    counterService.increment("services.issueservice.findAll.invoked");

    Iterable<Issue> issues = issueRepository.findAll();

    logger.info("< findAll");
    return issues;
  }
  @RequestMapping(
      value = "/api/todo/{id}",
      method = RequestMethod.DELETE,
      produces = MediaType.APPLICATION_JSON_VALUE)
  public ResponseEntity<Task> deleteTask(@PathVariable("id") long id) {

    counterService.increment("invoked.todoService.deleteTask");

    Task task = todoService.getTaskById(id);
    if (task == null) {
      logger.info("Unable to find task with id - {}", id);
      return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    todoService.delete(id);
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
  }
  @RequestMapping(
      value = "/api/todo/create",
      method = RequestMethod.POST,
      consumes = MediaType.APPLICATION_JSON_VALUE,
      produces = MediaType.APPLICATION_JSON_VALUE)
  public ResponseEntity<Task> createTask(@RequestBody Task task) {

    counterService.increment("invoked.todoService.createTask");

    if (task.getTask() == null || StringUtils.isEmpty(task.getTask())) {
      logger.info("Unable to create task with empty task", task);
      return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }

    Task savedTask = todoService.createTask(task);
    return new ResponseEntity<>(savedTask, HttpStatus.CREATED);
  }
  @RequestMapping(
      value = "/api/todo",
      method = RequestMethod.GET,
      produces = MediaType.APPLICATION_JSON_VALUE)
  public ResponseEntity<List<Task>> getAllTask() {

    counterService.increment("invoked.todoService.getAllTasks");

    List<Task> tasks = todoService.getAllTasks();

    if (tasks.size() <= 0) {
      logger.info("Data is empty? No task found");
      return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    return new ResponseEntity<>(tasks, HttpStatus.OK);
  }
  @Override
  public Issue create(Issue issue) {
    logger.info("> create");

    counterService.increment("services.issueservice.create.invoked");

    // Set default attribute values
    issue.setStatus(IssueStatus.OPEN);

    if (issue.getPriority() == null) {
      issue.setPriority(IssuePriority.MEDIUM);
    }

    Issue persistedIssue = issueRepository.save(issue);

    logger.info("< create");
    return persistedIssue;
  }