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 <yu...@gmail.com> on 2015/01/15 17:28:02 UTC

Review Request 29928: Alert Targets Can No Longer Dispatch

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/29928/
-----------------------------------------------------------

Review request for Ambari, Jonathan Hurley and Nate Cole.


Bugs: AMBARI-9152
    https://issues.apache.org/jira/browse/AMBARI-9152


Repository: ambari


Description
-------

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


Diffs
-----

  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProvider.java e0d9863 
  ambari-server/src/main/java/org/apache/ambari/server/notifications/NotificationDispatcher.java ec4093f 
  ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcher.java 67bd640 
  ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcher.java 0ed919f 
  ambari-server/src/test/java/org/apache/ambari/server/notifications/MockDispatcher.java 94202ca 
  ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcherTest.java 7522286 
  ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcherTest.java ed222ed 
  ambari-server/src/test/java/org/apache/ambari/server/state/services/AlertNoticeDispatchServiceTest.java d5ab08e 

Diff: https://reviews.apache.org/r/29928/diff/


Testing
-------

Results :

Tests run: 2537, Failures: 0, Errors: 0, Skipped: 15


Thanks,

Yurii Shylov


Re: Review Request 29928: Alert Targets Can No Longer Dispatch

Posted by Jonathan Hurley <jh...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/29928/#review68723
-----------------------------------------------------------


Submitted to Git; please close the review.

- Jonathan Hurley


On Jan. 16, 2015, 10:34 a.m., Yurii Shylov wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/29928/
> -----------------------------------------------------------
> 
> (Updated Jan. 16, 2015, 10:34 a.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley and Nate Cole.
> 
> 
> Bugs: AMBARI-9152
>     https://issues.apache.org/jira/browse/AMBARI-9152
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> 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
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProvider.java e0d9863 
>   ambari-server/src/main/java/org/apache/ambari/server/notifications/NotificationDispatcher.java ec4093f 
>   ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcher.java 67bd640 
>   ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcher.java 0ed919f 
>   ambari-server/src/test/java/org/apache/ambari/server/notifications/MockDispatcher.java 94202ca 
>   ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcherTest.java 7522286 
>   ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcherTest.java ed222ed 
>   ambari-server/src/test/java/org/apache/ambari/server/state/services/AlertNoticeDispatchServiceTest.java d5ab08e 
> 
> Diff: https://reviews.apache.org/r/29928/diff/
> 
> 
> Testing
> -------
> 
> Results :
> 
> Tests run: 2537, Failures: 0, Errors: 0, Skipped: 15
> 
> 
> Thanks,
> 
> Yurii Shylov
> 
>


Re: Review Request 29928: Alert Targets Can No Longer Dispatch

Posted by Jonathan Hurley <jh...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/29928/#review68433
-----------------------------------------------------------

Ship it!


Ship It!

- Jonathan Hurley


On Jan. 16, 2015, 10:34 a.m., Yurii Shylov wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/29928/
> -----------------------------------------------------------
> 
> (Updated Jan. 16, 2015, 10:34 a.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley and Nate Cole.
> 
> 
> Bugs: AMBARI-9152
>     https://issues.apache.org/jira/browse/AMBARI-9152
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> 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
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProvider.java e0d9863 
>   ambari-server/src/main/java/org/apache/ambari/server/notifications/NotificationDispatcher.java ec4093f 
>   ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcher.java 67bd640 
>   ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcher.java 0ed919f 
>   ambari-server/src/test/java/org/apache/ambari/server/notifications/MockDispatcher.java 94202ca 
>   ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcherTest.java 7522286 
>   ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcherTest.java ed222ed 
>   ambari-server/src/test/java/org/apache/ambari/server/state/services/AlertNoticeDispatchServiceTest.java d5ab08e 
> 
> Diff: https://reviews.apache.org/r/29928/diff/
> 
> 
> Testing
> -------
> 
> Results :
> 
> Tests run: 2537, Failures: 0, Errors: 0, Skipped: 15
> 
> 
> Thanks,
> 
> Yurii Shylov
> 
>


Re: Review Request 29928: Alert Targets Can No Longer Dispatch

Posted by Nate Cole <nc...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/29928/#review68669
-----------------------------------------------------------

Ship it!


Ship It!

- Nate Cole


On Jan. 16, 2015, 10:34 a.m., Yurii Shylov wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/29928/
> -----------------------------------------------------------
> 
> (Updated Jan. 16, 2015, 10:34 a.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley and Nate Cole.
> 
> 
> Bugs: AMBARI-9152
>     https://issues.apache.org/jira/browse/AMBARI-9152
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> 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
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProvider.java e0d9863 
>   ambari-server/src/main/java/org/apache/ambari/server/notifications/NotificationDispatcher.java ec4093f 
>   ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcher.java 67bd640 
>   ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcher.java 0ed919f 
>   ambari-server/src/test/java/org/apache/ambari/server/notifications/MockDispatcher.java 94202ca 
>   ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcherTest.java 7522286 
>   ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcherTest.java ed222ed 
>   ambari-server/src/test/java/org/apache/ambari/server/state/services/AlertNoticeDispatchServiceTest.java d5ab08e 
> 
> Diff: https://reviews.apache.org/r/29928/diff/
> 
> 
> Testing
> -------
> 
> Results :
> 
> Tests run: 2537, Failures: 0, Errors: 0, Skipped: 15
> 
> 
> Thanks,
> 
> Yurii Shylov
> 
>


Re: Review Request 29928: Alert Targets Can No Longer Dispatch

Posted by Yurii Shylov <yu...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/29928/
-----------------------------------------------------------

(Updated Янв. 16, 2015, 3:34 п.п.)


Review request for Ambari, Jonathan Hurley and Nate Cole.


Changes
-------

Fixed according to comments


Bugs: AMBARI-9152
    https://issues.apache.org/jira/browse/AMBARI-9152


Repository: ambari


Description
-------

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


Diffs (updated)
-----

  ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProvider.java e0d9863 
  ambari-server/src/main/java/org/apache/ambari/server/notifications/NotificationDispatcher.java ec4093f 
  ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcher.java 67bd640 
  ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcher.java 0ed919f 
  ambari-server/src/test/java/org/apache/ambari/server/notifications/MockDispatcher.java 94202ca 
  ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcherTest.java 7522286 
  ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcherTest.java ed222ed 
  ambari-server/src/test/java/org/apache/ambari/server/state/services/AlertNoticeDispatchServiceTest.java d5ab08e 

Diff: https://reviews.apache.org/r/29928/diff/


Testing
-------

Results :

Tests run: 2537, Failures: 0, Errors: 0, Skipped: 15


Thanks,

Yurii Shylov


Re: Review Request 29928: Alert Targets Can No Longer Dispatch

Posted by Jonathan Hurley <jh...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/29928/#review68270
-----------------------------------------------------------


Can we also add 1 new test to AlertTargetResourceProviderTest that provides an array of recipients on create and gets back the array to verify that this issues doesn't happen again?


ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcher.java
<https://reviews.apache.org/r/29928/#comment112443>

    Can we just cast these to strings? I'm worried about a scenario where a username is required but not a password and this would cause a NullPointerException.



ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcher.java
<https://reviews.apache.org/r/29928/#comment112445>

    Missing `break` statements on both.



ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcher.java
<https://reviews.apache.org/r/29928/#comment112446>

    Add `break` for sanity


- Jonathan Hurley


On Jan. 15, 2015, 11:28 a.m., Yurii Shylov wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/29928/
> -----------------------------------------------------------
> 
> (Updated Jan. 15, 2015, 11:28 a.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley and Nate Cole.
> 
> 
> Bugs: AMBARI-9152
>     https://issues.apache.org/jira/browse/AMBARI-9152
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> 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
> 
> 
> Diffs
> -----
> 
>   ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertTargetResourceProvider.java e0d9863 
>   ambari-server/src/main/java/org/apache/ambari/server/notifications/NotificationDispatcher.java ec4093f 
>   ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcher.java 67bd640 
>   ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcher.java 0ed919f 
>   ambari-server/src/test/java/org/apache/ambari/server/notifications/MockDispatcher.java 94202ca 
>   ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/EmailDispatcherTest.java 7522286 
>   ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcherTest.java ed222ed 
>   ambari-server/src/test/java/org/apache/ambari/server/state/services/AlertNoticeDispatchServiceTest.java d5ab08e 
> 
> Diff: https://reviews.apache.org/r/29928/diff/
> 
> 
> Testing
> -------
> 
> Results :
> 
> Tests run: 2537, Failures: 0, Errors: 0, Skipped: 15
> 
> 
> Thanks,
> 
> Yurii Shylov
> 
>