You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ha...@apache.org on 2015/11/19 11:47:31 UTC
[24/55] [abbrv] [partial] incubator-eagle git commit: [EAGLE-46]
Rename package name as "org.apache.eagle"
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/email/EagleMailClient.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/email/EagleMailClient.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/email/EagleMailClient.java
new file mode 100755
index 0000000..e647a2f
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/email/EagleMailClient.java
@@ -0,0 +1,248 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common.email;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.activation.FileDataSource;
+import javax.mail.Authenticator;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+import org.apache.commons.configuration.AbstractConfiguration;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.netflix.config.ConcurrentMapConfiguration;
+
+public class EagleMailClient {
+// private static final String CONFIG_FILE = "config.properties";
+ private static final String BASE_PATH = "templates/";
+ private static final String AUTH_CONFIG = "mail.smtp.auth";
+ private static final String DEBUG_CONFIG = "mail.debug";
+ private static final String USER_CONFIG = "mail.user";
+ private static final String PWD_CONFIG = "mail.pwd";
+
+ private VelocityEngine velocityEngine;
+ private Session session;
+ private static final Logger LOG = LoggerFactory.getLogger(EagleMailClient.class);
+
+ public EagleMailClient() {
+ this(new ConcurrentMapConfiguration());
+ }
+
+ public EagleMailClient(AbstractConfiguration configuration) {
+ try {
+ ConcurrentMapConfiguration con = (ConcurrentMapConfiguration)configuration;
+ velocityEngine = new VelocityEngine();
+ velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+ velocityEngine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+ velocityEngine.init();
+
+ con.setProperty("mail.transport.protocol", "smtp");
+ final Properties config = con.getProperties();
+ if(Boolean.parseBoolean(config.getProperty(AUTH_CONFIG))){
+ session = Session.getDefaultInstance(config, new Authenticator() {
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(config.getProperty(USER_CONFIG), config.getProperty(PWD_CONFIG));
+ }
+ });
+ }
+ else session = Session.getDefaultInstance(config, new Authenticator() {});
+ final String debugMode = config.getProperty(DEBUG_CONFIG, "false");
+ final boolean debug = Boolean.parseBoolean(debugMode);
+ session.setDebug(debug);
+ } catch (Exception e) {
+ LOG.error("Failed connect to smtp server",e);
+ }
+ }
+
+ private boolean _send(String from, String to, String cc, String title,
+ String content) {
+ Message msg = new MimeMessage(session);
+ try {
+ msg.setFrom(new InternetAddress(from));
+ msg.setSubject(title);
+ if (to != null) {
+ msg.setRecipients(Message.RecipientType.TO,
+ InternetAddress.parse(to));
+ }
+ if (cc != null) {
+ msg.setRecipients(Message.RecipientType.CC,
+ InternetAddress.parse(cc));
+ }
+ //msg.setRecipients(Message.RecipientType.BCC, InternetAddress.parse(DEFAULT_BCC_ADDRESS));
+ msg.setContent(content, "text/html;charset=utf-8");
+ LOG.info(String.format("Going to send mail: from[%s], to[%s], cc[%s], title[%s]", from, to, cc, title));
+ Transport.send(msg);
+ return true;
+ } catch (AddressException e) {
+ LOG.info("Send mail failed, got an AddressException: " + e.getMessage(), e);
+ return false;
+ } catch (MessagingException e) {
+ LOG.info("Send mail failed, got an AddressException: " + e.getMessage(), e);
+ return false;
+ }
+ }
+
+ private boolean _send(String from,String to,String cc,String title,String content,List<MimeBodyPart> attachments){
+ MimeMessage mail = new MimeMessage(session);
+ try {
+ mail.setFrom(new InternetAddress(from));
+ mail.setSubject(title);
+ if (to != null) {
+ mail.setRecipients(Message.RecipientType.TO,
+ InternetAddress.parse(to));
+ }
+ if (cc != null) {
+ mail.setRecipients(Message.RecipientType.CC,
+ InternetAddress.parse(cc));
+ }
+
+ //mail.setRecipients(Message.RecipientType.BCC, InternetAddress.parse(DEFAULT_BCC_ADDRESS));
+
+ MimeBodyPart mimeBodyPart = new MimeBodyPart();
+ mimeBodyPart.setContent(content,"text/html;charset=utf-8");
+
+ Multipart multipart = new MimeMultipart();
+ multipart.addBodyPart(mimeBodyPart);
+
+ for(MimeBodyPart attachment:attachments){
+ multipart.addBodyPart(attachment);
+ }
+
+ mail.setContent(multipart);
+// mail.setContent(content, "text/html;charset=utf-8");
+ LOG.info(String.format("Going to send mail: from[%s], to[%s], cc[%s], title[%s]", from, to, cc, title));
+ Transport.send(mail);
+ return true;
+ } catch (AddressException e) {
+ LOG.info("Send mail failed, got an AddressException: " + e.getMessage(), e);
+ return false;
+ } catch (MessagingException e) {
+ LOG.info("Send mail failed, got an AddressException: " + e.getMessage(), e);
+ return false;
+ }
+ }
+
+ public boolean send(String from, String to, String cc, String title,
+ String content) {
+ return this._send(from, to, cc, title, content);
+ }
+
+ public boolean send(String from, String to, String cc, String title,
+ String templatePath, VelocityContext context) {
+ Template t = null;
+ try {
+ t = velocityEngine.getTemplate(BASE_PATH + templatePath);
+ } catch (ResourceNotFoundException ex) {
+ }
+ if (t == null) {
+ try {
+ t = velocityEngine.getTemplate(templatePath);
+ } catch (ResourceNotFoundException e) {
+ t = velocityEngine.getTemplate("/" + templatePath);
+ }
+ }
+ final StringWriter writer = new StringWriter();
+ t.merge(context, writer);
+ if(LOG.isDebugEnabled()) LOG.debug(writer.toString());
+ return this.send(from, to, cc, title, writer.toString());
+ }
+
+ public boolean send(String from, String to, String cc, String title,
+ String templatePath, VelocityContext context, Map<String,File> attachments) {
+ if (attachments == null || attachments.isEmpty()) {
+ return send(from, to, cc, title, templatePath, context);
+ }
+ Template t = null;
+
+ List<MimeBodyPart> mimeBodyParts = new ArrayList<MimeBodyPart>();
+ Map<String,String> cid = new HashMap<String,String>();
+
+ for (Map.Entry<String,File> entry : attachments.entrySet()) {
+ final String attachment = entry.getKey();
+ final File attachmentFile = entry.getValue();
+ final MimeBodyPart mimeBodyPart = new MimeBodyPart();
+ if(attachmentFile !=null && attachmentFile.exists()){
+ DataSource source = new FileDataSource(attachmentFile);
+ try {
+ mimeBodyPart.setDataHandler(new DataHandler(source));
+ mimeBodyPart.setFileName(attachment);
+ mimeBodyPart.setDisposition(MimeBodyPart.ATTACHMENT);
+ mimeBodyPart.setContentID(attachment);
+ cid.put(attachment,mimeBodyPart.getContentID());
+ mimeBodyParts.add(mimeBodyPart);
+ } catch (MessagingException e) {
+ LOG.error("Generate mail failed, got exception while attaching files: " + e.getMessage(), e);
+ }
+ }else{
+ LOG.error("Attachment: " + attachment + " is null or not exists");
+ }
+ }
+ //TODO remove cid, because not used at all
+ if(LOG.isDebugEnabled()) LOG.debug("Cid maps: "+cid);
+ context.put("cid", cid);
+
+ try {
+ t = velocityEngine.getTemplate(BASE_PATH + templatePath);
+ } catch (ResourceNotFoundException ex) {
+// LOGGER.error("Template not found:"+BASE_PATH + templatePath, ex);
+ }
+
+ if (t == null) {
+ try {
+ t = velocityEngine.getTemplate(templatePath);
+ } catch (ResourceNotFoundException e) {
+ try {
+ t = velocityEngine.getTemplate("/" + templatePath);
+ }
+ catch (Exception ex) {
+ LOG.error("Template not found:"+ "/" + templatePath, ex);
+ }
+ }
+ }
+
+ final StringWriter writer = new StringWriter();
+ t.merge(context, writer);
+ if(LOG.isDebugEnabled()) LOG.debug(writer.toString());
+ return this._send(from, to, cc, title, writer.toString(), mimeBodyParts);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/metric/AlertContext.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/metric/AlertContext.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/metric/AlertContext.java
new file mode 100644
index 0000000..0d1faa1
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/metric/AlertContext.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common.metric;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * not thread safe
+ */
+public class AlertContext implements Serializable{
+ 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;
+ }
+
+ public AlertContext addAll(Map<String,String> propHash){
+ this.properties.putAll(propHash);
+ return this;
+ }
+
+ 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/afe86834/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopAccountService.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopAccountService.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopAccountService.java
new file mode 100644
index 0000000..0b4893a
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopAccountService.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common.service;
+
+import java.util.List;
+
+public interface HadoopAccountService {
+ public List<HadoopUser> searchByUsername(List<String> username);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopUser.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopUser.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopUser.java
new file mode 100644
index 0000000..2e84f77
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/HadoopUser.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common.service;
+
+import java.util.List;
+
+/**
+ * @since : 7/11/14,2014
+ */
+public class HadoopUser {
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ protected String username;
+
+ public List<String> getEmail() {
+ return email;
+ }
+
+ public void setEmail(List<String> emails) {
+ this.email = emails;
+ }
+
+ protected List<String> email;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/LdapService.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/LdapService.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/LdapService.java
new file mode 100644
index 0000000..31f1d01
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/LdapService.java
@@ -0,0 +1,259 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common.service;
+
+
+import org.apache.eagle.common.config.EagleConfig;
+import org.apache.eagle.common.config.EagleConfigFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.*;
+import java.util.*;
+
+/**
+ * @since : 7/11/14,2014
+ */
+public class LdapService {
+ private final static Logger LOG = LoggerFactory.getLogger(LdapService.class);
+
+ private final List<String> ldapSrvs;
+ private String ldapCerts;
+ private final String securityPrincipal;
+ private final String securityCredentials;
+
+ public final static String SECURITY_PRINCIPAL_CONFIG_NAME = "eagle.ldap.security-principal";
+ public final static String SECURITY_CREDENTIALS_CONFIG_NAME = "eagle.ldap.security-credentials";
+ public final static String LDAP_SERVER_CONFIG_NAME = "eagle.ldap.server";
+ public final static String LDAP_CERTS_CONFIG_NAME = "eagle.ldap.certs";
+ public final static String DEFAULT_LDAP_CERTS_FILE_NAME = "jssecacerts";
+
+ private LdapService(){
+ EagleConfig manager = EagleConfigFactory.load();
+ securityPrincipal = manager.getConfig().getString(SECURITY_PRINCIPAL_CONFIG_NAME);
+ securityCredentials = manager.getConfig().getString(SECURITY_CREDENTIALS_CONFIG_NAME);
+ String ldapServer = manager.getConfig().getString(LDAP_SERVER_CONFIG_NAME);
+ if(LOG.isDebugEnabled())
+ LOG.debug(SECURITY_PRINCIPAL_CONFIG_NAME+":"+securityPrincipal);
+ if(securityCredentials!=null){
+ if(LOG.isDebugEnabled())
+ LOG.debug(SECURITY_CREDENTIALS_CONFIG_NAME+": (hidden for security, length: "+securityCredentials.length()+")");
+ }else{
+ LOG.warn(SECURITY_CREDENTIALS_CONFIG_NAME+":"+null);
+ }
+ if(LOG.isDebugEnabled())
+ LOG.debug(LDAP_SERVER_CONFIG_NAME+":"+ldapServer);
+
+ ldapSrvs = Arrays.asList(ldapServer.split(","));
+ ldapCerts = manager.getConfig().getString(LDAP_CERTS_CONFIG_NAME);
+ if(ldapCerts == null) {
+ ldapCerts = LdapService.class.getClassLoader().getResource(DEFAULT_LDAP_CERTS_FILE_NAME).getPath();
+ }else if(!ldapCerts.startsWith("/") && !ldapCerts.matches("[a-zA-Z]+:.*")) {
+ ldapCerts = LdapService.class.getClassLoader().getResource(ldapCerts).getPath();
+ }
+ if(LOG.isDebugEnabled()) {
+ LOG.debug(SECURITY_PRINCIPAL_CONFIG_NAME +": "+securityPrincipal);
+ if(securityCredentials == null){
+ LOG.debug(SECURITY_CREDENTIALS_CONFIG_NAME +": null");
+ }else{
+ LOG.debug(SECURITY_CREDENTIALS_CONFIG_NAME +": (hidden, length: "+securityCredentials .length()+")");
+ }
+
+ LOG.debug(LDAP_SERVER_CONFIG_NAME +": "+ldapSrvs);
+ LOG.debug(LDAP_CERTS_CONFIG_NAME +": "+ldapCerts);
+ }
+ }
+
+ private static LdapService instance;
+
+ public static LdapService getInstance(){
+ if(instance == null){
+ instance = new LdapService();
+ }
+ return instance;
+ }
+
+ protected DirContext getDirContext(int id) {
+ if (ldapCerts != null) {
+ System.setProperty("javax.net.ssl.keyStore", ldapCerts);
+ System.setProperty("javax.net.ssl.trustStore", ldapCerts);
+ }
+
+ String host = ldapSrvs.get(id);
+
+ Hashtable<String, String> env = new Hashtable<String, String>();
+// if (ldapCerts != null) {
+ env.put(Context.SECURITY_PROTOCOL, "ssl");
+// }
+ env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+ env.put(Context.PROVIDER_URL, host);
+ env.put(Context.SECURITY_AUTHENTICATION, "simple");
+ env.put(Context.SECURITY_PRINCIPAL, securityPrincipal);
+ env.put(Context.SECURITY_CREDENTIALS, securityCredentials);
+ env.put("java.naming.ldap.attributes.binary", "objectSID");
+ env.put("java.naming.ldap.factory.socket","hadoop.eagle.common.service.TrustAllSSLSocketFactory");
+
+ DirContext ctx = null;
+ try {
+ ctx = new InitialDirContext(env);
+ } catch (Exception e) {
+ ctx = null;
+ LOG.error("LDAP authentication failed with exception: " + e.getMessage(), e);
+ }
+ return ctx;
+ }
+
+ public final static String CN= "cn";
+ public final static String DISPLAY_NAME = "displayName";
+ public final static String DESCRIPTION= "description";
+ public final static String SAMACCOUNT_NAME= "sAMAccountName";
+ public final static String TELEPHONE_NUMBER= "telephonenumber";
+ public final static String GIVEN_NAME= "givenName";
+ public final static String UID_NUMBER = "uidNumber";
+ public final static String L = "l";
+ public final static String ST = "st";
+ public final static String CO = "co";
+ public final static String MEMBER_OF = "memberof";
+ public final static String SN = "sn";
+ public final static String MAIL = "mail";
+ public final static String DISTINGUISHED_NAME = "distinguishedName";
+
+ protected SearchControls getSearchControl() {
+ SearchControls sc = new SearchControls();
+
+ String[] attributeFilter = new String[15];
+ attributeFilter[0] = CN;
+ attributeFilter[1] = DISPLAY_NAME ;
+ attributeFilter[2] = DESCRIPTION;
+ attributeFilter[3] = SAMACCOUNT_NAME;
+ attributeFilter[4] = TELEPHONE_NUMBER;
+ attributeFilter[5] = GIVEN_NAME;
+ attributeFilter[6] = UID_NUMBER;
+ attributeFilter[7] = L;
+ attributeFilter[8] = ST;
+ attributeFilter[9] =CO;
+ attributeFilter[10] = MEMBER_OF;
+ attributeFilter[11] = SN;
+ attributeFilter[12] = MAIL;
+ attributeFilter[13] = DISTINGUISHED_NAME;
+
+ sc.setReturningAttributes(attributeFilter);
+ sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
+
+ return sc;
+ }
+
+ public Map<String, String> getUserInfo(String userName) {
+ Map<String, String> infos = null;
+ for (int i = 0; i < ldapSrvs.size(); i++) {
+ if(LOG.isDebugEnabled()) LOG.debug("Using server: "+ldapSrvs.get(i));
+ infos = getUserInfo(i, userName);
+ if (infos.size() > 0)
+ break;
+ }
+ return infos;
+ }
+
+ public Map<String, String> getUserInfo(int id, String userName) {
+ if(LOG.isDebugEnabled()) LOG.debug("Ldap get user information for id:"+id+", username:"+userName);
+ DirContext ctx = getDirContext(id);
+ Map<String, String> infos = new HashMap<String, String>();
+
+ if (ctx != null) {
+ try {
+ SearchControls sc = getSearchControl();
+ String filter = "(&(objectClass=user)(sAMAccountName=" + userName + "))";
+ NamingEnumeration<?> results = ctx.search("OU=Accounts_User,DC=corp,DC=company1,DC=com", filter, sc);
+
+ while (results.hasMore()) {
+ SearchResult sr = (SearchResult) results.next();
+ Attributes attrs = sr.getAttributes();
+
+ for (NamingEnumeration<?> ae = attrs.getAll(); ae.hasMoreElements();) {
+ Attribute attr = (Attribute) ae.next();
+ String attrId = attr.getID();
+ for (NamingEnumeration<?> vals = attr.getAll(); vals.hasMore();) {
+ String thing = vals.next().toString();
+ infos.put(attrId, thing);
+ }
+ }
+ }
+ } catch (NamingException e) {
+ LOG.error("LDAP authentication failed with exception: "+e.getMessage(),e);
+ }
+ }
+
+ if(LOG.isDebugEnabled()) LOG.debug(infos.toString());
+ return infos;
+ }
+
+ public boolean authenticate(String userName, String password) {
+ for (int i = 0; i < ldapSrvs.size(); i++) {
+ if (authenticate(i, userName, password))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean authenticate(int id, String userName, String password) {
+ boolean result = false;
+
+ DirContext ctx = getDirContext(id);
+ if (ctx != null) {
+ try {
+ SearchControls sc = getSearchControl();
+ String filter = "(&(objectClass=user)(sAMAccountName=" + userName + "))";
+ NamingEnumeration<?> results = ctx.search("OU=Accounts_User,DC=corp,DC=company1,DC=com", filter, sc);
+
+ String userDN = null;
+ if (results.hasMore()) {
+ while (results.hasMore()) {
+ SearchResult sr = (SearchResult) results.next();
+ Attributes attrs = sr.getAttributes();
+
+ userDN = attrs.get("distinguishedName").get().toString();
+ }
+ }
+ ctx.close();
+
+ if (userDN != null) {
+ Hashtable<String, String> uenv = new Hashtable<String, String>();
+// if (ldapCerts != null) {
+ uenv.put(Context.SECURITY_PROTOCOL, "ssl");
+// }
+ uenv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+ uenv.put(Context.PROVIDER_URL, ldapSrvs.get(id));
+ uenv.put(Context.SECURITY_AUTHENTICATION, "simple");
+ uenv.put(Context.SECURITY_PRINCIPAL, userDN);
+ uenv.put(Context.SECURITY_CREDENTIALS, password);
+ uenv.put("java.naming.ldap.factory.socket","hadoop.eagle.common.service.TrustAllSSLSocketFactory");
+ DirContext uctx = new InitialDirContext(uenv);
+ uctx.close();
+
+ result = true;
+ }
+ } catch (NamingException e) {
+ LOG.error("LDAP authentication failed with exception: " + e.getMessage(), e);
+ }
+ }
+
+ return result;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/POSTResultEntityBase.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/POSTResultEntityBase.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/POSTResultEntityBase.java
new file mode 100644
index 0000000..e0daeb7
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/POSTResultEntityBase.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common.service;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(propOrder = {"success", "exception"})
+public class POSTResultEntityBase {
+ private boolean success;
+ private String exception;
+ public boolean isSuccess() {
+ return success;
+ }
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+ public String getException() {
+ return exception;
+ }
+ public void setException(String exception) {
+ this.exception = exception;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/TrustAllSSLSocketFactory.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/TrustAllSSLSocketFactory.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/TrustAllSSLSocketFactory.java
new file mode 100644
index 0000000..9facc82
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/service/TrustAllSSLSocketFactory.java
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common.service;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.cert.X509Certificate;
+
+public class TrustAllSSLSocketFactory extends SSLSocketFactory
+{
+ private SSLSocketFactory socketFactory;
+ public TrustAllSSLSocketFactory()
+ {
+ try {
+ SSLContext ctx = SSLContext.getInstance("SSL");
+// ctx.init(null, new TrustManager[]{new TrustAnyTrustManager() {}}, new SecureRandom());
+ ctx.init(null, new TrustManager[]{new TrustAnyTrustManager() {}}, null);
+ socketFactory = ctx.getSocketFactory();
+ } catch ( Exception ex ){ ex.printStackTrace(System.err); /* handle exception */ }
+ }
+ public static SocketFactory getDefault(){
+ return new TrustAllSSLSocketFactory();
+ }
+ @Override
+ public String[] getDefaultCipherSuites()
+ {
+ return socketFactory.getDefaultCipherSuites();
+ }
+ @Override
+ public String[] getSupportedCipherSuites()
+ {
+ return socketFactory.getSupportedCipherSuites();
+ }
+ @Override
+ public Socket createSocket(Socket socket, String string, int i, boolean bln) throws IOException
+ {
+ return socketFactory.createSocket(socket, string, i, bln);
+ }
+ @Override
+ public Socket createSocket(String string, int i) throws IOException, UnknownHostException
+ {
+ return socketFactory.createSocket(string, i);
+ }
+ @Override
+ public Socket createSocket(String string, int i, InetAddress ia, int i1) throws IOException, UnknownHostException
+ {
+ return socketFactory.createSocket(string, i, ia, i1);
+ }
+ @Override
+ public Socket createSocket(InetAddress ia, int i) throws IOException
+ {
+ return socketFactory.createSocket(ia, i);
+ }
+ @Override
+ public Socket createSocket(InetAddress ia, int i, InetAddress ia1, int i1) throws IOException
+ {
+ return socketFactory.createSocket(ia, i, ia1, i1);
+ }
+
+ private static class TrustAnyTrustManager implements X509TrustManager {
+ @Override
+ public void checkClientTrusted( final X509Certificate[] chain, final String authType ) {
+ }
+ @Override
+ public void checkServerTrusted( final X509Certificate[] chain, final String authType ) {
+ }
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/main/resources/footer.vm
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/resources/footer.vm b/eagle-core/eagle-query/eagle-common/src/main/resources/footer.vm
index 06c1c0b..7cf9c12 100755
--- a/eagle-core/eagle-query/eagle-common/src/main/resources/footer.vm
+++ b/eagle-core/eagle-query/eagle-common/src/main/resources/footer.vm
@@ -1,7 +1,5 @@
#**
-
-@author xudshen
-@version 1
+@version 0.3.0
*#
</td>
</tr>
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/main/resources/header.vm
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/resources/header.vm b/eagle-core/eagle-query/eagle-common/src/main/resources/header.vm
index b346251..3410e86 100755
--- a/eagle-core/eagle-query/eagle-common/src/main/resources/header.vm
+++ b/eagle-core/eagle-query/eagle-common/src/main/resources/header.vm
@@ -1,6 +1,5 @@
#**
-@author xudshen
-@version 1
+@version 0.3.0
*#
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/main/resources/templates/tec_alert.vm
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/resources/templates/tec_alert.vm b/eagle-core/eagle-query/eagle-common/src/main/resources/templates/tec_alert.vm
index 78f2013..fec05c8 100755
--- a/eagle-core/eagle-query/eagle-common/src/main/resources/templates/tec_alert.vm
+++ b/eagle-core/eagle-query/eagle-common/src/main/resources/templates/tec_alert.vm
@@ -1,6 +1,5 @@
#**
-@author xudshen
-@version 1
+@version 0.3.0
*#
#parse("header.vm")
<table cellpadding="0" cellspacing="0" border="0" align="left" width="800" style="">
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestByteUtil.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestByteUtil.java b/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestByteUtil.java
deleted file mode 100644
index e6437a6..0000000
--- a/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestByteUtil.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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.
- */
-package eagle.common;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-
-public class TestByteUtil {
-
- @Test
- public void testLongAndBytesConversion() {
- long origValue = 0x1234567812345678L;
- byte[] bytes = ByteUtil.longToBytes(origValue);
- checkNonZeros(bytes);
- long value = ByteUtil.bytesToLong(bytes);
- Assert.assertEquals(origValue, value);
- bytes = new byte[16];
- checkZeros(bytes);
- ByteUtil.longToBytes(origValue, bytes, 4);
- checkZeros(bytes, 0, 4);
- checkZeros(bytes, 12, 16);
- checkNonZeros(bytes, 4, 12);
- value = ByteUtil.bytesToLong(bytes, 4);
- Assert.assertEquals(origValue, value);
- }
-
- @Test
- public void testDoubleAndBytesConversion() {
- double origValue = (double)0x1234567812345678L;
- byte[] bytes = ByteUtil.doubleToBytes(origValue);
- checkNonZeros(bytes);
- double value = ByteUtil.bytesToDouble(bytes);
- Assert.assertEquals(origValue, value);
- bytes = new byte[16];
- checkZeros(bytes);
- ByteUtil.doubleToBytes(origValue, bytes, 4);
- checkZeros(bytes, 0, 4);
- checkZeros(bytes, 12, 16);
- checkNonZeros(bytes, 4, 12);
- value = ByteUtil.bytesToDouble(bytes, 4);
- Assert.assertEquals(origValue, value);
- }
-
- @Test
- public void testIntAndBytesConversion() {
- int origValue = 0x12345678;
- byte[] bytes = ByteUtil.intToBytes(origValue);
- Assert.assertEquals(4, bytes.length);
- Assert.assertEquals(0x12, bytes[0]);
- Assert.assertEquals(0x34, bytes[1]);
- Assert.assertEquals(0x56, bytes[2]);
- Assert.assertEquals(0x78, bytes[3]);
- checkNonZeros(bytes);
- int value = ByteUtil.bytesToInt(bytes);
- Assert.assertEquals(origValue, value);
- bytes = new byte[12];
- checkZeros(bytes);
- ByteUtil.intToBytes(origValue, bytes, 4);
- checkZeros(bytes, 0, 4);
- checkZeros(bytes, 8, 12);
- checkNonZeros(bytes, 4, 8);
- value = ByteUtil.bytesToInt(bytes, 4);
- Assert.assertEquals(origValue, value);
- }
-
- @Test
- public void testShortAndBytesConversion() {
- short origValue = 0x1234;
- byte[] bytes = ByteUtil.shortToBytes(origValue);
- Assert.assertEquals(2, bytes.length);
- Assert.assertEquals(0x12, bytes[0]);
- Assert.assertEquals(0x34, bytes[1]);
- checkNonZeros(bytes);
- short value = ByteUtil.bytesToShort(bytes);
- Assert.assertEquals(origValue, value);
- }
-
- private void checkZeros(byte[] bytes) {
- checkZeros(bytes, 0, bytes.length);
- }
-
- private void checkZeros(byte[] bytes, int i, int j) {
- for (int k = i; k < j; ++k) {
- Assert.assertEquals((byte)0, bytes[k]);
- }
- }
-
- private void checkNonZeros(byte[] bytes) {
- checkNonZeros(bytes, 0, bytes.length);
- }
-
- private void checkNonZeros(byte[] bytes, int i, int j) {
- for (int k = i; k < j; ++k) {
- Assert.assertNotSame((byte)0, bytes[k]);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestCircularArrayList.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestCircularArrayList.java b/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestCircularArrayList.java
deleted file mode 100644
index ad2d7d7..0000000
--- a/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestCircularArrayList.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.
- */
-package eagle.common;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-
-public class TestCircularArrayList {
-
- @Test
- public void testAddAndRemove() {
- Long[] array = new Long[5];
- CircularArrayList<Long> list = new CircularArrayList<Long>(array);
-
- for (long i = 0 ; i < 5; ++i) {
- list.add(i);
- Assert.assertEquals((Long)i, array[(int) i]);
- Assert.assertTrue(list.contains(i));
- Assert.assertEquals(i, list.find(i));
- }
- Assert.assertFalse(list.contains(6L));
- Exception e = null;
- try {
- list.add((long)5);
- } catch (Exception ex) {
- e = ex;
- }
- Assert.assertNotNull(e);
- Assert.assertEquals(0, list.tail());
- Assert.assertEquals(0, list.head());
- Assert.assertEquals(5, list.size());
- Assert.assertTrue(list.isFull());
- Long v = list.remove(1);
- Assert.assertEquals((Long)1L, v);
- Assert.assertEquals(4, list.size());
- Assert.assertEquals(1, list.head());
- Assert.assertEquals(0, list.tail());
- list.add((long)5);
- Assert.assertEquals(5, list.size());
- Assert.assertEquals(1, list.head());
- Assert.assertEquals(1, list.tail());
- Assert.assertEquals((Long)0L, list.remove(0));
- Assert.assertEquals(2, list.head());
- Assert.assertEquals(1, list.tail());
- Assert.assertEquals((Long)2L, list.remove(0));
- Assert.assertEquals(3, list.head());
- Assert.assertEquals(1, list.tail());
- Assert.assertEquals((Long)3L, list.remove(0));
- Assert.assertEquals(4, list.head());
- Assert.assertEquals(1, list.tail());
- Assert.assertEquals((Long)4L, list.remove(0));
- Assert.assertEquals(0, list.head());
- Assert.assertEquals(1, list.tail());
- Assert.assertEquals((Long)5L, list.remove(0));
- Assert.assertEquals(1, list.head());
- Assert.assertEquals(1, list.tail());
- Assert.assertTrue(list.isEmpty());
- Assert.assertFalse(list.isFull());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestCircularArrayListSortedSet.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestCircularArrayListSortedSet.java b/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestCircularArrayListSortedSet.java
deleted file mode 100644
index 69cb5a2..0000000
--- a/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestCircularArrayListSortedSet.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.
- */
-package eagle.common;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-
-public class TestCircularArrayListSortedSet {
-
- @Test
- public void testInsertAndRemove() {
- Long[] array = new Long[5];
- CircularArrayListSortedSet<Long> set = new CircularArrayListSortedSet<Long>(array);
-
- set.insert(3L);
- set.insert(2L);
- set.insert(1L);
- set.insert(5L);
- set.insert(4L);
-
- for (int i = 0; i < 5; ++i) {
- Assert.assertEquals((Long)(long)(i + 1),set.get(i));
- Assert.assertEquals(i, set.binarySearch((Long)(long)(i + 1)));
- }
- Assert.assertEquals(0, set.head());
- Assert.assertEquals(0, set.tail());
- Assert.assertTrue(set.isFull());
- Assert.assertEquals(-(5 + 1), set.binarySearch(6L));
-
- Assert.assertEquals(2, set.remove(3L));
- Assert.assertEquals(2, set.remove(4L));
- Assert.assertEquals(-(2 + 1), set.binarySearch(3L));
- set.insert(3L);
- set.insert(4L);
-
- for (int i = 0; i < 5; ++i) {
- Assert.assertEquals((Long)(long)(i + 1),set.get(i));
- Assert.assertEquals(i, set.binarySearch((Long)(long)(i + 1)));
- }
- Assert.assertEquals(2, set.head());
- Assert.assertEquals(2, set.tail());
- Assert.assertTrue(set.isFull());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestDateTimeUtil.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestDateTimeUtil.java b/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestDateTimeUtil.java
deleted file mode 100755
index 8bd1b33..0000000
--- a/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestDateTimeUtil.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.
- */
-package eagle.common;
-
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-
-public class TestDateTimeUtil {
- @Test
- public void testRound1(){
- long tsInMS = 1397016731576L;
- long tsInMin = DateTimeUtil.roundDown(Calendar.MINUTE, tsInMS);
- Assert.assertEquals(1397016720000L, tsInMin);
-
- GregorianCalendar cal = new GregorianCalendar();
- cal.setTimeInMillis(tsInMS);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- Assert.assertEquals(tsInMin, cal.getTimeInMillis());
- }
-
- @Test
- public void testRound2(){
- long tsInMS = 1397016731576L;
- long tsInHour = DateTimeUtil.roundDown(Calendar.HOUR, tsInMS);
- Assert.assertEquals(1397016000000L, tsInHour);
-
- GregorianCalendar cal = new GregorianCalendar();
- cal.setTimeInMillis(tsInMS);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- Assert.assertEquals(tsInHour, cal.getTimeInMillis());
- }
-
- @Test
- public void testRound3(){
- long tsInMS = 1L;
- long tsInDay = DateTimeUtil.roundDown(Calendar.DATE, tsInMS);
- Assert.assertEquals(0L, tsInDay);
-// Assert.assertEquals("1970-01-01 08:00:00", DateTimeUtil.millisecondsToHumanDateWithSeconds(tsInDay));
- }
-
- @Test
- public void testRound4(){
- long tsInMS = 0L;
- long tsInDay = DateTimeUtil.roundDown(Calendar.DATE, tsInMS);
- Assert.assertEquals(0L, tsInDay);
- String str = DateTimeUtil.millisecondsToHumanDateWithSeconds(tsInMS);
- System.out.println(str);
- }
-
- @Test
- public void testRound5(){
- long tsInMS = 8*3600*1000L;
- long tsInDay = DateTimeUtil.roundDown(Calendar.DATE, tsInMS);
- Assert.assertEquals(0L, tsInDay);
- String str = DateTimeUtil.millisecondsToHumanDateWithSeconds(tsInDay);
- System.out.println(str);
- }
-
- @Test
- public void testDayOfWeek() {
- GregorianCalendar cal = new GregorianCalendar();
- long tsInMS = 0L;
- cal.setTimeInMillis(tsInMS);
- //cal.setTimeInMillis(System.currentTimeMillis());
- System.out.println(cal.get(Calendar.DAY_OF_WEEK));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestEagleBase64Wrapper.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestEagleBase64Wrapper.java b/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestEagleBase64Wrapper.java
deleted file mode 100755
index 8b04481..0000000
--- a/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/TestEagleBase64Wrapper.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.
- */
-package eagle.common;
-
-import org.junit.Test;
-
-public class TestEagleBase64Wrapper {
- @Test
- public void test(){
- byte[] b = EagleBase64Wrapper.decode("BgVz-6vkdM8AAbGAf__-trtos5aqSGPod4Q1GwA268vF50iNBgmpmAxLXKkGbxkREWcmOzT3YIx3hDUb");
- byte[] c = EagleBase64Wrapper.decode("BgVz-6vkdM8AAbGAf__-trtos5aqSGPod4Q1G6pLeJcAATVuADbry8XnSI0GCamYDEtcqQZvGRERZyY7NPdgjHeENRs");
-
- System.out.println(new String(b));
- System.out.println(new String(c));
-
- int hash = "jobType".hashCode();
- byte b1 = (byte)((hash >> 24) & 0xff);
- byte b2 = (byte)(((hash << 8) >> 24) & 0xff);
- byte b3 = (byte)(((hash << 16) >> 24) & 0xff);
- byte b4 = (byte)(((hash << 24) >> 24) & 0xff);
-
- System.out.println(b1 + "," + b2 + "," + b3 + "," + b4);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/config/TestEagleConfig.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/config/TestEagleConfig.java b/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/config/TestEagleConfig.java
deleted file mode 100644
index 455e44b..0000000
--- a/eagle-core/eagle-query/eagle-common/src/test/java/eagle/common/config/TestEagleConfig.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-package eagle.common.config;
-
-import junit.framework.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @since 9/22/15
- */
-public class TestEagleConfig {
- private EagleConfig config;
-
- @Before
- public void setUp(){
- System.setProperty("config.resource","test-service-config.conf");
- config = EagleConfigFactory.load();
- }
-
- @Test
- public void testInit(){
- Assert.assertEquals("test",config.getEnv());
- Assert.assertEquals("localhost",config.getServiceHost());
- Assert.assertEquals(9090,config.getServicePort());
- Assert.assertEquals("hbase",config.getStorageType());
- Assert.assertEquals(false,config.isCoprocessorEnabled());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestByteUtil.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestByteUtil.java b/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestByteUtil.java
new file mode 100644
index 0000000..1cf6b8c
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestByteUtil.java
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class TestByteUtil {
+
+ @Test
+ public void testLongAndBytesConversion() {
+ long origValue = 0x1234567812345678L;
+ byte[] bytes = ByteUtil.longToBytes(origValue);
+ checkNonZeros(bytes);
+ long value = ByteUtil.bytesToLong(bytes);
+ Assert.assertEquals(origValue, value);
+ bytes = new byte[16];
+ checkZeros(bytes);
+ ByteUtil.longToBytes(origValue, bytes, 4);
+ checkZeros(bytes, 0, 4);
+ checkZeros(bytes, 12, 16);
+ checkNonZeros(bytes, 4, 12);
+ value = ByteUtil.bytesToLong(bytes, 4);
+ Assert.assertEquals(origValue, value);
+ }
+
+ @Test
+ public void testDoubleAndBytesConversion() {
+ double origValue = (double)0x1234567812345678L;
+ byte[] bytes = ByteUtil.doubleToBytes(origValue);
+ checkNonZeros(bytes);
+ double value = ByteUtil.bytesToDouble(bytes);
+ Assert.assertEquals(origValue, value);
+ bytes = new byte[16];
+ checkZeros(bytes);
+ ByteUtil.doubleToBytes(origValue, bytes, 4);
+ checkZeros(bytes, 0, 4);
+ checkZeros(bytes, 12, 16);
+ checkNonZeros(bytes, 4, 12);
+ value = ByteUtil.bytesToDouble(bytes, 4);
+ Assert.assertEquals(origValue, value);
+ }
+
+ @Test
+ public void testIntAndBytesConversion() {
+ int origValue = 0x12345678;
+ byte[] bytes = ByteUtil.intToBytes(origValue);
+ Assert.assertEquals(4, bytes.length);
+ Assert.assertEquals(0x12, bytes[0]);
+ Assert.assertEquals(0x34, bytes[1]);
+ Assert.assertEquals(0x56, bytes[2]);
+ Assert.assertEquals(0x78, bytes[3]);
+ checkNonZeros(bytes);
+ int value = ByteUtil.bytesToInt(bytes);
+ Assert.assertEquals(origValue, value);
+ bytes = new byte[12];
+ checkZeros(bytes);
+ ByteUtil.intToBytes(origValue, bytes, 4);
+ checkZeros(bytes, 0, 4);
+ checkZeros(bytes, 8, 12);
+ checkNonZeros(bytes, 4, 8);
+ value = ByteUtil.bytesToInt(bytes, 4);
+ Assert.assertEquals(origValue, value);
+ }
+
+ @Test
+ public void testShortAndBytesConversion() {
+ short origValue = 0x1234;
+ byte[] bytes = ByteUtil.shortToBytes(origValue);
+ Assert.assertEquals(2, bytes.length);
+ Assert.assertEquals(0x12, bytes[0]);
+ Assert.assertEquals(0x34, bytes[1]);
+ checkNonZeros(bytes);
+ short value = ByteUtil.bytesToShort(bytes);
+ Assert.assertEquals(origValue, value);
+ }
+
+ private void checkZeros(byte[] bytes) {
+ checkZeros(bytes, 0, bytes.length);
+ }
+
+ private void checkZeros(byte[] bytes, int i, int j) {
+ for (int k = i; k < j; ++k) {
+ Assert.assertEquals((byte)0, bytes[k]);
+ }
+ }
+
+ private void checkNonZeros(byte[] bytes) {
+ checkNonZeros(bytes, 0, bytes.length);
+ }
+
+ private void checkNonZeros(byte[] bytes, int i, int j) {
+ for (int k = i; k < j; ++k) {
+ Assert.assertNotSame((byte)0, bytes[k]);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestCircularArrayList.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestCircularArrayList.java b/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestCircularArrayList.java
new file mode 100644
index 0000000..942111d
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestCircularArrayList.java
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class TestCircularArrayList {
+
+ @Test
+ public void testAddAndRemove() {
+ Long[] array = new Long[5];
+ CircularArrayList<Long> list = new CircularArrayList<Long>(array);
+
+ for (long i = 0 ; i < 5; ++i) {
+ list.add(i);
+ Assert.assertEquals((Long)i, array[(int) i]);
+ Assert.assertTrue(list.contains(i));
+ Assert.assertEquals(i, list.find(i));
+ }
+ Assert.assertFalse(list.contains(6L));
+ Exception e = null;
+ try {
+ list.add((long)5);
+ } catch (Exception ex) {
+ e = ex;
+ }
+ Assert.assertNotNull(e);
+ Assert.assertEquals(0, list.tail());
+ Assert.assertEquals(0, list.head());
+ Assert.assertEquals(5, list.size());
+ Assert.assertTrue(list.isFull());
+ Long v = list.remove(1);
+ Assert.assertEquals((Long)1L, v);
+ Assert.assertEquals(4, list.size());
+ Assert.assertEquals(1, list.head());
+ Assert.assertEquals(0, list.tail());
+ list.add((long)5);
+ Assert.assertEquals(5, list.size());
+ Assert.assertEquals(1, list.head());
+ Assert.assertEquals(1, list.tail());
+ Assert.assertEquals((Long)0L, list.remove(0));
+ Assert.assertEquals(2, list.head());
+ Assert.assertEquals(1, list.tail());
+ Assert.assertEquals((Long)2L, list.remove(0));
+ Assert.assertEquals(3, list.head());
+ Assert.assertEquals(1, list.tail());
+ Assert.assertEquals((Long)3L, list.remove(0));
+ Assert.assertEquals(4, list.head());
+ Assert.assertEquals(1, list.tail());
+ Assert.assertEquals((Long)4L, list.remove(0));
+ Assert.assertEquals(0, list.head());
+ Assert.assertEquals(1, list.tail());
+ Assert.assertEquals((Long)5L, list.remove(0));
+ Assert.assertEquals(1, list.head());
+ Assert.assertEquals(1, list.tail());
+ Assert.assertTrue(list.isEmpty());
+ Assert.assertFalse(list.isFull());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestCircularArrayListSortedSet.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestCircularArrayListSortedSet.java b/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestCircularArrayListSortedSet.java
new file mode 100644
index 0000000..9422313
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestCircularArrayListSortedSet.java
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class TestCircularArrayListSortedSet {
+
+ @Test
+ public void testInsertAndRemove() {
+ Long[] array = new Long[5];
+ CircularArrayListSortedSet<Long> set = new CircularArrayListSortedSet<Long>(array);
+
+ set.insert(3L);
+ set.insert(2L);
+ set.insert(1L);
+ set.insert(5L);
+ set.insert(4L);
+
+ for (int i = 0; i < 5; ++i) {
+ Assert.assertEquals((Long)(long)(i + 1),set.get(i));
+ Assert.assertEquals(i, set.binarySearch((Long)(long)(i + 1)));
+ }
+ Assert.assertEquals(0, set.head());
+ Assert.assertEquals(0, set.tail());
+ Assert.assertTrue(set.isFull());
+ Assert.assertEquals(-(5 + 1), set.binarySearch(6L));
+
+ Assert.assertEquals(2, set.remove(3L));
+ Assert.assertEquals(2, set.remove(4L));
+ Assert.assertEquals(-(2 + 1), set.binarySearch(3L));
+ set.insert(3L);
+ set.insert(4L);
+
+ for (int i = 0; i < 5; ++i) {
+ Assert.assertEquals((Long)(long)(i + 1),set.get(i));
+ Assert.assertEquals(i, set.binarySearch((Long)(long)(i + 1)));
+ }
+ Assert.assertEquals(2, set.head());
+ Assert.assertEquals(2, set.tail());
+ Assert.assertTrue(set.isFull());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestDateTimeUtil.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestDateTimeUtil.java b/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestDateTimeUtil.java
new file mode 100755
index 0000000..8b7c1cd
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestDateTimeUtil.java
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class TestDateTimeUtil {
+ @Test
+ public void testRound1(){
+ long tsInMS = 1397016731576L;
+ long tsInMin = DateTimeUtil.roundDown(Calendar.MINUTE, tsInMS);
+ Assert.assertEquals(1397016720000L, tsInMin);
+
+ GregorianCalendar cal = new GregorianCalendar();
+ cal.setTimeInMillis(tsInMS);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ Assert.assertEquals(tsInMin, cal.getTimeInMillis());
+ }
+
+ @Test
+ public void testRound2(){
+ long tsInMS = 1397016731576L;
+ long tsInHour = DateTimeUtil.roundDown(Calendar.HOUR, tsInMS);
+ Assert.assertEquals(1397016000000L, tsInHour);
+
+ GregorianCalendar cal = new GregorianCalendar();
+ cal.setTimeInMillis(tsInMS);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ Assert.assertEquals(tsInHour, cal.getTimeInMillis());
+ }
+
+ @Test
+ public void testRound3(){
+ long tsInMS = 1L;
+ long tsInDay = DateTimeUtil.roundDown(Calendar.DATE, tsInMS);
+ Assert.assertEquals(0L, tsInDay);
+// Assert.assertEquals("1970-01-01 08:00:00", DateTimeUtil.millisecondsToHumanDateWithSeconds(tsInDay));
+ }
+
+ @Test
+ public void testRound4(){
+ long tsInMS = 0L;
+ long tsInDay = DateTimeUtil.roundDown(Calendar.DATE, tsInMS);
+ Assert.assertEquals(0L, tsInDay);
+ String str = DateTimeUtil.millisecondsToHumanDateWithSeconds(tsInMS);
+ System.out.println(str);
+ }
+
+ @Test
+ public void testRound5(){
+ long tsInMS = 8*3600*1000L;
+ long tsInDay = DateTimeUtil.roundDown(Calendar.DATE, tsInMS);
+ Assert.assertEquals(0L, tsInDay);
+ String str = DateTimeUtil.millisecondsToHumanDateWithSeconds(tsInDay);
+ System.out.println(str);
+ }
+
+ @Test
+ public void testDayOfWeek() {
+ GregorianCalendar cal = new GregorianCalendar();
+ long tsInMS = 0L;
+ cal.setTimeInMillis(tsInMS);
+ //cal.setTimeInMillis(System.currentTimeMillis());
+ System.out.println(cal.get(Calendar.DAY_OF_WEEK));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestEagleBase64Wrapper.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestEagleBase64Wrapper.java b/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestEagleBase64Wrapper.java
new file mode 100755
index 0000000..384c274
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/TestEagleBase64Wrapper.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common;
+
+import org.junit.Test;
+
+public class TestEagleBase64Wrapper {
+ @Test
+ public void test(){
+ byte[] b = EagleBase64Wrapper.decode("BgVz-6vkdM8AAbGAf__-trtos5aqSGPod4Q1GwA268vF50iNBgmpmAxLXKkGbxkREWcmOzT3YIx3hDUb");
+ byte[] c = EagleBase64Wrapper.decode("BgVz-6vkdM8AAbGAf__-trtos5aqSGPod4Q1G6pLeJcAATVuADbry8XnSI0GCamYDEtcqQZvGRERZyY7NPdgjHeENRs");
+
+ System.out.println(new String(b));
+ System.out.println(new String(c));
+
+ int hash = "jobType".hashCode();
+ byte b1 = (byte)((hash >> 24) & 0xff);
+ byte b2 = (byte)(((hash << 8) >> 24) & 0xff);
+ byte b3 = (byte)(((hash << 16) >> 24) & 0xff);
+ byte b4 = (byte)(((hash << 24) >> 24) & 0xff);
+
+ System.out.println(b1 + "," + b2 + "," + b3 + "," + b4);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/config/TestEagleConfig.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/config/TestEagleConfig.java b/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/config/TestEagleConfig.java
new file mode 100644
index 0000000..6894b7d
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/test/java/org/apache/eagle/common/config/TestEagleConfig.java
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.eagle.common.config;
+
+import junit.framework.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @since 9/22/15
+ */
+public class TestEagleConfig {
+ private EagleConfig config;
+
+ @Before
+ public void setUp(){
+ System.setProperty("config.resource","test-service-config.conf");
+ config = EagleConfigFactory.load();
+ }
+
+ @Test
+ public void testInit(){
+ Assert.assertEquals("test",config.getEnv());
+ Assert.assertEquals("localhost",config.getServiceHost());
+ Assert.assertEquals(9090,config.getServicePort());
+ Assert.assertEquals("hbase",config.getStorageType());
+ Assert.assertEquals(false,config.isCoprocessorEnabled());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/resources/footer.vm
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/resources/footer.vm b/eagle-core/eagle-query/eagle-common/src/test/resources/footer.vm
index 06c1c0b..36cf012 100755
--- a/eagle-core/eagle-query/eagle-common/src/test/resources/footer.vm
+++ b/eagle-core/eagle-query/eagle-common/src/test/resources/footer.vm
@@ -1,6 +1,4 @@
#**
-
-@author xudshen
@version 1
*#
</td>
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/resources/header.vm
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/resources/header.vm b/eagle-core/eagle-query/eagle-common/src/test/resources/header.vm
index aa801b4..8d5f8b2 100755
--- a/eagle-core/eagle-query/eagle-common/src/test/resources/header.vm
+++ b/eagle-core/eagle-query/eagle-common/src/test/resources/header.vm
@@ -1,5 +1,4 @@
#**
-@author xudshen
@version 1
*#
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/resources/templates/tec_alert.vm
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/resources/templates/tec_alert.vm b/eagle-core/eagle-query/eagle-common/src/test/resources/templates/tec_alert.vm
index c8a9583..192e88f 100755
--- a/eagle-core/eagle-query/eagle-common/src/test/resources/templates/tec_alert.vm
+++ b/eagle-core/eagle-query/eagle-common/src/test/resources/templates/tec_alert.vm
@@ -1,5 +1,4 @@
#**
-@author xudshen
@version 1
*#
#parse("header.vm")
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/resources/templates/test_anomaly_alert.vm
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/resources/templates/test_anomaly_alert.vm b/eagle-core/eagle-query/eagle-common/src/test/resources/templates/test_anomaly_alert.vm
index 5dc9f6a..3d8d61c 100644
--- a/eagle-core/eagle-query/eagle-common/src/test/resources/templates/test_anomaly_alert.vm
+++ b/eagle-core/eagle-query/eagle-common/src/test/resources/templates/test_anomaly_alert.vm
@@ -1,5 +1,4 @@
#**
-@author xinzli@xyz.com
@version 1
*#
#parse("header.vm")
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/resources/test-service-config.conf
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/resources/test-service-config.conf b/eagle-core/eagle-query/eagle-common/src/test/resources/test-service-config.conf
index f3b2ecc..3b5befe 100644
--- a/eagle-core/eagle-query/eagle-common/src/test/resources/test-service-config.conf
+++ b/eagle-core/eagle-query/eagle-common/src/test/resources/test-service-config.conf
@@ -2,14 +2,14 @@ eagle {
timezone = "UTC"
service {
- env="test"
- host="localhost"
- port=9090
- storage-type="hbase"
- table-name-prefixed-with-environment=true
- hbase-zookeeper-quorum="localhost"
- hbase-zookeeper-property-clientPort=2181
- zookeeper-znode-parent="/hbase-unsecure"
- coprocessor-enabled=false
+ env = "test"
+ host = "localhost"
+ port = 9090
+ storage-type = "hbase"
+ table-name-prefixed-with-environment = true
+ hbase-zookeeper-quorum = "localhost"
+ hbase-zookeeper-property-clientPort = 2181
+ zookeeper-znode-parent = "/hbase-unsecure"
+ coprocessor-enabled = false
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-common/src/test/resources/test_embed.png
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/test/resources/test_embed.png b/eagle-core/eagle-query/eagle-common/src/test/resources/test_embed.png
deleted file mode 100644
index 453d13c..0000000
Binary files a/eagle-core/eagle-query/eagle-common/src/test/resources/test_embed.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/eagle/log/base/taggedlog/EntityContext.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/eagle/log/base/taggedlog/EntityContext.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/eagle/log/base/taggedlog/EntityContext.java
deleted file mode 100644
index 4de7c6e..0000000
--- a/eagle-core/eagle-query/eagle-entity-base/src/main/java/eagle/log/base/taggedlog/EntityContext.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.
- */
-package eagle.log.base.taggedlog;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class EntityContext {
- private Map<String, Object> context;
-
- public Map<String, Object> getContext() {
- return context;
- }
-
- public EntityContext() {
- this.context = new HashMap<>();
- }
-
- protected EntityContext(EntityContext context) {
- this.context = new HashMap<>(context.context);
- }
-
- public EntityContext cloneEntity() {
- return new EntityContext(this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/eagle/log/base/taggedlog/NoSuchRowException.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/eagle/log/base/taggedlog/NoSuchRowException.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/eagle/log/base/taggedlog/NoSuchRowException.java
deleted file mode 100644
index 556c85c..0000000
--- a/eagle-core/eagle-query/eagle-entity-base/src/main/java/eagle/log/base/taggedlog/NoSuchRowException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.
- */
-package eagle.log.base.taggedlog;
-
-public class NoSuchRowException extends RuntimeException{
- static final long serialVersionUID = -4538233994503905943L;
-
- public NoSuchRowException(){
- super();
- }
-
- public NoSuchRowException(String s){
- super(s);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/eagle/log/base/taggedlog/RowkeyAPIEntity.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/eagle/log/base/taggedlog/RowkeyAPIEntity.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/eagle/log/base/taggedlog/RowkeyAPIEntity.java
deleted file mode 100644
index 6e62b05..0000000
--- a/eagle-core/eagle-query/eagle-entity-base/src/main/java/eagle/log/base/taggedlog/RowkeyAPIEntity.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.
- */
-package eagle.log.base.taggedlog;
-
-import java.util.Map;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(propOrder = {"success", "exception", "prefixHashCode", "timestamp", "humanTime", "tagNameHashValueHashMap", "fieldNameValueMap"})
-public class RowkeyAPIEntity {
- boolean success;
- String exception;
- int prefixHashCode;
- long timestamp;
- String humanTime;
- Map<Integer, Integer> tagNameHashValueHashMap;
- Map<String, String> fieldNameValueMap;
-
- public boolean isSuccess() {
- return success;
- }
- public void setSuccess(boolean success) {
- this.success = success;
- }
- public String getException() {
- return exception;
- }
- public void setException(String exception) {
- this.exception = exception;
- }
- public String getHumanTime() {
- return humanTime;
- }
- public void setHumanTime(String humanTime) {
- this.humanTime = humanTime;
- }
- public int getPrefixHashCode() {
- return prefixHashCode;
- }
- public void setPrefixHashCode(int prefixHashcode) {
- this.prefixHashCode = prefixHashcode;
- }
- public long getTimestamp() {
- return timestamp;
- }
- public void setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- }
- public Map<Integer, Integer> getTagNameHashValueHashMap() {
- return tagNameHashValueHashMap;
- }
- public void setTagNameHashValueHashMap(
- Map<Integer, Integer> tagNameHashValueHashMap) {
- this.tagNameHashValueHashMap = tagNameHashValueHashMap;
- }
- public Map<String, String> getFieldNameValueMap() {
- return fieldNameValueMap;
- }
- public void setFieldNameValueMap(Map<String, String> fieldNameValueMap) {
- this.fieldNameValueMap = fieldNameValueMap;
- }
-}