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:32 UTC

[25/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/eagle/common/config/EagleConfigFactory.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/config/EagleConfigFactory.java b/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/config/EagleConfigFactory.java
deleted file mode 100755
index 3c06003..0000000
--- a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/config/EagleConfigFactory.java
+++ /dev/null
@@ -1,183 +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 com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hbase.client.HTablePool;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.TimeZone;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import static eagle.common.config.EagleConfigConstants.*;
-
-public class EagleConfigFactory implements EagleConfig {
-	private static final Logger LOG = LoggerFactory.getLogger(EagleConfigFactory.class);
-
-	private String env;
-	private String zkQuorum;
-	private String zkPort;
-
-    private Configuration hbaseConf;
-	private String eagleServiceHost;
-	private int eagleServicePort;
-    private String storageType;
-    private Config config;
-    private TimeZone timeZone;
-
-    public boolean isCoprocessorEnabled() {
-		return isCoprocessorEnabled;
-	}
-
-	private boolean isCoprocessorEnabled;
-
-	private boolean tableNamePrefixedWithEnv;
-
-	private HTablePool pool;
-	private int hbaseClientScanCacheSize = 1000;
-
-	private ThreadPoolExecutor executor = null;
-
-	private static EagleConfigFactory manager = new EagleConfigFactory();
-
-	private EagleConfigFactory(){
-		init();
-		this.pool = new HTablePool(this.hbaseConf, 10);
-	}
-	
-	public static EagleConfig load(){
-		return manager;
-	}
-	
-	public HTableInterface getHTable(String tableName){
-        return pool.getTable(tableName);
-    }
-
-    private String getString(Config config,String path,String defaultValue){
-        if(config.hasPath(path)){
-            return config.getString(path);
-        }else{
-            return defaultValue;
-        }
-    }
-
-    public String getStorageType() {
-        return storageType;
-    }
-
-    public ThreadPoolExecutor getExecutor() {
-        return executor;
-    }
-
-    private void init(){
-        this.config = ConfigFactory.load();
-        this.timeZone = TimeZone.getTimeZone((config.hasPath(EAGLE_TIME_ZONE)? config.getString(EAGLE_TIME_ZONE):DEFAULT_EAGLE_TIME_ZONE));
-        this.env = config.hasPath(SERVICE_ENV) ? config.getString(SERVICE_ENV):"dev";
-		this.zkQuorum = config.hasPath(SERVICE_HBASE_ZOOKEEPER_QUORUM) ? config.getString(SERVICE_HBASE_ZOOKEEPER_QUORUM):null;
-		this.zkPort = config.hasPath(SERVICE_HBASE_ZOOKEEPER_PROPERTY_CLIENTPORT) ? config.getString(SERVICE_HBASE_ZOOKEEPER_PROPERTY_CLIENTPORT): null;
-        String zkZnodeParent = config.hasPath(SERVICE_ZOOKEEPER_ZNODE_PARENT)? config.getString(SERVICE_ZOOKEEPER_ZNODE_PARENT):DEFAULT_ZOOKEEPER_ZNODE_PARENT;
-		String clientIPCPoolSize = getString(config, SERVICE_HBASE_CLIENT_IPC_POOL_SIZE, "10");
-		this.hbaseConf = HBaseConfiguration.create();
-
-        if (this.zkQuorum != null)
-            this.hbaseConf.set("hbase.zookeeper.quorum", this.zkQuorum);
-
-		if (this.zkPort != null)
-            this.hbaseConf.set("hbase.zookeeper.property.clientPort", this.zkPort);
-
-        if(zkZnodeParent != null)
-            this.hbaseConf.set("zookeeper.znode.parent", zkZnodeParent);
-        else
-            this.hbaseConf.set("zookeeper.znode.parent", DEFAULT_ZOOKEEPER_ZNODE_PARENT);
-
-        this.hbaseConf.set("hbase.client.ipc.pool.size", clientIPCPoolSize);
-
-		this.eagleServiceHost = config.hasPath(SERVICE_HOST) ? config.getString(SERVICE_HOST) : DEFAULT_SERVICE_HOST;
-        this.storageType = config.hasPath(SERVICE_STORAGE_TYPE) ? config.getString(SERVICE_STORAGE_TYPE) : DEFAULT_STORAGE_TYPE;
-        this.isCoprocessorEnabled = config.hasPath(SERVICE_COPROCESSOR_ENABLED) && config.getBoolean(SERVICE_COPROCESSOR_ENABLED);
-		this.eagleServicePort = config.hasPath(SERVICE_PORT) ? config.getInt(SERVICE_PORT) : DEFAULT_SERVICE_PORT;
-        this.tableNamePrefixedWithEnv = config.hasPath(SERVICE_TABLE_NAME_PREFIXED_WITH_ENVIRONMENT) && config.getBoolean(SERVICE_TABLE_NAME_PREFIXED_WITH_ENVIRONMENT);
-        this.hbaseClientScanCacheSize = config.hasPath(SERVICE_HBASE_CLIENT_SCAN_CACHE_SIZE)? config.getInt(SERVICE_HBASE_CLIENT_SCAN_CACHE_SIZE) : hbaseClientScanCacheSize;
-        // initilize eagle service thread pool for parallel execution of hbase scan etc.
-		int threadPoolCoreSize = config.hasPath(SERVICE_THREADPOOL_CORE_SIZE)? config.getInt(SERVICE_THREADPOOL_CORE_SIZE): DEFAULT_THREAD_POOL_CORE_SIZE;
-		int threadPoolMaxSize = config.hasPath(SERVICE_THREADPOOL_MAX_SIZE) ? config.getInt(SERVICE_THREADPOOL_MAX_SIZE) : DEFAULT_THREAD_POOL_MAX_SIZE;
-		long threadPoolShrinkTime = config.hasPath(SERVICE_THREADPOOL_SHRINK_SIZE) ? config.getLong(SERVICE_THREADPOOL_SHRINK_SIZE) : DEFAULT_THREAD_POOL_SHRINK_TIME;
-
-		this.executor = new ThreadPoolExecutor(threadPoolCoreSize, threadPoolMaxSize, threadPoolShrinkTime, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
-
-		LOG.info("Successfully initialized config");
-
-		if(LOG.isDebugEnabled()) {
-			if(this.isCoprocessorEnabled){
-				LOG.debug("Eagle HBase Coprocessor is enabled");
-			}else{
-				LOG.debug("Eagle HBase Coprocessor is disabled");
-			}
-		}
-	}
-
-    @Override
-	public String getZKQuorum(){
-		return this.zkQuorum;
-    }
-
-    @Override
-	public String getZKPort(){
-		return this.zkPort;
-	}
-
-    @Override
-	public String getServiceHost() {
-		return eagleServiceHost;
-	}
-
-    @Override
-	public int getServicePort() {
-		return eagleServicePort;
-	}
-
-    @Override
-	public String getEnv() {
-		return env;
-	}
-
-    @Override
-	public boolean isTableNamePrefixedWithEnvironment(){
-		return this.tableNamePrefixedWithEnv;
-	}
-
-    @Override
-	public int getHBaseClientScanCacheSize(){
-		return this.hbaseClientScanCacheSize;
-	}
-
-    @Override
-    public TimeZone getTimeZone() {
-        return this.timeZone;
-    }
-
-    @Override
-    public Config getConfig() {
-        return this.config;
-    }
-}
\ 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/eagle/common/email/EagleMailClient.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/email/EagleMailClient.java b/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/email/EagleMailClient.java
deleted file mode 100755
index 6d694ad..0000000
--- a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/email/EagleMailClient.java
+++ /dev/null
@@ -1,248 +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.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/eagle/common/metric/AlertContext.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/metric/AlertContext.java b/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/metric/AlertContext.java
deleted file mode 100644
index 8fc1d89..0000000
--- a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/metric/AlertContext.java
+++ /dev/null
@@ -1,66 +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.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/eagle/common/service/HadoopAccountService.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/HadoopAccountService.java b/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/HadoopAccountService.java
deleted file mode 100644
index 6aa4401..0000000
--- a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/HadoopAccountService.java
+++ /dev/null
@@ -1,23 +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.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/eagle/common/service/HadoopUser.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/HadoopUser.java b/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/HadoopUser.java
deleted file mode 100644
index 8c9ae69..0000000
--- a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/HadoopUser.java
+++ /dev/null
@@ -1,44 +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.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/eagle/common/service/LdapService.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/LdapService.java b/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/LdapService.java
deleted file mode 100644
index 009270f..0000000
--- a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/LdapService.java
+++ /dev/null
@@ -1,259 +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.service;
-
-
-import eagle.common.config.EagleConfig;
-import 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/eagle/common/service/POSTResultEntityBase.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/POSTResultEntityBase.java b/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/POSTResultEntityBase.java
deleted file mode 100644
index b792d3c..0000000
--- a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/POSTResultEntityBase.java
+++ /dev/null
@@ -1,42 +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.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/eagle/common/service/TrustAllSSLSocketFactory.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/TrustAllSSLSocketFactory.java b/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/TrustAllSSLSocketFactory.java
deleted file mode 100644
index 0d2214c..0000000
--- a/eagle-core/eagle-query/eagle-common/src/main/java/eagle/common/service/TrustAllSSLSocketFactory.java
+++ /dev/null
@@ -1,94 +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.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/java/org/apache/eagle/common/Base64.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/Base64.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/Base64.java
new file mode 100644
index 0000000..aec84a3
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/Base64.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;
+
+import java.io.UnsupportedEncodingException;
+
+import javax.xml.bind.DatatypeConverter;
+
+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 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/afe86834/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/ByteUtil.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/ByteUtil.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/ByteUtil.java
new file mode 100644
index 0000000..c1d4976
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/ByteUtil.java
@@ -0,0 +1,178 @@
+/*
+ * 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;
+
+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) {
+        int length = 0;
+        for (byte[] array : arrays) {
+            length += array.length;
+        }
+        byte[] result = new byte[length];
+        int pos = 0;
+        for (byte[] array : arrays) {
+            System.arraycopy(array, 0, result, pos, array.length);
+            pos += array.length;
+        }
+        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");
+//    	}
+//    }
+}

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/CircularArrayList.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayList.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayList.java
new file mode 100644
index 0000000..49695e5
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayList.java
@@ -0,0 +1,149 @@
+/*
+ * 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.AbstractList;
+import java.util.RandomAccess;
+
+/**
+ * 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;
+    }
+    
+    public int tail() {
+    	return tail;
+    }
+    
+    public boolean isFull() {
+    	return full;
+    }
+    
+    @Override
+    public void clear() {
+        head = 0;
+        tail = 0;
+        full = false;
+        for (int i = 0; i < buf.length; ++i) {
+        	buf[i] = null;
+        }
+    }
+
+    private int wrapIndex(int i) {
+        int m = i % buf.length;
+        if (m < 0) { // java modulus can be negative
+            throw new IndexOutOfBoundsException();
+        }
+        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) {
+        assert (endIndex > startIndex);
+        for (int i = endIndex - 1; i >= startIndex; i--) {
+            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;
+    }
+  
+    @Override
+    public int size() {
+    	if (full) {
+    		return buf.length;
+    	}
+        return tail - head + (tail < head ? buf.length : 0);
+    }
+  
+    @Override
+    public E get(int i) {
+        if (i < 0 || i >= size()) {
+            throw new IndexOutOfBoundsException();
+        }
+        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;
+    }
+  
+    @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.");
+        }
+        full = (s + 1 == buf.length);
+        if (i < 0 || i > s) {
+            throw new IndexOutOfBoundsException();
+        }
+        tail = wrapIndex(tail + 1);
+        if (i < s) {
+            shiftBlock(i, s);
+        }
+        set(i, e);
+    }
+  
+    @Override
+    public E remove(int i) {
+        int s = size();
+        if (i < 0 || i >= s) {
+            throw new IndexOutOfBoundsException();
+        }
+        final E e = get(i);
+        if (i > 0) {
+            shiftBlock(0, i);
+        }
+    	buf[head] = null;
+        head = wrapIndex(head + 1);
+        full = false;
+        return e;
+    }
+}
\ 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/CircularArrayListSortedSet.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayListSortedSet.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayListSortedSet.java
new file mode 100644
index 0000000..ef47624
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/CircularArrayListSortedSet.java
@@ -0,0 +1,106 @@
+/*
+ * 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.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+public class CircularArrayListSortedSet<E> {
+
+	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 int capacity() {
+        return list.capacity();
+    }
+    
+    public int head() {
+    	return list.head();
+    }
+    
+    public int tail() {
+    	return list.tail();
+    }
+    
+    public boolean isFull() {
+    	return list.isFull();
+    }
+  
+    public void clear() {
+    	list.clear();
+    }
+    
+    public int 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 replace(E e) {
+    	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;
+    }
+  
+    public E remove(int 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;
+    }
+}

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/DateTimeUtil.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/DateTimeUtil.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/DateTimeUtil.java
new file mode 100644
index 0000000..58794ca
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/DateTimeUtil.java
@@ -0,0 +1,138 @@
+/*
+ * 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.apache.eagle.common.config.EagleConfigFactory;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * be aware that SimpleDateFormat instantiation is expensive, so if that's under a tight loop, probably we need
+ * a thread local SimpleDateFormat object
+ */
+public class DateTimeUtil {
+	public static final long ONESECOND = 1L * 1000L;
+	public static final long ONEMINUTE = 1L * 60L * 1000L;
+	public static final long ONEHOUR = 1L * 60L * 60L * 1000L;
+	public static final long ONEDAY = 24L * 60L * 60L * 1000L;
+    private static TimeZone CURRENT_TIME_ZONE = EagleConfigFactory.load().getTimeZone();
+	
+	public static Date humanDateToDate(String date) throws ParseException{
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        sdf.setTimeZone(CURRENT_TIME_ZONE);
+		return sdf.parse(date);
+	}
+	
+	public static String secondsToHumanDate(long seconds){
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        sdf.setTimeZone(CURRENT_TIME_ZONE);
+		Date t = new Date();
+		t.setTime(seconds*1000);
+		return sdf.format(t);
+	}
+	
+	public static String millisecondsToHumanDateWithMilliseconds(long milliseconds){
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
+        sdf.setTimeZone(CURRENT_TIME_ZONE);
+		Date t = new Date();
+		t.setTime(milliseconds);
+		return sdf.format(t);
+	}
+	
+	public static String millisecondsToHumanDateWithSeconds(long milliseconds){
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        sdf.setTimeZone(CURRENT_TIME_ZONE);
+		Date t = new Date();
+		t.setTime(milliseconds);
+		return sdf.format(t);
+	}
+	
+	public static long humanDateToSeconds(String date) throws ParseException{
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        sdf.setTimeZone(CURRENT_TIME_ZONE);
+		Date d = sdf.parse(date);
+		return d.getTime()/1000;
+	}
+	
+	public static long humanDateToMilliseconds(String date) throws ParseException{
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
+        sdf.setTimeZone(CURRENT_TIME_ZONE);
+		Date d = sdf.parse(date);
+		return d.getTime();
+	}
+	
+	
+	public static long humanDateToMillisecondsWithoutException(String date){
+		try{
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
+            sdf.setTimeZone(CURRENT_TIME_ZONE);
+			Date d = sdf.parse(date);
+			return d.getTime();
+		}catch(ParseException ex){
+			return 0L;
+		}
+	}
+	
+	public static long humanDateToSecondsWithoutException(String date){
+		try{
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            sdf.setTimeZone(CURRENT_TIME_ZONE);
+			Date d = sdf.parse(date);
+			return (d.getTime() / 1000);
+		}catch(ParseException ex){
+			return 0L;
+		}
+	}
+	/**
+	 * this could be accurate only when timezone is UTC
+	 * for the timezones other than UTC, there is possibly issue, for example
+	 * assume timezone is GMT+8 in China
+	 * When user time is "2014-07-15 05:00:00", it will be converted to timestamp first, internally it would be  "2014-07-14 21:00:00" in UTC timezone. When rounded down to day, the internal time would 
+	 * be changed to "2014-07-14 00:00:00", and that means the user time is "2014-07-14 08:00:00". But originally user wants to round it to "2014-07-15 00:00:00"
+	 * 
+	 * @param field
+	 * @param timeInMillis the seconds elapsed since 1970-01-01 00:00:00
+	 * @return
+	 */
+	public static long roundDown(int field, long timeInMillis){
+		switch(field){
+			case Calendar.DAY_OF_MONTH:
+			case Calendar.DAY_OF_WEEK:
+			case Calendar.DAY_OF_YEAR:
+				return (timeInMillis - timeInMillis % (24*60*60*1000));
+			case Calendar.HOUR:
+				return (timeInMillis - timeInMillis % (60*60*1000));
+			case Calendar.MINUTE:
+				return (timeInMillis - timeInMillis % (60*1000));
+			case Calendar.SECOND:
+				return (timeInMillis - timeInMillis % (1000));
+			default:
+				return 0L;
+		}
+	}
+
+	public static String format(long milliseconds, String format) {
+		SimpleDateFormat sdf = new SimpleDateFormat(format);
+        sdf.setTimeZone(CURRENT_TIME_ZONE);
+		Date t = new Date();
+		t.setTime(milliseconds);
+		return sdf.format(t);
+	}
+}

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/EagleBase64Wrapper.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/EagleBase64Wrapper.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/EagleBase64Wrapper.java
new file mode 100644
index 0000000..e31ef99
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/EagleBase64Wrapper.java
@@ -0,0 +1,32 @@
+/*
+ * 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.apache.commons.net.util.Base64;
+
+/**
+ * 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);
+	}
+}

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/EagleExceptionWrapper.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/EagleExceptionWrapper.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/EagleExceptionWrapper.java
new file mode 100644
index 0000000..1fc4e85
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/EagleExceptionWrapper.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;
+
+public class EagleExceptionWrapper {
+	private final static int MAX_DEPTH = 10;
+	
+	public static String wrap(Exception ex){
+		return wrap(ex, EagleExceptionWrapper.MAX_DEPTH);
+	}
+	
+	public static String wrap(Exception ex, int maxdepth){
+		int d = maxdepth;
+		if(d <= 0)
+			d = EagleExceptionWrapper.MAX_DEPTH;
+		int index = 0;
+		StringBuffer sb = new StringBuffer();
+		sb.append(ex);
+		sb.append(System.getProperty("line.separator"));
+		for(StackTraceElement element : ex.getStackTrace()){
+			sb.append(element.toString());
+			sb.append(System.getProperty("line.separator"));
+			if(++index >= d)
+				break;
+		}
+		return sb.toString();
+	}
+}

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/Environment.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/Environment.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/Environment.java
new file mode 100644
index 0000000..dd69ed5
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/Environment.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;
+
+public enum Environment {
+	dev,
+	test,
+	prod,
+}

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/OS.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/OS.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/OS.java
new file mode 100644
index 0000000..05e8db1
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/OS.java
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+public class OS {
+
+	private final static String os = System.getProperty("os.name")
+			.toLowerCase();
+
+	public static boolean isWindows() {
+		return (os.indexOf("win") >= 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 isSolaris() {
+		return (os.indexOf("sunos") >= 0);
+	}
+
+}

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/config/EagleConfig.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java
new file mode 100755
index 0000000..658721f
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java
@@ -0,0 +1,55 @@
+/*
+ * 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 com.typesafe.config.Config;
+import org.apache.hadoop.hbase.client.HTableInterface;
+
+import java.util.TimeZone;
+import java.util.concurrent.ThreadPoolExecutor;
+
+public interface EagleConfig {
+
+    boolean isCoprocessorEnabled();
+
+	HTableInterface getHTable(String tableName);
+
+    String getStorageType();
+
+    ThreadPoolExecutor getExecutor();
+
+	String getZKQuorum();
+
+	String getZKPort();
+
+	String getServiceHost();
+
+	int getServicePort();
+
+    String getEnv();
+
+    boolean isTableNamePrefixedWithEnvironment();
+	
+    int getHBaseClientScanCacheSize();
+
+    TimeZone getTimeZone();
+
+    /**
+     * @return root config
+     */
+    Config getConfig();
+}
\ 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/config/EagleConfigConstants.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java
new file mode 100644
index 0000000..f27e71a
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+public final class EagleConfigConstants {
+    public final static String SERVICE_ENV = "eagle.service.env";
+    public final static String SERVICE_HOST = "eagle.service.host";
+    public final static String SERVICE_PORT = "eagle.service.port";
+    public final static String SERVICE_HBASE_ZOOKEEPER_QUORUM = "eagle.service.hbase-zookeeper-quorum";
+    public final static String SERVICE_HBASE_ZOOKEEPER_PROPERTY_CLIENTPORT = "eagle.service.hbase-zookeeper-property-clientPort";
+    public final static String SERVICE_ZOOKEEPER_ZNODE_PARENT = "eagle.service.zookeeper-znode-parent";
+    public final static String SERVICE_HBASE_CLIENT_IPC_POOL_SIZE = "eagle.service.hbase-client-ipc-pool-size";
+    public final static String SERVICE_STORAGE_TYPE = "eagle.service.storage-type";
+    public final static String SERVICE_COPROCESSOR_ENABLED = "eagle.service.coprocessor-enabled";
+    public final static String SERVICE_TABLE_NAME_PREFIXED_WITH_ENVIRONMENT = "eagle.service.table-name-prefixed-with-environment";
+    public final static String SERVICE_HBASE_CLIENT_SCAN_CACHE_SIZE = "eagle.service.hbase-client-scan-cache-size";
+    public final static String SERVICE_THREADPOOL_CORE_SIZE = "eagle.service.threadpool-core-size";
+    public final static String SERVICE_THREADPOOL_MAX_SIZE = "eagle.service.threadpool-max-size";
+    public final static String SERVICE_THREADPOOL_SHRINK_SIZE = "eagle.service.threadpool-shrink-size";
+
+    public final static String EAGLE_TIME_ZONE = "eagle.timezone";
+    public final static String DEFAULT_EAGLE_TIME_ZONE = "UTC";
+
+    public final static int DEFAULT_THREAD_POOL_CORE_SIZE = 10;
+    public final static int DEFAULT_THREAD_POOL_MAX_SIZE = 20;
+    public final static long DEFAULT_THREAD_POOL_SHRINK_TIME = 60000L;
+    public final static String DEFAULT_SERVICE_HOST = "localhost";
+    public final static String DEFAULT_STORAGE_TYPE = "hbase";
+    public final static int DEFAULT_SERVICE_PORT = 8080;
+    public final static String DEFAULT_ZOOKEEPER_ZNODE_PARENT = "/hbase-unsecure";
+
+    public final static String EAGLE_PROPS="eagleProps";
+    public final static String EAGLE_SERVICE = "eagleService";
+    public final static String HOST = "host";
+    public final static String PORT = "port";
+    public final static String USERNAME = "username";
+    public final static String PASSWORD = "password";
+
+    public final static String SITE = "site";
+    public final static String DATA_SOURCE = "dataSource";
+}
\ 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/config/EagleConfigFactory.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java
new file mode 100755
index 0000000..7b82117
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java
@@ -0,0 +1,182 @@
+/*
+ * 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 com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.client.HTableInterface;
+import org.apache.hadoop.hbase.client.HTablePool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.TimeZone;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+public class EagleConfigFactory implements EagleConfig {
+	private static final Logger LOG = LoggerFactory.getLogger(EagleConfigFactory.class);
+
+	private String env;
+	private String zkQuorum;
+	private String zkPort;
+
+    private Configuration hbaseConf;
+	private String eagleServiceHost;
+	private int eagleServicePort;
+    private String storageType;
+    private Config config;
+    private TimeZone timeZone;
+
+    public boolean isCoprocessorEnabled() {
+		return isCoprocessorEnabled;
+	}
+
+	private boolean isCoprocessorEnabled;
+
+	private boolean tableNamePrefixedWithEnv;
+
+	private HTablePool pool;
+	private int hbaseClientScanCacheSize = 1000;
+
+	private ThreadPoolExecutor executor = null;
+
+	private static EagleConfigFactory manager = new EagleConfigFactory();
+
+	private EagleConfigFactory(){
+		init();
+		this.pool = new HTablePool(this.hbaseConf, 10);
+	}
+	
+	public static EagleConfig load(){
+		return manager;
+	}
+	
+	public HTableInterface getHTable(String tableName){
+        return pool.getTable(tableName);
+    }
+
+    private String getString(Config config,String path,String defaultValue){
+        if(config.hasPath(path)){
+            return config.getString(path);
+        }else{
+            return defaultValue;
+        }
+    }
+
+    public String getStorageType() {
+        return storageType;
+    }
+
+    public ThreadPoolExecutor getExecutor() {
+        return executor;
+    }
+
+    private void init(){
+        this.config = ConfigFactory.load();
+        this.timeZone = TimeZone.getTimeZone((config.hasPath(EagleConfigConstants.EAGLE_TIME_ZONE)? config.getString(EagleConfigConstants.EAGLE_TIME_ZONE): EagleConfigConstants.DEFAULT_EAGLE_TIME_ZONE));
+        this.env = config.hasPath(EagleConfigConstants.SERVICE_ENV) ? config.getString(EagleConfigConstants.SERVICE_ENV):"dev";
+		this.zkQuorum = config.hasPath(EagleConfigConstants.SERVICE_HBASE_ZOOKEEPER_QUORUM) ? config.getString(EagleConfigConstants.SERVICE_HBASE_ZOOKEEPER_QUORUM):null;
+		this.zkPort = config.hasPath(EagleConfigConstants.SERVICE_HBASE_ZOOKEEPER_PROPERTY_CLIENTPORT) ? config.getString(EagleConfigConstants.SERVICE_HBASE_ZOOKEEPER_PROPERTY_CLIENTPORT): null;
+        String zkZnodeParent = config.hasPath(EagleConfigConstants.SERVICE_ZOOKEEPER_ZNODE_PARENT)? 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();
+
+        if (this.zkQuorum != null)
+            this.hbaseConf.set("hbase.zookeeper.quorum", this.zkQuorum);
+
+		if (this.zkPort != null)
+            this.hbaseConf.set("hbase.zookeeper.property.clientPort", this.zkPort);
+
+        if(zkZnodeParent != null)
+            this.hbaseConf.set("zookeeper.znode.parent", zkZnodeParent);
+        else
+            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;
+        // 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;
+
+		this.executor = new ThreadPoolExecutor(threadPoolCoreSize, threadPoolMaxSize, threadPoolShrinkTime, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
+
+		LOG.info("Successfully initialized config");
+
+		if(LOG.isDebugEnabled()) {
+			if(this.isCoprocessorEnabled){
+				LOG.debug("Eagle HBase Coprocessor is enabled");
+			}else{
+				LOG.debug("Eagle HBase Coprocessor is disabled");
+			}
+		}
+	}
+
+    @Override
+	public String getZKQuorum(){
+		return this.zkQuorum;
+    }
+
+    @Override
+	public String getZKPort(){
+		return this.zkPort;
+	}
+
+    @Override
+	public String getServiceHost() {
+		return eagleServiceHost;
+	}
+
+    @Override
+	public int getServicePort() {
+		return eagleServicePort;
+	}
+
+    @Override
+	public String getEnv() {
+		return env;
+	}
+
+    @Override
+	public boolean isTableNamePrefixedWithEnvironment(){
+		return this.tableNamePrefixedWithEnv;
+	}
+
+    @Override
+	public int getHBaseClientScanCacheSize(){
+		return this.hbaseClientScanCacheSize;
+	}
+
+    @Override
+    public TimeZone getTimeZone() {
+        return this.timeZone;
+    }
+
+    @Override
+    public Config getConfig() {
+        return this.config;
+    }
+}
\ No newline at end of file