zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [39/51] [partial] zookeeper git commit: ZOOKEEPER-3032: MAVEN MIGRATION - move java server, client
Date Fri, 05 Oct 2018 12:26:32 GMT
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/jmx/ManagedUtil.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/jmx/ManagedUtil.java b/src/java/main/org/apache/zookeeper/jmx/ManagedUtil.java
deleted file mode 100644
index 43451b0..0000000
--- a/src/java/main/org/apache/zookeeper/jmx/ManagedUtil.java
+++ /dev/null
@@ -1,120 +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 org.apache.zookeeper.jmx;
-
-import java.util.Enumeration;
-
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Shared utilities
- */
-public class ManagedUtil {
-    private static final Logger LOG = LoggerFactory.getLogger(ManagedUtil.class);
-
-    private static final boolean isLog4jJmxEnabled() {
-        boolean enabled = false;
-
-        try {
-            Class.forName("org.apache.log4j.spi.LoggerRepository");
-
-            if (Boolean.getBoolean("zookeeper.jmx.log4j.disable") == true) {
-                LOG.info("Log4j found but jmx support is disabled.");
-            } else {
-                enabled = true;
-                LOG.info("Log4j found with jmx enabled.");
-            }
-
-        } catch (ClassNotFoundException e) {
-            LOG.info("Log4j not found.");
-        }
-
-        return enabled;
-    }
-
-
-    /**
-     * Register the log4j JMX mbeans. Set environment variable
-     * "zookeeper.jmx.log4j.disable" to true to disable registration.
-     * @see http://logging.apache.org/log4j/1.2/apidocs/index.html?org/apache/log4j/jmx/package-summary.html
-     * @throws JMException if registration fails
-     */
-    @SuppressWarnings("rawtypes")
-    public static void registerLog4jMBeans() throws JMException {
-        if (isLog4jJmxEnabled()) {
-            LOG.debug("registerLog4jMBeans()");
-            MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer();
-
-            try {
-                // Create and Register the top level Log4J MBean
-                // org.apache.log4j.jmx.HierarchyDynamicMBean hdm = new org.apache.log4j.jmx.HierarchyDynamicMBean();
-                Object hdm = Class.forName("org.apache.log4j.jmx.HierarchyDynamicMBean").getDeclaredConstructor().newInstance();
-
-                ObjectName mbo = new ObjectName("log4j:hiearchy=default");
-                mbs.registerMBean(hdm, mbo);
-
-                // Add the root logger to the Hierarchy MBean
-                // org.apache.log4j.Logger rootLogger =
-                // org.apache.log4j.Logger.getRootLogger();
-                Object rootLogger = Class.forName("org.apache.log4j.Logger")
-                        .getMethod("getRootLogger", (Class<?>[]) null)
-                        .invoke(null, (Object[]) null);
-
-                // hdm.addLoggerMBean(rootLogger.getName());
-                Object rootLoggerName = rootLogger.getClass()
-                        .getMethod("getName", (Class<?>[]) null)
-                        .invoke(rootLogger, (Object[]) null);
-                hdm.getClass().getMethod("addLoggerMBean", String.class)
-                        .invoke(hdm, rootLoggerName);
-
-                // Get each logger from the Log4J Repository and add it to the
-                // Hierarchy MBean created above.
-                // org.apache.log4j.spi.LoggerRepository r =
-                // org.apache.log4j.LogManager.getLoggerRepository();
-                Object r = Class.forName("org.apache.log4j.LogManager")
-                        .getMethod("getLoggerRepository", (Class<?>[]) null)
-                        .invoke(null, (Object[]) null);
-
-                // Enumeration enumer = r.getCurrentLoggers();
-                Enumeration enumer = (Enumeration) r.getClass()
-                        .getMethod("getCurrentLoggers", (Class<?>[]) null)
-                        .invoke(r, (Object[]) null);
-
-                while (enumer.hasMoreElements()) {
-                    Object logger = enumer.nextElement();
-                    // hdm.addLoggerMBean(logger.getName());
-                    Object loggerName = logger.getClass()
-                            .getMethod("getName", (Class<?>[]) null)
-                            .invoke(logger, (Object[]) null);
-                    hdm.getClass().getMethod("addLoggerMBean", String.class)
-                            .invoke(hdm, loggerName);
-                }
-            } catch (Exception e) {
-                LOG.error("Problems while registering log4j jmx beans!", e);
-                throw new JMException(e.toString());
-            }
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/jmx/ZKMBeanInfo.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/jmx/ZKMBeanInfo.java b/src/java/main/org/apache/zookeeper/jmx/ZKMBeanInfo.java
deleted file mode 100644
index 1e87d92..0000000
--- a/src/java/main/org/apache/zookeeper/jmx/ZKMBeanInfo.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 org.apache.zookeeper.jmx;
-
-/**
- * Zookeeper MBean info interface. MBeanRegistry uses the interface to generate
- * JMX object name.
- */
-public interface ZKMBeanInfo {
-    /**
-     * @return a string identifying the MBean 
-     */
-    public String getName();
-    /**
-     * If isHidden returns true, the MBean won't be registered with MBean server,
-     * and thus won't be available for management tools. Used for grouping MBeans.
-     * @return true if the MBean is hidden.
-     */
-    public boolean isHidden();
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/metrics/Counter.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/metrics/Counter.java b/src/java/main/org/apache/zookeeper/metrics/Counter.java
deleted file mode 100644
index f11717a..0000000
--- a/src/java/main/org/apache/zookeeper/metrics/Counter.java
+++ /dev/null
@@ -1,50 +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 org.apache.zookeeper.metrics;
-
-/**
- * A counter refers to a value which can only increase.
- * Usually the value is reset when the process starts.
- */
-public interface Counter {
-
-    /**
-     * Increment the value by one.
-     * <p>This method is thread safe, The MetricsProvider will take care of synchronization.</p>
-     */
-    default void inc() {
-        inc(1);
-    }
-
-    /**
-     * Increment the value by a given amount.
-     * <p>This method is thread safe, The MetricsProvider will take care of synchronization.</p>
-     *
-     * @param delta amount to increment, this cannot be a negative number.
-     */
-    void inc(long delta);
-
-    /**
-     * Get the current value held by the counter.
-     * <p>This method is thread safe, The MetricsProvider will take care of synchronization.</p>
-     *
-     * @return the current value
-     */
-    long get();
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/metrics/Gauge.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/metrics/Gauge.java b/src/java/main/org/apache/zookeeper/metrics/Gauge.java
deleted file mode 100644
index fb8fd67..0000000
--- a/src/java/main/org/apache/zookeeper/metrics/Gauge.java
+++ /dev/null
@@ -1,35 +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 org.apache.zookeeper.metrics;
-
-/**
- * A Gauge is an application provided object which will be called by the framework in order to sample the value
- * of an integer value.
- */
-public interface Gauge {
-
-    /**
-     * Returns the current value associated with this gauge.
-     * The MetricsProvider will call this callback without taking care of synchronization, it is up to the application
-     * to handle thread safety.
-     *
-     * @return the current value for the gauge
-     */
-    long get();
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/metrics/MetricsContext.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/metrics/MetricsContext.java b/src/java/main/org/apache/zookeeper/metrics/MetricsContext.java
deleted file mode 100644
index f095e91..0000000
--- a/src/java/main/org/apache/zookeeper/metrics/MetricsContext.java
+++ /dev/null
@@ -1,71 +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 org.apache.zookeeper.metrics;
-
-/**
- * A MetricsContext is like a namespace for metrics.
- * Each component/submodule will have its own MetricsContext.
- * <p>In some cases it is possible to have a separate MetricsContext
- * for each instance of a component, for instance on the server side
- * a possible usecase it to gather metrics for every other peer.
- * </p>
- * <p>
- * Contexts are organized in a hierarchy.
- * </p>
- *
- */
-public interface MetricsContext {
-
-    /**
-     * Returns a sub context.
-     *
-     * @param name the name of the subcontext
-     *
-     * @return a new metrics context.
-     */
-    MetricsContext getContext(String name);
-
-    /**
-     * Returns a counter.
-     *
-     * @param name
-     * @return the counter identified by name in this context.
-     */
-    Counter getCounter(String name);
-
-    /**
-     * Registers an user provided {@link Gauge} which will be called by the MetricsProvider in order to sample
-     * an integer value.
-     *
-     * @param name unique name of the Gauge in this context
-     * @param gauge the implementation of the Gauge
-     *
-     * @return true if the Gauge was successfully registered, false if the Gauge was already registered.
-     */
-    boolean registerGauge(String name, Gauge gauge);
-
-    /**
-     * Returns a summary.
-     *
-     * @param name
-     * @return the summary identified by name in this context.
-     */
-    Summary getSummary(String name);
-
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/metrics/MetricsProvider.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/metrics/MetricsProvider.java b/src/java/main/org/apache/zookeeper/metrics/MetricsProvider.java
deleted file mode 100644
index 16e9e0d..0000000
--- a/src/java/main/org/apache/zookeeper/metrics/MetricsProvider.java
+++ /dev/null
@@ -1,64 +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 org.apache.zookeeper.metrics;
-
-import java.util.Properties;
-
-/**
- * A MetricsProvider is a system which collects Metrics and publishes current values to external facilities.
- *
- * The system will create an instance of the configured class using the default constructor, which must be public.<br>
- * After the instantiation of the provider, the system will call {@link #configure(java.util.Map) } in order to provide configuration,
- * and then when the system is ready to work it will call {@link #start() }.
- * <br>
- * Providers can be used both on ZooKeeper servers and on ZooKeeper clients.
- */
-public interface MetricsProvider {
-
-    /**
-     * Configure the provider.
-     *
-     * @param configuration the configuration.
-     *
-     * @throws MetricsProviderLifeCycleException in case of invalid configuration.
-     */
-    void configure(Properties configuration) throws MetricsProviderLifeCycleException;
-
-    /**
-     * Start the provider.
-     * For instance such method will start a network endpoint.
-     *
-     * @throws MetricsProviderLifeCycleException in case of failure
-     */
-    void start() throws MetricsProviderLifeCycleException;
-
-    /**
-     * Provides access to the root context.
-     *
-     * @return the root context
-     */
-    MetricsContext getRootContext();
-
-    /**
-     * Releases resources held by the provider.<br>
-     * This method must not throw exceptions.<br>
-     * This method can be called more than once.
-     */
-    void stop();
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/metrics/MetricsProviderLifeCycleException.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/metrics/MetricsProviderLifeCycleException.java b/src/java/main/org/apache/zookeeper/metrics/MetricsProviderLifeCycleException.java
deleted file mode 100644
index 809ead3..0000000
--- a/src/java/main/org/apache/zookeeper/metrics/MetricsProviderLifeCycleException.java
+++ /dev/null
@@ -1,45 +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 org.apache.zookeeper.metrics;
-
-/**
- * A generic exception thrown during the licecycle of a MetricsProvider.
- * <p>These exception will prevent the system from booting.</p>
- * <p>Normally these exception will be ignored during shutdown.</p>
- */
-public class MetricsProviderLifeCycleException extends Exception {
-
-    private static final long serialVersionUID = 1L;
-
-    public MetricsProviderLifeCycleException() {
-    }
-
-    public MetricsProviderLifeCycleException(String message) {
-        super(message);
-    }
-
-    public MetricsProviderLifeCycleException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public MetricsProviderLifeCycleException(Throwable cause) {
-        super(cause);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/metrics/Summary.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/metrics/Summary.java b/src/java/main/org/apache/zookeeper/metrics/Summary.java
deleted file mode 100644
index 8b882ac..0000000
--- a/src/java/main/org/apache/zookeeper/metrics/Summary.java
+++ /dev/null
@@ -1,35 +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 org.apache.zookeeper.metrics;
-
-/**
- * Summaries track the size and number of events.
- * They are able to publish minumum, maximum, average values, depending on the capabilities of the MetricsProvider.
- */
-public interface Summary {
-
-     /**
-      * Register a value.
-      * <p>This method is thread safe, The MetricsProvider will take care of synchronization.</p>
-      *
-      * @param value current value
-      */
-     void registerValue(long value);
-
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/metrics/impl/MetricsProviderBootstrap.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/metrics/impl/MetricsProviderBootstrap.java b/src/java/main/org/apache/zookeeper/metrics/impl/MetricsProviderBootstrap.java
deleted file mode 100644
index 85716b2..0000000
--- a/src/java/main/org/apache/zookeeper/metrics/impl/MetricsProviderBootstrap.java
+++ /dev/null
@@ -1,50 +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 org.apache.zookeeper.metrics.impl;
-
-import java.util.Properties;
-import org.apache.zookeeper.metrics.MetricsProvider;
-import org.apache.zookeeper.metrics.MetricsProviderLifeCycleException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Utility for bootstrap process of MetricsProviders
- */
-public abstract class MetricsProviderBootstrap {
-
-    private static final Logger LOG = LoggerFactory.getLogger(MetricsProviderBootstrap.class);
-
-    public static MetricsProvider startMetricsProvider(String metricsProviderClassName, Properties configuration)
-            throws MetricsProviderLifeCycleException {
-        try {
-            MetricsProvider metricsProvider = (MetricsProvider) Class.forName(metricsProviderClassName,
-                    true, Thread.currentThread().getContextClassLoader()).newInstance();
-            metricsProvider.configure(configuration);
-            metricsProvider.start();
-            return metricsProvider;
-        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException error) {
-            LOG.error("Cannot boot MetricsProvider {}", metricsProviderClassName, error);
-            throw new MetricsProviderLifeCycleException("Cannot boot MetricsProvider " + metricsProviderClassName,
-                    error);
-        } catch (MetricsProviderLifeCycleException error) {
-            LOG.error("Cannot boot MetricsProvider {}", metricsProviderClassName, error);
-            throw error;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/metrics/impl/NullMetricsProvider.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/metrics/impl/NullMetricsProvider.java b/src/java/main/org/apache/zookeeper/metrics/impl/NullMetricsProvider.java
deleted file mode 100644
index 8b22557..0000000
--- a/src/java/main/org/apache/zookeeper/metrics/impl/NullMetricsProvider.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 org.apache.zookeeper.metrics.impl;
-
-import java.util.Properties;
-import org.apache.zookeeper.metrics.Counter;
-import org.apache.zookeeper.metrics.Gauge;
-import org.apache.zookeeper.metrics.MetricsContext;
-import org.apache.zookeeper.metrics.MetricsProvider;
-import org.apache.zookeeper.metrics.MetricsProviderLifeCycleException;
-import org.apache.zookeeper.metrics.Summary;
-
-/**
- * This is a dummy MetricsProvider which does nothing.
- */
-public class NullMetricsProvider implements MetricsProvider {
-
-    @Override
-    public void configure(Properties configuration) throws MetricsProviderLifeCycleException {
-    }
-
-    @Override
-    public void start() throws MetricsProviderLifeCycleException {
-    }
-
-    @Override
-    public MetricsContext getRootContext() {
-        return NullMetricsContext.INSTANCE;
-    }
-
-    @Override
-    public void stop() {
-    }
-
-    public static final class NullMetricsContext implements MetricsContext {
-
-        public static final NullMetricsContext INSTANCE = new NullMetricsContext();
-
-        @Override
-        public MetricsContext getContext(String name) {
-            return INSTANCE;
-        }
-
-        @Override
-        public Counter getCounter(String name) {
-            return NullCounter.INSTANCE;
-        }
-
-        @Override
-        public boolean registerGauge(String name, Gauge gauge) {
-            return true;
-        }
-
-        @Override
-        public Summary getSummary(String name) {
-            return NullSummary.INSTANCE;
-        }
-
-    }
-
-    private static final class NullCounter implements Counter {
-
-        private static final NullCounter INSTANCE = new NullCounter();
-
-        @Override
-        public void inc(long delta) {
-        }
-
-        @Override
-        public long get() {
-            return 0;
-        }
-
-    }
-
-    private static final class NullSummary implements Summary {
-
-        private static final NullSummary INSTANCE = new NullSummary();
-
-        @Override
-        public void registerValue(long value) {
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/ByteBufferInputStream.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/ByteBufferInputStream.java b/src/java/main/org/apache/zookeeper/server/ByteBufferInputStream.java
deleted file mode 100644
index 48d4a8d..0000000
--- a/src/java/main/org/apache/zookeeper/server/ByteBufferInputStream.java
+++ /dev/null
@@ -1,82 +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 org.apache.zookeeper.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-
-import org.apache.jute.BinaryInputArchive;
-import org.apache.jute.Record;
-
-public class ByteBufferInputStream extends InputStream {
-    ByteBuffer bb;
-
-    public ByteBufferInputStream(ByteBuffer bb) {
-        this.bb = bb;
-    }
-
-    @Override
-    public int read() throws IOException {
-        if (bb.remaining() == 0) {
-            return -1;
-        }
-        return bb.get() & 0xff;
-    }
-
-    @Override
-    public int available() throws IOException {
-        return bb.remaining();
-    }
-
-    @Override
-    public int read(byte[] b, int off, int len) throws IOException {
-        if (bb.remaining() == 0) {
-            return -1;
-        }
-        if (len > bb.remaining()) {
-            len = bb.remaining();
-        }
-        bb.get(b, off, len);
-        return len;
-    }
-
-    @Override
-    public int read(byte[] b) throws IOException {
-        return read(b, 0, b.length);
-    }
-
-    @Override
-    public long skip(long n) throws IOException {
-        if (n < 0L) {
-            return 0;
-        }
-        n = Math.min(n, bb.remaining());
-        bb.position(bb.position() + (int) n);
-        return n;
-    }
-
-    static public void byteBuffer2Record(ByteBuffer bb, Record record)
-            throws IOException {
-        BinaryInputArchive ia;
-        ia = BinaryInputArchive.getArchive(new ByteBufferInputStream(bb));
-        record.deserialize(ia, "request");
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/ByteBufferOutputStream.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/ByteBufferOutputStream.java b/src/java/main/org/apache/zookeeper/server/ByteBufferOutputStream.java
deleted file mode 100644
index a1bdabd..0000000
--- a/src/java/main/org/apache/zookeeper/server/ByteBufferOutputStream.java
+++ /dev/null
@@ -1,51 +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 org.apache.zookeeper.server;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-
-import org.apache.jute.BinaryOutputArchive;
-import org.apache.jute.Record;
-
-public class ByteBufferOutputStream extends OutputStream {
-    ByteBuffer bb;
-    public ByteBufferOutputStream(ByteBuffer bb) {
-        this.bb = bb;
-    }
-    @Override
-    public void write(int b) throws IOException {
-        bb.put((byte)b);
-    }
-    @Override
-    public void write(byte[] b) throws IOException {
-        bb.put(b);
-    }
-    @Override
-    public void write(byte[] b, int off, int len) throws IOException {
-        bb.put(b, off, len);
-    }
-    static public void record2ByteBuffer(Record record, ByteBuffer bb)
-    throws IOException {
-        BinaryOutputArchive oa;
-        oa = BinaryOutputArchive.getArchive(new ByteBufferOutputStream(bb));
-        record.serialize(oa, "request");
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/ConnectionBean.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/ConnectionBean.java b/src/java/main/org/apache/zookeeper/server/ConnectionBean.java
deleted file mode 100644
index 58917e0..0000000
--- a/src/java/main/org/apache/zookeeper/server/ConnectionBean.java
+++ /dev/null
@@ -1,173 +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 org.apache.zookeeper.server;
-
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.util.Arrays;
-
-import javax.management.ObjectName;
-
-import org.apache.zookeeper.common.Time;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.zookeeper.jmx.MBeanRegistry;
-import org.apache.zookeeper.jmx.ZKMBeanInfo;
-
-/**
- * Implementation of connection MBean interface.
- */
-public class ConnectionBean implements ConnectionMXBean, ZKMBeanInfo {
-    private static final Logger LOG = LoggerFactory.getLogger(ConnectionBean.class);
-
-    private final ServerCnxn connection;
-    private final Stats stats;
-
-    private final ZooKeeperServer zk;
-    
-    private final String remoteIP;
-    private final long sessionId;
-
-    public ConnectionBean(ServerCnxn connection,ZooKeeperServer zk){
-        this.connection = connection;
-        this.stats = connection;
-        this.zk = zk;
-        
-        InetSocketAddress sockAddr = connection.getRemoteSocketAddress();
-        if (sockAddr == null) {
-            remoteIP = "Unknown";
-        } else {
-            InetAddress addr = sockAddr.getAddress();
-            if (addr instanceof Inet6Address) {
-                remoteIP = ObjectName.quote(addr.getHostAddress());
-            } else {
-                remoteIP = addr.getHostAddress();
-            }
-        }
-        sessionId = connection.getSessionId();
-    }
-    
-    public String getSessionId() {
-        return "0x" + Long.toHexString(sessionId);
-    }
-
-    public String getSourceIP() {
-        InetSocketAddress sockAddr = connection.getRemoteSocketAddress();
-        if (sockAddr == null) {
-            return null;
-        }
-        return sockAddr.getAddress().getHostAddress()
-            + ":" + sockAddr.getPort();
-    }
-
-    public String getName() {
-        return MBeanRegistry.getInstance().makeFullPath("Connections", remoteIP,
-                getSessionId());
-    }
-    
-    public boolean isHidden() {
-        return false;
-    }
-    
-    public String[] getEphemeralNodes() {
-        if(zk.getZKDatabase()  !=null){
-            String[] res = zk.getZKDatabase().getEphemerals(sessionId)
-                .toArray(new String[0]);
-            Arrays.sort(res);
-            return res;
-        }
-        return null;
-    }
-    
-    public String getStartedTime() {
-        return stats.getEstablished().toString();
-    }
-    
-    public void terminateSession() {
-        try {
-            zk.closeSession(sessionId);
-        } catch (Exception e) {
-            LOG.warn("Unable to closeSession() for session: 0x" 
-                    + getSessionId(), e);
-        }
-    }
-    
-    public void terminateConnection() {
-        connection.sendCloseSession();
-    }
-
-    public void resetCounters() {
-        stats.resetStats();
-    }
-
-    @Override
-    public String toString() {
-        return "ConnectionBean{ClientIP=" + ObjectName.quote(getSourceIP())
-            + ",SessionId=0x" + getSessionId() + "}";
-    }
-    
-    public long getOutstandingRequests() {
-        return stats.getOutstandingRequests();
-    }
-    
-    public long getPacketsReceived() {
-        return stats.getPacketsReceived();
-    }
-    
-    public long getPacketsSent() {
-        return stats.getPacketsSent();
-    }
-    
-    public int getSessionTimeout() {
-        return connection.getSessionTimeout();
-    }
-
-    public long getMinLatency() {
-        return stats.getMinLatency();
-    }
-
-    public long getAvgLatency() {
-        return stats.getAvgLatency();
-    }
-
-    public long getMaxLatency() {
-        return stats.getMaxLatency();
-    }
-    
-    public String getLastOperation() {
-        return stats.getLastOperation();
-    }
-
-    public String getLastCxid() {
-        return "0x" + Long.toHexString(stats.getLastCxid());
-    }
-
-    public String getLastZxid() {
-        return "0x" + Long.toHexString(stats.getLastZxid());
-    }
-
-    public String getLastResponseTime() {
-        return Time.elapsedTimeToDate(stats.getLastResponseTime()).toString();
-    }
-
-    public long getLastLatency() {
-        return stats.getLastLatency();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/ConnectionMXBean.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/ConnectionMXBean.java b/src/java/main/org/apache/zookeeper/server/ConnectionMXBean.java
deleted file mode 100644
index 8bdec9a..0000000
--- a/src/java/main/org/apache/zookeeper/server/ConnectionMXBean.java
+++ /dev/null
@@ -1,98 +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 org.apache.zookeeper.server;
-
-/**
- * This MBean represents a client connection.
- */
-public interface ConnectionMXBean {
-    /**
-     * @return source (client) IP address
-     */
-    public String getSourceIP();
-    /**
-     * @return client's session id
-     */
-    public String getSessionId();
-    /**
-     * @return time the connection was started
-     */
-    public String getStartedTime();
-    /**
-     * @return number of ephemeral nodes owned by this connection
-     */
-    public String[] getEphemeralNodes();
-    /**
-     * @return packets received from this client
-     */
-    public long getPacketsReceived();
-    /**
-     * @return number of packets sent to this client
-     */
-    public long getPacketsSent();
-    /**
-     * @return number of requets being processed
-     */
-    public long getOutstandingRequests();
-    /**
-     * @return session timeout in ms
-     */
-    public int getSessionTimeout();
-    
-    /**
-     * Terminate this client session. The client will reconnect with a different
-     * session id.
-     */
-    public void terminateSession();
-    /**
-     * Terminate thei client connection. The client will immediately attempt to 
-     * reconnect with the same session id.
-     */
-    public void terminateConnection();
-
-
-    /** Min latency in ms
-     * @since 3.3.0 */
-    long getMinLatency();
-    /** Average latency in ms
-     * @since 3.3.0 */
-    long getAvgLatency();
-    /** Max latency in ms
-     * @since 3.3.0 */
-    long getMaxLatency();
-    /** Last operation performed by this connection
-     * @since 3.3.0 */
-    String getLastOperation();
-    /** Last cxid of this connection
-     * @since 3.3.0 */
-    String getLastCxid();
-    /** Last zxid of this connection
-     * @since 3.3.0 */
-    String getLastZxid();
-    /** Last time server sent a response to client on this connection
-     * @since 3.3.0 */
-    String getLastResponseTime();
-    /** Latency of last response to client on this connection in ms
-     * @since 3.3.0 */
-    long getLastLatency();
-
-    /** Reset counters
-     * @since 3.3.0 */
-    void resetCounters();
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/ContainerManager.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/ContainerManager.java b/src/java/main/org/apache/zookeeper/server/ContainerManager.java
deleted file mode 100644
index 4c47aba..0000000
--- a/src/java/main/org/apache/zookeeper/server/ContainerManager.java
+++ /dev/null
@@ -1,178 +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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.zookeeper.server;
-
-import org.apache.zookeeper.ZooDefs;
-import org.apache.zookeeper.common.Time;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.nio.ByteBuffer;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * Manages cleanup of container ZNodes. This class is meant to only
- * be run from the leader. There's no harm in running from followers/observers
- * but that will be extra work that's not needed. Once started, it periodically
- * checks container nodes that have a cversion > 0 and have no children. A
- * delete is attempted on the node. The result of the delete is unimportant.
- * If the proposal fails or the container node is not empty there's no harm.
- */
-public class ContainerManager {
-    private static final Logger LOG = LoggerFactory.getLogger(ContainerManager.class);
-    private final ZKDatabase zkDb;
-    private final RequestProcessor requestProcessor;
-    private final int checkIntervalMs;
-    private final int maxPerMinute;
-    private final Timer timer;
-    private final AtomicReference<TimerTask> task = new AtomicReference<TimerTask>(null);
-
-    /**
-     * @param zkDb the ZK database
-     * @param requestProcessor request processer - used to inject delete
-     *                         container requests
-     * @param checkIntervalMs how often to check containers in milliseconds
-     * @param maxPerMinute the max containers to delete per second - avoids
-     *                     herding of container deletions
-     */
-    public ContainerManager(ZKDatabase zkDb, RequestProcessor requestProcessor,
-                            int checkIntervalMs, int maxPerMinute) {
-        this.zkDb = zkDb;
-        this.requestProcessor = requestProcessor;
-        this.checkIntervalMs = checkIntervalMs;
-        this.maxPerMinute = maxPerMinute;
-        timer = new Timer("ContainerManagerTask", true);
-
-        LOG.info(String.format("Using checkIntervalMs=%d maxPerMinute=%d",
-                checkIntervalMs, maxPerMinute));
-    }
-
-    /**
-     * start/restart the timer the runs the check. Can safely be called
-     * multiple times.
-     */
-    public void start() {
-        if (task.get() == null) {
-            TimerTask timerTask = new TimerTask() {
-                @Override
-                public void run() {
-                    try {
-                        checkContainers();
-                    } catch (InterruptedException e) {
-                        Thread.currentThread().interrupt();
-                        LOG.info("interrupted");
-                        cancel();
-                    } catch ( Throwable e ) {
-                        LOG.error("Error checking containers", e);
-                    }
-                }
-            };
-            if (task.compareAndSet(null, timerTask)) {
-                timer.scheduleAtFixedRate(timerTask, checkIntervalMs,
-                        checkIntervalMs);
-            }
-        }
-    }
-
-    /**
-     * stop the timer if necessary. Can safely be called multiple times.
-     */
-    public void stop() {
-        TimerTask timerTask = task.getAndSet(null);
-        if (timerTask != null) {
-            timerTask.cancel();
-        }
-        timer.cancel();
-    }
-
-    /**
-     * Manually check the containers. Not normally used directly
-     */
-    public void checkContainers()
-            throws InterruptedException {
-        long minIntervalMs = getMinIntervalMs();
-        for (String containerPath : getCandidates()) {
-            long startMs = Time.currentElapsedTime();
-
-            ByteBuffer path = ByteBuffer.wrap(containerPath.getBytes());
-            Request request = new Request(null, 0, 0,
-                    ZooDefs.OpCode.deleteContainer, path, null);
-            try {
-                LOG.info("Attempting to delete candidate container: {}",
-                        containerPath);
-                requestProcessor.processRequest(request);
-            } catch (Exception e) {
-                LOG.error("Could not delete container: {}",
-                        containerPath, e);
-            }
-
-            long elapsedMs = Time.currentElapsedTime() - startMs;
-            long waitMs = minIntervalMs - elapsedMs;
-            if (waitMs > 0) {
-                Thread.sleep(waitMs);
-            }
-        }
-    }
-
-    // VisibleForTesting
-    protected long getMinIntervalMs() {
-        return TimeUnit.MINUTES.toMillis(1) / maxPerMinute;
-    }
-
-    // VisibleForTesting
-    protected Collection<String> getCandidates() {
-        Set<String> candidates = new HashSet<String>();
-        for (String containerPath : zkDb.getDataTree().getContainers()) {
-            DataNode node = zkDb.getDataTree().getNode(containerPath);
-            /*
-                cversion > 0: keep newly created containers from being deleted
-                before any children have been added. If you were to create the
-                container just before a container cleaning period the container
-                would be immediately be deleted.
-             */
-            if ((node != null) && (node.stat.getCversion() > 0) &&
-                    (node.getChildren().isEmpty())) {
-                candidates.add(containerPath);
-            }
-        }
-        for (String ttlPath : zkDb.getDataTree().getTtls()) {
-            DataNode node = zkDb.getDataTree().getNode(ttlPath);
-            if (node != null) {
-                Set<String> children = node.getChildren();
-                if (children.isEmpty()) {
-                    if ( EphemeralType.get(node.stat.getEphemeralOwner()) == EphemeralType.TTL ) {
-                        long elapsed = getElapsed(node);
-                        long ttl = EphemeralType.TTL.getValue(node.stat.getEphemeralOwner());
-                        if ((ttl != 0) && (getElapsed(node) > ttl)) {
-                            candidates.add(ttlPath);
-                        }
-                    }
-                }
-            }
-        }
-        return candidates;
-    }
-
-    // VisibleForTesting
-    protected long getElapsed(DataNode node) {
-        return Time.currentWallTime() - node.stat.getMtime();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/DataNode.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/DataNode.java b/src/java/main/org/apache/zookeeper/server/DataNode.java
deleted file mode 100644
index 5922d16..0000000
--- a/src/java/main/org/apache/zookeeper/server/DataNode.java
+++ /dev/null
@@ -1,185 +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 org.apache.zookeeper.server;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.Collections;
-
-import org.apache.jute.InputArchive;
-import org.apache.jute.OutputArchive;
-import org.apache.jute.Record;
-import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.data.StatPersisted;
-
-/**
- * This class contains the data for a node in the data tree.
- * <p>
- * A data node contains a reference to its parent, a byte array as its data, an
- * array of ACLs, a stat object, and a set of its children's paths.
- * 
- */
-public class DataNode implements Record {
-    /** the data for this datanode */
-    byte data[];
-
-    /**
-     * the acl map long for this datanode. the datatree has the map
-     */
-    Long acl;
-
-    /**
-     * the stat for this node that is persisted to disk.
-     */
-    public StatPersisted stat;
-
-    /**
-     * the list of children for this node. note that the list of children string
-     * does not contain the parent path -- just the last part of the path. This
-     * should be synchronized on except deserializing (for speed up issues).
-     */
-    private Set<String> children = null;
-
-    private static final Set<String> EMPTY_SET = Collections.emptySet();
-
-    /**
-     * default constructor for the datanode
-     */
-    DataNode() {
-        // default constructor
-    }
-
-    /**
-     * create a DataNode with parent, data, acls and stat
-     * 
-     * @param parent
-     *            the parent of this DataNode
-     * @param data
-     *            the data to be set
-     * @param acl
-     *            the acls for this node
-     * @param stat
-     *            the stat for this node.
-     */
-    public DataNode(byte data[], Long acl, StatPersisted stat) {
-        this.data = data;
-        this.acl = acl;
-        this.stat = stat;
-    }
-
-    /**
-     * Method that inserts a child into the children set
-     * 
-     * @param child
-     *            to be inserted
-     * @return true if this set did not already contain the specified element
-     */
-    public synchronized boolean addChild(String child) {
-        if (children == null) {
-            // let's be conservative on the typical number of children
-            children = new HashSet<String>(8);
-        }
-        return children.add(child);
-    }
-
-    /**
-     * Method that removes a child from the children set
-     * 
-     * @param child
-     * @return true if this set contained the specified element
-     */
-    public synchronized boolean removeChild(String child) {
-        if (children == null) {
-            return false;
-        }
-        return children.remove(child);
-    }
-
-    /**
-     * convenience method for setting the children for this datanode
-     * 
-     * @param children
-     */
-    public synchronized void setChildren(HashSet<String> children) {
-        this.children = children;
-    }
-
-    /**
-     * convenience methods to get the children
-     * 
-     * @return the children of this datanode. If the datanode has no children, empty
-     *         set is returned
-     */
-    public synchronized Set<String> getChildren() {
-        if (children == null) {
-            return EMPTY_SET;
-        }
-
-        return Collections.unmodifiableSet(children);
-    }
-
-    synchronized public void copyStat(Stat to) {
-        to.setAversion(stat.getAversion());
-        to.setCtime(stat.getCtime());
-        to.setCzxid(stat.getCzxid());
-        to.setMtime(stat.getMtime());
-        to.setMzxid(stat.getMzxid());
-        to.setPzxid(stat.getPzxid());
-        to.setVersion(stat.getVersion());
-        to.setEphemeralOwner(getClientEphemeralOwner(stat));
-        to.setDataLength(data == null ? 0 : data.length);
-        int numChildren = 0;
-        if (this.children != null) {
-            numChildren = children.size();
-        }
-        // when we do the Cversion we need to translate from the count of the creates
-        // to the count of the changes (v3 semantics)
-        // for every create there is a delete except for the children still present
-        to.setCversion(stat.getCversion()*2 - numChildren);
-        to.setNumChildren(numChildren);
-    }
-
-    private static long getClientEphemeralOwner(StatPersisted stat) {
-        EphemeralType ephemeralType = EphemeralType.get(stat.getEphemeralOwner());
-        if (ephemeralType != EphemeralType.NORMAL) {
-            return 0;
-        }
-        return stat.getEphemeralOwner();
-    }
-
-    synchronized public void deserialize(InputArchive archive, String tag)
-            throws IOException {
-        archive.startRecord("node");
-        data = archive.readBuffer("data");
-        acl = archive.readLong("acl");
-        stat = new StatPersisted();
-        stat.deserialize(archive, "statpersisted");
-        archive.endRecord("node");
-    }
-
-    synchronized public void serialize(OutputArchive archive, String tag)
-            throws IOException {
-        archive.startRecord(this, "node");
-        archive.writeBuffer(data, "data");
-        archive.writeLong(acl, "acl");
-        stat.serialize(archive, "statpersisted");
-        archive.endRecord(this, "node");
-    }
-}


Mime
View raw message