Return-Path:
Delivered-To: apmail-hadoop-zookeeper-commits-archive@locus.apache.org
Received: (qmail 17807 invoked from network); 2 Dec 2008 00:14:51 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2)
by minotaur.apache.org with SMTP; 2 Dec 2008 00:14:51 -0000
Received: (qmail 22992 invoked by uid 500); 2 Dec 2008 00:15:03 -0000
Delivered-To: apmail-hadoop-zookeeper-commits-archive@hadoop.apache.org
Received: (qmail 22975 invoked by uid 500); 2 Dec 2008 00:15:03 -0000
Mailing-List: contact zookeeper-commits-help@hadoop.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: zookeeper-dev@
Delivered-To: mailing list zookeeper-commits@hadoop.apache.org
Received: (qmail 22964 invoked by uid 99); 2 Dec 2008 00:15:03 -0000
Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)
by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Dec 2008 16:15:03 -0800
X-ASF-Spam-Status: No, hits=-2000.0 required=10.0
tests=ALL_TRUSTED
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Dec 2008 00:13:33 +0000
Received: by eris.apache.org (Postfix, from userid 65534)
id 2DCAD238889E; Mon, 1 Dec 2008 16:13:51 -0800 (PST)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r722308 - in /hadoop/zookeeper/trunk: ./ docs/ src/c/
src/c/src/
src/docs/src/documentation/content/xdocs/ src/java/main/org/apache/zookeeper/
src/java/main/org/apache/zookeeper/server/
Date: Tue, 02 Dec 2008 00:13:50 -0000
To: zookeeper-commits@hadoop.apache.org
From: mahadev@apache.org
X-Mailer: svnmailer-1.0.8
Message-Id: <20081202001351.2DCAD238889E@eris.apache.org>
X-Virus-Checked: Checked by ClamAV on apache.org
Author: mahadev
Date: Mon Dec 1 16:13:50 2008
New Revision: 722308
URL: http://svn.apache.org/viewvc?rev=722308&view=rev
Log:
ZOOKEEPER-64. Log system env information when initializing server and client (pat via mahadev)
Added:
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/Environment.java
Modified:
hadoop/zookeeper/trunk/CHANGES.txt
hadoop/zookeeper/trunk/docs/zookeeperAdmin.html
hadoop/zookeeper/trunk/docs/zookeeperAdmin.pdf
hadoop/zookeeper/trunk/src/c/configure.ac
hadoop/zookeeper/trunk/src/c/src/zookeeper.c
hadoop/zookeeper/trunk/src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java
hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java
Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=722308&r1=722307&r2=722308&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Mon Dec 1 16:13:50 2008
@@ -41,6 +41,12 @@
ZOOKEEPER-232. fix apache licence header in TestableZookeeper (mahadev)
+IMPROVEMENTS:
+
+ ZOOKEEPER-64. Log system env information when initializing server and
+client (pat via mahadev)
+
+
Release 3.0.0 - 2008-10-21
Non-backward compatible changes:
Modified: hadoop/zookeeper/trunk/docs/zookeeperAdmin.html
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/docs/zookeeperAdmin.html?rev=722308&r1=722307&r2=722308&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/docs/zookeeperAdmin.html (original)
+++ hadoop/zookeeper/trunk/docs/zookeeperAdmin.html Mon Dec 1 16:13:50 2008
@@ -945,6 +945,14 @@
+envi
+
+
+Print details about serving environment
+
+
+
+
kill
@@ -954,6 +962,14 @@
+reqs
+
+
+List outstanding requests
+
+
+
+
ruok
@@ -977,7 +993,7 @@
$ echo ruok | nc 127.0.0.1 5111
imok
-
+
Data File Management
ZooKeeper stores its data in a data directory and its transaction
log in a transaction log directory. By default these two directories are
@@ -985,7 +1001,7 @@
transaction log files in a separate directory than the data files.
Throughput increases and latency decreases when transaction logs reside
on a dedicated log devices.
-
+
The Data Directory
This directory has two files in it:
@@ -1031,14 +1047,14 @@
idempotent nature of its updates. By replaying the transaction log
against fuzzy snapshots ZooKeeper gets the state of the system at the
end of the log.
-
+
The Log Directory
The Log Directory contains the ZooKeeper transaction logs.
Before any update takes place, ZooKeeper ensures that the transaction
that represents the update is written to non-volatile storage. A new
log file is started each time a snapshot is begun. The log file's
suffix is the first zxid written to that log.
-
+
File Management
The format of snapshot and log files does not change between
standalone ZooKeeper servers and different configurations of
@@ -1055,7 +1071,7 @@
needs the latest complete fuzzy snapshot and the log files from the
start of that snapshot. The PurgeTxnLog utility implements a simple
retention policy that administrators can use.
-
+
Things to Avoid
Here are some common problems you can avoid by configuring
ZooKeeper correctly:
@@ -1109,7 +1125,7 @@
-
+
Best Practices
For best results, take note of the following list of good
Zookeeper practices. [tbd...]
Modified: hadoop/zookeeper/trunk/docs/zookeeperAdmin.pdf
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/docs/zookeeperAdmin.pdf?rev=722308&r1=722307&r2=722308&view=diff
==============================================================================
Binary files - no diff available.
Modified: hadoop/zookeeper/trunk/src/c/configure.ac
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/configure.ac?rev=722308&r1=722307&r2=722308&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/c/configure.ac (original)
+++ hadoop/zookeeper/trunk/src/c/configure.ac Mon Dec 1 16:13:50 2008
@@ -60,7 +60,7 @@
# Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h sys/utsname.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
@@ -72,7 +72,7 @@
[#include ])
# Checks for library functions.
-AC_CHECK_FUNCS([gethostbyname gettimeofday memmove memset poll socket strchr strdup strerror strtol])
+AC_CHECK_FUNCS([getcwd gethostbyname gethostname getlogin getpwuid_r gettimeofday getuid memmove memset poll socket strchr strdup strerror strtol])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
Modified: hadoop/zookeeper/trunk/src/c/src/zookeeper.c
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/src/zookeeper.c?rev=722308&r1=722307&r2=722308&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/c/src/zookeeper.c (original)
+++ hadoop/zookeeper/trunk/src/c/src/zookeeper.c Mon Dec 1 16:13:50 2008
@@ -49,6 +49,16 @@
#include
#include
+#include "config.h"
+
+#ifdef HAVE_SYS_UTSNAME_H
+#include
+#endif
+
+#ifdef HAVE_GETPWUID_R
+#include
+#endif
+
#define IF_DEBUG(x) if(logLevel==ZOO_LOG_LEVEL_DEBUG) {x;}
const int ZOOKEEPER_WRITE = 1 << 0;
@@ -415,12 +425,68 @@
return oldWatcher;
}
+static void log_env() {
+ char buf[2048];
+
+ LOG_INFO(("Client environment:zookeeper.version=%s", PACKAGE_STRING));
+
+#ifdef HAVE_GETHOSTNAME
+ gethostname(buf, sizeof(buf));
+ LOG_INFO(("Client environment:host.name=%s", buf));
+#else
+ LOG_INFO(("Client environment:host.name="));
+#endif
+
+#ifdef HAVE_SYS_UTSNAME_H
+ struct utsname utsname;
+ uname(&utsname);
+ LOG_INFO(("Client environment:os.name=%s", utsname.sysname));
+ LOG_INFO(("Client environment:os.arch=%s", utsname.release));
+ LOG_INFO(("Client environment:os.version=%s", utsname.version));
+#else
+ LOG_INFO(("Client environment:os.name="));
+ LOG_INFO(("Client environment:os.arch="));
+ LOG_INFO(("Client environment:os.version="));
+#endif
+
+#ifdef HAVE_GETLOGIN
+ LOG_INFO(("Client environment:user.name=%s", getlogin()));
+#else
+ LOG_INFO(("Client environment:user.name="));
+#endif
+
+#if defined(HAVE_GETUID) && defined(HAVE_GETPWUID_R)
+ uid_t uid = getuid();
+ struct passwd pw;
+ struct passwd *pwp;
+ if (!getpwuid_r(uid, &pw, buf, sizeof(buf), &pwp)) {
+ LOG_INFO(("Client environment:user.home=%s", pw.pw_dir));
+ } else {
+ LOG_INFO(("Client environment:user.home="));
+ }
+#else
+ LOG_INFO(("Client environment:user.home="));
+#endif
+
+#ifdef HAVE_GETCWD
+ if (!getcwd(buf, sizeof(buf))) {
+ LOG_INFO(("Client environment:user.dir="));
+ } else {
+ LOG_INFO(("Client environment:user.dir=%s", buf));
+ }
+#else
+ LOG_INFO(("Client environment:user.dir="));
+#endif
+}
+
/**
* Create a zookeeper handle associated with the given host and port.
*/
zhandle_t *zookeeper_init(const char *host, watcher_fn watcher,
int recv_timeout, const clientid_t *clientid, void *context, int flags)
{
+ log_env();
+
int errnosave;
zhandle_t *zh = calloc(1, sizeof(*zh));
if (!zh) {
Modified: hadoop/zookeeper/trunk/src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml?rev=722308&r1=722307&r2=722308&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml (original)
+++ hadoop/zookeeper/trunk/src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml Mon Dec 1 16:13:50 2008
@@ -663,6 +663,14 @@
+ envi
+
+
+ Print details about serving environment
+
+
+
+
kill
@@ -672,6 +680,14 @@
+ reqs
+
+
+ List outstanding requests
+
+
+
+
ruok
Added: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/Environment.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/Environment.java?rev=722308&view=auto
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/Environment.java (added)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/Environment.java Mon Dec 1 16:13:50 2008
@@ -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.zookeeper;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Provide insight into the runtime environment.
+ *
+ */
+public class Environment {
+ public static class Entry {
+ private String k;
+ private String v;
+ public Entry(String k, String v) {
+ this.k = k;
+ this.v = v;
+ }
+ public String getKey() { return k; }
+ public String getValue() { return v; }
+
+ @Override
+ public String toString() {
+ return k + "=" + v;
+ }
+ }
+
+ private static void put(ArrayList l, String k, String v) {
+ l.add(new Entry(k,v));
+ }
+
+ public static List list() {
+ ArrayList l = new ArrayList();
+ put(l, "zookeeper.version", Version.getFullVersion());
+
+ try {
+ put(l, "host.name",
+ InetAddress.getLocalHost().getCanonicalHostName().toString());
+ } catch (UnknownHostException e) {
+ put(l, "host.name", "");
+ }
+
+ put(l, "java.version",
+ System.getProperty("java.version", ""));
+ put(l, "java.vendor",
+ System.getProperty("java.vendor", ""));
+ put(l, "java.home",
+ System.getProperty("java.home", ""));
+ put(l, "java.class.path",
+ System.getProperty("java.class.path", ""));
+ put(l, "java.library.path",
+ System.getProperty("java.library.path", ""));
+ put(l, "java.io.tmpdir",
+ System.getProperty("java.io.tmpdir", ""));
+ put(l, "java.compiler",
+ System.getProperty("java.compiler", ""));
+ put(l, "os.name",
+ System.getProperty("os.name", ""));
+ put(l, "os.arch",
+ System.getProperty("os.arch", ""));
+ put(l, "os.version",
+ System.getProperty("os.version", ""));
+ put(l, "user.name",
+ System.getProperty("user.name", ""));
+ put(l, "user.home",
+ System.getProperty("user.home", ""));
+ put(l, "user.dir",
+ System.getProperty("user.dir", ""));
+
+ return l;
+ }
+
+ public static void logEnv(String msg, Logger log) {
+ List env = Environment.list();
+ for (Entry e : env) {
+ log.info(msg + e.toString());
+ }
+ }
+}
Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java?rev=722308&r1=722307&r2=722308&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java Mon Dec 1 16:13:50 2008
@@ -96,7 +96,14 @@
*
*/
public class ZooKeeper {
- private static final Logger LOG = Logger.getLogger(ZooKeeper.class);
+ private static final Logger LOG;
+
+ static {
+ LOG = Logger.getLogger(ZooKeeper.class);
+
+ Environment.logEnv("Client environment:", LOG);
+ }
+
private final ZKWatchManager watchManager = new ZKWatchManager();
Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java?rev=722308&r1=722307&r2=722308&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java Mon Dec 1 16:13:50 2008
@@ -35,18 +35,19 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
-import org.apache.log4j.Logger;
-
import org.apache.jute.BinaryInputArchive;
import org.apache.jute.BinaryOutputArchive;
import org.apache.jute.Record;
+import org.apache.log4j.Logger;
+import org.apache.zookeeper.Environment;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.Version;
-import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooDefs.OpCode;
import org.apache.zookeeper.data.Id;
import org.apache.zookeeper.proto.AuthPacket;
@@ -604,6 +605,20 @@
sendBuffer(ByteBuffer.wrap(sb.toString().getBytes()));
k.interestOps(SelectionKey.OP_WRITE);
return;
+ } else if (len == enviCmd) {
+ StringBuffer sb = new StringBuffer();
+
+ List env = Environment.list();
+
+ sb.append("Environment:\n");
+ for(Environment.Entry e : env) {
+ sb.append(e.getKey()).append("=").append(e.getValue())
+ .append("\n");
+ }
+
+ sendBuffer(ByteBuffer.wrap(sb.toString().getBytes()));
+ k.interestOps(SelectionKey.OP_WRITE);
+ return;
}
}
if (len < 0 || len > BinaryInputArchive.maxBuffer) {
Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java?rev=722308&r1=722307&r2=722308&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java Mon Dec 1 16:13:50 2008
@@ -47,6 +47,8 @@
final static int getTraceMaskCmd = ByteBuffer.wrap("gtmk".getBytes())
.getInt();
+ final static int enviCmd = ByteBuffer.wrap("envi".getBytes()).getInt();
+
final static ByteBuffer imok = ByteBuffer.wrap("imok".getBytes());
public abstract int getSessionTimeout();
Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java?rev=722308&r1=722307&r2=722308&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java Mon Dec 1 16:13:50 2008
@@ -36,10 +36,10 @@
import org.apache.jute.OutputArchive;
import org.apache.jute.Record;
import org.apache.log4j.Logger;
+import org.apache.zookeeper.Environment;
import org.apache.zookeeper.ZooDefs.OpCode;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Id;
-import org.apache.zookeeper.data.Stat;
import org.apache.zookeeper.data.StatPersisted;
import org.apache.zookeeper.proto.RequestHeader;
import org.apache.zookeeper.server.SessionTracker.SessionExpirer;
@@ -57,7 +57,13 @@
* PrepRequestProcessor -> SyncRequestProcessor -> FinalRequestProcessor
*/
public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
- private static final Logger LOG = Logger.getLogger(ZooKeeperServer.class);
+ private static final Logger LOG;
+
+ static {
+ LOG = Logger.getLogger(ZooKeeperServer.class);
+
+ Environment.logEnv("Server environment:", LOG);
+ }
/**
* Create an instance of Zookeeper server