You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@omid.apache.org by ik...@apache.org on 2016/04/21 02:02:44 UTC

[27/52] [abbrv] incubator-omid git commit: Move com.yahoo -> org.apache

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/statemachine/src/main/java/com/yahoo/statemachine/StateMachine.java
----------------------------------------------------------------------
diff --git a/statemachine/src/main/java/com/yahoo/statemachine/StateMachine.java b/statemachine/src/main/java/com/yahoo/statemachine/StateMachine.java
deleted file mode 100644
index a1ff834..0000000
--- a/statemachine/src/main/java/com/yahoo/statemachine/StateMachine.java
+++ /dev/null
@@ -1,256 +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 com.yahoo.statemachine;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Future;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-public class StateMachine {
-
-    private static final Logger LOG = LoggerFactory.getLogger(StateMachine.class);
-
-    private static final String HANDLER_METHOD_NAME = "handleEvent";
-
-    private static ConcurrentHashMap<Class<?>, ConcurrentHashMap<Class<?>, Method>> stateCaches;
-
-    static {
-        stateCaches = new ConcurrentHashMap<>();
-    }
-
-    public static abstract class State {
-
-        protected final Fsm fsm;
-        private final ConcurrentHashMap<Class<?>, Method> handlerCache;
-
-        public State(Fsm fsm) {
-            this.fsm = fsm;
-
-            ConcurrentHashMap<Class<?>, Method> handlerCache = stateCaches.get(getClass());
-            if (handlerCache == null) {
-                handlerCache = new ConcurrentHashMap<>();
-                ConcurrentHashMap<Class<?>, Method> old = stateCaches.putIfAbsent(getClass(), handlerCache);
-                if (old != null) {
-                    handlerCache = old;
-                }
-            }
-            this.handlerCache = handlerCache;
-        }
-
-        private Method findHandlerInternal(Class<?> state, Class<?> e) throws NoSuchMethodException {
-            Method[] methods = state.getMethods();
-            List<Method> candidates = new ArrayList<>();
-            for (Method m : methods) {
-                if (m.getName().equals(HANDLER_METHOD_NAME)
-                        && State.class.isAssignableFrom(m.getReturnType())
-                        && m.getGenericParameterTypes().length == 1) {
-                    candidates.add(m);
-                }
-            }
-
-            Method best = null;
-            for (Method m : candidates) {
-                if (m.getParameterTypes()[0].isAssignableFrom(e)) {
-                    if (best == null) {
-                        best = m;
-                    } else if (best.getParameterTypes()[0]
-                            .isAssignableFrom(m.getParameterTypes()[0])) {
-                        best = m;
-                    }
-                }
-            }
-            if (best != null) {
-                best.setAccessible(true);
-                return best;
-            }
-            throw new NoSuchMethodException("Handler doesn't exist");
-        }
-
-        private Method findHandler(Class<?> event) throws NoSuchMethodException {
-            Method m = handlerCache.get(event);
-            if (m == null) {
-                m = findHandlerInternal(getClass(), event);
-                Method m2 = handlerCache.putIfAbsent(event, m);
-                if (m2 != null) {
-                    m = m2;
-                }
-            }
-            return m;
-        }
-
-        State dispatch(Event e) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
-            return (State) findHandler(e.getClass()).invoke(this, e);
-        }
-
-    }
-
-    public interface Event {
-    }
-
-    public interface Fsm {
-        Fsm newChildFsm();
-
-        void setInitState(State initState);
-
-        void sendEvent(Event e);
-
-        Future<?> sendEvent(Event e, long delay, TimeUnit unit);
-
-        void deferEvent(DeferrableEvent e);
-    }
-
-    public static class FsmImpl implements Fsm {
-        ScheduledExecutorService executor;
-        private State state;
-        private Queue<DeferrableEvent> deferred;
-
-        public FsmImpl(ScheduledExecutorService executor) {
-            this.executor = executor;
-            state = null;
-            deferred = new ArrayDeque<>();
-        }
-
-        private void errorDeferredEvents(Throwable t) {
-            Queue<DeferrableEvent> oldDeferred = deferred;
-            deferred = new ArrayDeque<>();
-
-            for (DeferrableEvent e : oldDeferred) {
-                e.error(new IllegalStateException(t));
-            }
-        }
-
-        @Override
-        public Fsm newChildFsm() {
-            return new FsmImpl(executor);
-        }
-
-        @Override
-        public void setInitState(State initState) {
-            assert (state == null);
-            state = initState;
-        }
-
-        public State getState() {
-            return state;
-        }
-
-        void setState(final State curState, final State newState) {
-            if (curState != state) {
-                LOG.error("FSM-{}: Tried to transition from {} to {}, but current state is {}",
-                          getFsmId(), state, newState, curState);
-                throw new IllegalArgumentException();
-            }
-            state = newState;
-
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("FSM-{}: State transition {} -> {}", getFsmId(), curState, newState);
-            }
-        }
-
-        boolean processEvent(Event e) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("FSM-{}: Received event {}@{} in state {}@{}",
-                          getFsmId(), e.getClass().getSimpleName(),
-                          System.identityHashCode(e),
-                          state.getClass().getSimpleName(),
-                          System.identityHashCode(state));
-            }
-            try {
-                State newState = state.dispatch(e);
-
-                if (newState != state) {
-                    setState(state, newState);
-                    return true;
-                }
-            } catch (Throwable t) {
-                LOG.error("Caught throwable while handling event", t);
-                errorDeferredEvents(t);
-            }
-            return false;
-        }
-
-        class FSMRunnable implements Runnable {
-            final Event e;
-
-            FSMRunnable(Event e) {
-                this.e = e;
-            }
-
-            @Override
-            public void run() {
-                boolean stateChanged = processEvent(e);
-                while (stateChanged) {
-                    stateChanged = false;
-                    Queue<DeferrableEvent> prevDeferred = deferred;
-                    deferred = new ArrayDeque<>();
-                    for (DeferrableEvent d : prevDeferred) {
-                        if (stateChanged) {
-                            deferred.add(d);
-                        } else if (processEvent(d)) {
-                            stateChanged = true;
-                        }
-                    }
-                }
-            }
-        }
-
-        @Override
-        public void sendEvent(final Event e) {
-            executor.submit(new FSMRunnable(e));
-        }
-
-        @Override
-        public Future<?> sendEvent(final Event e, final long delay, final TimeUnit unit) {
-            return executor.schedule(new FSMRunnable(e), delay, unit);
-        }
-
-        @Override
-        public void deferEvent(DeferrableEvent e) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("FSM-{}: deferred {}@{}",
-                          getFsmId(), e.getClass().getSimpleName(), System.identityHashCode(e));
-            }
-            deferred.add(e);
-        }
-
-        int getFsmId() {
-            return System.identityHashCode(this);
-        }
-
-        @Override
-        public void finalize() throws Throwable {
-            super.finalize();
-            LOG.debug("FSM-{}: Finalizing", getFsmId());
-        }
-    }
-
-    public interface DeferrableEvent extends Event {
-        void error(Throwable exception);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/statemachine/src/main/java/com/yahoo/statemachine/StateMachineLogParser.java
----------------------------------------------------------------------
diff --git a/statemachine/src/main/java/com/yahoo/statemachine/StateMachineLogParser.java b/statemachine/src/main/java/com/yahoo/statemachine/StateMachineLogParser.java
deleted file mode 100644
index 7b66d8a..0000000
--- a/statemachine/src/main/java/com/yahoo/statemachine/StateMachineLogParser.java
+++ /dev/null
@@ -1,163 +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 com.yahoo.statemachine;
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class StateMachineLogParser {
-
-    static Pattern fsmPattern = Pattern.compile("FSM-(\\d+):");
-
-    static Map<String, List<String>> getFsmEventMap(BufferedReader f) throws IOException {
-        String s = f.readLine();
-        Map<String, List<String>> map = new HashMap<String, List<String>>();
-        while (s != null) {
-            Matcher m = fsmPattern.matcher(s);
-            if (m.find()) {
-                String key = m.group(1);
-                if (!map.containsKey(key)) {
-                    map.put(key, new ArrayList<String>());
-                }
-                map.get(key).add(s);
-            }
-            s = f.readLine();
-        }
-        return map;
-    }
-
-    static class Tuple {
-        final String state1;
-        final String state2;
-        final String event;
-
-        Tuple(String state1, String event, String state2) {
-            this.state1 = state1;
-            this.state2 = state2;
-            this.event = event;
-        }
-
-        @Override
-        public boolean equals(Object o) {
-            if (o instanceof Tuple) {
-                Tuple t = (Tuple) o;
-                return state1.equals(t.state1)
-                        && state2.equals(t.state2)
-                        && event.equals(t.event);
-            }
-            return false;
-        }
-
-        @Override
-        public int hashCode() {
-            return (state1 + event + state2).hashCode();
-        }
-
-        @Override
-        public String toString() {
-            return state1 + " + " + event + " = " + state2;
-        }
-    }
-
-    static Pattern hashcodePattern = Pattern.compile("(.+)@(.+)");
-    static Pattern subclassPattern = Pattern.compile("(.+)\\$(.+)");
-
-    static String cleanupState(String state) {
-        Matcher m = hashcodePattern.matcher(state);
-        if (m.find()) {
-            state = m.group(1);
-        }
-        m = subclassPattern.matcher(state);
-        if (m.find()) {
-            state = m.group(2);
-        }
-        return state;
-    }
-
-    static Pattern eventPattern = Pattern.compile("Received event (.+)@\\d+ in state (.+)@\\d+");
-    static Pattern transitionPattern = Pattern.compile("State transition (.+) -> (.+)");
-
-    static Set<Tuple> getStateTuples(Map<String, List<String>> fsms) {
-        Set<Tuple> tuples = new HashSet<Tuple>();
-        for (List<String> transitions : fsms.values()) {
-            String currentEvent = null;
-            for (String s : transitions) {
-                //System.err.println(s);
-                Matcher m = eventPattern.matcher(s);
-                if (m.find()) {
-                    currentEvent = m.group(1);
-                    continue;
-                }
-                m = transitionPattern.matcher(s);
-                if (m.find()) {
-                    if (currentEvent == null) {
-                        System.err.println("event is null");
-                    }
-                    String state1 = m.group(1);
-                    String state2 = m.group(2);
-                    tuples.add(new Tuple(cleanupState(state1),
-                            currentEvent,
-                            cleanupState(state2)));
-                    continue;
-                }
-                if (s.contains("deferred")) {
-                    currentEvent = currentEvent + "[deferred]";
-                }
-            }
-        }
-        return tuples;
-    }
-
-    static void drawDotGraph(Set<Tuple> tuples) {
-        Set<String> states = new HashSet<String>();
-        for (Tuple t : tuples) {
-            states.add(t.state1);
-            states.add(t.state2);
-        }
-
-        System.out.println("digraph finite_state_machine {");
-        for (String s : states) {
-            System.out.println("\tnode [ shape = circle ] " + s + ";");
-        }
-        for (Tuple t : tuples) {
-            System.out.println("\t" + t.state1 + " -> " + t.state2 + " [ label = \"" + t.event + "\" ];");
-        }
-        System.out.println("}");
-    }
-
-    public static void main(String[] args) throws Exception {
-        if (args.length == 0) {
-            System.out.println("Usage: StateMachineLogParser <logfile> | dot -Tsvg ");
-            System.exit(-1);
-        }
-        BufferedReader f = new BufferedReader(new InputStreamReader(new FileInputStream(args[0])));
-        Map<String, List<String>> fsms = getFsmEventMap(f);
-        Set<Tuple> tuples = getStateTuples(fsms);
-        drawDotGraph(tuples);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/statemachine/src/main/java/org/apache/statemachine/StateMachine.java
----------------------------------------------------------------------
diff --git a/statemachine/src/main/java/org/apache/statemachine/StateMachine.java b/statemachine/src/main/java/org/apache/statemachine/StateMachine.java
new file mode 100644
index 0000000..184539d
--- /dev/null
+++ b/statemachine/src/main/java/org/apache/statemachine/StateMachine.java
@@ -0,0 +1,256 @@
+/**
+ * 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.statemachine;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+public class StateMachine {
+
+    private static final Logger LOG = LoggerFactory.getLogger(StateMachine.class);
+
+    private static final String HANDLER_METHOD_NAME = "handleEvent";
+
+    private static ConcurrentHashMap<Class<?>, ConcurrentHashMap<Class<?>, Method>> stateCaches;
+
+    static {
+        stateCaches = new ConcurrentHashMap<>();
+    }
+
+    public static abstract class State {
+
+        protected final Fsm fsm;
+        private final ConcurrentHashMap<Class<?>, Method> handlerCache;
+
+        public State(Fsm fsm) {
+            this.fsm = fsm;
+
+            ConcurrentHashMap<Class<?>, Method> handlerCache = stateCaches.get(getClass());
+            if (handlerCache == null) {
+                handlerCache = new ConcurrentHashMap<>();
+                ConcurrentHashMap<Class<?>, Method> old = stateCaches.putIfAbsent(getClass(), handlerCache);
+                if (old != null) {
+                    handlerCache = old;
+                }
+            }
+            this.handlerCache = handlerCache;
+        }
+
+        private Method findHandlerInternal(Class<?> state, Class<?> e) throws NoSuchMethodException {
+            Method[] methods = state.getMethods();
+            List<Method> candidates = new ArrayList<>();
+            for (Method m : methods) {
+                if (m.getName().equals(HANDLER_METHOD_NAME)
+                        && State.class.isAssignableFrom(m.getReturnType())
+                        && m.getGenericParameterTypes().length == 1) {
+                    candidates.add(m);
+                }
+            }
+
+            Method best = null;
+            for (Method m : candidates) {
+                if (m.getParameterTypes()[0].isAssignableFrom(e)) {
+                    if (best == null) {
+                        best = m;
+                    } else if (best.getParameterTypes()[0]
+                            .isAssignableFrom(m.getParameterTypes()[0])) {
+                        best = m;
+                    }
+                }
+            }
+            if (best != null) {
+                best.setAccessible(true);
+                return best;
+            }
+            throw new NoSuchMethodException("Handler doesn't exist");
+        }
+
+        private Method findHandler(Class<?> event) throws NoSuchMethodException {
+            Method m = handlerCache.get(event);
+            if (m == null) {
+                m = findHandlerInternal(getClass(), event);
+                Method m2 = handlerCache.putIfAbsent(event, m);
+                if (m2 != null) {
+                    m = m2;
+                }
+            }
+            return m;
+        }
+
+        State dispatch(Event e) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+            return (State) findHandler(e.getClass()).invoke(this, e);
+        }
+
+    }
+
+    public interface Event {
+    }
+
+    public interface Fsm {
+        Fsm newChildFsm();
+
+        void setInitState(State initState);
+
+        void sendEvent(Event e);
+
+        Future<?> sendEvent(Event e, long delay, TimeUnit unit);
+
+        void deferEvent(DeferrableEvent e);
+    }
+
+    public static class FsmImpl implements Fsm {
+        ScheduledExecutorService executor;
+        private State state;
+        private Queue<DeferrableEvent> deferred;
+
+        public FsmImpl(ScheduledExecutorService executor) {
+            this.executor = executor;
+            state = null;
+            deferred = new ArrayDeque<>();
+        }
+
+        private void errorDeferredEvents(Throwable t) {
+            Queue<DeferrableEvent> oldDeferred = deferred;
+            deferred = new ArrayDeque<>();
+
+            for (DeferrableEvent e : oldDeferred) {
+                e.error(new IllegalStateException(t));
+            }
+        }
+
+        @Override
+        public Fsm newChildFsm() {
+            return new FsmImpl(executor);
+        }
+
+        @Override
+        public void setInitState(State initState) {
+            assert (state == null);
+            state = initState;
+        }
+
+        public State getState() {
+            return state;
+        }
+
+        void setState(final State curState, final State newState) {
+            if (curState != state) {
+                LOG.error("FSM-{}: Tried to transition from {} to {}, but current state is {}",
+                          getFsmId(), state, newState, curState);
+                throw new IllegalArgumentException();
+            }
+            state = newState;
+
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("FSM-{}: State transition {} -> {}", getFsmId(), curState, newState);
+            }
+        }
+
+        boolean processEvent(Event e) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("FSM-{}: Received event {}@{} in state {}@{}",
+                          getFsmId(), e.getClass().getSimpleName(),
+                          System.identityHashCode(e),
+                          state.getClass().getSimpleName(),
+                          System.identityHashCode(state));
+            }
+            try {
+                State newState = state.dispatch(e);
+
+                if (newState != state) {
+                    setState(state, newState);
+                    return true;
+                }
+            } catch (Throwable t) {
+                LOG.error("Caught throwable while handling event", t);
+                errorDeferredEvents(t);
+            }
+            return false;
+        }
+
+        class FSMRunnable implements Runnable {
+            final Event e;
+
+            FSMRunnable(Event e) {
+                this.e = e;
+            }
+
+            @Override
+            public void run() {
+                boolean stateChanged = processEvent(e);
+                while (stateChanged) {
+                    stateChanged = false;
+                    Queue<DeferrableEvent> prevDeferred = deferred;
+                    deferred = new ArrayDeque<>();
+                    for (DeferrableEvent d : prevDeferred) {
+                        if (stateChanged) {
+                            deferred.add(d);
+                        } else if (processEvent(d)) {
+                            stateChanged = true;
+                        }
+                    }
+                }
+            }
+        }
+
+        @Override
+        public void sendEvent(final Event e) {
+            executor.submit(new FSMRunnable(e));
+        }
+
+        @Override
+        public Future<?> sendEvent(final Event e, final long delay, final TimeUnit unit) {
+            return executor.schedule(new FSMRunnable(e), delay, unit);
+        }
+
+        @Override
+        public void deferEvent(DeferrableEvent e) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("FSM-{}: deferred {}@{}",
+                          getFsmId(), e.getClass().getSimpleName(), System.identityHashCode(e));
+            }
+            deferred.add(e);
+        }
+
+        int getFsmId() {
+            return System.identityHashCode(this);
+        }
+
+        @Override
+        public void finalize() throws Throwable {
+            super.finalize();
+            LOG.debug("FSM-{}: Finalizing", getFsmId());
+        }
+    }
+
+    public interface DeferrableEvent extends Event {
+        void error(Throwable exception);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/statemachine/src/main/java/org/apache/statemachine/StateMachineLogParser.java
----------------------------------------------------------------------
diff --git a/statemachine/src/main/java/org/apache/statemachine/StateMachineLogParser.java b/statemachine/src/main/java/org/apache/statemachine/StateMachineLogParser.java
new file mode 100644
index 0000000..15e5fe0
--- /dev/null
+++ b/statemachine/src/main/java/org/apache/statemachine/StateMachineLogParser.java
@@ -0,0 +1,163 @@
+/**
+ * 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.statemachine;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class StateMachineLogParser {
+
+    static Pattern fsmPattern = Pattern.compile("FSM-(\\d+):");
+
+    static Map<String, List<String>> getFsmEventMap(BufferedReader f) throws IOException {
+        String s = f.readLine();
+        Map<String, List<String>> map = new HashMap<String, List<String>>();
+        while (s != null) {
+            Matcher m = fsmPattern.matcher(s);
+            if (m.find()) {
+                String key = m.group(1);
+                if (!map.containsKey(key)) {
+                    map.put(key, new ArrayList<String>());
+                }
+                map.get(key).add(s);
+            }
+            s = f.readLine();
+        }
+        return map;
+    }
+
+    static class Tuple {
+        final String state1;
+        final String state2;
+        final String event;
+
+        Tuple(String state1, String event, String state2) {
+            this.state1 = state1;
+            this.state2 = state2;
+            this.event = event;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o instanceof Tuple) {
+                Tuple t = (Tuple) o;
+                return state1.equals(t.state1)
+                        && state2.equals(t.state2)
+                        && event.equals(t.event);
+            }
+            return false;
+        }
+
+        @Override
+        public int hashCode() {
+            return (state1 + event + state2).hashCode();
+        }
+
+        @Override
+        public String toString() {
+            return state1 + " + " + event + " = " + state2;
+        }
+    }
+
+    static Pattern hashcodePattern = Pattern.compile("(.+)@(.+)");
+    static Pattern subclassPattern = Pattern.compile("(.+)\\$(.+)");
+
+    static String cleanupState(String state) {
+        Matcher m = hashcodePattern.matcher(state);
+        if (m.find()) {
+            state = m.group(1);
+        }
+        m = subclassPattern.matcher(state);
+        if (m.find()) {
+            state = m.group(2);
+        }
+        return state;
+    }
+
+    static Pattern eventPattern = Pattern.compile("Received event (.+)@\\d+ in state (.+)@\\d+");
+    static Pattern transitionPattern = Pattern.compile("State transition (.+) -> (.+)");
+
+    static Set<Tuple> getStateTuples(Map<String, List<String>> fsms) {
+        Set<Tuple> tuples = new HashSet<Tuple>();
+        for (List<String> transitions : fsms.values()) {
+            String currentEvent = null;
+            for (String s : transitions) {
+                //System.err.println(s);
+                Matcher m = eventPattern.matcher(s);
+                if (m.find()) {
+                    currentEvent = m.group(1);
+                    continue;
+                }
+                m = transitionPattern.matcher(s);
+                if (m.find()) {
+                    if (currentEvent == null) {
+                        System.err.println("event is null");
+                    }
+                    String state1 = m.group(1);
+                    String state2 = m.group(2);
+                    tuples.add(new Tuple(cleanupState(state1),
+                            currentEvent,
+                            cleanupState(state2)));
+                    continue;
+                }
+                if (s.contains("deferred")) {
+                    currentEvent = currentEvent + "[deferred]";
+                }
+            }
+        }
+        return tuples;
+    }
+
+    static void drawDotGraph(Set<Tuple> tuples) {
+        Set<String> states = new HashSet<String>();
+        for (Tuple t : tuples) {
+            states.add(t.state1);
+            states.add(t.state2);
+        }
+
+        System.out.println("digraph finite_state_machine {");
+        for (String s : states) {
+            System.out.println("\tnode [ shape = circle ] " + s + ";");
+        }
+        for (Tuple t : tuples) {
+            System.out.println("\t" + t.state1 + " -> " + t.state2 + " [ label = \"" + t.event + "\" ];");
+        }
+        System.out.println("}");
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (args.length == 0) {
+            System.out.println("Usage: StateMachineLogParser <logfile> | dot -Tsvg ");
+            System.exit(-1);
+        }
+        BufferedReader f = new BufferedReader(new InputStreamReader(new FileInputStream(args[0])));
+        Map<String, List<String>> fsms = getFsmEventMap(f);
+        Set<Tuple> tuples = getStateTuples(fsms);
+        drawDotGraph(tuples);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/statemachine/src/test/java/com/yahoo/statemachine/TestStateMachine.java
----------------------------------------------------------------------
diff --git a/statemachine/src/test/java/com/yahoo/statemachine/TestStateMachine.java b/statemachine/src/test/java/com/yahoo/statemachine/TestStateMachine.java
deleted file mode 100644
index 9f90163..0000000
--- a/statemachine/src/test/java/com/yahoo/statemachine/TestStateMachine.java
+++ /dev/null
@@ -1,100 +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 com.yahoo.statemachine;
-
-import com.yahoo.statemachine.StateMachine.Fsm;
-import com.yahoo.statemachine.StateMachine.FsmImpl;
-import com.yahoo.statemachine.StateMachine.State;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Executors;
-
-public class TestStateMachine {
-    private final static Logger LOG = LoggerFactory.getLogger(TestStateMachine.class);
-
-    static class TestEvent implements StateMachine.DeferrableEvent {
-        CountDownLatch latch = new CountDownLatch(1);
-        Throwable t = null;
-        int i = 0;
-
-        public void error(Throwable t) {
-            this.t = t;
-            latch.countDown();
-        }
-
-        public void success(int i) {
-            this.i = i;
-            latch.countDown();
-        }
-
-        public int get() throws InterruptedException, Throwable {
-            latch.await();
-            if (t != null) {
-                throw t;
-            }
-            return i;
-        }
-    }
-
-    static class CompletingState extends State {
-        int completed = 0;
-
-        CompletingState(Fsm fsm) {
-            super(fsm);
-        }
-
-        public State handleEvent(TestEvent e) {
-            e.success(completed++);
-            return this;
-        }
-    }
-
-    static class DeferringState extends State {
-        int count = 0;
-
-        DeferringState(Fsm fsm) {
-            super(fsm);
-        }
-
-        public State handleEvent(TestEvent e) {
-            if (count++ < 5) {
-                fsm.deferEvent(e);
-                return this;
-            } else {
-                fsm.deferEvent(e);
-                return new CompletingState(fsm);
-            }
-        }
-    }
-
-    @Test(timeOut = 60000)
-    public void testOrdering() throws Throwable {
-        Fsm fsm = new FsmImpl(Executors.newSingleThreadScheduledExecutor());
-        fsm.setInitState(new DeferringState(fsm));
-        for (int i = 0; i < 10; i++) {
-            fsm.sendEvent(new TestEvent());
-        }
-        TestEvent te = new TestEvent();
-        fsm.sendEvent(te);
-        Assert.assertEquals(10, te.get());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/statemachine/src/test/java/org/apache/statemachine/TestStateMachine.java
----------------------------------------------------------------------
diff --git a/statemachine/src/test/java/org/apache/statemachine/TestStateMachine.java b/statemachine/src/test/java/org/apache/statemachine/TestStateMachine.java
new file mode 100644
index 0000000..567ec11
--- /dev/null
+++ b/statemachine/src/test/java/org/apache/statemachine/TestStateMachine.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.statemachine;
+
+import org.apache.statemachine.StateMachine.Fsm;
+import org.apache.statemachine.StateMachine.FsmImpl;
+import org.apache.statemachine.StateMachine.State;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
+
+public class TestStateMachine {
+    private final static Logger LOG = LoggerFactory.getLogger(TestStateMachine.class);
+
+    static class TestEvent implements StateMachine.DeferrableEvent {
+        CountDownLatch latch = new CountDownLatch(1);
+        Throwable t = null;
+        int i = 0;
+
+        public void error(Throwable t) {
+            this.t = t;
+            latch.countDown();
+        }
+
+        public void success(int i) {
+            this.i = i;
+            latch.countDown();
+        }
+
+        public int get() throws InterruptedException, Throwable {
+            latch.await();
+            if (t != null) {
+                throw t;
+            }
+            return i;
+        }
+    }
+
+    static class CompletingState extends State {
+        int completed = 0;
+
+        CompletingState(Fsm fsm) {
+            super(fsm);
+        }
+
+        public State handleEvent(TestEvent e) {
+            e.success(completed++);
+            return this;
+        }
+    }
+
+    static class DeferringState extends State {
+        int count = 0;
+
+        DeferringState(Fsm fsm) {
+            super(fsm);
+        }
+
+        public State handleEvent(TestEvent e) {
+            if (count++ < 5) {
+                fsm.deferEvent(e);
+                return this;
+            } else {
+                fsm.deferEvent(e);
+                return new CompletingState(fsm);
+            }
+        }
+    }
+
+    @Test(timeOut = 60000)
+    public void testOrdering() throws Throwable {
+        Fsm fsm = new FsmImpl(Executors.newSingleThreadScheduledExecutor());
+        fsm.setInitState(new DeferringState(fsm));
+        for (int i = 0; i < 10; i++) {
+            fsm.sendEvent(new TestEvent());
+        }
+        TestEvent te = new TestEvent();
+        fsm.sendEvent(te);
+        Assert.assertEquals(10, te.get());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/pom.xml
----------------------------------------------------------------------
diff --git a/timestamp-storage/pom.xml b/timestamp-storage/pom.xml
index 3e8e60e..3d379ad 100644
--- a/timestamp-storage/pom.xml
+++ b/timestamp-storage/pom.xml
@@ -3,7 +3,7 @@
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
-        <groupId>com.yahoo.omid</groupId>
+        <groupId>org.apache.omid</groupId>
         <artifactId>omid</artifactId>
         <version>0.8.1.37-SNAPSHOT</version>
     </parent>
@@ -17,12 +17,12 @@
         <!-- Dependencies on Omid modules -->
 
         <dependency>
-            <groupId>com.yahoo.omid</groupId>
+            <groupId>org.apache.omid</groupId>
             <artifactId>hbase-common</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
-            <groupId>com.yahoo.omid</groupId>
+            <groupId>org.apache.omid</groupId>
             <artifactId>common</artifactId>
             <version>${project.version}</version>
         </dependency>
@@ -116,7 +116,7 @@
             </activation>
             <dependencies>
                 <dependency>
-                    <groupId>com.yahoo.omid</groupId>
+                    <groupId>org.apache.omid</groupId>
                     <artifactId>hbase0-shims</artifactId>
                     <version>${project.version}</version>
                 </dependency>
@@ -127,7 +127,7 @@
             <id>hbase-1</id>
             <dependencies>
                 <dependency>
-                    <groupId>com.yahoo.omid</groupId>
+                    <groupId>org.apache.omid</groupId>
                     <artifactId>hbase1-shims</artifactId>
                     <version>${project.version}</version>
                 </dependency>

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/DefaultHBaseTimestampStorageModule.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/DefaultHBaseTimestampStorageModule.java b/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/DefaultHBaseTimestampStorageModule.java
deleted file mode 100644
index 4d84cc8..0000000
--- a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/DefaultHBaseTimestampStorageModule.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.yahoo.omid.timestamp.storage;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.name.Names;
-import com.yahoo.omid.HBaseConfigModule;
-
-import static com.yahoo.omid.timestamp.storage.HBaseTimestampStorageConfig.DEFAULT_TIMESTAMP_STORAGE_CF_NAME;
-import static com.yahoo.omid.timestamp.storage.HBaseTimestampStorageConfig.DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME;
-
-/**
- * This class is instantiated by the yaml parser.
- * Snake_yaml needs a public POJO style class to work properly with all the setters and getters.
- */
-public class DefaultHBaseTimestampStorageModule extends AbstractModule {
-
-    private String tableName = DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME;
-    private String familyName = DEFAULT_TIMESTAMP_STORAGE_CF_NAME;
-    private String keytab;
-    private String principal;
-
-    @Override
-    public void configure() {
-        bindConstant().annotatedWith(Names.named(HBaseTimestampStorageConfig.TIMESTAMP_STORAGE_TABLE_NAME_KEY)).to(tableName);
-        bindConstant().annotatedWith(Names.named(HBaseTimestampStorageConfig.TIMESTAMP_STORAGE_CF_NAME_KEY)).to(familyName);
-        install(new HBaseConfigModule(principal, keytab));
-        install(new HBaseTimestampStorageModule());
-    }
-
-    // ----------------------------------------------------------------------------------------------------------------
-    // WARNING: Do not remove getters/setters, needed by snake_yaml!
-    // ----------------------------------------------------------------------------------------------------------------
-
-    public String getTableName() {
-        return tableName;
-    }
-
-    public void setTableName(String tableName) {
-        this.tableName = tableName;
-    }
-
-    public String getFamilyName() {
-        return familyName;
-    }
-
-    public void setFamilyName(String familyName) {
-        this.familyName = familyName;
-    }
-
-    public String getPrincipal() {
-        return principal;
-    }
-
-    public void setPrincipal(String principal) {
-        this.principal = principal;
-    }
-
-    public String getKeytab() {
-        return keytab;
-    }
-
-    public void setKeytab(String keytab) {
-        this.keytab = keytab;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/DefaultZKTimestampStorageModule.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/DefaultZKTimestampStorageModule.java b/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/DefaultZKTimestampStorageModule.java
deleted file mode 100644
index 525a2d7..0000000
--- a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/DefaultZKTimestampStorageModule.java
+++ /dev/null
@@ -1,57 +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 com.yahoo.omid.timestamp.storage;
-
-import com.google.inject.AbstractModule;
-
-/**
- * This class is instantiated by the yaml parser.
- * Snake_yaml needs a public POJO style class to work properly with all the setters and getters.
- */
-public class DefaultZKTimestampStorageModule extends AbstractModule {
-
-    private String zkCluster = "localhost:2181";
-    private String namespace = "omid";
-
-    @Override
-    public void configure() {
-        install(new ZKModule(zkCluster, namespace));
-        install(new ZKTimestampStorageModule());
-    }
-
-    // ----------------------------------------------------------------------------------------------------------------
-    // WARNING: Do not remove getters/setters, needed by snake_yaml!
-    // ----------------------------------------------------------------------------------------------------------------
-
-    public String getZkCluster() {
-        return zkCluster;
-    }
-
-    public void setZkCluster(String zkCluster) {
-        this.zkCluster = zkCluster;
-    }
-
-    public String getNamespace() {
-        return namespace;
-    }
-
-    public void setNamespace(String namespace) {
-        this.namespace = namespace;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/HBaseTimestampStorage.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/HBaseTimestampStorage.java b/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/HBaseTimestampStorage.java
deleted file mode 100644
index f56aea4..0000000
--- a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/HBaseTimestampStorage.java
+++ /dev/null
@@ -1,89 +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 com.yahoo.omid.timestamp.storage;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Inject;
-import java.io.IOException;
-
-import static com.google.common.base.Charsets.UTF_8;
-
-/**
- * Stores the max timestamp assigned by the TO in HBase.
- * It's always written non-transactionally in the same row and column
- */
-public class HBaseTimestampStorage implements TimestampStorage {
-
-    private static final long INITIAL_MAX_TS_VALUE = 0;
-
-    private static final Logger LOG = LoggerFactory.getLogger(HBaseTimestampStorage.class);
-
-    // ROW and COLUMN to write the assigned timestamp
-    private static final byte[] TSO_ROW = "MAX_TIMESTAMP_R".getBytes(UTF_8);
-    private static final byte[] TSO_QUALIFIER = "MAX_TIMESTAMP_Q".getBytes(UTF_8);
-
-    private final HTable table;
-    private final byte[] cfName;
-
-    @Inject
-    public HBaseTimestampStorage(Configuration hbaseConfig, HBaseTimestampStorageConfig config) throws IOException {
-        this.table = new HTable(hbaseConfig, config.getTableName());
-        this.cfName = config.getFamilyName().getBytes(UTF_8);
-    }
-
-    @Override
-    public void updateMaxTimestamp(long previousMaxTimestamp, long newMaxTimestamp) throws IOException {
-        if (newMaxTimestamp < 0) {
-            LOG.error("Negative value received for maxTimestamp: {}", newMaxTimestamp);
-            throw new IllegalArgumentException("Negative value received for maxTimestamp" + newMaxTimestamp);
-        }
-        Put put = new Put(TSO_ROW);
-        put.add(cfName, TSO_QUALIFIER, Bytes.toBytes(newMaxTimestamp));
-        byte[] previousVal = null;
-        if (previousMaxTimestamp != INITIAL_MAX_TS_VALUE) {
-            previousVal = Bytes.toBytes(previousMaxTimestamp);
-        }
-        if (!table.checkAndPut(TSO_ROW, cfName, TSO_QUALIFIER, previousVal, put)) {
-            throw new IOException("Previous max timestamp is incorrect");
-        }
-    }
-
-    @Override
-    public long getMaxTimestamp() throws IOException {
-        Get get = new Get(TSO_ROW);
-        get.addColumn(cfName, TSO_QUALIFIER);
-
-        Result result = table.get(get);
-        if (result.containsColumn(cfName, TSO_QUALIFIER)) {
-            return Bytes.toLong(result.getValue(cfName, TSO_QUALIFIER));
-        } else {
-            // This happens for example when a new cluster is created
-            return INITIAL_MAX_TS_VALUE;
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/HBaseTimestampStorageConfig.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/HBaseTimestampStorageConfig.java b/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/HBaseTimestampStorageConfig.java
deleted file mode 100644
index 829201b..0000000
--- a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/HBaseTimestampStorageConfig.java
+++ /dev/null
@@ -1,60 +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 com.yahoo.omid.timestamp.storage;
-
-import com.google.inject.Inject;
-
-import javax.inject.Named;
-
-public class HBaseTimestampStorageConfig {
-
-    public static final String TIMESTAMP_STORAGE_TABLE_NAME_KEY = "omid.timestampstorage.tablename";
-    public static final String TIMESTAMP_STORAGE_CF_NAME_KEY = "omid.timestampstorage.cfname";
-
-    public static final String DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME = "OMID_TIMESTAMP_TABLE";
-    public static final String DEFAULT_TIMESTAMP_STORAGE_CF_NAME = "MAX_TIMESTAMP_CF";
-
-    // ----------------------------------------------------------------------------------------------------------------
-    // Configuration parameters
-    // ----------------------------------------------------------------------------------------------------------------
-
-    private String tableName = DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME;
-    private String familyName = DEFAULT_TIMESTAMP_STORAGE_CF_NAME;
-
-    // ----------------------------------------------------------------------------------------------------------------
-    // Getters and setters
-    // ----------------------------------------------------------------------------------------------------------------
-
-    public String getTableName() {
-        return tableName;
-    }
-
-    @Inject(optional = true)
-    public void setTableName(@Named(TIMESTAMP_STORAGE_TABLE_NAME_KEY) String tableName) {
-        this.tableName = tableName;
-    }
-
-    public String getFamilyName() {
-        return familyName;
-    }
-
-    @Inject(optional = true)
-    public void setFamilyName(@Named(TIMESTAMP_STORAGE_CF_NAME_KEY) String familyName) {
-        this.familyName = familyName;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/HBaseTimestampStorageModule.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/HBaseTimestampStorageModule.java b/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/HBaseTimestampStorageModule.java
deleted file mode 100644
index 1246e43..0000000
--- a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/HBaseTimestampStorageModule.java
+++ /dev/null
@@ -1,36 +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 com.yahoo.omid.timestamp.storage;
-
-import com.google.inject.AbstractModule;
-import org.apache.hadoop.conf.Configuration;
-
-import javax.inject.Singleton;
-
-public class HBaseTimestampStorageModule extends AbstractModule {
-
-    @Override
-    public void configure() {
-
-        requireBinding(Configuration.class);
-        // Timestamp storage creation
-        bind(TimestampStorage.class).to(HBaseTimestampStorage.class).in(Singleton.class);
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/TimestampStorage.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/TimestampStorage.java b/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/TimestampStorage.java
deleted file mode 100644
index 00c92b7..0000000
--- a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/TimestampStorage.java
+++ /dev/null
@@ -1,28 +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 com.yahoo.omid.timestamp.storage;
-
-import java.io.IOException;
-
-public interface TimestampStorage {
-
-    void updateMaxTimestamp(long previousMaxTimestamp, long newMaxTimestamp) throws IOException;
-
-    long getMaxTimestamp() throws IOException;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKModule.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKModule.java b/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKModule.java
deleted file mode 100644
index 57dfe71..0000000
--- a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKModule.java
+++ /dev/null
@@ -1,49 +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 com.yahoo.omid.timestamp.storage;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.yahoo.omid.zk.ZKUtils;
-import org.apache.curator.framework.CuratorFramework;
-
-import javax.inject.Singleton;
-import java.io.IOException;
-
-//TODO:IK: move to common?
-public class ZKModule extends AbstractModule {
-
-    private final String zkCluster;
-    private final String namespace;
-
-    public ZKModule(String zkCluster, String namespace) {
-        this.zkCluster = zkCluster;
-        this.namespace = namespace;
-    }
-
-    @Override
-    public void configure() {
-    }
-
-    @Provides
-    @Singleton
-    CuratorFramework provideInitializedZookeeperClient() throws IOException, InterruptedException {
-        return ZKUtils.initZKClient(zkCluster, namespace, 10);
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKTimestampPaths.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKTimestampPaths.java b/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKTimestampPaths.java
deleted file mode 100644
index 88d0ea0..0000000
--- a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKTimestampPaths.java
+++ /dev/null
@@ -1,28 +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 com.yahoo.omid.timestamp.storage;
-
-public class ZKTimestampPaths {
-
-    public static final String TIMESTAMP_ZNODE = "/omid/timestamp";
-
-    // Avoid instantiation
-    private ZKTimestampPaths() {
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKTimestampStorage.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKTimestampStorage.java b/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKTimestampStorage.java
deleted file mode 100644
index 173b9fa..0000000
--- a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKTimestampStorage.java
+++ /dev/null
@@ -1,90 +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 com.yahoo.omid.timestamp.storage;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.recipes.atomic.AtomicValue;
-import org.apache.curator.framework.recipes.atomic.DistributedAtomicLong;
-import org.apache.curator.retry.RetryNTimes;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.inject.Inject;
-import java.io.IOException;
-
-import static com.yahoo.omid.timestamp.storage.ZKTimestampPaths.TIMESTAMP_ZNODE;
-
-class ZKTimestampStorage implements TimestampStorage {
-
-    private static final Logger LOG = LoggerFactory.getLogger(ZKTimestampStorage.class);
-
-    static final long INITIAL_MAX_TS_VALUE = 0;
-
-    private final DistributedAtomicLong timestamp;
-
-    @Inject
-    public ZKTimestampStorage(CuratorFramework zkClient) throws Exception {
-        LOG.info("ZK Client state {}", zkClient.getState());
-        timestamp = new DistributedAtomicLong(zkClient, TIMESTAMP_ZNODE, new RetryNTimes(3, 1000)); // TODO Configure
-        // this?
-        if (timestamp.initialize(INITIAL_MAX_TS_VALUE)) {
-            LOG.info("Timestamp value in ZNode initialized to {}", INITIAL_MAX_TS_VALUE);
-        }
-    }
-
-    @Override
-    public void updateMaxTimestamp(long previousMaxTimestamp, long newMaxTimestamp) throws IOException {
-
-        if (newMaxTimestamp < 0) {
-            LOG.error("Negative value received for maxTimestamp: {}", newMaxTimestamp);
-            throw new IllegalArgumentException();
-        }
-        if (newMaxTimestamp <= previousMaxTimestamp) {
-            LOG.error("maxTimestamp {} <= previousMaxTimesamp: {}", newMaxTimestamp, previousMaxTimestamp);
-            throw new IllegalArgumentException();
-        }
-        AtomicValue<Long> compareAndSet;
-        try {
-            compareAndSet = timestamp.compareAndSet(previousMaxTimestamp, newMaxTimestamp);
-        } catch (Exception e) {
-            throw new IOException("Problem setting timestamp in ZK", e);
-        }
-        if (!compareAndSet.succeeded()) { // We have to explicitly check for success (See Curator doc)
-            throw new IOException("GetAndSet operation for storing timestamp in ZK did not succeed "
-                    + compareAndSet.preValue() + " " + compareAndSet.postValue());
-        }
-
-    }
-
-    @Override
-    public long getMaxTimestamp() throws IOException {
-
-        AtomicValue<Long> atomicValue;
-        try {
-            atomicValue = timestamp.get();
-        } catch (Exception e) {
-            throw new IOException("Problem getting data from ZK", e);
-        }
-        if (!atomicValue.succeeded()) { // We have to explicitly check for success (See Curator doc)
-            throw new IOException("Get operation to obtain timestamp from ZK did not succeed");
-        }
-        return atomicValue.postValue();
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKTimestampStorageModule.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKTimestampStorageModule.java b/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKTimestampStorageModule.java
deleted file mode 100644
index 02be0ea..0000000
--- a/timestamp-storage/src/main/java/com/yahoo/omid/timestamp/storage/ZKTimestampStorageModule.java
+++ /dev/null
@@ -1,37 +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 com.yahoo.omid.timestamp.storage;
-
-import com.google.inject.AbstractModule;
-import org.apache.curator.framework.CuratorFramework;
-
-import javax.inject.Singleton;
-
-public class ZKTimestampStorageModule extends AbstractModule {
-
-
-    @Override
-    public void configure() {
-
-        requireBinding(CuratorFramework.class);
-        // Timestamp storage creation
-        bind(TimestampStorage.class).to(ZKTimestampStorage.class).in(Singleton.class);
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/DefaultHBaseTimestampStorageModule.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/DefaultHBaseTimestampStorageModule.java b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/DefaultHBaseTimestampStorageModule.java
new file mode 100644
index 0000000..b78dae6
--- /dev/null
+++ b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/DefaultHBaseTimestampStorageModule.java
@@ -0,0 +1,81 @@
+/**
+ * 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.omid.timestamp.storage;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.name.Names;
+import org.apache.omid.HBaseConfigModule;
+
+import static org.apache.omid.timestamp.storage.HBaseTimestampStorageConfig.DEFAULT_TIMESTAMP_STORAGE_CF_NAME;
+import static org.apache.omid.timestamp.storage.HBaseTimestampStorageConfig.DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME;
+
+/**
+ * This class is instantiated by the yaml parser.
+ * Snake_yaml needs a public POJO style class to work properly with all the setters and getters.
+ */
+public class DefaultHBaseTimestampStorageModule extends AbstractModule {
+
+    private String tableName = DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME;
+    private String familyName = DEFAULT_TIMESTAMP_STORAGE_CF_NAME;
+    private String keytab;
+    private String principal;
+
+    @Override
+    public void configure() {
+        bindConstant().annotatedWith(Names.named(HBaseTimestampStorageConfig.TIMESTAMP_STORAGE_TABLE_NAME_KEY)).to(tableName);
+        bindConstant().annotatedWith(Names.named(HBaseTimestampStorageConfig.TIMESTAMP_STORAGE_CF_NAME_KEY)).to(familyName);
+        install(new HBaseConfigModule(principal, keytab));
+        install(new HBaseTimestampStorageModule());
+    }
+
+    // ----------------------------------------------------------------------------------------------------------------
+    // WARNING: Do not remove getters/setters, needed by snake_yaml!
+    // ----------------------------------------------------------------------------------------------------------------
+
+    public String getTableName() {
+        return tableName;
+    }
+
+    public void setTableName(String tableName) {
+        this.tableName = tableName;
+    }
+
+    public String getFamilyName() {
+        return familyName;
+    }
+
+    public void setFamilyName(String familyName) {
+        this.familyName = familyName;
+    }
+
+    public String getPrincipal() {
+        return principal;
+    }
+
+    public void setPrincipal(String principal) {
+        this.principal = principal;
+    }
+
+    public String getKeytab() {
+        return keytab;
+    }
+
+    public void setKeytab(String keytab) {
+        this.keytab = keytab;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/DefaultZKTimestampStorageModule.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/DefaultZKTimestampStorageModule.java b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/DefaultZKTimestampStorageModule.java
new file mode 100644
index 0000000..cdf874a
--- /dev/null
+++ b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/DefaultZKTimestampStorageModule.java
@@ -0,0 +1,57 @@
+/**
+ * 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.omid.timestamp.storage;
+
+import com.google.inject.AbstractModule;
+
+/**
+ * This class is instantiated by the yaml parser.
+ * Snake_yaml needs a public POJO style class to work properly with all the setters and getters.
+ */
+public class DefaultZKTimestampStorageModule extends AbstractModule {
+
+    private String zkCluster = "localhost:2181";
+    private String namespace = "omid";
+
+    @Override
+    public void configure() {
+        install(new ZKModule(zkCluster, namespace));
+        install(new ZKTimestampStorageModule());
+    }
+
+    // ----------------------------------------------------------------------------------------------------------------
+    // WARNING: Do not remove getters/setters, needed by snake_yaml!
+    // ----------------------------------------------------------------------------------------------------------------
+
+    public String getZkCluster() {
+        return zkCluster;
+    }
+
+    public void setZkCluster(String zkCluster) {
+        this.zkCluster = zkCluster;
+    }
+
+    public String getNamespace() {
+        return namespace;
+    }
+
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorage.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorage.java b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorage.java
new file mode 100644
index 0000000..9acb8ba
--- /dev/null
+++ b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorage.java
@@ -0,0 +1,89 @@
+/**
+ * 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.omid.timestamp.storage;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.io.IOException;
+
+import static com.google.common.base.Charsets.UTF_8;
+
+/**
+ * Stores the max timestamp assigned by the TO in HBase.
+ * It's always written non-transactionally in the same row and column
+ */
+public class HBaseTimestampStorage implements TimestampStorage {
+
+    private static final long INITIAL_MAX_TS_VALUE = 0;
+
+    private static final Logger LOG = LoggerFactory.getLogger(HBaseTimestampStorage.class);
+
+    // ROW and COLUMN to write the assigned timestamp
+    private static final byte[] TSO_ROW = "MAX_TIMESTAMP_R".getBytes(UTF_8);
+    private static final byte[] TSO_QUALIFIER = "MAX_TIMESTAMP_Q".getBytes(UTF_8);
+
+    private final HTable table;
+    private final byte[] cfName;
+
+    @Inject
+    public HBaseTimestampStorage(Configuration hbaseConfig, HBaseTimestampStorageConfig config) throws IOException {
+        this.table = new HTable(hbaseConfig, config.getTableName());
+        this.cfName = config.getFamilyName().getBytes(UTF_8);
+    }
+
+    @Override
+    public void updateMaxTimestamp(long previousMaxTimestamp, long newMaxTimestamp) throws IOException {
+        if (newMaxTimestamp < 0) {
+            LOG.error("Negative value received for maxTimestamp: {}", newMaxTimestamp);
+            throw new IllegalArgumentException("Negative value received for maxTimestamp" + newMaxTimestamp);
+        }
+        Put put = new Put(TSO_ROW);
+        put.add(cfName, TSO_QUALIFIER, Bytes.toBytes(newMaxTimestamp));
+        byte[] previousVal = null;
+        if (previousMaxTimestamp != INITIAL_MAX_TS_VALUE) {
+            previousVal = Bytes.toBytes(previousMaxTimestamp);
+        }
+        if (!table.checkAndPut(TSO_ROW, cfName, TSO_QUALIFIER, previousVal, put)) {
+            throw new IOException("Previous max timestamp is incorrect");
+        }
+    }
+
+    @Override
+    public long getMaxTimestamp() throws IOException {
+        Get get = new Get(TSO_ROW);
+        get.addColumn(cfName, TSO_QUALIFIER);
+
+        Result result = table.get(get);
+        if (result.containsColumn(cfName, TSO_QUALIFIER)) {
+            return Bytes.toLong(result.getValue(cfName, TSO_QUALIFIER));
+        } else {
+            // This happens for example when a new cluster is created
+            return INITIAL_MAX_TS_VALUE;
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorageConfig.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorageConfig.java b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorageConfig.java
new file mode 100644
index 0000000..45124ef
--- /dev/null
+++ b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorageConfig.java
@@ -0,0 +1,60 @@
+/**
+ * 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.omid.timestamp.storage;
+
+import com.google.inject.Inject;
+
+import javax.inject.Named;
+
+public class HBaseTimestampStorageConfig {
+
+    public static final String TIMESTAMP_STORAGE_TABLE_NAME_KEY = "omid.timestampstorage.tablename";
+    public static final String TIMESTAMP_STORAGE_CF_NAME_KEY = "omid.timestampstorage.cfname";
+
+    public static final String DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME = "OMID_TIMESTAMP_TABLE";
+    public static final String DEFAULT_TIMESTAMP_STORAGE_CF_NAME = "MAX_TIMESTAMP_CF";
+
+    // ----------------------------------------------------------------------------------------------------------------
+    // Configuration parameters
+    // ----------------------------------------------------------------------------------------------------------------
+
+    private String tableName = DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME;
+    private String familyName = DEFAULT_TIMESTAMP_STORAGE_CF_NAME;
+
+    // ----------------------------------------------------------------------------------------------------------------
+    // Getters and setters
+    // ----------------------------------------------------------------------------------------------------------------
+
+    public String getTableName() {
+        return tableName;
+    }
+
+    @Inject(optional = true)
+    public void setTableName(@Named(TIMESTAMP_STORAGE_TABLE_NAME_KEY) String tableName) {
+        this.tableName = tableName;
+    }
+
+    public String getFamilyName() {
+        return familyName;
+    }
+
+    @Inject(optional = true)
+    public void setFamilyName(@Named(TIMESTAMP_STORAGE_CF_NAME_KEY) String familyName) {
+        this.familyName = familyName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorageModule.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorageModule.java b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorageModule.java
new file mode 100644
index 0000000..4cae8b1
--- /dev/null
+++ b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/HBaseTimestampStorageModule.java
@@ -0,0 +1,36 @@
+/**
+ * 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.omid.timestamp.storage;
+
+import com.google.inject.AbstractModule;
+import org.apache.hadoop.conf.Configuration;
+
+import javax.inject.Singleton;
+
+public class HBaseTimestampStorageModule extends AbstractModule {
+
+    @Override
+    public void configure() {
+
+        requireBinding(Configuration.class);
+        // Timestamp storage creation
+        bind(TimestampStorage.class).to(HBaseTimestampStorage.class).in(Singleton.class);
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/TimestampStorage.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/TimestampStorage.java b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/TimestampStorage.java
new file mode 100644
index 0000000..f976e83
--- /dev/null
+++ b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/TimestampStorage.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.omid.timestamp.storage;
+
+import java.io.IOException;
+
+public interface TimestampStorage {
+
+    void updateMaxTimestamp(long previousMaxTimestamp, long newMaxTimestamp) throws IOException;
+
+    long getMaxTimestamp() throws IOException;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/ZKModule.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/ZKModule.java b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/ZKModule.java
new file mode 100644
index 0000000..18ddcd6
--- /dev/null
+++ b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/ZKModule.java
@@ -0,0 +1,49 @@
+/**
+ * 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.omid.timestamp.storage;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import org.apache.omid.zk.ZKUtils;
+import org.apache.curator.framework.CuratorFramework;
+
+import javax.inject.Singleton;
+import java.io.IOException;
+
+//TODO:IK: move to common?
+public class ZKModule extends AbstractModule {
+
+    private final String zkCluster;
+    private final String namespace;
+
+    public ZKModule(String zkCluster, String namespace) {
+        this.zkCluster = zkCluster;
+        this.namespace = namespace;
+    }
+
+    @Override
+    public void configure() {
+    }
+
+    @Provides
+    @Singleton
+    CuratorFramework provideInitializedZookeeperClient() throws IOException, InterruptedException {
+        return ZKUtils.initZKClient(zkCluster, namespace, 10);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/9cd856c6/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/ZKTimestampPaths.java
----------------------------------------------------------------------
diff --git a/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/ZKTimestampPaths.java b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/ZKTimestampPaths.java
new file mode 100644
index 0000000..7b60a40
--- /dev/null
+++ b/timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/ZKTimestampPaths.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.omid.timestamp.storage;
+
+public class ZKTimestampPaths {
+
+    public static final String TIMESTAMP_ZNODE = "/omid/timestamp";
+
+    // Avoid instantiation
+    private ZKTimestampPaths() {
+    }
+
+}