[EAGLE-724] Fix eagle-common checkstyle problem <!-- {% 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 %} --> Fix eagle-common checkstyle problem https://issues.apache.org/jira/browse/EAGLE-724 --- Author: koone <luokun1...@126.com> Closes #610 from koone/EAGLE-724. Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/ca0fae40 Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/ca0fae40 Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/ca0fae40 Branch: refs/heads/master Commit: ca0fae40712fe5bb6962554b5fe17e7ff360763f Parents: 38f2926 Author: koone <luokun1...@126.com> Authored: Fri Nov 4 18:50:43 2016 +0800 Committer: Zhao, Qingwen <qingwz...@apache.org> Committed: Fri Nov 4 18:50:43 2016 +0800 ---------------------------------------------------------------------- eagle-core/eagle-common/pom.xml | 13 + .../java/org/apache/eagle/common/Base64.java | 34 +- .../java/org/apache/eagle/common/ByteUtil.java | 292 +++++----- .../apache/eagle/common/CircularArrayList.java | 64 +-- .../common/CircularArrayListSortedSet.java | 106 ++-- .../org/apache/eagle/common/DateTimeUtil.java | 9 +- .../apache/eagle/common/EagleBase64Wrapper.java | 16 +- .../eagle/common/EagleExceptionWrapper.java | 2 +- .../org/apache/eagle/common/Environment.java | 6 +- .../main/java/org/apache/eagle/common/OS.java | 30 +- .../apache/eagle/common/SerializableUtils.java | 168 +++--- .../eagle/common/agg/AggregateResult.java | 11 +- .../eagle/common/agg/SiddhiAggregator.java | 36 +- .../eagle/common/agg/StreamAggregator.java | 37 +- .../eagle/common/authentication/User.java | 3 +- .../config/AbstractConfigOptionParser.java | 20 +- .../eagle/common/config/ConfigOptionParser.java | 30 +- .../apache/eagle/common/config/EagleConfig.java | 2 +- .../common/config/EagleConfigConstants.java | 2 +- .../eagle/common/config/EagleConfigFactory.java | 17 +- .../eagle/common/config/EagleConfigHelper.java | 8 +- .../common/function/ThrowableConsumer2.java | 4 +- .../common/function/ThrowableFunction.java | 2 - .../eagle/common/metric/AlertContext.java | 119 ++-- .../eagle/common/module/CommonGuiceModule.java | 2 +- .../apache/eagle/common/module/GlobalScope.java | 5 +- .../eagle/common/module/GuiceJUnitRunner.java | 9 +- .../eagle/common/module/ModuleRegistry.java | 26 +- .../eagle/common/module/ModuleRegistryImpl.java | 12 +- .../apache/eagle/common/module/ModuleScope.java | 6 +- .../org/apache/eagle/common/module/Modules.java | 7 +- .../common/service/HadoopAccountService.java | 2 +- .../apache/eagle/common/service/HadoopUser.java | 29 +- .../eagle/common/service/LdapService.java | 134 +++-- .../common/service/POSTResultEntityBase.java | 32 +- .../service/TrustAllSSLSocketFactory.java | 9 +- .../eagle-common/src/main/resources/footer.vm | 6 +- .../eagle-common/src/main/resources/header.vm | 553 ++++++++++--------- .../src/main/resources/templates/tec_alert.vm | 159 +++--- .../org/apache/eagle/common/TestByteUtil.java | 170 +++--- .../eagle/common/TestCircularArrayList.java | 100 ++-- .../common/TestCircularArrayListSortedSet.java | 68 +-- .../apache/eagle/common/TestDateTimeUtil.java | 126 ++--- .../eagle/common/TestEagleBase64Wrapper.java | 32 +- .../eagle/common/TestSerializableUtils.java | 13 +- .../eagle/common/TestSiddhiAggregator.java | 75 +-- .../eagle/common/agg/TestSiddhiAggregator.java | 24 +- .../common/agg/TestSiddhiExternalTimeBatch.java | 77 ++- .../eagle/common/agg/TestStreamAggregator.java | 58 +- .../eagle/common/config/TestEagleConfig.java | 18 +- .../eagle/common/metric/TestAlertContext.java | 2 +- .../eagle/common/module/ModuleRegistryTest.java | 15 +- .../eagle-common/src/test/resources/footer.vm | 6 +- .../eagle-common/src/test/resources/header.vm | 545 +++++++++--------- .../src/test/resources/log4j.properties | 4 - .../src/test/resources/templates/tec_alert.vm | 159 +++--- .../resources/templates/test_anomaly_alert.vm | 198 +++---- 57 files changed, 1888 insertions(+), 1824 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/pom.xml b/eagle-core/eagle-common/pom.xml index 639d4d5..26b8f8f 100644 --- a/eagle-core/eagle-common/pom.xml +++ b/eagle-core/eagle-common/pom.xml @@ -98,5 +98,18 @@ <version>${guice.version}</version> </dependency> </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <failOnViolation>true</failOnViolation> + <failsOnError>true</failsOnError> + </configuration> + </plugin> + </plugins> + </build> </project> http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/Base64.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/Base64.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/Base64.java index aec84a3..42f028e 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/Base64.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/Base64.java @@ -14,31 +14,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * - */ package org.apache.eagle.common; -import java.io.UnsupportedEncodingException; - import javax.xml.bind.DatatypeConverter; +import java.io.UnsupportedEncodingException; public class Base64 { - public static String decode(String salted) { - try { - return new String(DatatypeConverter.parseBase64Binary(salted), "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException("UTF-8 must be supported", e); - } - } + public static String decode(String salted) { + try { + return new String(DatatypeConverter.parseBase64Binary(salted), "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("UTF-8 must be supported", e); + } + } - public static String encode(String plain) { - try { - return DatatypeConverter.printBase64Binary(plain.getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException("UTF-8 must be supported", e); - } - } + public static String encode(String plain) { + try { + return DatatypeConverter.printBase64Binary(plain.getBytes("UTF-8")); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("UTF-8 must be supported", e); + } + } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/ByteUtil.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/ByteUtil.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/ByteUtil.java index c1d4976..909279c 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/ByteUtil.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/ByteUtil.java @@ -17,135 +17,135 @@ package org.apache.eagle.common; public class ByteUtil { - - public static double bytesToDouble(byte[] bytes, int offset){ - return Double.longBitsToDouble(bytesToLong(bytes, offset)); - } - - public static double bytesToDouble(byte[] bytes){ - return Double.longBitsToDouble(bytesToLong(bytes)); - } - - public static void doubleToBytes(double v, byte[] bytes){ - doubleToBytes(v, bytes, 0); - } - - public static void doubleToBytes(double v, byte[] bytes, int offset){ - longToBytes(Double.doubleToLongBits(v), bytes, offset); - } - - public static byte[] doubleToBytes(double v){ - return longToBytes(Double.doubleToLongBits(v)); - } - - public static long bytesToLong(byte[] bytes){ - return bytesToLong(bytes, 0); - } - - public static long bytesToLong(byte[] bytes, int offset){ - long value = 0; - for(int i=0; i<8; i++){ - value <<= 8; - value |= (bytes[i+offset] & 0xFF); - } - return value; - } - - public static void longToBytes(long v, byte[] bytes){ - longToBytes(v, bytes, 0); - } - - public static void longToBytes(long v, byte[] bytes, int offset){ - long tmp = v; - for(int i=0; i<8; i++){ - bytes[offset + 7 - i] = (byte)(tmp & 0xFF); - tmp >>= 8; - } - } - - public static byte[] longToBytes(long v){ - long tmp = v; - byte[] b = new byte[8]; - for(int i=0; i<8; i++){ - b[7-i] = (byte)(tmp & 0xFF); - tmp >>= 8; - } - return b; - } - - public static int bytesToInt(byte[] bytes){ - return bytesToInt(bytes, 0); - } - - public static int bytesToInt(byte[] bytes, int offset){ - int value = 0; - for(int i=0; i<4; i++){ - value <<= 8; - value |= (bytes[i+offset] & 0xFF); - } - return value; - } - - public static void intToBytes(int v, byte[] bytes){ - intToBytes(v, bytes, 0); - } - - public static void intToBytes(int v, byte[] bytes, int offset){ - int tmp = v; - for(int i=0; i<4; i++){ - bytes[offset + 3 - i] = (byte)(tmp & 0xFF); - tmp >>= 8; - } - } - - public static byte[] intToBytes(int v){ - int tmp = v; - byte[] b = new byte[4]; - for(int i=0; i<4; i++){ - b[3-i] = (byte)(tmp & 0xFF); - tmp >>= 8; - } - return b; - } - - ////// - - public static short bytesToShort(byte[] bytes){ - return bytesToShort(bytes, 0); - } - - public static short bytesToShort(byte[] bytes, int offset){ - short value = 0; - for(int i=0; i < 2; i++){ - value <<= 8; - value |= (bytes[i+offset] & 0xFF); - } - return value; - } - - public static void shortToBytes(short v, byte[] bytes){ - shortToBytes(v, bytes, 0); - } - - public static void shortToBytes(short v, byte[] bytes, int offset){ - int tmp = v; - for(int i=0; i < 2; i++){ - bytes[offset + 1 - i] = (byte)(tmp & 0xFF); - tmp >>= 8; - } - } - - public static byte[] shortToBytes(short v){ - int tmp = v; - byte[] b = new byte[2]; - for(int i=0; i<2; i++){ - b[1-i] = (byte)(tmp & 0xFF); - tmp >>= 8; - } - return b; - } - - public static byte[] concat(byte[]... arrays) { + + public static double bytesToDouble(byte[] bytes, int offset) { + return Double.longBitsToDouble(bytesToLong(bytes, offset)); + } + + public static double bytesToDouble(byte[] bytes) { + return Double.longBitsToDouble(bytesToLong(bytes)); + } + + public static void doubleToBytes(double v, byte[] bytes) { + doubleToBytes(v, bytes, 0); + } + + public static void doubleToBytes(double v, byte[] bytes, int offset) { + longToBytes(Double.doubleToLongBits(v), bytes, offset); + } + + public static byte[] doubleToBytes(double v) { + return longToBytes(Double.doubleToLongBits(v)); + } + + public static long bytesToLong(byte[] bytes) { + return bytesToLong(bytes, 0); + } + + public static long bytesToLong(byte[] bytes, int offset) { + long value = 0; + for (int i = 0; i < 8; i++) { + value <<= 8; + value |= (bytes[i + offset] & 0xFF); + } + return value; + } + + public static void longToBytes(long v, byte[] bytes) { + longToBytes(v, bytes, 0); + } + + public static void longToBytes(long v, byte[] bytes, int offset) { + long tmp = v; + for (int i = 0; i < 8; i++) { + bytes[offset + 7 - i] = (byte) (tmp & 0xFF); + tmp >>= 8; + } + } + + public static byte[] longToBytes(long v) { + long tmp = v; + byte[] b = new byte[8]; + for (int i = 0; i < 8; i++) { + b[7 - i] = (byte) (tmp & 0xFF); + tmp >>= 8; + } + return b; + } + + public static int bytesToInt(byte[] bytes) { + return bytesToInt(bytes, 0); + } + + public static int bytesToInt(byte[] bytes, int offset) { + int value = 0; + for (int i = 0; i < 4; i++) { + value <<= 8; + value |= (bytes[i + offset] & 0xFF); + } + return value; + } + + public static void intToBytes(int v, byte[] bytes) { + intToBytes(v, bytes, 0); + } + + public static void intToBytes(int v, byte[] bytes, int offset) { + int tmp = v; + for (int i = 0; i < 4; i++) { + bytes[offset + 3 - i] = (byte) (tmp & 0xFF); + tmp >>= 8; + } + } + + public static byte[] intToBytes(int v) { + int tmp = v; + byte[] b = new byte[4]; + for (int i = 0; i < 4; i++) { + b[3 - i] = (byte) (tmp & 0xFF); + tmp >>= 8; + } + return b; + } + + ////// + + public static short bytesToShort(byte[] bytes) { + return bytesToShort(bytes, 0); + } + + public static short bytesToShort(byte[] bytes, int offset) { + short value = 0; + for (int i = 0; i < 2; i++) { + value <<= 8; + value |= (bytes[i + offset] & 0xFF); + } + return value; + } + + public static void shortToBytes(short v, byte[] bytes) { + shortToBytes(v, bytes, 0); + } + + public static void shortToBytes(short v, byte[] bytes, int offset) { + int tmp = v; + for (int i = 0; i < 2; i++) { + bytes[offset + 1 - i] = (byte) (tmp & 0xFF); + tmp >>= 8; + } + } + + public static byte[] shortToBytes(short v) { + int tmp = v; + byte[] b = new byte[2]; + for (int i = 0; i < 2; i++) { + b[1 - i] = (byte) (tmp & 0xFF); + tmp >>= 8; + } + return b; + } + + public static byte[] concat(byte[]... arrays) { int length = 0; for (byte[] array : arrays) { length += array.length; @@ -158,21 +158,21 @@ public class ByteUtil { } return result; } - -// public static void main(String[] args){ -// int a = "ThreadName".hashCode(); -// byte[] b = intToBytes(a); -// byte[] c = intToBytes(1676687583); -// String s = new String(b); -// System.out.println(s); - -// byte[] d = intToBytes(8652353); -// System.out.println(bytesToInt(d)); - -// byte[] e = longToBytes(12131513513l); -// System.out.println(bytesToLong(e)); -// if(12131513513l == bytesToLong(e)){ -// System.out.println("yes"); -// } -// } + + public static void main(String[] args) { + int a = "ThreadName".hashCode(); + byte[] b = intToBytes(a); + byte[] c = intToBytes(1676687583); + String s = new String(b); + System.out.println(s); + + byte[] d = intToBytes(8652353); + System.out.println(bytesToInt(d)); + + byte[] e = longToBytes(12131513513L); + System.out.println(bytesToLong(e)); + if (12131513513L == bytesToLong(e)) { + System.out.println("yes"); + } + } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayList.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayList.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayList.java index 49695e5..ccb7b65 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayList.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayList.java @@ -20,45 +20,45 @@ import java.util.AbstractList; import java.util.RandomAccess; /** - * Circular array implementation + * Circular array implementation. * * @param <E> */ public class CircularArrayList<E> extends AbstractList<E> implements RandomAccess { - + private final E[] buf; // a List implementing RandomAccess private int head = 0; private int tail = 0; private boolean full = false; - + public CircularArrayList(E[] array) { buf = array; full = (buf.length == 0); } - + public int capacity() { return buf.length; } - + public int head() { - return head; + return head; } - + public int tail() { - return tail; + return tail; } - + public boolean isFull() { - return full; + return full; } - + @Override public void clear() { head = 0; tail = 0; full = false; for (int i = 0; i < buf.length; ++i) { - buf[i] = null; + buf[i] = null; } } @@ -69,7 +69,7 @@ public class CircularArrayList<E> extends AbstractList<E> implements RandomAcces } return m; } - + // This method is O(n) but will never be called if the // CircularArrayList is used in its typical/intended role. private void shiftBlock(int startIndex, int endIndex) { @@ -78,25 +78,25 @@ public class CircularArrayList<E> extends AbstractList<E> implements RandomAcces set(i + 1, get(i)); } } - + public int find(E e) { - final int size = size(); - for (int i = 0; i < size; ++i) { - if (e.equals(get(i))) { - return i; - } - } - return -1; + final int size = size(); + for (int i = 0; i < size; ++i) { + if (e.equals(get(i))) { + return i; + } + } + return -1; } - + @Override public int size() { - if (full) { - return buf.length; - } + if (full) { + return buf.length; + } return tail - head + (tail < head ? buf.length : 0); } - + @Override public E get(int i) { if (i < 0 || i >= size()) { @@ -104,21 +104,21 @@ public class CircularArrayList<E> extends AbstractList<E> implements RandomAcces } return buf[wrapIndex(head + i)]; } - + @Override public E set(int i, E e) { if (i < 0 || i >= size()) { throw new IndexOutOfBoundsException(); } - return buf[wrapIndex(head + i)] = e; + return buf[wrapIndex(head + i)] = e; } - + @Override public void add(int i, E e) { int s = size(); if (s == buf.length) { throw new IllegalStateException("Cannot add element." - + " CircularArrayList is filled to capacity."); + + " CircularArrayList is filled to capacity."); } full = (s + 1 == buf.length); if (i < 0 || i > s) { @@ -130,7 +130,7 @@ public class CircularArrayList<E> extends AbstractList<E> implements RandomAcces } set(i, e); } - + @Override public E remove(int i) { int s = size(); @@ -141,7 +141,7 @@ public class CircularArrayList<E> extends AbstractList<E> implements RandomAcces if (i > 0) { shiftBlock(0, i); } - buf[head] = null; + buf[head] = null; head = wrapIndex(head + 1); full = false; return e; http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayListSortedSet.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayListSortedSet.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayListSortedSet.java index ef47624..0dc6ab3 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayListSortedSet.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayListSortedSet.java @@ -22,85 +22,85 @@ import java.util.List; public class CircularArrayListSortedSet<E> { - private final CircularArrayList<E> list; + private final CircularArrayList<E> list; private final Comparator<? super E> comparator; - public CircularArrayListSortedSet(E[] array) { - this.list = new CircularArrayList<E>(array); - this.comparator = null; - } - - public CircularArrayListSortedSet(E[] array, Comparator<? super E> comparator) { - this.list = new CircularArrayList<E>(array); - this.comparator = comparator; - } - + public CircularArrayListSortedSet(E[] array) { + this.list = new CircularArrayList<E>(array); + this.comparator = null; + } + + public CircularArrayListSortedSet(E[] array, Comparator<? super E> comparator) { + this.list = new CircularArrayList<E>(array); + this.comparator = comparator; + } + public int capacity() { return list.capacity(); } - + public int head() { - return list.head(); + return list.head(); } - + public int tail() { - return list.tail(); + return list.tail(); } - + public boolean isFull() { - return list.isFull(); + return list.isFull(); } - + public void clear() { - list.clear(); + list.clear(); } - + public int size() { - return list.size(); + return list.size(); } - + public E get(int i) { return list.get(i); } - + @SuppressWarnings("unchecked") - public int binarySearch(E e) { - if (comparator != null) { - return Collections.binarySearch(list, e, comparator); - } else { - return Collections.binarySearch((List<? extends Comparable<? super E>>)list, e); - } + public int binarySearch(E e) { + if (comparator != null) { + return Collections.binarySearch(list, e, comparator); + } else { + return Collections.binarySearch((List<? extends Comparable<? super E>>) list, e); + } } - + public int replace(E e) { - int index = binarySearch(e); - if (index < 0) { - return -1; - } - list.set(index, e); - return index; + int index = binarySearch(e); + if (index < 0) { + return -1; + } + list.set(index, e); + return index; } - + public int insert(E e) { - int index = binarySearch(e); - if (index > 0) { - return -1; - } - index = 0 - index - 1; - list.add(index, e); - return index; + int index = binarySearch(e); + if (index > 0) { + return -1; + } + index = 0 - index - 1; + list.add(index, e); + return index; } - + public E remove(int i) { - return list.remove(i); + return list.remove(i); } - + public int remove(E e) { - final int index = binarySearch(e); - if (index > 0) { - list.remove(index); - return index; - } - return -1; + final int index = binarySearch(e); + if (index > 0) { + list.remove(index); + return index; + } + return -1; } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/DateTimeUtil.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/DateTimeUtil.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/DateTimeUtil.java index c21d2bc..74b733d 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/DateTimeUtil.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/DateTimeUtil.java @@ -36,6 +36,7 @@ public class DateTimeUtil { public static final long ONEHOUR = 1L * 60L * 60L * 1000L; public static final long ONEDAY = 24L * 60L * 60L * 1000L; private static TimeZone CURRENT_TIME_ZONE; + static { Config config = ConfigFactory.load(); CURRENT_TIME_ZONE = TimeZone.getTimeZone((config.hasPath(EagleConfigConstants.EAGLE_TIME_ZONE) @@ -151,10 +152,10 @@ public class DateTimeUtil { //For mapr //exp: 2015-06-06T10:44:22.800Z - public static long maprhumanDateToMilliseconds(String date) throws ParseException{ - date = date.replace('T',' '); - date = date.replace('Z',' '); - date = date.replace('.',','); + public static long maprhumanDateToMilliseconds(String date) throws ParseException { + date = date.replace('T', ' '); + date = date.replace('Z', ' '); + date = date.replace('.', ','); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS "); sdf.setTimeZone(CURRENT_TIME_ZONE); Date d = sdf.parse(date); http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/EagleBase64Wrapper.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/EagleBase64Wrapper.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/EagleBase64Wrapper.java index e31ef99..65f858c 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/EagleBase64Wrapper.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/EagleBase64Wrapper.java @@ -19,14 +19,14 @@ package org.apache.eagle.common; import org.apache.commons.net.util.Base64; /** - * wrap base64 encoding and decoding, so reduce the confuse of using many Base64 methods. + * wrap base64 encoding and decoding, so reduce the confuse of using many Base64 methods. */ public class EagleBase64Wrapper { - public static String encodeByteArray2URLSafeString(byte[] bytes){ - return Base64.encodeBase64URLSafeString(bytes); - } - - public static byte[] decode(String input){ - return Base64.decodeBase64(input); - } + public static String encodeByteArray2URLSafeString(byte[] bytes) { + return Base64.encodeBase64URLSafeString(bytes); + } + + public static byte[] decode(String input) { + return Base64.decodeBase64(input); + } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/EagleExceptionWrapper.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/EagleExceptionWrapper.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/EagleExceptionWrapper.java index 4ab2b78..74bbe2c 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/EagleExceptionWrapper.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/EagleExceptionWrapper.java @@ -25,7 +25,7 @@ public class EagleExceptionWrapper { } public static String wrap(Exception ex, int maxdepth) { - if(ex == null) { + if (ex == null) { return null; } int d = maxdepth; http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/Environment.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/Environment.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/Environment.java index dd69ed5..2350a44 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/Environment.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/Environment.java @@ -17,7 +17,7 @@ package org.apache.eagle.common; public enum Environment { - dev, - test, - prod, + dev, + test, + prod, } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/OS.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/OS.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/OS.java index 05e8db1..029f298 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/OS.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/OS.java @@ -18,24 +18,24 @@ package org.apache.eagle.common; public class OS { - private final static String os = System.getProperty("os.name") - .toLowerCase(); + private static final String os = System.getProperty("os.name") + .toLowerCase(); - public static boolean isWindows() { - return (os.indexOf("win") >= 0); - } + public static boolean isWindows() { + return (os.indexOf("win") >= 0); + } - public static boolean isMac() { - return (os.indexOf("mac") >= 0); - } + public static boolean isMac() { + return (os.indexOf("mac") >= 0); + } - public static boolean isUnix() { - return (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0 || os - .indexOf("aix") > 0); - } + public static boolean isUnix() { + return (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0 || os + .indexOf("aix") > 0); + } - public static boolean isSolaris() { - return (os.indexOf("sunos") >= 0); - } + public static boolean isSolaris() { + return (os.indexOf("sunos") >= 0); + } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/SerializableUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/SerializableUtils.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/SerializableUtils.java index c5823ea..ee1c330 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/SerializableUtils.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/SerializableUtils.java @@ -27,100 +27,100 @@ import java.io.*; /** * Utilities for working with Serializables. * - * Derived from "com.google.cloud.dataflow.sdk.util.SerializableUtils": + * <p>Derived from "com.google.cloud.dataflow.sdk.util.SerializableUtils": * https://github.com/apache/incubator-beam/blob/master/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/util/SerializableUtils.java */ public class SerializableUtils { - /** - * Serializes the argument into an array of bytes, and returns it. - * - * @throws IllegalArgumentException if there are errors when serializing - */ - public static byte[] serializeToCompressedByteArray(Object value) { - try { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - try (ObjectOutputStream oos = new ObjectOutputStream(new SnappyOutputStream(buffer))) { - oos.writeObject(value); - } - return buffer.toByteArray(); - } catch (IOException exn) { - throw new IllegalArgumentException( - "unable to serialize " + value, - exn); + /** + * Serializes the argument into an array of bytes, and returns it. + * + * @throws IllegalArgumentException if there are errors when serializing + */ + public static byte[] serializeToCompressedByteArray(Object value) { + try { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + try (ObjectOutputStream oos = new ObjectOutputStream(new SnappyOutputStream(buffer))) { + oos.writeObject(value); + } + return buffer.toByteArray(); + } catch (IOException exn) { + throw new IllegalArgumentException( + "unable to serialize " + value, + exn); + } } - } - /** - * Serializes the argument into an array of bytes, and returns it. - * - * @throws IllegalArgumentException if there are errors when serializing - */ - public static byte[] serializeToByteArray(Object value) { - try { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - try (ObjectOutputStream oos = new ObjectOutputStream(buffer)) { - oos.writeObject(value); - } - return buffer.toByteArray(); - } catch (IOException exn) { - throw new IllegalArgumentException("unable to serialize " + value, exn); + /** + * Serializes the argument into an array of bytes, and returns it. + * + * @throws IllegalArgumentException if there are errors when serializing + */ + public static byte[] serializeToByteArray(Object value) { + try { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + try (ObjectOutputStream oos = new ObjectOutputStream(buffer)) { + oos.writeObject(value); + } + return buffer.toByteArray(); + } catch (IOException exn) { + throw new IllegalArgumentException("unable to serialize " + value, exn); + } } - } - /** - * Deserializes an object from the given array of bytes, e.g., as - * serialized using {@link #serializeToCompressedByteArray}, and returns it. - * - * @throws IllegalArgumentException if there are errors when - * deserializing, using the provided description to identify what - * was being deserialized - */ - public static Object deserializeFromByteArray(byte[] encodedValue, - String description) { - try { - try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(encodedValue))) { - return ois.readObject(); - } - } catch (IOException | ClassNotFoundException exn) { - throw new IllegalArgumentException( - "unable to deserialize " + description, - exn); + /** + * Deserializes an object from the given array of bytes, e.g., as + * serialized using {@link #serializeToCompressedByteArray}, and returns it. + * + * @throws IllegalArgumentException if there are errors when + * deserializing, using the provided description to identify what + * was being deserialized + */ + public static Object deserializeFromByteArray(byte[] encodedValue, + String description) { + try { + try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(encodedValue))) { + return ois.readObject(); + } + } catch (IOException | ClassNotFoundException exn) { + throw new IllegalArgumentException( + "unable to deserialize " + description, + exn); + } } - } - /** - * Deserializes an object from the given array of bytes, e.g., as - * serialized using {@link #serializeToCompressedByteArray}, and returns it. - * - * @throws IllegalArgumentException if there are errors when - * deserializing, using the provided description to identify what - * was being deserialized - */ - public static Object deserializeFromCompressedByteArray(byte[] encodedValue, - String description) { - try { - try (ObjectInputStream ois = new ObjectInputStream( - new SnappyInputStream(new ByteArrayInputStream(encodedValue)))) { - return ois.readObject(); - } - } catch (IOException | ClassNotFoundException exn) { - throw new IllegalArgumentException( - "unable to deserialize " + description, - exn); + /** + * Deserializes an object from the given array of bytes, e.g., as + * serialized using {@link #serializeToCompressedByteArray}, and returns it. + * + * @throws IllegalArgumentException if there are errors when + * deserializing, using the provided description to identify what + * was being deserialized + */ + public static Object deserializeFromCompressedByteArray(byte[] encodedValue, + String description) { + try { + try (ObjectInputStream ois = new ObjectInputStream( + new SnappyInputStream(new ByteArrayInputStream(encodedValue)))) { + return ois.readObject(); + } + } catch (IOException | ClassNotFoundException exn) { + throw new IllegalArgumentException( + "unable to deserialize " + description, + exn); + } } - } - public static <T extends Serializable> T ensureSerializable(T value) { - @SuppressWarnings("unchecked") - T copy = (T) deserializeFromCompressedByteArray(serializeToCompressedByteArray(value), - value.toString()); - return copy; - } + public static <T extends Serializable> T ensureSerializable(T value) { + @SuppressWarnings("unchecked") + T copy = (T) deserializeFromCompressedByteArray(serializeToCompressedByteArray(value), + value.toString()); + return copy; + } - public static <T extends Serializable> T clone(T value) { - @SuppressWarnings("unchecked") - T copy = (T) deserializeFromCompressedByteArray(serializeToCompressedByteArray(value), - value.toString()); - return copy; - } + public static <T extends Serializable> T clone(T value) { + @SuppressWarnings("unchecked") + T copy = (T) deserializeFromCompressedByteArray(serializeToCompressedByteArray(value), + value.toString()); + return copy; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/AggregateResult.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/AggregateResult.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/AggregateResult.java index bb0ac5d..5ce644f 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/AggregateResult.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/AggregateResult.java @@ -30,25 +30,26 @@ public class AggregateResult { private Object[] data; private Map<String, Integer> colIndices; private List<String> colNames; - public AggregateResult(Object[] data, Map<String, Integer> colIndices, List<String> colNames){ + + public AggregateResult(Object[] data, Map<String, Integer> colIndices, List<String> colNames) { this.data = data; this.colIndices = colIndices; this.colNames = colNames; } - public Object get(int index){ + public Object get(int index) { return data[index]; } - public Object get(String fieldName){ + public Object get(String fieldName) { int index = colIndices.get(fieldName); return get(index); } - public String toString(){ + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); - for(int i=0; i<data.length; i++){ + for (int i = 0; i < data.length; i++) { sb.append(colNames.get(i)); sb.append("="); sb.append(data[i]); http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/SiddhiAggregator.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/SiddhiAggregator.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/SiddhiAggregator.java index d0b3987..cbe0ff9 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/SiddhiAggregator.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/SiddhiAggregator.java @@ -37,18 +37,19 @@ public class SiddhiAggregator { private TimeBatchWindowSpec spec; private StreamDefinition sd; private InputHandler input; - public SiddhiAggregator(TimeBatchWindowSpec spec, StreamDefinition sd, final AggregateHandler handler){ + + public SiddhiAggregator(TimeBatchWindowSpec spec, StreamDefinition sd, final AggregateHandler handler) { this.spec = spec; this.sd = sd; Map<String, Integer> colIndices = new HashMap<>(); List<String> colNames = new ArrayList<>(); int i = 0; - for(String col : spec.groupby.cols){ + for (String col : spec.groupby.cols) { colIndices.put(col, i++); colNames.add(col); } - for(Agg agg : spec.aggs){ + for (Agg agg : spec.aggs) { colIndices.put(agg.alias, i++); colNames.add(agg.alias); } @@ -63,7 +64,7 @@ public class SiddhiAggregator { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { List<AggregateResult> rows = new ArrayList<AggregateResult>(); - for(Event e : inEvents) { + for (Event e : inEvents) { AggregateResult result = new AggregateResult(e.getData(), colIndices, colNames); rows.add(result); } @@ -73,28 +74,29 @@ public class SiddhiAggregator { runtime.start(); } - public void add(Object[] data) throws Exception{ + public void add(Object[] data) throws Exception { input.send(data); } /** * example siddhi query - * String ql = "define stream s (host string, timestamp long, metric string, site string, value double);" + - "@info(name='query') " + - " from s[metric == \"missingblocks\"]#window.externalTimeBatch(timestamp, 1 min, 0) select host, count(value) as avg group by host insert into tmp; "; + * String ql = "define stream s (host string, timestamp long, metric string, site string, value double);" + + * "@info(name='query') " + + * " from s[metric == \"missingblocks\"]#window.externalTimeBatch(timestamp, 1 min, 0) select host, count(value) as avg group by host insert into tmp; "; + * * @return */ - private String buildSiddhiAggQuery(){ + private String buildSiddhiAggQuery() { StringBuilder sb = new StringBuilder(); sb.append("define stream s("); - if(sd.columns == null || sd.columns.size() == 0) { + if (sd.columns == null || sd.columns.size() == 0) { throw new IllegalStateException("input stream should contains at least one column"); } - for(Column col : sd.columns){ + for (Column col : sd.columns) { appendColumnDef(sb, col); sb.append(","); } - sb.deleteCharAt(sb.length()-1); + sb.deleteCharAt(sb.length() - 1); sb.append(");"); sb.append(" @info(name='query') "); @@ -108,14 +110,14 @@ public class SiddhiAggregator { sb.append(spec.start); sb.append(")"); sb.append(" select "); - for(String gbField : spec.groupby.cols){ + for (String gbField : spec.groupby.cols) { sb.append(gbField); sb.append(","); } - if(spec.aggs == null){ + if (spec.aggs == null) { throw new IllegalStateException("at least one aggregate function should be present"); } - for(Agg agg : spec.aggs){ + for (Agg agg : spec.aggs) { sb.append(agg.function); sb.append("("); sb.append(agg.field); @@ -125,7 +127,7 @@ public class SiddhiAggregator { } sb.deleteCharAt(sb.length() - 1); sb.append(" group by "); - for(String gbField : spec.groupby.cols){ + for (String gbField : spec.groupby.cols) { sb.append(gbField); sb.append(","); } @@ -135,7 +137,7 @@ public class SiddhiAggregator { return sb.toString(); } - private void appendColumnDef(StringBuilder sb, Column col){ + private void appendColumnDef(StringBuilder sb, Column col) { sb.append(col.name); sb.append(" "); sb.append(col.type); http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/StreamAggregator.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/StreamAggregator.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/StreamAggregator.java index 37802fd..2977be3 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/StreamAggregator.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/agg/StreamAggregator.java @@ -27,10 +27,11 @@ import java.util.List; * Since 8/4/16. */ public class StreamAggregator { - public static StreamAggregatorBuilder builder(){ + public static StreamAggregatorBuilder builder() { return new StreamAggregatorBuilder(); } - public static class StreamAggregatorBuilder{ + + public static class StreamAggregatorBuilder { private Groupby gb = new Groupby(); private String windowDuration; private long start; @@ -39,28 +40,34 @@ public class StreamAggregator { private String timestampColumn; private StreamDefinition sd = new StreamDefinition(); private AggregateHandler handler; - public StreamAggregatorBuilder groupby(String ... gbFields){ + + public StreamAggregatorBuilder groupby(String... gbFields) { gb.cols = Arrays.asList(gbFields); return this; } - public StreamAggregatorBuilder window(String windowDuration){ + + public StreamAggregatorBuilder window(String windowDuration) { window(windowDuration, 0); return this; } - public StreamAggregatorBuilder window(String windowDuration, long start){ + + public StreamAggregatorBuilder window(String windowDuration, long start) { this.windowDuration = windowDuration; this.start = start; return this; } - public StreamAggregatorBuilder timeColumn(String timestampColumn){ + + public StreamAggregatorBuilder timeColumn(String timestampColumn) { this.timestampColumn = timestampColumn; return this; } - public StreamAggregatorBuilder filter(String filter){ + + public StreamAggregatorBuilder filter(String filter) { this.filter = filter; return this; } - public StreamAggregatorBuilder agg(String function, String field, String alias){ + + public StreamAggregatorBuilder agg(String function, String field, String alias) { Agg agg = new Agg(); agg.function = function; agg.field = field; @@ -68,25 +75,29 @@ public class StreamAggregator { aggs.add(agg); return this; } - public StreamAggregatorBuilder columnDef(String colName, String colType){ + + public StreamAggregatorBuilder columnDef(String colName, String colType) { Column col = new Column(); col.name = colName; col.type = colType; - if(sd.columns == null){ + if (sd.columns == null) { sd.columns = new ArrayList<>(); } sd.columns.add(col); return this; } - public StreamAggregatorBuilder streamDef(StreamDefinition sd){ + + public StreamAggregatorBuilder streamDef(StreamDefinition sd) { this.sd = sd; return this; } - public StreamAggregatorBuilder aggregateHandler(AggregateHandler handler){ + + public StreamAggregatorBuilder aggregateHandler(AggregateHandler handler) { this.handler = handler; return this; } - public SiddhiAggregator build(){ + + public SiddhiAggregator build() { TimeBatchWindowSpec spec = new TimeBatchWindowSpec(); spec.aggs = aggs; spec.filter = filter; http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/authentication/User.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/authentication/User.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/authentication/User.java index 85388cd..e967624 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/authentication/User.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/authentication/User.java @@ -24,7 +24,8 @@ public class User implements Principal, Serializable { private String username = "Unauthenticated"; private Set<String> roles = null; - public User() {} + public User() { + } public User(String username) { this.username = username; http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/AbstractConfigOptionParser.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/AbstractConfigOptionParser.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/AbstractConfigOptionParser.java index a8a4b69..b2845a4 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/AbstractConfigOptionParser.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/AbstractConfigOptionParser.java @@ -25,47 +25,47 @@ import org.apache.commons.cli.Parser; import java.util.Map; -/** - * @since 8/22/15 - */ + public abstract class AbstractConfigOptionParser { // private final Options options; private final Parser parser; - public AbstractConfigOptionParser(){ + public AbstractConfigOptionParser() { parser = parser(); //options = options(); } /** + * Get parser. * @return Parser */ protected abstract Parser parser(); /** + * Get options. * @return Options */ protected abstract Options options(); - public abstract Map<String,String> parseConfig(String[] arguments) throws ParseException; + public abstract Map<String, String> parseConfig(String[] arguments) throws ParseException; /** - * Load config as system properties + * Load config as system properties. * * @param arguments command line arguments * @throws ParseException */ public Config load(String[] arguments) throws ParseException { - Map<String,String> configProps = parseConfig(arguments); - for(Map.Entry<String,String> entry:configProps.entrySet()){ - System.setProperty(entry.getKey(),entry.getValue()); + Map<String, String> configProps = parseConfig(arguments); + for (Map.Entry<String, String> entry : configProps.entrySet()) { + System.setProperty(entry.getKey(), entry.getValue()); } System.setProperty("config.trace", "loads"); return ConfigFactory.load(); } public CommandLine parse(String[] arguments) throws ParseException { - return this.parser.parse(this.options(),arguments); + return this.parser.parse(this.options(), arguments); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/ConfigOptionParser.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/ConfigOptionParser.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/ConfigOptionParser.java index 3cb42ca..6c75a29 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/ConfigOptionParser.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/ConfigOptionParser.java @@ -23,7 +23,7 @@ import java.util.Map; public class ConfigOptionParser extends AbstractConfigOptionParser { - private final static String CONFIG_OPT_FLAG = "D"; + private static final String CONFIG_OPT_FLAG = "D"; @Override protected Parser parser() { @@ -38,27 +38,27 @@ public class ConfigOptionParser extends AbstractConfigOptionParser { } @Override - public Map<String,String> parseConfig(String[] arguments) throws ParseException { + public Map<String, String> parseConfig(String[] arguments) throws ParseException { CommandLine cmd = parse(arguments); return parseCommand(cmd); } - protected Map<String,String> parseCommand(CommandLine cmd) throws ParseException { - Map<String,String> result = new HashMap<>(); - if(cmd.hasOption(CONFIG_OPT_FLAG)){ + protected Map<String, String> parseCommand(CommandLine cmd) throws ParseException { + Map<String, String> result = new HashMap<>(); + if (cmd.hasOption(CONFIG_OPT_FLAG)) { String[] values = cmd.getOptionValues(CONFIG_OPT_FLAG); - for(String value:values){ + for (String value : values) { int eqIndex = value.indexOf("="); - if(eqIndex>0 && eqIndex<value.length()){ - String k = value.substring(0,eqIndex); - String v = value.substring(eqIndex+1,value.length()); - if(result.containsKey(k)){ - throw new ParseException("Duplicated "+CONFIG_OPT_FLAG+" "+value); - }else{ - result.put(k,v); + if (eqIndex > 0 && eqIndex < value.length()) { + String k = value.substring(0, eqIndex); + String v = value.substring(eqIndex + 1, value.length()); + if (result.containsKey(k)) { + throw new ParseException("Duplicated " + CONFIG_OPT_FLAG + " " + value); + } else { + result.put(k, v); } - }else{ - throw new ParseException("Invalid format: -"+CONFIG_OPT_FLAG+" "+value+", required: -"+CONFIG_OPT_FLAG+" key=value"); + } else { + throw new ParseException("Invalid format: -" + CONFIG_OPT_FLAG + " " + value + ", required: -" + CONFIG_OPT_FLAG + " key=value"); } } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java index 8b4b959..f85d161 100755 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java @@ -16,9 +16,9 @@ */ package org.apache.eagle.common.config; +import com.typesafe.config.Config; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.client.HTableInterface; -import com.typesafe.config.Config; import java.util.TimeZone; import java.util.concurrent.ThreadPoolExecutor; http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java index 693041d..c700c61 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java @@ -44,7 +44,7 @@ public final class EagleConfigConstants { public static final int DEFAULT_SERVICE_PORT = 8080; public static final String DEFAULT_ZOOKEEPER_ZNODE_PARENT = "/hbase-unsecure"; - public static final String EAGLE_PROPS="eagleProps"; + public static final String EAGLE_PROPS = "eagleProps"; public static final String EAGLE_SERVICE = "eagleService"; public static final String HOST = "host"; public static final String PORT = "port"; http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java index 2bd144d..65d93e9 100755 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java @@ -103,6 +103,7 @@ public class EagleConfigFactory implements EagleConfig { ? config.getString(EagleConfigConstants.SERVICE_ZOOKEEPER_ZNODE_PARENT) : EagleConfigConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT; String clientIPCPoolSize = getString(config, EagleConfigConstants.SERVICE_HBASE_CLIENT_IPC_POOL_SIZE, "10"); this.hbaseConf = HBaseConfiguration.create(); + this.hbaseConf.set("hbase.client.ipc.pool.size", clientIPCPoolSize); if (this.zkQuorum != null) { this.hbaseConf.set("hbase.zookeeper.quorum", this.zkQuorum); @@ -118,18 +119,22 @@ public class EagleConfigFactory implements EagleConfig { this.hbaseConf.set("zookeeper.znode.parent", EagleConfigConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT); } - this.hbaseConf.set("hbase.client.ipc.pool.size", clientIPCPoolSize); this.eagleServiceHost = config.hasPath(EagleConfigConstants.SERVICE_HOST) ? config.getString(EagleConfigConstants.SERVICE_HOST) : EagleConfigConstants.DEFAULT_SERVICE_HOST; this.storageType = config.hasPath(EagleConfigConstants.SERVICE_STORAGE_TYPE) ? config.getString(EagleConfigConstants.SERVICE_STORAGE_TYPE) : EagleConfigConstants.DEFAULT_STORAGE_TYPE; this.isCoprocessorEnabled = config.hasPath(EagleConfigConstants.SERVICE_COPROCESSOR_ENABLED) && config.getBoolean(EagleConfigConstants.SERVICE_COPROCESSOR_ENABLED); this.eagleServicePort = config.hasPath(EagleConfigConstants.SERVICE_PORT) ? config.getInt(EagleConfigConstants.SERVICE_PORT) : EagleConfigConstants.DEFAULT_SERVICE_PORT; - this.tableNamePrefixedWithEnv = config.hasPath(EagleConfigConstants.SERVICE_TABLE_NAME_PREFIXED_WITH_ENVIRONMENT) && config.getBoolean(EagleConfigConstants.SERVICE_TABLE_NAME_PREFIXED_WITH_ENVIRONMENT); - this.hbaseClientScanCacheSize = config.hasPath(EagleConfigConstants.SERVICE_HBASE_CLIENT_SCAN_CACHE_SIZE) ? config.getInt(EagleConfigConstants.SERVICE_HBASE_CLIENT_SCAN_CACHE_SIZE) : hbaseClientScanCacheSize; + this.tableNamePrefixedWithEnv = config.hasPath(EagleConfigConstants.SERVICE_TABLE_NAME_PREFIXED_WITH_ENVIRONMENT) && config.getBoolean(EagleConfigConstants + .SERVICE_TABLE_NAME_PREFIXED_WITH_ENVIRONMENT); + this.hbaseClientScanCacheSize = config.hasPath(EagleConfigConstants.SERVICE_HBASE_CLIENT_SCAN_CACHE_SIZE) ? config.getInt(EagleConfigConstants.SERVICE_HBASE_CLIENT_SCAN_CACHE_SIZE) : + hbaseClientScanCacheSize; // initilize eagle service thread pool for parallel execution of hbase scan etc. - int threadPoolCoreSize = config.hasPath(EagleConfigConstants.SERVICE_THREADPOOL_CORE_SIZE) ? config.getInt(EagleConfigConstants.SERVICE_THREADPOOL_CORE_SIZE) : EagleConfigConstants.DEFAULT_THREAD_POOL_CORE_SIZE; - int threadPoolMaxSize = config.hasPath(EagleConfigConstants.SERVICE_THREADPOOL_MAX_SIZE) ? config.getInt(EagleConfigConstants.SERVICE_THREADPOOL_MAX_SIZE) : EagleConfigConstants.DEFAULT_THREAD_POOL_MAX_SIZE; - long threadPoolShrinkTime = config.hasPath(EagleConfigConstants.SERVICE_THREADPOOL_SHRINK_SIZE) ? config.getLong(EagleConfigConstants.SERVICE_THREADPOOL_SHRINK_SIZE) : EagleConfigConstants.DEFAULT_THREAD_POOL_SHRINK_TIME; + int threadPoolCoreSize = config.hasPath(EagleConfigConstants.SERVICE_THREADPOOL_CORE_SIZE) ? config.getInt(EagleConfigConstants.SERVICE_THREADPOOL_CORE_SIZE) : EagleConfigConstants + .DEFAULT_THREAD_POOL_CORE_SIZE; + int threadPoolMaxSize = config.hasPath(EagleConfigConstants.SERVICE_THREADPOOL_MAX_SIZE) ? config.getInt(EagleConfigConstants.SERVICE_THREADPOOL_MAX_SIZE) : EagleConfigConstants + .DEFAULT_THREAD_POOL_MAX_SIZE; + long threadPoolShrinkTime = config.hasPath(EagleConfigConstants.SERVICE_THREADPOOL_SHRINK_SIZE) ? config.getLong(EagleConfigConstants.SERVICE_THREADPOOL_SHRINK_SIZE) : EagleConfigConstants + .DEFAULT_THREAD_POOL_SHRINK_TIME; this.isServiceAuditingEnabled = config.hasPath(EagleConfigConstants.SERVICE_AUDITING_ENABLED) && config.getBoolean(EagleConfigConstants.SERVICE_AUDITING_ENABLED); this.executor = new ThreadPoolExecutor(threadPoolCoreSize, threadPoolMaxSize, threadPoolShrinkTime, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigHelper.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigHelper.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigHelper.java index 2f15cd6..f79c340 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigHelper.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigHelper.java @@ -32,12 +32,12 @@ public class EagleConfigHelper { } public static String getServiceUser(Config config) { - return config.hasPath(EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.USERNAME) ? - config.getString(EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.USERNAME) : null; + return config.hasPath(EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.USERNAME) ? config.getString(EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.USERNAME) + : null; } public static String getServicePassword(Config config) { - return config.hasPath(EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PASSWORD) ? - config.getString(EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PASSWORD) : null; + return config.hasPath(EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PASSWORD) ? config.getString(EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PASSWORD) + : null; } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/function/ThrowableConsumer2.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/function/ThrowableConsumer2.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/function/ThrowableConsumer2.java index 330d48e..c78e770 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/function/ThrowableConsumer2.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/function/ThrowableConsumer2.java @@ -17,6 +17,6 @@ package org.apache.eagle.common.function; * limitations under the License. */ @FunctionalInterface -public interface ThrowableConsumer2<T1,T2, E extends Throwable> { - void accept(T1 o1,T2 o2) throws E; +public interface ThrowableConsumer2<T1, T2, E extends Throwable> { + void accept(T1 o1, T2 o2) throws E; } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/function/ThrowableFunction.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/function/ThrowableFunction.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/function/ThrowableFunction.java index 562abea..b91f927 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/function/ThrowableFunction.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/function/ThrowableFunction.java @@ -1,7 +1,5 @@ package org.apache.eagle.common.function; -import java.sql.SQLException; - /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/metric/AlertContext.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/metric/AlertContext.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/metric/AlertContext.java index f8b11c3..bf719fc 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/metric/AlertContext.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/metric/AlertContext.java @@ -24,71 +24,70 @@ import java.util.HashMap; import java.util.Map; /** - * not thread safe + * not thread safe. */ -public class AlertContext implements Serializable{ - private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(AlertContext.class); +public class AlertContext implements Serializable { + private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(AlertContext.class); - private Map<String, String> properties = new HashMap<String, String>(); - - public AlertContext(){ - } - - public AlertContext(AlertContext context){ - this.properties = new HashMap<String, String>(context.properties); - } - - public String removeProperty(String name) - { - return properties.remove(name); - } - - public AlertContext addProperty(String name, String value){ - properties.put(name, value); - return this; - } + private Map<String, String> properties = new HashMap<String, String>(); - public AlertContext addAll(Map<String,String> propHash){ - this.properties.putAll(propHash); - return this; - } + public AlertContext() { + } - public String toJsonString(){ - ObjectMapper objectMapper = new ObjectMapper(); - try { - return objectMapper.writeValueAsString(properties); - }catch(Exception ex){ - LOG.error("fail converting alertcontext into string", ex); - return null; - } - } + public AlertContext(AlertContext context) { + this.properties = new HashMap<String, String>(context.properties); + } - public static AlertContext fromJsonString(String json){ - ObjectMapper objectMapper = new ObjectMapper(); - try{ - Map m = objectMapper.readValue(json, Map.class); - AlertContext c = new AlertContext(); - c.addAll(m); - return c; - }catch(Exception ex){ - LOG.error("fail converting string into alertcontext", ex); - return null; - } - } + public String removeProperty(String name) { + return properties.remove(name); + } - public String getProperty(String name){ - return properties.get(name); - } - - public String toString(){ - return properties.toString(); - } + public AlertContext addProperty(String name, String value) { + properties.put(name, value); + return this; + } - public Map<String, String> getProperties(){ - return properties; - } - - public void setProperties(Map<String, String> properties){ - this.properties = properties; - } + public AlertContext addAll(Map<String, String> propHash) { + this.properties.putAll(propHash); + return this; + } + + public String toJsonString() { + ObjectMapper objectMapper = new ObjectMapper(); + try { + return objectMapper.writeValueAsString(properties); + } catch (Exception ex) { + LOG.error("fail converting alertcontext into string", ex); + return null; + } + } + + public static AlertContext fromJsonString(String json) { + ObjectMapper objectMapper = new ObjectMapper(); + try { + Map m = objectMapper.readValue(json, Map.class); + AlertContext c = new AlertContext(); + c.addAll(m); + return c; + } catch (Exception ex) { + LOG.error("fail converting string into alertcontext", ex); + return null; + } + } + + public String getProperty(String name) { + return properties.get(name); + } + + public String toString() { + return properties.toString(); + } + + public Map<String, String> getProperties() { + return properties; + } + + public void setProperties(Map<String, String> properties) { + this.properties = properties; + } } http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/CommonGuiceModule.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/CommonGuiceModule.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/CommonGuiceModule.java index c44ca01..86a3ea1 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/CommonGuiceModule.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/CommonGuiceModule.java @@ -20,7 +20,7 @@ import com.google.inject.AbstractModule; import com.google.inject.Singleton; import com.typesafe.config.Config; -public class CommonGuiceModule extends AbstractModule{ +public class CommonGuiceModule extends AbstractModule { @Override protected void configure() { bind(Config.class).toProvider(ConfigServiceProvider.class).in(Singleton.class); http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/GlobalScope.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/GlobalScope.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/GlobalScope.java index e7c73e4..ee2f435 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/GlobalScope.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/GlobalScope.java @@ -17,6 +17,7 @@ package org.apache.eagle.common.module; /** - * Global Scope + * Global Scope. */ -public enum GlobalScope implements ModuleScope {} \ No newline at end of file +public enum GlobalScope implements ModuleScope { +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/GuiceJUnitRunner.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/GuiceJUnitRunner.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/GuiceJUnitRunner.java index ce04058..d22195d 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/GuiceJUnitRunner.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/GuiceJUnitRunner.java @@ -28,6 +28,7 @@ import java.util.List; public class GuiceJUnitRunner extends BlockJUnit4ClassRunner { private final Injector injector; + public GuiceJUnitRunner(Class<?> klass) throws InitializationError { super(klass); injector = createInjectorFor(getModulesFor(klass)); @@ -43,14 +44,15 @@ public class GuiceJUnitRunner extends BlockJUnit4ClassRunner { /** * Create a Guice Injector for the class under test. + * * @param classes Guice Modules * @return A Guice Injector instance. * @throws InitializationError If couldn't instantiate a module. */ private Injector createInjectorFor(final Class<?>[] classes) - throws InitializationError { + throws InitializationError { final List<Module> modules = new ArrayList<>(); - if(classes!= null) { + if (classes != null) { for (final Class<?> module : Arrays.asList(classes)) { try { modules.add((Module) module.newInstance()); @@ -65,12 +67,13 @@ public class GuiceJUnitRunner extends BlockJUnit4ClassRunner { /** * Get the list of Guice Modules request by GuiceModules annotation in the * class under test. + * * @param klass Class under test. * @return A Class Array of Guice Modules required by this class. * @throws InitializationError If the annotation is not present. */ private Class<?>[] getModulesFor(final Class<?> klass) - throws InitializationError { + throws InitializationError { final Modules annotation = klass.getAnnotation(Modules.class); if (annotation == null) { return null; http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleRegistry.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleRegistry.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleRegistry.java index 8ae3984..49c1548 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleRegistry.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleRegistry.java @@ -21,32 +21,38 @@ import com.google.inject.Module; import java.util.List; /** - * Module Registry Repository + * Module Registry Repository. */ public interface ModuleRegistry { + /** + * Get Register. * @param modules */ - void register(Class<? extends ModuleScope> scope, Module ... modules); + void register(Class<? extends ModuleScope> scope, Module... modules); + + default void register(Module... modules) { + register(GlobalScope.class, modules); + } /** - * + * Get Module With Scope. * @param moduleScope * @return */ List<Module> getModules(Class<? extends ModuleScope> moduleScope); /** - * @return + * Get All Modules. + * @return all modules */ - List<Class<? extends ModuleScope>> getScopes(); + List<Module> getModules(); /** - * @return all modules + * Get All Scopes. + * @return */ - List<Module> getModules(); + List<Class<? extends ModuleScope>> getScopes(); + - default void register(Module ... modules){ - register(GlobalScope.class,modules); - } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleRegistryImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleRegistryImpl.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleRegistryImpl.java index 3c45dac..4f13e50 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleRegistryImpl.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleRegistryImpl.java @@ -24,7 +24,8 @@ import java.util.List; public class ModuleRegistryImpl implements ModuleRegistry { private final LinkedListMultimap<Class<? extends ModuleScope>, Module> moduleRepo; - public ModuleRegistryImpl(){ + + public ModuleRegistryImpl() { moduleRepo = LinkedListMultimap.create(); } @@ -39,12 +40,13 @@ public class ModuleRegistryImpl implements ModuleRegistry { } @Override - public List<Class<? extends ModuleScope>> getScopes() { - return Arrays.asList((Class<? extends ModuleScope>[]) moduleRepo.keys().toArray()); + public List<Module> getModules() { + return moduleRepo.values(); } @Override - public List<Module> getModules() { - return moduleRepo.values(); + public List<Class<? extends ModuleScope>> getScopes() { + return Arrays.asList((Class<? extends ModuleScope>[]) moduleRepo.keys().toArray()); } + } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleScope.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleScope.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleScope.java index b385fba..b79a112 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleScope.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/ModuleScope.java @@ -21,18 +21,20 @@ import com.google.inject.Module; import java.util.List; /** + * Module Scope. * @see ModuleRegistry */ public interface ModuleScope { /** + * Get Modules. * @param registry ModuleRegistry * @return */ - default List<Module> getModules(ModuleRegistry registry){ + default List<Module> getModules(ModuleRegistry registry) { return registry.getModules(this.getClass()); } - default String getName(){ + default String getName() { return getClass().getName(); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/Modules.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/Modules.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/Modules.java index 8292e08..0f53948 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/Modules.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/module/Modules.java @@ -17,11 +17,8 @@ package org.apache.eagle.common.module; import com.google.inject.AbstractModule; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; + +import java.lang.annotation.*; /** * Defines the Guice Modules in use in the test class. http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopAccountService.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopAccountService.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopAccountService.java index 0b4893a..925142d 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopAccountService.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopAccountService.java @@ -19,5 +19,5 @@ package org.apache.eagle.common.service; import java.util.List; public interface HadoopAccountService { - public List<HadoopUser> searchByUsername(List<String> username); + public List<HadoopUser> searchByUsername(List<String> username); } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ca0fae40/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopUser.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopUser.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopUser.java index 2e84f77..5c9cf80 100644 --- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopUser.java +++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopUser.java @@ -19,26 +19,27 @@ package org.apache.eagle.common.service; import java.util.List; /** + * Hadoop User. * @since : 7/11/14,2014 */ public class HadoopUser { - public String getUsername() { - return username; - } + public String getUsername() { + return username; + } - public void setUsername(String username) { - this.username = username; - } + public void setUsername(String username) { + this.username = username; + } - protected String username; + protected String username; - public List<String> getEmail() { - return email; - } + public List<String> getEmail() { + return email; + } - public void setEmail(List<String> emails) { - this.email = emails; - } + public void setEmail(List<String> emails) { + this.email = emails; + } - protected List<String> email; + protected List<String> email; } \ No newline at end of file