You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by "Yurii Shylov (JIRA)" <ji...@apache.org> on 2015/01/15 17:22:34 UTC

[jira] [Created] (AMBARI-9152) Alert Targets Can No Longer Dispatch

Yurii Shylov created AMBARI-9152:
------------------------------------

             Summary: Alert Targets Can No Longer Dispatch
                 Key: AMBARI-9152
                 URL: https://issues.apache.org/jira/browse/AMBARI-9152
             Project: Ambari
          Issue Type: Task
          Components: ambari-server
    Affects Versions: 2.0.0
            Reporter: Yurii Shylov
            Assignee: Yurii Shylov
            Priority: Critical
             Fix For: 2.0.0


Git 275e898 (https://github.com/apache/ambari/commit/275e898) introduced the following change:

{code}
-        normalizedMap.put(propKey, entry.getValue());
+        normalizedMap.put(propKey, entry.getValue().toString());
{code}

in {{AlertTargetResourceProvider}}. This causes a problem when there is a JSON array in the structure of an AlertTarget, such as when creating:

{code}
{
  "AlertTarget": {
    "name": "Administrators",
    "description": "The Admins",
    "notification_type": "EMAIL",
    "global": true,
    "properties":{
      "ambari.dispatch.credential.username":"ambari",
      "ambari.dispatch.credential.password":"password",
      "ambari.dispatch.recipients":["ambari@repo.ambari.apache.org"],
      "mail.smtp.host":"repo.ambari.apache.org",
      "mail.smtp.port":"25",
      "mail.smtp.auth":"true",
      "mail.smtp.starttls.enable":"false",
      "mail.smtp.from":"ambari@repo.ambari.apache.org"
    }
  }
}
{code}

When getting this target back, the target's {{ambari.dispatch.recipients}} is malformed:

{code}
    "properties" : {
      "mail.smtp.from" : "ambari@repo.ambari.apache.org",
      "ambari.dispatch.credential.username" : "ambari",
      "mail.smtp.host" : "repo.ambari.apache.org",
      "mail.smtp.port" : "25",
      "mail.smtp.auth" : "true",
      "ambari.dispatch.credential.password" : "password",
      "ambari.dispatch.recipients" : "[ambari@repo.ambari.apache.org]",
      "mail.smtp.starttls.enable" : "false"
    }
  }
{code}

This causes the following exception on dispatch:
{noformat}
SEVERE: Service AlertNoticeDispatchService [FAILED] has failed in the RUNNING state.
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: This is not a JSON Array.
	at com.google.gson.Gson.fromJson(Gson.java:806)
	at com.google.gson.Gson.fromJson(Gson.java:761)
	at com.google.gson.Gson.fromJson(Gson.java:710)
	at com.google.gson.Gson.fromJson(Gson.java:682)
	at org.apache.ambari.server.state.services.AlertNoticeDispatchService.buildNotificationFromTarget(AlertNoticeDispatchService.java:392)
	at org.apache.ambari.server.state.services.AlertNoticeDispatchService.runOneIteration(AlertNoticeDispatchService.java:309)
	at com.google.common.util.concurrent.AbstractScheduledService$1$1.run(AbstractScheduledService.java:170)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
	at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
	at java.lang.Thread.run(Thread.java:695)
Caused by: java.lang.IllegalStateException: This is not a JSON Array.
	at com.google.gson.JsonElement.getAsJsonArray(JsonElement.java:100)
	at org.apache.ambari.server.state.services.AlertNoticeDispatchService$AlertTargetPropertyDeserializer.deserialize(AlertNoticeDispatchService.java:599)
	at org.apache.ambari.server.state.services.AlertNoticeDispatchService$AlertTargetPropertyDeserializer.deserialize(AlertNoticeDispatchService.java:1)
	at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58)
	at com.google.gson.Gson.fromJson(Gson.java:795)
	... 15 more
{noformat}

STR:
1) Create an alert target with a list of recipients
2) Trigger an alert
3) Observe the exception and the malformed alert target



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)