Repository: eagle
Updated Branches:
  refs/heads/master 732a8654c -> 52edcd1b7


[EAGLE-1075] Can't specify configuration options for AlertFilePublisher

<!--
{% comment %}
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to you under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
{% endcomment %}
-->

Be sure to do all of the following to help us incorporate your contribution
quickly and easily:

 - [ ] Make sure the PR title is formatted like:
   `[EAGLE-<Jira issue #>] Description of pull request`
 - [ ] Make sure tests pass via `mvn clean verify`. (Even better, enable
       Travis-CI on your fork and ensure the whole test matrix passes).
 - [ ] Replace `<Jira issue #>` in the title with the actual Jira issue
       number, if there is one.
 - [ ] If this contribution is large, please file an Apache
       [Individual Contributor License 
Agreement](https://www.apache.org/licenses/icla.txt).

---

Author: Colm O hEigeartaigh <[email protected]>

Closes #978 from coheigea/EAGLE-1075.


Project: http://git-wip-us.apache.org/repos/asf/eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/eagle/commit/52edcd1b
Tree: http://git-wip-us.apache.org/repos/asf/eagle/tree/52edcd1b
Diff: http://git-wip-us.apache.org/repos/asf/eagle/diff/52edcd1b

Branch: refs/heads/master
Commit: 52edcd1b7bbb4965957e7942b20379453fc10244
Parents: 732a865
Author: Colm O hEigeartaigh <[email protected]>
Authored: Wed Jan 31 11:34:53 2018 -0800
Committer: Jay Sen <[email protected]>
Committed: Wed Jan 31 11:34:53 2018 -0800

----------------------------------------------------------------------
 .../publisher/impl/AbstractPublishPlugin.java   |  4 ++--
 .../publisher/impl/AlertFilePublisher.java      | 22 +++++++++++++++++---
 2 files changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/eagle/blob/52edcd1b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AbstractPublishPlugin.java
----------------------------------------------------------------------
diff --git 
a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AbstractPublishPlugin.java
 
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AbstractPublishPlugin.java
index 771f736..a04d59a 100644
--- 
a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AbstractPublishPlugin.java
+++ 
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AbstractPublishPlugin.java
@@ -66,7 +66,7 @@ public abstract class AbstractPublishPlugin implements 
AlertPublishPlugin {
                     publishment.getDedupStateField(),
                     dedupCache,
                     publishment.getName());
-                getLogger().info("{} initiliazed extended deduplicator {} with 
properties {} successfully",
+                getLogger().info("{} initialized extended deduplicator {} with 
properties {} successfully",
                     publishment.getName(), spec.getClassName(), 
Joiner.on(",").withKeyValueSeparator(">").join(
                         spec.getProperties() == null ? new HashMap<String, 
String>() : spec.getProperties()));
             } catch (Throwable t) {
@@ -94,7 +94,7 @@ public abstract class AbstractPublishPlugin implements 
AlertPublishPlugin {
             }
             serializer = (IEventSerializer) obj;
         } catch (Exception e) {
-            getLogger().error("initialized failed, use default 
StringEventSerializer, failure message : {}", e.getMessage(), e);
+            getLogger().error("initialization failed, use default 
StringEventSerializer, failure message : {}", e.getMessage(), e);
             serializer = new StringEventSerializer(conf);
         }
     }

http://git-wip-us.apache.org/repos/asf/eagle/blob/52edcd1b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AlertFilePublisher.java
----------------------------------------------------------------------
diff --git 
a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AlertFilePublisher.java
 
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AlertFilePublisher.java
index 375a0da..0b071d7 100644
--- 
a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AlertFilePublisher.java
+++ 
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/impl/AlertFilePublisher.java
@@ -54,13 +54,26 @@ public class AlertFilePublisher extends 
AbstractPublishPlugin implements AlertPu
         int numOfFiles = DEFAULT_FILE_NUMBER;
         if (publishment.getProperties() != null) {
             if 
(publishment.getProperties().containsKey(PublishConstants.FILE_NAME)) {
-                fileName = (String) 
publishment.getProperties().get(PublishConstants.FILE_NAME);
+                String property = (String) 
publishment.getProperties().get(PublishConstants.FILE_NAME);
+                if (property != null && !"".equals(property)) {
+                    fileName = property;
+                }
             }
             if 
(publishment.getProperties().containsKey(PublishConstants.ROTATE_EVERY_KB)) {
-                rotateSize = 
Integer.valueOf(publishment.getProperties().get(PublishConstants.ROTATE_EVERY_KB).toString());
+                Object property = 
publishment.getProperties().get(PublishConstants.ROTATE_EVERY_KB);
+                if (property instanceof Integer) {
+                    rotateSize = (Integer)property;
+                } else if (property instanceof String && 
!"".equals((String)property)) {
+                    rotateSize = Integer.valueOf((String)property);
+                }
             }
             if 
(publishment.getProperties().containsKey(PublishConstants.NUMBER_OF_FILES)) {
-                numOfFiles = 
Integer.valueOf(publishment.getProperties().get(PublishConstants.NUMBER_OF_FILES).toString());
+                Object property = 
publishment.getProperties().get(PublishConstants.NUMBER_OF_FILES);
+                if (property instanceof Integer) {
+                    numOfFiles = (Integer)property;
+                } else if (property instanceof String && 
!"".equals((String)property)) {
+                    numOfFiles = Integer.valueOf((String)property);
+                }
             }
         }
         handler = new FileHandler(fileName, rotateSize * 1024, numOfFiles, 
true);
@@ -75,6 +88,9 @@ public class AlertFilePublisher extends AbstractPublishPlugin 
implements AlertPu
                 .name("File")
                 .type(AlertFilePublisher.class)
                 .description("Local log file publisher")
+                .field(PublishConstants.FILE_NAME)
+                .field(PublishConstants.ROTATE_EVERY_KB)
+                .field(PublishConstants.NUMBER_OF_FILES)
                 .build();
     }
 

Reply via email to