eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject [14/55] [abbrv] [partial] incubator-eagle git commit: [EAGLE-46] Rename package name as "org.apache.eagle"
Date Thu, 19 Nov 2015 10:47:21 GMT
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Qualifier.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Qualifier.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Qualifier.java
new file mode 100755
index 0000000..a8fc8d2
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Qualifier.java
@@ -0,0 +1,100 @@
+/*
+ * 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.log.entity.meta;
+
+import org.apache.hadoop.io.Writable;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Qualifier implements Writable{
+	private final static Logger LOG = LoggerFactory.getLogger(Qualifier.class);
+
+	private String displayName;
+	private String qualifierName;
+	private EntitySerDeser<Object> serDeser;
+	@JsonIgnore
+	public EntitySerDeser<Object> getSerDeser() {
+		return serDeser;
+	}
+	public void setSerDeser(EntitySerDeser<Object> serDeser) {
+		this.serDeser = serDeser;
+	}
+	public String getDisplayName() {
+		return displayName;
+	}
+	public void setDisplayName(String displayName) {
+		this.displayName = displayName;
+	}
+	public String getQualifierName() {
+		return qualifierName;
+	}
+	public void setQualifierName(String qualifierName) {
+		this.qualifierName = qualifierName;
+	}
+	
+	public String toString(){
+		StringBuffer sb = new StringBuffer();
+		sb.append("displayName:");
+		sb.append(displayName);
+		sb.append(",");
+		sb.append("qualifierName:");
+		sb.append(qualifierName);
+		sb.append(",");
+		sb.append("serDeser class:");
+		sb.append(serDeser.getClass().getName());
+		return sb.toString();
+	}
+
+	@Override
+	public void write(DataOutput out) throws IOException {
+		out.writeUTF(displayName);
+		out.writeUTF(qualifierName);
+		out.writeUTF(serDeser.getClass().getName());
+	}
+
+	private final static Map<String, EntitySerDeser> _entitySerDeserCache = new HashMap<String,EntitySerDeser>();
+
+	@Override
+	public void readFields(DataInput in) throws IOException {
+		displayName = in.readUTF();
+		qualifierName = in.readUTF();
+		String serDeserClassName = in.readUTF();
+
+		EntitySerDeser _cached = _entitySerDeserCache.get(serDeserClassName);
+		if(_cached != null){
+			this.serDeser = _cached;
+		}else {
+			try {
+				if (LOG.isDebugEnabled()) LOG.debug("Creating new instance for " + serDeserClassName);
+				Class serDeserClass = Class.forName(serDeserClassName);
+				this.serDeser = (EntitySerDeser) serDeserClass.newInstance();
+				_entitySerDeserCache.put(serDeserClassName, this.serDeser);
+			} catch (Exception e) {
+				if (LOG.isDebugEnabled()) {
+					LOG.warn("Class not found for " + serDeserClassName + ": " + e.getMessage(), e);
+				}
+			}
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Service.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Service.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Service.java
new file mode 100644
index 0000000..22d70ed
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Service.java
@@ -0,0 +1,28 @@
+/*
+ * 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.log.entity.meta;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Service {
+	String value() default "";
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/ServicePath.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/ServicePath.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/ServicePath.java
new file mode 100644
index 0000000..8c712d0
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/ServicePath.java
@@ -0,0 +1,34 @@
+/*
+ * 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.log.entity.meta;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This class is for service client for generic entity creation API (entities and metrics)
+ *
+ */
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ServicePath {
+
+    public String path() default "";
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/StringArraySerDeser.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/StringArraySerDeser.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/StringArraySerDeser.java
new file mode 100755
index 0000000..635065b
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/StringArraySerDeser.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.log.entity.meta;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.eagle.common.ByteUtil;
+
+/**
+ * String array entity serializer and deserializer
+ *
+ */
+public class StringArraySerDeser implements EntitySerDeser<String[]> {
+
+	public static final int MAX_STRING_LENGTH = 65535;
+	public static final String UTF_8 = "UTF-8";
+	
+	@Override
+	public String[] deserialize(byte[] bytes) {
+		if(bytes == null || bytes.length < 4)
+			return null;
+		int offset = 0;
+		// get size of int array
+		final int size = ByteUtil.bytesToInt(bytes, offset);
+		offset += 4;
+		final String[] strings = new String[size];
+		try {
+			for(int i = 0; i < size; i++) {
+				final int len = ByteUtil.bytesToInt(bytes, offset);
+				offset += 4;
+				strings[i] = new String(bytes, offset, len, UTF_8);
+				offset += len;
+			}
+		} catch (UnsupportedEncodingException e) {
+			throw new IllegalArgumentException("Invalid byte array");
+		}
+		return strings;
+	}
+	
+	/**
+	 *  size + str1 length + str1 + str2 length + str2 + ...
+	 *   4B        4B         n1B        4B        n2B
+	 *  
+	 * @param obj
+	 * @return
+	 */
+	@Override
+	public byte[] serialize(String[] array) {
+		if(array == null)
+			return null;
+		final int size = array.length;
+		final byte[][] tmp = new byte[size][];
+		int total = 4 + 4 * size;
+		for (int i = 0; i < size; ++i) {
+			try {
+				tmp[i] = array[i].getBytes(UTF_8);
+			} catch (UnsupportedEncodingException e) {
+				throw new IllegalArgumentException("String doesn't support UTF-8 encoding: " + array[i]);
+			}
+			total += tmp[i].length;
+		}
+		final byte[] result = new byte[total];
+		int offset = 0;
+		ByteUtil.intToBytes(size, result, offset);
+		offset += 4;
+		for (int i = 0; i < size; ++i) {
+			ByteUtil.intToBytes(tmp[i].length, result, offset);
+			offset += 4;
+			System.arraycopy(tmp[i], 0, result, offset, tmp[i].length);
+			offset += tmp[i].length;
+		}
+		return result;
+	}
+
+	@Override
+	public Class<String[]> type() {
+		return String[].class;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/StringSerDeser.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/StringSerDeser.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/StringSerDeser.java
new file mode 100755
index 0000000..eef6e4f
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/StringSerDeser.java
@@ -0,0 +1,39 @@
+/*
+ * 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.log.entity.meta;
+
+public class StringSerDeser implements EntitySerDeser<String> {
+
+	public StringSerDeser(){}
+
+	@Override
+	public String deserialize(byte[] bytes){
+		return new String(bytes);
+	}
+	
+	@Override
+	public byte[] serialize(String obj){
+		if(obj == null)
+			return null;
+		return obj.getBytes();
+	}
+
+	@Override
+	public Class<String> type() {
+		return String.class;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Table.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Table.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Table.java
new file mode 100644
index 0000000..ac722cd
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Table.java
@@ -0,0 +1,28 @@
+/*
+ * 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.log.entity.meta;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Table {
+	String value() default "";
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Tags.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Tags.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Tags.java
new file mode 100644
index 0000000..ac9b328
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/Tags.java
@@ -0,0 +1,31 @@
+/*
+ * 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.log.entity.meta;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * specify list of tag names which are used by embracing hbase table
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Tags {
+	String[] value() default {""};
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/TimeSeries.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/TimeSeries.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/TimeSeries.java
new file mode 100644
index 0000000..01023bc
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/meta/TimeSeries.java
@@ -0,0 +1,28 @@
+/*
+ * 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.log.entity.meta;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TimeSeries {
+	boolean value() default true;
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericByRowkeyReader.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericByRowkeyReader.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericByRowkeyReader.java
new file mode 100644
index 0000000..43a7073
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericByRowkeyReader.java
@@ -0,0 +1,78 @@
+/*
+ * 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.log.entity.old;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogObjectMapper;
+import org.apache.eagle.log.entity.InternalLog;
+import org.apache.eagle.common.EagleBase64Wrapper;
+
+public class GenericByRowkeyReader {
+	private static final Logger LOG = LoggerFactory.getLogger(GenericByRowkeyReader.class);
+
+	private TaggedLogObjectMapper mapper;
+	private String table;
+	private String columnFamily;
+	private boolean outputAll;
+	private List<String> outputColumns;
+	private GenericReader.EntityFactory entityFactory;
+	
+	public GenericByRowkeyReader(TaggedLogObjectMapper mapper, GenericReader.EntityFactory entityFactory, String table, String columnFamily, boolean outputAll, List<String> outputColumns){
+		this.mapper = mapper;
+		this.entityFactory = entityFactory;
+		this.table = table;
+		this.columnFamily = columnFamily;
+		this.outputAll = outputAll;
+		this.outputColumns = outputColumns;
+	}
+	
+	public List<TaggedLogAPIEntity> read(List<String> rowkeys) throws IOException{
+		HBaseLogByRowkeyReader reader = new HBaseLogByRowkeyReader(this.table, this.columnFamily, 
+				outputAll, outputColumns);
+		List<TaggedLogAPIEntity> entities = new ArrayList<TaggedLogAPIEntity>();
+		try{
+			reader.open();
+			for(String rowkeyString : rowkeys){
+				byte[] rowkey = EagleBase64Wrapper.decode(rowkeyString);
+				InternalLog log = reader.get(rowkey);
+				TaggedLogAPIEntity entity = entityFactory.create();
+				entities.add(entity);
+				entity.setTags(log.getTags());
+				entity.setTimestamp(log.getTimestamp());
+				entity.setEncodedRowkey(log.getEncodedRowkey());
+				entity.setPrefix(log.getPrefix());
+				Map<String, byte[]> qualifierValues = log.getQualifierValues();
+				mapper.populateQualifierValues(entity, qualifierValues);
+			}
+		}catch(IOException ex){
+			LOG.error("Fail read by rowkey", ex);
+			throw ex;
+		}finally{
+			reader.close();
+		}
+		
+		return entities;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericDeleter.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericDeleter.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericDeleter.java
new file mode 100755
index 0000000..e97b522
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericDeleter.java
@@ -0,0 +1,135 @@
+/*
+ * 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.log.entity.old;
+
+import java.io.IOException;
+import java.util.*;
+
+import org.apache.eagle.common.EagleBase64Wrapper;
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.HBaseInternalLogHelper;
+import org.apache.eagle.log.entity.meta.EntityConstants;
+import org.apache.eagle.log.entity.InternalLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.eagle.log.entity.meta.EntityDefinition;
+import org.apache.eagle.log.entity.meta.EntityDefinitionManager;
+import org.apache.eagle.log.entity.meta.IndexDefinition;
+
+public class GenericDeleter {
+	private static final Logger LOG = LoggerFactory.getLogger(GenericDeleter.class);
+
+	private final HBaseLogDeleter deleter;
+	private final HBaseLogByRowkeyReader reader;
+	
+	
+	public GenericDeleter(EntityDefinition ed) {
+		this(ed.getTable(), ed.getColumnFamily());
+	}
+	
+	public GenericDeleter(String table, String columnFamily) {
+		this.deleter = new HBaseLogDeleter(table, columnFamily);
+		this.reader = new HBaseLogByRowkeyReader(table, columnFamily, true, null);
+	}
+
+    public void deleteByRowkeys(List<byte[]> rowkeys) throws Exception {
+        try {
+            deleter.open();
+            deleter.deleteRowkeys(rowkeys);
+        } catch (IOException e) {
+            LOG.error(e.getMessage(), e);
+            throw e;
+        }
+    }
+
+    public void deleteByEncodedRowkeys(List<String> encodedRowkeys) throws Exception {
+        try {
+            deleter.open();
+            deleter.deleteRowByRowkey(encodedRowkeys);
+        } catch (IOException e) {
+            LOG.error(e.getMessage(), e);
+            throw e;
+        }
+    }
+	
+	public List<String> delete(List<? extends TaggedLogAPIEntity> entities) throws Exception{
+        List<String> encodedRowkey = new LinkedList<String>();
+		try{
+			deleter.open();
+			final Map<Class<? extends TaggedLogAPIEntity>, List<TaggedLogAPIEntity>> entityClassMap = classifyEntities(entities);
+			for (Map.Entry<Class<? extends TaggedLogAPIEntity>, List<TaggedLogAPIEntity>> entry : entityClassMap.entrySet()) {
+				final Class<? extends TaggedLogAPIEntity> clazz = entry.getKey();
+				final List<? extends TaggedLogAPIEntity> entityList = entry.getValue();
+
+				final EntityDefinition entityDef = EntityDefinitionManager.getEntityDefinitionByEntityClass(clazz);
+				// TODO: we should fix this hardcoded prefix hack
+				fixPrefixAndTimestampIssue(entityList, entityDef);
+
+				final List<byte[]> rowkeys = RowkeyHelper.getRowkeysByEntities(entityList, entityDef);
+				// Check index
+				final IndexDefinition[] indexes = entityDef.getIndexes();
+				if (indexes != null && indexes.length > 0) {
+					reader.open();
+					final List<InternalLog> logs = reader.get(rowkeys);
+					final List<TaggedLogAPIEntity> newEntities = HBaseInternalLogHelper.buildEntities(logs, entityDef);
+					for (TaggedLogAPIEntity entity : newEntities) {
+						// Add index rowkeys
+						for (IndexDefinition index : indexes) {
+							final byte[] indexRowkey = index.generateIndexRowkey(entity);
+							rowkeys.add(indexRowkey);
+						}
+					}
+				}
+                for(byte[] rowkey:rowkeys) {
+                    encodedRowkey.add(EagleBase64Wrapper.encodeByteArray2URLSafeString(rowkey));
+                }
+				deleter.deleteRowkeys(rowkeys);
+			}
+		}catch(IOException ioe){
+			LOG.error("Fail writing tagged log", ioe);
+			throw ioe;
+		}finally{
+			deleter.close();
+	 	}
+        return encodedRowkey;
+	}
+
+	private void fixPrefixAndTimestampIssue(List<? extends TaggedLogAPIEntity> entities, EntityDefinition entityDef) {
+		for (TaggedLogAPIEntity e : entities) {
+			e.setPrefix(entityDef.getPrefix());
+			if (!entityDef.isTimeSeries()) {
+				e.setTimestamp(EntityConstants.FIXED_WRITE_TIMESTAMP); // set timestamp to MAX, then actually stored 0
+			}
+		}
+	}
+
+	private Map<Class<? extends TaggedLogAPIEntity>, List<TaggedLogAPIEntity>> classifyEntities(List<? extends TaggedLogAPIEntity> entities) {
+		final Map<Class<? extends TaggedLogAPIEntity>, List<TaggedLogAPIEntity>> result = new 
+				HashMap<Class<? extends TaggedLogAPIEntity>, List<TaggedLogAPIEntity>>();
+		for (TaggedLogAPIEntity entity : entities) {
+			final Class<? extends TaggedLogAPIEntity> clazz = entity.getClass();
+			List<TaggedLogAPIEntity> list = result.get(clazz);
+			if (list == null) {
+				list = new ArrayList<TaggedLogAPIEntity>();
+				result.put(clazz, list);
+			}
+			list.add(entity);
+		}
+		return result;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericReader.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericReader.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericReader.java
new file mode 100644
index 0000000..76e314b
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericReader.java
@@ -0,0 +1,115 @@
+/*
+ * 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.log.entity.old;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.base.taggedlog.TaggedLogObjectMapper;
+import org.apache.eagle.log.entity.InternalLog;
+import org.apache.eagle.common.DateTimeUtil;
+
+public class GenericReader {
+	private static final Logger LOG = LoggerFactory.getLogger(GenericReader.class);
+
+	public interface EntityFactory{
+		public TaggedLogAPIEntity create();
+	}
+	
+	private Schema schema;
+	private EntityFactory entityFactory;
+	private TaggedLogObjectMapper mapper;
+	
+	public GenericReader(TaggedLogObjectMapper mapper, Schema schema, EntityFactory factory){
+		this.mapper = mapper;
+		this.schema = schema;
+		this.entityFactory = factory;
+	}
+	
+	public List<TaggedLogAPIEntity> read(String startTime, 
+			String endTime, List<String> tagNameValues, List<String> outputTags, 
+			List<String> outputFields, String startRowkey, int pageSize) throws Exception{
+		Date start = DateTimeUtil.humanDateToDate(startTime);
+		Date end = DateTimeUtil.humanDateToDate(endTime);
+		
+		// decode the query parameters
+		// TODO should support one tag has multiple tag values
+		Map<String, List<String>> searchTags = new HashMap<String, List<String>>();
+		for(String tagNameValue : tagNameValues){
+			String[] tmp = tagNameValue.split("=");
+			if(tmp == null || tmp.length <=1){
+				continue; // silently ignore this parameter
+			}
+			List<String> tagValues = searchTags.get(tmp[0]);
+			if(tagValues == null){
+				tagValues = new ArrayList<String>();
+				searchTags.put(tmp[0], tagValues);
+			}
+			tagValues.add(tmp[1]);
+		}
+		
+		int numTags = outputTags.size();
+		int numFields = outputFields.size();
+		byte[][] outputQualifiers = new byte[numTags+numFields][];
+		int i = 0;
+		for(String tag : outputTags){
+			outputQualifiers[i++] = tag.getBytes();
+		}
+		for(String field : outputFields){
+			outputQualifiers[i++] = field.getBytes();
+		}
+		// shortcut to avoid read when pageSize=0
+		List<TaggedLogAPIEntity> entities = new ArrayList<TaggedLogAPIEntity>();
+		if(pageSize <= 0){
+			return entities; // return empty entities
+		}
+
+		HBaseLogReader reader = new HBaseLogReader(schema, start, end, searchTags, startRowkey, outputQualifiers);
+		try{
+			reader.open();
+			InternalLog log;
+			int count = 0;
+			while ((log = reader.read()) != null) {
+				TaggedLogAPIEntity entity = entityFactory.create();
+				entity.setTags(log.getTags());
+				entity.setTimestamp(log.getTimestamp());
+				entity.setEncodedRowkey(log.getEncodedRowkey());
+				entity.setPrefix(log.getPrefix());
+				entities.add(entity);
+				
+				Map<String, byte[]> qualifierValues = log.getQualifierValues();
+				mapper.populateQualifierValues(entity, qualifierValues);
+				if(++count == pageSize)
+					break;
+			}
+		}catch(IOException ioe){
+			LOG.error("Fail reading log", ioe);
+			throw ioe;
+		}finally{
+			reader.close();
+		}		
+		return entities;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericWriter.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericWriter.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericWriter.java
new file mode 100644
index 0000000..3d29237
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/GenericWriter.java
@@ -0,0 +1,93 @@
+/*
+ * 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.log.entity.old;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.base.taggedlog.TaggedLogObjectMapper;
+import org.apache.eagle.log.entity.HBaseLogWriter;
+import org.apache.eagle.log.entity.InternalLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.eagle.common.EagleBase64Wrapper;
+
+public class GenericWriter {
+	private static final Logger LOG = LoggerFactory.getLogger(GenericWriter.class);
+
+	private String table;
+	private String columnFamily;
+	private TaggedLogObjectMapper mapper;
+	
+	public GenericWriter(TaggedLogObjectMapper mapper, String table, String columnFamily){
+		this.mapper = mapper;
+		this.table = table;
+		this.columnFamily = columnFamily;
+	}
+	
+	public List<String> write(List<? extends TaggedLogAPIEntity> entities) throws IOException{
+		HBaseLogWriter writer = new HBaseLogWriter(table, columnFamily);
+		List<String> rowkeys = new ArrayList<String>();
+		
+		try{
+			writer.open();
+			for(TaggedLogAPIEntity entity : entities){
+				InternalLog log = new InternalLog();
+				Map<String, String> inputTags = entity.getTags();
+				Map<String, String> tags = new TreeMap<String, String>();
+				for(Map.Entry<String, String> entry : inputTags.entrySet()){
+					tags.put(entry.getKey(), entry.getValue());
+				}
+				log.setTags(tags);
+				log.setTimestamp(entity.getTimestamp());
+				log.setPrefix(entity.getPrefix());
+				log.setQualifierValues(mapper.createQualifierValues(entity));
+				byte[] rowkey  = writer.write(log);
+				rowkeys.add(EagleBase64Wrapper.encodeByteArray2URLSafeString(rowkey));
+			}
+		}catch(IOException ioe){
+			LOG.error("Fail writing tagged log", ioe);
+			throw ioe;
+		}finally{
+			writer.close();
+	 	}
+		return rowkeys;
+	}
+	
+	public void updateByRowkey(List<? extends TaggedLogAPIEntity> entities) throws IOException{
+		HBaseLogWriter writer = new HBaseLogWriter(table, columnFamily);
+		try{
+			writer.open();
+			for(TaggedLogAPIEntity entity : entities){
+				byte[] rowkey = EagleBase64Wrapper.decode(entity.getEncodedRowkey());
+				InternalLog log = new InternalLog();
+				log.setQualifierValues(mapper.createQualifierValues(entity));
+				writer.updateByRowkey(rowkey, log);
+			}
+		}catch(IOException ioe){
+			LOG.error("Fail writing tagged log", ioe);
+			throw ioe;
+		}finally{
+			writer.close();
+	 	}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/HBaseLogByRowkeyReader.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/HBaseLogByRowkeyReader.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/HBaseLogByRowkeyReader.java
new file mode 100644
index 0000000..37e55ac
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/HBaseLogByRowkeyReader.java
@@ -0,0 +1,161 @@
+/*
+ * 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.log.entity.old;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+
+import org.apache.eagle.common.config.EagleConfigFactory;
+import org.apache.eagle.log.base.taggedlog.NoSuchRowException;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.HTableFactory;
+import org.apache.hadoop.hbase.client.HTableInterface;
+import org.apache.hadoop.hbase.client.Result;
+
+import org.apache.eagle.log.entity.InternalLog;
+import org.apache.eagle.common.ByteUtil;
+import org.apache.eagle.common.EagleBase64Wrapper;
+
+/**
+ * Get details of rowkey and qualifiers given a raw rowkey. This function mostly is used for inspecting one row's content 
+ * This only supports single column family, which is mostly used in log application 
+ */
+public class HBaseLogByRowkeyReader implements Closeable{
+	private String table;
+	private String columnFamily;
+	private byte[][] outputQualifiers;
+	private boolean includingAllQualifiers;
+	private HTableInterface tbl;
+	private boolean isOpen;
+	
+	/**
+	 * if includingAllQualifiers is true, then the fourth argument outputQualifiers is ignored
+	 * if includingAllQualifiers is false, then need calculate based on the fourth argument outputQualifiers
+	 */
+	public HBaseLogByRowkeyReader(String table, String columnFamily, boolean includingAllQualifiers, List<String> qualifiers){
+		this.table = table;
+		this.columnFamily = columnFamily;
+		if(qualifiers != null){
+			this.outputQualifiers = new byte[qualifiers.size()][];
+			int i = 0;
+			for(String qualifier : qualifiers){
+				this.outputQualifiers[i++] = qualifier.getBytes();
+			}
+		}
+		this.includingAllQualifiers = includingAllQualifiers;
+	}
+	
+	
+	public void open() throws IOException {
+		if (isOpen)
+			return; // silently return
+		try {
+			tbl = EagleConfigFactory.load().getHTable(this.table);
+		} catch (RuntimeException ex) {
+			throw new IOException(ex);
+		}
+		
+		isOpen = true;
+	}
+
+	/**
+	 * Here all qualifiers' values goes into qualifierValues of InternalLog as given a row, we can't differentiate it's a tag or a field
+	 * @param rowkeys
+	 * @return
+	 * @throws IOException
+	 */
+	public List<InternalLog> get(List<byte[]> rowkeys) throws IOException, NoSuchRowException {
+		final List<Get> gets = createGets(rowkeys);
+		final Result[] results = tbl.get(gets);
+		final List<InternalLog> logs = new ArrayList<InternalLog>();
+		for (Result result : results) {
+			final InternalLog log = buildLog(result);
+			logs.add(log);
+		}
+		return logs;
+	}
+	
+	private List<Get> createGets(List<byte[]> rowkeys) {
+		final List<Get> gets = new ArrayList<Get>();
+		for (byte[] rowkey : rowkeys) {
+			final Get get = createGet(rowkey);
+			gets.add(get);
+		}
+		return gets;
+	}
+
+
+	private Get createGet(byte[] rowkey) {
+		final Get get = new Get(rowkey);
+		byte[] cf = this.columnFamily.getBytes();
+		if(includingAllQualifiers){
+			get.addFamily(cf);
+		}else{
+			for(byte[] outputQualifier : outputQualifiers){
+				get.addColumn(cf, outputQualifier);
+			}
+		}
+		return get;
+	}
+
+
+	/**
+	 * Here all qualifiers' values goes into qualifierValues of InternalLog as given a row, we can't differentiate it's a tag or a field
+	 * @param rowkey
+	 * @return
+	 * @throws IOException
+	 */
+	public InternalLog get(byte[] rowkey) throws IOException, NoSuchRowException{
+		final Get get = createGet(rowkey);
+		final Result result = tbl.get(get);
+		final InternalLog log = buildLog(result);
+		return log;
+	}
+	
+	private InternalLog buildLog(Result result) {
+		final InternalLog log = new InternalLog();
+		final byte[] rowkey = result.getRow();
+		log.setEncodedRowkey(EagleBase64Wrapper.encodeByteArray2URLSafeString(rowkey));
+		long timestamp = ByteUtil.bytesToLong(rowkey, 4);
+		timestamp = Long.MAX_VALUE - timestamp;
+		log.setTimestamp(timestamp);
+		Map<String, byte[]> qualifierValues = new HashMap<String, byte[]>();
+		log.setQualifierValues(qualifierValues);
+		NavigableMap<byte[], byte[]> map = result.getFamilyMap(this.columnFamily.getBytes());
+		if(map == null){
+			throw new NoSuchRowException(EagleBase64Wrapper.encodeByteArray2URLSafeString(rowkey));
+		}
+		for(Map.Entry<byte[], byte[]> entry : map.entrySet()){
+			byte[] qualifier = entry.getKey();
+			byte[] value = entry.getValue();
+			qualifierValues.put(new String(qualifier), value);
+		}
+		return log;
+	}
+
+
+	public void close() throws IOException {
+		if(tbl != null){
+			new HTableFactory().releaseHTableInterface(tbl);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/HBaseLogDeleter.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/HBaseLogDeleter.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/HBaseLogDeleter.java
new file mode 100644
index 0000000..3460949
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/HBaseLogDeleter.java
@@ -0,0 +1,131 @@
+/*
+ * 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.log.entity.old;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.eagle.common.config.EagleConfigFactory;
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.HTableFactory;
+import org.apache.hadoop.hbase.client.HTableInterface;
+
+import org.apache.eagle.log.entity.InternalLog;
+import org.apache.eagle.log.entity.meta.EntityDefinition;
+import org.apache.eagle.common.EagleBase64Wrapper;
+
+public class HBaseLogDeleter implements LogDeleter{
+	private HTableInterface tbl;
+	private String table;
+	private String columnFamily;
+	
+	public HBaseLogDeleter(String table, String columnFamily) {
+		this.table = table;
+		this.columnFamily = columnFamily;
+	}
+	
+	@Override
+	public void open() throws IOException {
+		try{
+			tbl = EagleConfigFactory.load().getHTable(this.table);
+		}catch(RuntimeException ex){
+			throw new IOException(ex);
+		}
+	}
+
+	@Override
+	public void close() throws IOException {
+		if(tbl != null){
+			new HTableFactory().releaseHTableInterface(tbl);
+		}
+	}
+	
+	@Override
+	public void flush() throws IOException{
+		throw new IllegalArgumentException("Not supported flush for hbase delete");
+	}
+	
+	/**
+	 * support delete by constructing a rowkey or by encoded rowkey passed from client
+	 */
+	@Override
+	public void delete(InternalLog log) throws IOException{
+		final byte[] rowkey = RowkeyHelper.getRowkey(log);
+		final Delete delete = createDelete(rowkey);
+		tbl.delete(delete);
+	}
+	
+	public void delete(TaggedLogAPIEntity entity, EntityDefinition entityDef) throws Exception {
+		final byte[] rowkey = RowkeyHelper.getRowkey(entity, entityDef);
+		final Delete delete = createDelete(rowkey);
+		tbl.delete(delete);
+	}
+	
+	/**
+	 * Batch delete
+	 * @param logs
+	 * @throws IOException
+	 */
+	public void delete(List<InternalLog> logs) throws IOException{
+		final List<byte[]> rowkeys = RowkeyHelper.getRowkeysByLogs(logs);
+		deleteRowkeys(rowkeys);
+	}
+
+
+	/**
+	 * Batch delete
+	 * @throws Exception
+	 */
+	public void deleteEntities(List<? extends TaggedLogAPIEntity> entities, EntityDefinition entityDef) throws Exception{
+		final List<byte[]> rowkeys = RowkeyHelper.getRowkeysByEntities(entities, entityDef);
+		deleteRowkeys(rowkeys);
+	}
+	
+	/**
+	 * Batch delete
+	 * @throws IOException
+	 */
+	public void deleteRowkeys(List<byte[]> rowkeys) throws IOException {
+		final List<Delete> deletes = new ArrayList<Delete>(rowkeys.size());
+		for (byte[] rowkey : rowkeys) {
+			final Delete delete = createDelete(rowkey);
+			deletes.add(delete);
+		}
+		tbl.delete(deletes);
+	}
+	
+	@Override
+	public void deleteRowByRowkey(String encodedRowkey) throws IOException{
+		byte[] row = EagleBase64Wrapper.decode(encodedRowkey);
+		final Delete delete = createDelete(row);
+		tbl.delete(delete);
+	}
+
+	public void deleteRowByRowkey(List<String> encodedRowkeys) throws IOException {
+		final List<byte[]> rowkeys = RowkeyHelper.getRowkeysByEncodedRowkeys(encodedRowkeys);
+		deleteRowkeys(rowkeys);
+	}
+	
+	private Delete createDelete(byte[] row) throws IOException{
+		Delete delete = new Delete(row);
+		delete.deleteFamily(columnFamily.getBytes());
+		return delete;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/HBaseLogReader.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/HBaseLogReader.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/HBaseLogReader.java
new file mode 100755
index 0000000..c75b94f
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/HBaseLogReader.java
@@ -0,0 +1,247 @@
+/*
+ * 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.log.entity.old;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.eagle.common.config.EagleConfigFactory;
+import org.apache.eagle.log.entity.InternalLog;
+import org.apache.eagle.log.entity.LogReader;
+import org.apache.hadoop.hbase.client.HTableFactory;
+import org.apache.hadoop.hbase.client.HTableInterface;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
+import org.apache.hadoop.hbase.filter.FilterList;
+import org.apache.hadoop.hbase.filter.RegexStringComparator;
+import org.apache.hadoop.hbase.filter.RowFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.eagle.common.ByteUtil;
+import org.apache.eagle.common.EagleBase64Wrapper;
+
+public class HBaseLogReader implements LogReader {
+	private static Logger LOG = LoggerFactory.getLogger(HBaseLogReader.class);
+
+	protected byte[][] qualifiers;
+	private HTableInterface tbl;
+	private byte[] startKey;
+	private byte[] stopKey;
+	protected Map<String, List<String>> searchTags;
+
+	private ResultScanner rs;
+	private boolean isOpen = false;
+	
+	private Schema schema;
+
+	public HBaseLogReader(Schema schema, Date startTime, Date endTime, 
+			Map<String, List<String>> searchTags, String lastScanKey,
+			byte[][] outputQualifier){
+		this.schema = schema;
+		this.qualifiers = outputQualifier;
+		this.startKey = buildRowKey(schema.getPrefix(), startTime);
+		if (lastScanKey == null) {
+			this.stopKey = buildRowKey(schema.getPrefix(), endTime);
+		} else {
+			// build stop key
+			this.stopKey = EagleBase64Wrapper.decode(lastScanKey);
+			// concat byte 0 to exclude this stopKey
+			this.stopKey = ByteUtil.concat(this.stopKey, new byte[] { 0 });
+		}
+		this.searchTags = searchTags;
+	}
+	
+	/**
+	 * TODO If the required field is null for a row, then this row will not be fetched. That could be a problem for counting
+	 * Need another version of read to strictly get the number of rows which will return all the columns for a column family
+	 */
+	public void open() throws IOException {
+		if (isOpen)
+			return; // silently return
+		try {
+			tbl = EagleConfigFactory.load().getHTable(schema.getTable());
+		} catch (RuntimeException ex) {
+			throw new IOException(ex);
+		}
+
+		String rowkeyRegex = buildRegex2(searchTags);
+		RegexStringComparator regexStringComparator = new RegexStringComparator(
+				rowkeyRegex);
+		regexStringComparator.setCharset(Charset.forName("ISO-8859-1"));
+		RowFilter filter = new RowFilter(CompareOp.EQUAL, regexStringComparator);
+		FilterList filterList = new FilterList();
+		filterList.addFilter(filter);
+		Scan s1 = new Scan();
+		// reverse timestamp, startRow is stopKey, and stopRow is startKey
+		s1.setStartRow(stopKey);
+		s1.setStopRow(startKey);
+		s1.setFilter(filterList);
+		// TODO the # of cached rows should be minimum of (pagesize and 100)
+		s1.setCaching(100);
+		// TODO not optimized for all applications
+		s1.setCacheBlocks(true);
+		// scan specified columnfamily and qualifiers
+		for(byte[] qualifier : qualifiers){
+			s1.addColumn(schema.getColumnFamily().getBytes(), qualifier);
+		}
+		rs = tbl.getScanner(s1);
+		isOpen = true;
+	}
+
+	public void close() throws IOException {
+		if(tbl != null){
+			new HTableFactory().releaseHTableInterface(tbl);
+		}
+		if(rs != null){
+			rs.close();
+		}
+	}
+
+	public void flush() throws IOException {
+		tbl.flushCommits();
+	}
+
+	private byte[] buildRowKey(String appName, Date t){
+		byte[] key = new byte[4 + 8];
+		byte[] b = ByteUtil.intToBytes(appName.hashCode());
+		System.arraycopy(b, 0, key, 0, 4);
+		// reverse timestamp
+		long ts = Long.MAX_VALUE - t.getTime();
+		System.arraycopy(ByteUtil.longToBytes(ts), 0, key, 4, 8);
+		return key;
+	}
+
+	/**
+	 * one search tag may have multiple values which have OR relationship, and relationship between
+	 * different search tags is AND
+	 * the query is like "(TAG1=value11 OR TAG1=value12) AND TAG2=value2"
+	 * @param tags
+	 * @return
+	 */
+	protected String buildRegex2(Map<String, List<String>> tags){
+		// TODO need consider that \E could be part of tag, refer to https://github.com/OpenTSDB/opentsdb/blob/master/src/core/TsdbQuery.java
+		SortedMap<Integer, List<Integer>> tagHash = new TreeMap<Integer, List<Integer>>();
+
+		for(Map.Entry<String, List<String>> entry : tags.entrySet()){
+			String tagName = entry.getKey();
+			List<String> stringValues = entry.getValue();
+			List<Integer> hashValues = new ArrayList<Integer>(1);
+			for(String value : stringValues){
+				hashValues.add(value.hashCode());
+			}
+			tagHash.put(tagName.hashCode(), hashValues);
+		}
+		// <tag1:3><value1:3> ... <tagn:3><valuen:3>
+		StringBuilder sb = new StringBuilder();
+		sb.append("(?s)");
+		sb.append("^(?:.{12})");
+		sb.append("(?:.{").append(8).append("})*"); // for any number of tags
+		for (Map.Entry<Integer, List<Integer>> entry : tagHash.entrySet()) {
+			try {
+				sb.append("\\Q");
+				sb.append(new String(ByteUtil.intToBytes(entry.getKey()), "ISO-8859-1")).append("\\E");
+				List<Integer> hashValues = entry.getValue();
+				sb.append("(?:");
+				boolean first = true;
+				for(Integer value : hashValues){
+					if(!first){
+						sb.append('|');
+					}
+					sb.append("\\Q");
+					sb.append(new String(ByteUtil.intToBytes(value), "ISO-8859-1"));
+					sb.append("\\E");
+					first = false;
+				}
+				sb.append(")");
+				sb.append("(?:.{").append(8).append("})*"); // for any number of tags
+					} catch (Exception ex) {
+						LOG.error("Constructing regex error", ex);
+					}
+				}
+				sb.append("$");
+				if (LOG.isDebugEnabled()) {
+					LOG.debug("Pattern is " + sb.toString());
+				}
+				return sb.toString();
+	}
+	
+	public InternalLog read() throws IOException {
+		if (rs == null)
+			throw new IllegalArgumentException(
+					"ResultScanner must be initialized before reading");
+
+		InternalLog t = null;
+
+		Result r = rs.next();
+		if (r != null) {
+			byte[] row = r.getRow();
+			// skip the first 4 bytes : prefix
+			long timestamp = ByteUtil.bytesToLong(row, 4);
+			// reverse timestamp
+			timestamp = Long.MAX_VALUE - timestamp;
+			int count = 0; 
+			if(qualifiers != null){
+				count = qualifiers.length;
+			}
+			byte[][] values = new byte[count][];
+			Map<String, byte[]> allQualifierValues = new HashMap<String, byte[]>();
+			for (int i = 0; i < count; i++) {
+				// TODO if returned value is null, it means no this column for this row, so why set null to the object?
+				values[i] = r.getValue(schema.getColumnFamily().getBytes(), qualifiers[i]);
+				allQualifierValues.put(new String(qualifiers[i]), values[i]);
+			}
+			t = buildObject(row, timestamp, allQualifierValues);
+		}
+
+		return t;
+	}
+
+	public InternalLog buildObject(byte[] row, long timestamp,
+			Map<String, byte[]> allQualifierValues) {
+		InternalLog alertDetail = new InternalLog();
+		String myRow = EagleBase64Wrapper.encodeByteArray2URLSafeString(row);
+		alertDetail.setEncodedRowkey(myRow);
+		alertDetail.setPrefix(schema.getPrefix());
+		alertDetail.setSearchTags(searchTags);
+		alertDetail.setTimestamp(timestamp);
+
+		Map<String, byte[]> logQualifierValues = new HashMap<String, byte[]>();
+		Map<String, String> logTags = new HashMap<String, String>();
+		for (Map.Entry<String, byte[]> entry : allQualifierValues.entrySet()) {
+			if (schema.isTag(entry.getKey())) {
+				if (entry.getValue() != null) {
+					logTags.put(entry.getKey(), new String(entry.getValue()));
+				}
+			} else {
+				logQualifierValues.put(entry.getKey(),entry.getValue());
+			}
+		}
+		alertDetail.setQualifierValues(logQualifierValues);
+		alertDetail.setTags(logTags);
+		return alertDetail;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/LogDeleter.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/LogDeleter.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/LogDeleter.java
new file mode 100644
index 0000000..c5087e7
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/LogDeleter.java
@@ -0,0 +1,34 @@
+/*
+ * 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.log.entity.old;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+import org.apache.eagle.log.entity.InternalLog;
+
+public interface LogDeleter extends Closeable{
+	public void flush() throws IOException;
+
+	public void open() throws IOException;
+
+	public void close() throws IOException;
+
+	public void delete(InternalLog log) throws IOException;
+	
+	public void deleteRowByRowkey(String encodedRowkey) throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/RowkeyHelper.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/RowkeyHelper.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/RowkeyHelper.java
new file mode 100644
index 0000000..f2bdd15
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/RowkeyHelper.java
@@ -0,0 +1,85 @@
+/*
+ * 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.log.entity.old;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.HBaseInternalLogHelper;
+import org.apache.eagle.log.entity.InternalLog;
+import org.apache.eagle.log.entity.RowkeyBuilder;
+import org.apache.eagle.log.entity.meta.EntityDefinition;
+import org.apache.eagle.common.EagleBase64Wrapper;
+
+public final class RowkeyHelper {
+
+	public static byte[] getRowkey(TaggedLogAPIEntity entity, EntityDefinition entityDef) throws Exception {
+		byte[] rowkey = null;
+		if(entity.getEncodedRowkey() != null && !(entity.getEncodedRowkey().isEmpty())){
+			rowkey = EagleBase64Wrapper.decode(entity.getEncodedRowkey());
+		}else{
+			InternalLog log = HBaseInternalLogHelper.convertToInternalLog(entity, entityDef);
+			rowkey = RowkeyBuilder.buildRowkey(log);
+		}
+		return rowkey;
+	}
+
+	public static List<byte[]> getRowkeysByEntities(List<? extends TaggedLogAPIEntity> entities, EntityDefinition entityDef) throws Exception {
+		final List<byte[]> result = new ArrayList<byte[]>(entities.size());
+		for (TaggedLogAPIEntity entity : entities) {
+			final byte[] rowkey = getRowkey(entity, entityDef);
+			result.add(rowkey);
+		}
+		return result;
+	}
+	
+
+	public static byte[] getRowkey(InternalLog log) {
+		byte[] rowkey = null;
+		if(log.getEncodedRowkey() != null && !(log.getEncodedRowkey().isEmpty())){
+			rowkey = EagleBase64Wrapper.decode(log.getEncodedRowkey());
+		}else{
+			rowkey = RowkeyBuilder.buildRowkey(log);
+		}
+		return rowkey;
+	}
+
+	public static List<byte[]> getRowkeysByLogs(List<InternalLog> logs) {
+		final List<byte[]> result = new ArrayList<byte[]>(logs.size());
+		for (InternalLog log : logs) {
+			final byte[] rowkey = getRowkey(log);
+			result.add(rowkey);
+		}
+		return result;
+	}
+
+	public static byte[] getRowkey(String encodedRowkey) {
+		byte[] rowkey = EagleBase64Wrapper.decode(encodedRowkey);
+		return rowkey;
+	}
+
+	public static List<byte[]> getRowkeysByEncodedRowkeys(List<String> encodedRowkeys) {
+		final List<byte[]> result = new ArrayList<byte[]>(encodedRowkeys.size());
+		for (String encodedRowkey : encodedRowkeys) {
+			byte[] rowkey = EagleBase64Wrapper.decode(encodedRowkey);
+			result.add(rowkey);
+		}
+		return result;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/Schema.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/Schema.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/Schema.java
new file mode 100644
index 0000000..55556bd
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/old/Schema.java
@@ -0,0 +1,24 @@
+/*
+ * 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.log.entity.old;
+
+public interface Schema {
+	public boolean isTag(String qualifier);
+	public String getTable();
+	public String getColumnFamily();
+	public String getPrefix();
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/repo/DefaultEntityRepository.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/repo/DefaultEntityRepository.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/repo/DefaultEntityRepository.java
new file mode 100755
index 0000000..1d0d398
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/repo/DefaultEntityRepository.java
@@ -0,0 +1,34 @@
+/*
+ * 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.log.entity.repo;
+
+import org.apache.eagle.log.entity.MetricMetadataEntity;
+import org.apache.eagle.log.entity.test.TestLogAPIEntity;
+import org.apache.eagle.log.entity.test.TestTimeSeriesAPIEntity;
+
+/**
+ * Default Eagle framework entity repository class.
+ * 
+ *
+ */
+public class DefaultEntityRepository extends EntityRepository {
+	public DefaultEntityRepository() {
+		entitySet.add(MetricMetadataEntity.class);
+		entitySet.add(TestLogAPIEntity.class);
+		entitySet.add(TestTimeSeriesAPIEntity.class);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/repo/EntityRepository.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/repo/EntityRepository.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/repo/EntityRepository.java
new file mode 100644
index 0000000..0c24d30
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/repo/EntityRepository.java
@@ -0,0 +1,56 @@
+/*
+ * 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.log.entity.repo;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.meta.EntitySerDeser;
+
+/**
+ * Entity repository is used to store entity definition class. Each domain should define its own entities. Eagle entity
+ * framework will scan all derived class implementations to get all entity definitions, then register them to EntityDefinitionManager.
+ * 
+ *
+ */
+public abstract class EntityRepository {
+
+	protected Set<Class<? extends TaggedLogAPIEntity>> entitySet = new HashSet<Class<? extends TaggedLogAPIEntity>>();
+	protected Map<Class<?>, EntitySerDeser<?>> serDeserMap = new HashMap<Class<?>, EntitySerDeser<?>>();
+
+	public synchronized Collection<Class<? extends TaggedLogAPIEntity>> getEntitySet() {
+		return new ArrayList<Class<? extends TaggedLogAPIEntity>>(entitySet);
+	}
+	
+	public synchronized Map<Class<?>, EntitySerDeser<?>> getSerDeserMap() {
+		return new HashMap<Class<?>, EntitySerDeser<?>>(serDeserMap);
+	}
+	
+	public synchronized void registerEntity(Class<? extends TaggedLogAPIEntity> clazz) {
+		entitySet.add(clazz);
+	}
+
+	public synchronized void registerSerDeser(Class<?> clazz, EntitySerDeser<?> serDeser) {
+		serDeserMap.put(clazz, serDeser);
+	}
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/repo/EntityRepositoryScanner.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/repo/EntityRepositoryScanner.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/repo/EntityRepositoryScanner.java
new file mode 100644
index 0000000..28f2c73
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/repo/EntityRepositoryScanner.java
@@ -0,0 +1,72 @@
+/*
+ * 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.log.entity.repo;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.meta.EntitySerDeser;
+import net.sf.extcos.ComponentQuery;
+import net.sf.extcos.ComponentScanner;
+
+import org.apache.eagle.log.entity.meta.EntityDefinitionManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class EntityRepositoryScanner {
+
+	private static final Logger LOG = LoggerFactory.getLogger(EntityRepositoryScanner.class);
+
+	public static void scan() throws InstantiationException, IllegalAccessException {
+		// TODO currently extcos 0.3b doesn't support to search packages like "com.*.eagle.*", "org.*.eagle.*". However 0.4b depends on asm-all version 4.0, which is 
+		// conflicted with jersey server 1.8. We should fix it later
+		LOG.info("Scanning all entity repositories with pattern \"eagle.*\"");
+		final ComponentScanner scanner = new ComponentScanner();
+		final Set<Class<?>> classes = scanner.getClasses(new EntityRepoScanQuery() );
+		for (Class<?> entityClass : classes) {
+			LOG.info("Processing entity repository: " + entityClass.getName());
+			if (EntityRepository.class.isAssignableFrom(entityClass)) {
+				EntityRepository repo = (EntityRepository)entityClass.newInstance();
+				addRepo(repo);
+			}
+		}
+	}
+
+	private static void addRepo(EntityRepository repo) {
+		final Map<Class<?>, EntitySerDeser<?>> serDeserMap = repo.getSerDeserMap();
+		for (Map.Entry<Class<?>, EntitySerDeser<?>> entry : serDeserMap.entrySet()) {
+			EntityDefinitionManager.registerSerDeser(entry.getKey(), entry.getValue());
+		}
+		final Collection<Class<? extends TaggedLogAPIEntity>> entityClasses = repo.getEntitySet();
+		for (Class<? extends TaggedLogAPIEntity> clazz : entityClasses) {
+			EntityDefinitionManager.registerEntity(clazz);
+		}
+	}
+
+	public static class EntityRepoScanQuery extends ComponentQuery {
+
+		@Override
+		protected void query() {
+			select().from("eagle").returning(
+			allExtending(EntityRepository.class));
+		}
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/test/TestEntity.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/test/TestEntity.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/test/TestEntity.java
new file mode 100755
index 0000000..402e170
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/test/TestEntity.java
@@ -0,0 +1,107 @@
+/*
+ * 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.log.entity.test;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.meta.Column;
+import org.apache.eagle.log.entity.meta.ColumnFamily;
+import org.apache.eagle.log.entity.meta.TimeSeries;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import org.apache.eagle.log.entity.meta.Prefix;
+import org.apache.eagle.log.entity.meta.Table;
+
+/**
+ * this class is written by customer, but it has some contracts
+ * 0. This class should conform to java bean conventions
+ * 1. Annotate this class with hbase table name
+ * 2. Annotate this class with hbase column family name
+ * 3. Annotate those qualifier fields with column name
+ * 4. Fire property change event for all fields' setter method, where field name is mandatory parameter
+ */
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@Table("alertdetail")
+@ColumnFamily("f")
+@Prefix("hadoop")
+@TimeSeries(true)
+public class TestEntity extends TaggedLogAPIEntity {
+	@Column("remediationID")
+	private String remediationID;
+	@Column("remediationStatus")
+	private String remediationStatus;
+	@Column("c")
+	private long count;
+	@Column("d")
+	private int numHosts;
+	@Column("e")
+	private Long numClusters;
+
+	public Long getNumClusters() {
+		return numClusters;
+	}
+
+	public void setNumClusters(Long numClusters) {
+		this.numClusters = numClusters;
+		_pcs.firePropertyChange("numClusters", null, null);
+	}
+
+	public int getNumHosts() {
+		return numHosts;
+	}
+
+	public void setNumHosts(int numHosts) {
+		this.numHosts = numHosts;
+		_pcs.firePropertyChange("numHosts", null, null);
+	}
+
+	public long getCount() {
+		return count;
+	}
+
+	public void setCount(long count) {
+		this.count = count;
+		_pcs.firePropertyChange("count", null, null);
+	}
+
+	public String getRemediationID() {
+		return remediationID;
+	}
+
+	public void setRemediationID(String remediationID) {
+		this.remediationID = remediationID;
+		_pcs.firePropertyChange("remediationID", null, null);
+	}
+
+	public String getRemediationStatus() {
+		return remediationStatus;
+	}
+
+	public void setRemediationStatus(String remediationStatus) {
+		this.remediationStatus = remediationStatus;
+		_pcs.firePropertyChange("remediationStatus", null, null);
+	}
+	
+	public String toString(){
+		StringBuffer sb = new StringBuffer();
+		sb.append(super.toString());
+		sb.append(", remediationID:");
+		sb.append(remediationID);
+		sb.append(", remediationStatus:");
+		sb.append(remediationStatus);
+		return sb.toString();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/test/TestLogAPIEntity.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/test/TestLogAPIEntity.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/test/TestLogAPIEntity.java
new file mode 100755
index 0000000..ea73f81
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/test/TestLogAPIEntity.java
@@ -0,0 +1,99 @@
+/*
+ * 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.log.entity.test;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.meta.*;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@Table("unittest")
+@ColumnFamily("f")
+@Prefix("entityut")
+@Service("TestLogAPIEntity")
+@TimeSeries(false)
+@Indexes({
+	@Index(name="jobIdIndex1", columns = { "jobID" }, unique = true),
+	@Index(name="jobIdNonIndex2", columns = { "hostname" }, unique = false)
+	})
+public class TestLogAPIEntity extends TaggedLogAPIEntity {
+
+	@Column("a")
+	private int field1;
+	@Column("b")
+	private Integer field2;
+	@Column("c")
+	private long field3;
+	@Column("d")
+	private Long field4;
+	@Column("e")
+	private double field5;
+	@Column("f")
+	private Double field6;
+	@Column("g")
+	private String field7;
+	
+	public int getField1() {
+		return field1;
+	}
+	public void setField1(int field1) {
+		this.field1 = field1;
+		_pcs.firePropertyChange("field1", null, null);
+	}
+	public Integer getField2() {
+		return field2;
+	}
+	public void setField2(Integer field2) {
+		this.field2 = field2;
+		_pcs.firePropertyChange("field2", null, null);
+	}
+	public long getField3() {
+		return field3;
+	}
+	public void setField3(long field3) {
+		this.field3 = field3;
+		_pcs.firePropertyChange("field3", null, null);
+	}
+	public Long getField4() {
+		return field4;
+	}
+	public void setField4(Long field4) {
+		this.field4 = field4;
+		_pcs.firePropertyChange("field4", null, null);
+	}
+	public double getField5() {
+		return field5;
+	}
+	public void setField5(double field5) {
+		this.field5 = field5;
+		_pcs.firePropertyChange("field5", null, null);
+	}
+	public Double getField6() {
+		return field6;
+	}
+	public void setField6(Double field6) {
+		this.field6 = field6;
+		_pcs.firePropertyChange("field6", null, null);
+	}
+	public String getField7() {
+		return field7;
+	}
+	public void setField7(String field7) {
+		this.field7 = field7;
+		_pcs.firePropertyChange("field7", null, null);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/test/TestTimeSeriesAPIEntity.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/test/TestTimeSeriesAPIEntity.java b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/test/TestTimeSeriesAPIEntity.java
new file mode 100755
index 0000000..1205961
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-entity-base/src/main/java/org/apache/eagle/log/entity/test/TestTimeSeriesAPIEntity.java
@@ -0,0 +1,101 @@
+/*
+ * 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.log.entity.test;
+
+import org.apache.eagle.log.entity.meta.ColumnFamily;
+import org.apache.eagle.log.entity.meta.Service;
+import org.apache.eagle.log.entity.meta.Column;
+import org.apache.eagle.log.entity.meta.TimeSeries;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.meta.Prefix;
+import org.apache.eagle.log.entity.meta.Table;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@Table("unittest")
+@ColumnFamily("f")
+@Prefix("testTSEntity")
+@Service("TestTimeSeriesAPIEntity")
+@TimeSeries(true)
+public class TestTimeSeriesAPIEntity extends TaggedLogAPIEntity {
+
+	@Column("a")
+	private int field1;
+	@Column("b")
+	private Integer field2;
+	@Column("c")
+	private long field3;
+	@Column("d")
+	private Long field4;
+	@Column("e")
+	private double field5;
+	@Column("f")
+	private Double field6;
+	@Column("g")
+	private String field7;
+	
+	public int getField1() {
+		return field1;
+	}
+	public void setField1(int field1) {
+		this.field1 = field1;
+		_pcs.firePropertyChange("field1", null, null);
+	}
+	public Integer getField2() {
+		return field2;
+	}
+	public void setField2(Integer field2) {
+		this.field2 = field2;
+		_pcs.firePropertyChange("field2", null, null);
+	}
+	public long getField3() {
+		return field3;
+	}
+	public void setField3(long field3) {
+		this.field3 = field3;
+		_pcs.firePropertyChange("field3", null, null);
+	}
+	public Long getField4() {
+		return field4;
+	}
+	public void setField4(Long field4) {
+		this.field4 = field4;
+		_pcs.firePropertyChange("field4", null, null);
+	}
+	public double getField5() {
+		return field5;
+	}
+	public void setField5(double field5) {
+		this.field5 = field5;
+		_pcs.firePropertyChange("field5", null, null);
+	}
+	public Double getField6() {
+		return field6;
+	}
+	public void setField6(Double field6) {
+		this.field6 = field6;
+		_pcs.firePropertyChange("field6", null, null);
+	}
+	public String getField7() {
+		return field7;
+	}
+	public void setField7(String field7) {
+		this.field7 = field7;
+		_pcs.firePropertyChange("field7", null, null);
+	}
+}


Mime
View raw message