From ac1efc47fda406988f0705a7e615d972d11cdf11 Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Fri, 04 Jan 2008 12:38:05 +0000
Subject: [PATCH] Issue 2650: import-ldif command should give information about JRE version and settings

---
 opends/src/server/org/opends/server/core/DirectoryServer.java    |  132 +++++-----------
 opends/src/server/org/opends/server/util/RuntimeInformation.java |  223 +++++++++++++++++++++++++++
 opends/src/messages/messages/core.properties                     |   23 ++
 opends/src/messages/messages/runtime_information.properties      |   73 +++++++++
 opends/build.xml                                                 |    5 
 opends/src/server/org/opends/server/backends/jeb/ImportJob.java  |    9 +
 opends/src/messages/messages/jeb.properties                      |    4 
 opends/src/messages/src/org/opends/messages/Category.java        |    8 
 8 files changed, 377 insertions(+), 100 deletions(-)

diff --git a/opends/build.xml b/opends/build.xml
index 3f9f56d..b6f8ad2 100644
--- a/opends/build.xml
+++ b/opends/build.xml
@@ -22,7 +22,7 @@
  ! CDDL HEADER END
  !
  !
- !      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+ !      Portions Copyright 2006-2008 Sun Microsystems, Inc.
  ! -->
 
 <project name="Directory Server" basedir="." default="package">
@@ -250,6 +250,9 @@
     <genmsg sourceProps="${msg.prop.dir}/version.properties"
             destJava="${msg.javagen.dir}/org/opends/messages/VersionMessages.java">
     </genmsg>
+    <genmsg sourceProps="${msg.prop.dir}/runtime_information.properties"
+            destJava="${msg.javagen.dir}/org/opends/messages/RuntimeMessages.java">
+    </genmsg>
   </target>
 
 
diff --git a/opends/src/messages/messages/core.properties b/opends/src/messages/messages/core.properties
index ec3231e..0a38d16 100644
--- a/opends/src/messages/messages/core.properties
+++ b/opends/src/messages/messages/core.properties
@@ -190,7 +190,7 @@
  configuration bootstrapping process
 INFO_DIRECTORY_BOOTSTRAPPED_133=The Directory Server has completed the \
  configuration bootstrapping process
-NOTICE_DIRECTORY_SERVER_STARTING_134=%s starting up
+NOTICE_DIRECTORY_SERVER_STARTING_134=%s (build %s, R%d) starting up
 NOTICE_DIRECTORY_SERVER_STARTED_135=The Directory Server has started \
  successfully
 INFO_ERROR_CATEGORY_EXTENSIONS_137=extensions
@@ -1739,7 +1739,7 @@
  symmetric key attribute value that can be decoded by this instance
 SEVERE_ERR_CRYPTOMGR_IMPORT_KEY_ENTRY_FIELD_MISMATCH_688=CryptoManager \
  detected a field mismatch between the key entry to be imported and an entry \
- in the key cache that share the key identifier "%s"  
+ in the key cache that share the key identifier "%s"
 SEVERE_ERR_CRYPTOMGR_IMPORT_KEY_ENTRY_FAILED_OTHER_689=CryptoManager failed \
  to import the symmetric key entry "%s":  %s
 SEVERE_ERR_CRYPTOMGR_IMPORT_KEY_ENTRY_FAILED_TO_ADD_KEY_690=CryptoManager \
@@ -1764,4 +1764,21 @@
 MILD_ERR_ADD_ENTRY_UNKNOWN_SUFFIX_697=The provided entry %s cannot be added \
  because its suffix is not defined as one of the suffixes within the \
  Directory Server
-
+#Messages for start-ds -F option, the alignment matters
+NOTICE_VERSION_698=%s
+NOTICE_MAJOR_VERSION_699=Major Version:           %d
+NOTICE_MINOR_VERSION_700=Minor Version:           %d
+NOTICE_POINT_VERSION_701=Point Version:           %d
+NOTICE_VERSION_QUALIFIER_702=Version Qualifier:       %s
+NOTICE_BUILD_NUMBER_703=Build Number:                 %s
+NOTICE_REVISION_NUMBER_704=Revision Number:         %d
+NOTICE_FIX_IDS_705=Fix IDs:                           %s
+NOTICE_DEBUG_BUILD_706=Debug Build:             %b
+NOTICE_BUILD_OS_707=Build OS:                %s
+NOTICE_BUILD_USER_708=Build User:              %s
+NOTICE_UPGRADE_EVENTS_709=Upgrade Event IDs:       %s
+NOTICE_BUILD_JAVA_VERSION_710=Build Java Version:      %s
+NOTICE_BUILD_JAVA_VENDOR_711=Build Java Vendor:       %s
+NOTICE_BUILD_JVM_VERSION_712=Build JVM Version:       %s
+NOTICE_BUILD_JVM_VENDOR_713=Build JVM Vendor:        %s
+NOTICE_BUILD_ID_714=Buld ID:                 %s
diff --git a/opends/src/messages/messages/jeb.properties b/opends/src/messages/messages/jeb.properties
index ba6716e..45ac799 100644
--- a/opends/src/messages/messages/jeb.properties
+++ b/opends/src/messages/messages/jeb.properties
@@ -178,7 +178,7 @@
  seconds (average rate %.1f/sec)
 INFO_JEB_EXPORT_PROGRESS_REPORT_88=Exported %d records and skipped %d (recent \
  rate %.1f/sec)
-INFO_JEB_IMPORT_THREAD_COUNT_89=Starting import (using %d threads)
+INFO_JEB_IMPORT_THREAD_COUNT_89=Import Thread Count: %d threads
 INFO_JEB_IMPORT_BUFFER_SIZE_90=Buffer size per thread = %,d
 INFO_JEB_IMPORT_LDIF_PROCESSING_TIME_91=LDIF processing took %d seconds
 INFO_JEB_IMPORT_INDEX_PROCESSING_TIME_92=Index processing took %d seconds
@@ -337,4 +337,4 @@
   will not take effect until the backend is restarted. The DB files from the \
   previous directory %s must be moved to the new directory %s after shutting \
   down the backend to retain the existing data
-
+INFO_JEB_IMPORT_STARTING_173=%s starting import (build %s, R%d)
diff --git a/opends/src/messages/messages/runtime_information.properties b/opends/src/messages/messages/runtime_information.properties
new file mode 100644
index 0000000..7836774
--- /dev/null
+++ b/opends/src/messages/messages/runtime_information.properties
@@ -0,0 +1,73 @@
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE
+# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+# add the following below this CDDL HEADER, with the fields enclosed
+# by brackets "[]" replaced with your own identifying information:
+#      Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#      Portions Copyright 2006-2008 Sun Microsystems, Inc.
+
+
+
+#
+# Global directives
+#
+global.category=RUNTIME_INFORMATION
+
+#
+# Format string definitions
+#
+# Keys must be formatted as follows:
+#
+# [SEVERITY]_[DESCRIPTION]_[ORDINAL]
+#
+# where:
+#
+# SEVERITY is one of:
+# [INFO, MILD_WARN, SEVERE_WARN, MILD_ERR, SEVERE_ERR, FATAL_ERR, DEBUG, NOTICE]
+#
+# DESCRIPTION is an upper case string providing a hint as to the context of
+# the message in upper case with the underscore ('_') character serving as
+# word separator
+#
+# ORDINAL is an integer unique among other ordinals in this file
+#
+#Messages for start-ds -s option, alignment matters.
+NOTICE_JAVA_VERSION_1=JAVA Version:            %s
+NOTICE_JAVA_VENDOR_2=JAVA Vendor:             %s
+NOTICE_JVM_VERSION_3=JVM Version:             %s
+NOTICE_JVM_VENDOR_4=JVM Vendor:              %s
+NOTICE_JAVA_HOME_5=JAVA Home:               %s
+NOTICE_JAVA_CLASSPATH_6=Class Path:              %s
+NOTICE_JE_VERSION_7=JE Version:              %s
+NOTICE_CURRENT_DIRECTORY_8=Current Directory:       %s
+NOTICE_OPERATING_SYSTEM_9=Operating System:        %s
+NOTICE_JVM_ARCH_10=JVM Architecture:        %s
+NOTICE_SYSTEM_NAME_11=System Name:             %s
+NOTICE_AVAILABLE_PROCESSORS_12=Available Processors:    %d
+NOTICE_MAX_MEMORY_13=Max Available Memory:    %d
+NOTICE_TOTAL_MEMORY_14=Currently Used Memory:   %d
+NOTICE_FREE_MEMORY_15=Currently Free Memory:   %d
+NOTICE_JVM_INPUT_ARGUMENTS_16=JVM Input Arguments:     %s
+#Messages written to server.out
+NOTICE_JVM_INFO_17=JVM Information: %s by %s, %s architecture, \
+                                    %d bytes heap size
+NOTICE_JVM_HOST_18=JVM Host: %s, running %s, %d bytes physical memory size, \
+                   number of processors available %d
+NOTICE_JVM_ARGS_19=JVM Arguments: %s
+
diff --git a/opends/src/messages/src/org/opends/messages/Category.java b/opends/src/messages/src/org/opends/messages/Category.java
index b2d33c2..456c52e 100644
--- a/opends/src/messages/src/org/opends/messages/Category.java
+++ b/opends/src/messages/src/org/opends/messages/Category.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2007-2008 Sun Microsystems, Inc.
  */
 
 package org.opends.messages;
@@ -151,6 +151,12 @@
   DSCONFIG(0x01200000),
 
   /**
+   * The category used for messages associated with the runtime information.
+   */
+
+  RUNTIME_INFORMATION(0x01300000),
+
+  /**
    * The category that will be used for messages associated with
    * third-party (including user-defined) modules.
    */
diff --git a/opends/src/server/org/opends/server/backends/jeb/ImportJob.java b/opends/src/server/org/opends/server/backends/jeb/ImportJob.java
index c4c8216..ebafd98 100644
--- a/opends/src/server/org/opends/server/backends/jeb/ImportJob.java
+++ b/opends/src/server/org/opends/server/backends/jeb/ImportJob.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
  */
 package org.opends.server.backends.jeb;
 import org.opends.messages.Message;
@@ -40,8 +40,10 @@
 import org.opends.server.util.LDIFException;
 import org.opends.server.util.LDIFReader;
 import org.opends.server.util.StaticUtils;
+import org.opends.server.util.RuntimeInformation;
 import static org.opends.server.util.StaticUtils.getFileForPath;
 
+import static org.opends.server.util.DynamicConstants.*;
 import java.io.File;
 import java.io.IOException;
 import java.util.*;
@@ -60,6 +62,7 @@
 import org.opends.server.admin.std.server.LocalDBBackendCfg;
 import org.opends.server.protocols.asn1.ASN1OctetString;
 import org.opends.server.config.ConfigException;
+import org.opends.server.core.DirectoryServer;
 
 /**
  * Import from LDIF to a JE backend.
@@ -200,9 +203,13 @@
       long bufferSize = config.getImportBufferSize() /
           (importThreadCount*rootContainer.getBaseDNs().size());
 
+      message = INFO_JEB_IMPORT_STARTING.get(DirectoryServer.getVersionString(),
+                                                     BUILD_ID, REVISION_NUMBER);
+      logError(message);
       message = INFO_JEB_IMPORT_THREAD_COUNT.get(importThreadCount);
       logError(message);
 
+      RuntimeInformation.logInfo();
       if (debugEnabled())
       {
 
diff --git a/opends/src/server/org/opends/server/core/DirectoryServer.java b/opends/src/server/org/opends/server/core/DirectoryServer.java
index 10a98cc..1c739b1 100644
--- a/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -22,12 +22,10 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
  */
 package org.opends.server.core;
 
-import com.sleepycat.je.JEVersion;
-
 import org.opends.server.admin.ClassLoaderProvider;
 import org.opends.server.admin.server.ServerManagementContext;
 import org.opends.server.admin.std.meta.GlobalCfgDefn.WorkflowConfigurationMode;
@@ -174,15 +172,10 @@
 import org.opends.server.types.DirectoryEnvironmentConfig;
 import org.opends.server.types.LockManager;
 import static org.opends.server.util.DynamicConstants.*;
-import org.opends.server.util.MultiOutputStream;
 import static org.opends.server.util.ServerConstants.*;
-import org.opends.server.util.SetupUtils;
-import org.opends.server.util.StaticUtils;
 import static org.opends.server.util.StaticUtils.*;
-import org.opends.server.util.TimeThread;
-import org.opends.server.util.Validator;
 import static org.opends.server.util.Validator.ensureNotNull;
-import org.opends.server.util.VersionCompatibilityIssue;
+import org.opends.server.util.*;
 import org.opends.server.util.args.ArgumentException;
 import org.opends.server.util.args.ArgumentParser;
 import org.opends.server.util.args.BooleanArgument;
@@ -1262,9 +1255,10 @@
       }
 
 
-      logError(NOTE_DIRECTORY_SERVER_STARTING.get(getVersionString()));
+      logError(NOTE_DIRECTORY_SERVER_STARTING.get(getVersionString(),
+                                                  BUILD_ID, REVISION_NUMBER));
 
-
+      RuntimeInformation.logInfo();
       // Acquire an exclusive lock for the Directory Server process.
       if (! serverLocked)
       {
@@ -9338,91 +9332,12 @@
     }
     else if (fullVersion.isPresent())
     {
-      System.out.println(getVersionString());
-      System.out.println("Build ID:            " + BUILD_ID);
-      System.out.println("Major Version:       " + MAJOR_VERSION);
-      System.out.println("Minor Version:       " + MINOR_VERSION);
-      System.out.println("Point Version:       " + POINT_VERSION);
-      System.out.println("Version Qualifier:   " + VERSION_QUALIFIER);
-
-      if (BUILD_NUMBER > 0)
-      {
-        System.out.println("Build Number:        " +
-                           new DecimalFormat("000").format(BUILD_NUMBER));
-      }
-
-      System.out.println("Revision Number:     " + REVISION_NUMBER);
-      System.out.println("Fix IDs:             " + FIX_IDS);
-      System.out.println("Debug Build:         " + DEBUG_BUILD);
-      System.out.println("Build OS:            " + BUILD_OS);
-      System.out.println("Build User:          " + BUILD_USER);
-      System.out.println("Build Java Version:  " + BUILD_JAVA_VERSION);
-      System.out.println("Build Java Vendor:   " + BUILD_JAVA_VENDOR);
-      System.out.println("Build JVM Version:   " + BUILD_JVM_VERSION);
-      System.out.println("Build JVM Vendor:    " + BUILD_JVM_VENDOR);
-
-      System.out.println("Upgrade Event IDs:   " +
-              StaticUtils.listToString(
-                      VersionCompatibilityIssue.getAllEvents(), ","));
-
+      printFullVersionInformation();
       return;
     }
     else if (systemInfo.isPresent())
     {
-      System.out.println(getVersionString());
-      System.out.println("Build ID:               " + BUILD_ID);
-      System.out.println("Java Version:           " +
-                         System.getProperty("java.version"));
-      System.out.println("Java Vendor:            " +
-                         System.getProperty("java.vendor"));
-      System.out.println("JVM Version:            " +
-                         System.getProperty("java.vm.version"));
-      System.out.println("JVM Vendor:             " +
-                         System.getProperty("java.vm.vendor"));
-      System.out.println("Java Home:              " +
-                         System.getProperty("java.home"));
-      System.out.println("Class Path:             " +
-                         System.getProperty("java.class.path"));
-      System.out.println("JE Version:             " +
-                         JEVersion.CURRENT_VERSION.toString());
-      System.out.println("Current Directory:      " +
-                         System.getProperty("user.dir"));
-      System.out.println("Operating System:       " +
-                         System.getProperty("os.name") + " " +
-                         System.getProperty("os.version") + " " +
-                         System.getProperty("os.arch"));
-      String sunOsArchDataModel = System.getProperty("sun.arch.data.model");
-      if (sunOsArchDataModel != null)
-      {
-        System.out.print  ("JVM Architecture:       " + sunOsArchDataModel);
-        if (! sunOsArchDataModel.toLowerCase().equals("unknown"))
-        {
-          System.out.print("-bit");
-        }
-        System.out.println();
-      }
-      else
-      {
-        System.out.println("JVM Architecture:        unknown");
-      }
-
-      try
-      {
-        System.out.println("System Name:            " +
-                           InetAddress.getLocalHost().getCanonicalHostName());
-      }
-      catch (Exception e)
-      {
-        System.out.println("System Name:             Unknown (" + e + ")");
-      }
-
-      Runtime runtime = Runtime.getRuntime();
-      System.out.println("Available Processors:   " +
-                         runtime.availableProcessors());
-      System.out.println("Max Available Memory:   " + runtime.maxMemory());
-      System.out.println("Currently Used Memory:  " + runtime.totalMemory());
-      System.out.println("Currently Free Memory:  " + runtime.freeMemory());
-
+      RuntimeInformation.printInfo();
       return;
     }
 
@@ -9907,5 +9822,38 @@
   {
     return directoryServer.workflowConfigurationMode;
   }
+
+
+
+  /**
+   * Print messages for start-ds "-F" option (full version information).
+   */
+
+  private static
+  void printFullVersionInformation() {
+    System.out.println(NOTE_VERSION.get(getVersionString()));
+    System.out.println(NOTE_BUILD_ID.get(BUILD_ID));
+    System.out.println(NOTE_MAJOR_VERSION.get(MAJOR_VERSION));
+    System.out.println(NOTE_MINOR_VERSION.get(MINOR_VERSION));
+    System.out.println(NOTE_POINT_VERSION.get(POINT_VERSION));
+    System.out.println(NOTE_VERSION_QUALIFIER.get(VERSION_QUALIFIER));
+    if (BUILD_NUMBER > 0)
+    {
+      System.out.println(NOTE_BUILD_NUMBER.get(
+                     new DecimalFormat("000").format(BUILD_NUMBER)));
+    }
+    System.out.println(NOTE_REVISION_NUMBER.get(REVISION_NUMBER));
+    System.out.println(NOTE_FIX_IDS.get(FIX_IDS));
+    System.out.println(NOTE_DEBUG_BUILD.get(DEBUG_BUILD));
+    System.out.println(NOTE_BUILD_OS.get(BUILD_OS));
+    System.out.println(NOTE_BUILD_USER.get(BUILD_USER));
+    System.out.println(NOTE_BUILD_JAVA_VERSION.get(BUILD_JAVA_VERSION));
+    System.out.println(NOTE_BUILD_JAVA_VENDOR.get(BUILD_JAVA_VENDOR));
+    System.out.println(NOTE_BUILD_JVM_VERSION.get(BUILD_JVM_VERSION));
+    System.out.println(NOTE_BUILD_JVM_VENDOR.get(BUILD_JVM_VENDOR));
+    System.out.println(NOTE_UPGRADE_EVENTS.get(StaticUtils.listToString(
+                      VersionCompatibilityIssue.getAllEvents(), ",")));
+  }
+
 }
 
diff --git a/opends/src/server/org/opends/server/util/RuntimeInformation.java b/opends/src/server/org/opends/server/util/RuntimeInformation.java
new file mode 100644
index 0000000..94828e9
--- /dev/null
+++ b/opends/src/server/org/opends/server/util/RuntimeInformation.java
@@ -0,0 +1,223 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Portions Copyright 2008 Sun Microsystems, Inc.
+ */
+
+ package org.opends.server.util;
+ import static org.opends.server.loggers.ErrorLogger.logError;
+ import static org.opends.messages.RuntimeMessages.*;
+ import static org.opends.messages.CoreMessages.*;
+ import static org.opends.server.util.DynamicConstants.*;
+ import org.opends.server.core.DirectoryServer;
+ import java.net.InetAddress;
+ import java.lang.management.RuntimeMXBean;
+ import java.lang.management.ManagementFactory;
+ import java.util.List;
+ import com.sleepycat.je.JEVersion;
+
+
+ /**
+  * This class is used to gather and display information from the runtime
+  * environment.
+  */
+ public class RuntimeInformation {
+
+
+   private static boolean is64Bit=false;
+
+   static {
+     String arch = System.getProperty("sun.arch.data.model");
+     if (arch != null) {
+       try {
+         is64Bit = Integer.parseInt(arch) == 64;
+       } catch (NumberFormatException ex) {
+         //Default to 32 bit.
+       }
+     }
+   }
+
+   /**
+    * Returns whether the architecture of the JVM we are running under is 64-bit
+    * or not.
+    *
+    * @return <CODE>true</CODE> if the JVM architecture we running under is
+    * 64-bit and <CODE>false</CODE> otherwise.
+    */
+   public static boolean is64Bit() {
+     return is64Bit;
+   }
+
+   /**
+    * Returns a string representing the JVM input arguments as determined by the
+    * MX runtime bean. The individual arguments are separated by commas.
+    *
+    * @return  A string representation of the JVM input arguments.
+    */
+   private static String getInputArguments() {
+     int count=0;
+     RuntimeMXBean rtBean = ManagementFactory.getRuntimeMXBean();
+     StringBuilder argList = new StringBuilder();
+     List<String> jvmArguments = rtBean.getInputArguments();
+     if ((jvmArguments != null) && (! jvmArguments.isEmpty())) {
+       for (String jvmArg : jvmArguments) {
+         if (argList.length() > 0)  {
+           argList.append(" ");
+         }
+         argList.append("\"");
+         argList.append(jvmArg);
+         argList.append("\"");
+         count++;
+         if (count < jvmArguments.size())  {
+           argList.append(",");
+         }
+       }
+     }
+     return argList.toString();
+   }
+
+   /**
+    * Writes runtime information to a print stream.
+    */
+   public static void printInfo() {
+     System.out.println(NOTE_VERSION.get(DirectoryServer.getVersionString()));
+     System.out.println(NOTE_BUILD_ID.get(BUILD_ID));
+     System.out.println(
+             NOTE_JAVA_VERSION.get(System.getProperty("java.version")));
+     System.out.println(
+             NOTE_JAVA_VENDOR.get(System.getProperty("java.vendor")));
+     System.out.println(
+             NOTE_JVM_VERSION.get(System.getProperty("java.vm.version")));
+     System.out.println(
+             NOTE_JVM_VENDOR.get(System.getProperty("java.vm.vendor")));
+     System.out.println(
+             NOTE_JAVA_HOME.get(System.getProperty("java.home")));
+     System.out.println(
+             NOTE_JAVA_CLASSPATH.get(System.getProperty("java.class.path")));
+     System.out.println(
+             NOTE_JE_VERSION.get(JEVersion.CURRENT_VERSION.toString()));
+     System.out.println(
+             NOTE_CURRENT_DIRECTORY.get(System.getProperty("user.dir")));
+     System.out.println(
+             NOTE_OPERATING_SYSTEM.get(System.getProperty("os.name") + " " +
+                     System.getProperty("os.version") + " " +
+                     System.getProperty("os.arch")));
+     String sunOsArchDataModel = System.getProperty("sun.arch.data.model");
+     if (sunOsArchDataModel != null) {
+       if (! sunOsArchDataModel.toLowerCase().equals("unknown")) {
+         System.out.println(NOTE_JVM_ARCH.get(sunOsArchDataModel + "-bit"));
+       }
+     }
+     else{
+       System.out.println(NOTE_JVM_ARCH.get("unknown"));
+     }
+     try {
+       System.out.println(NOTE_SYSTEM_NAME.get(InetAddress.getLocalHost().
+               getCanonicalHostName()));
+     }
+     catch (Exception e) {
+       System.out.println(NOTE_SYSTEM_NAME.get("Unknown (" + e + ")"));
+     }
+     System.out.println(NOTE_AVAILABLE_PROCESSORS.get(Runtime.getRuntime().
+             availableProcessors()));
+     System.out.println(NOTE_MAX_MEMORY.get(Runtime.getRuntime().maxMemory()));
+     System.out.println(
+             NOTE_TOTAL_MEMORY.get(Runtime.getRuntime().totalMemory()));
+     System.out.println(
+             NOTE_FREE_MEMORY.get(Runtime.getRuntime().freeMemory()));
+   }
+
+   /**
+    * Returns the physical memory size, in bytes, of the hardware we are
+    * running on.
+    *
+    * @return Bytes of physical memory of the hardware we are running on.
+    */
+   private static long getPhysicalMemorySize() {
+     com.sun.management.OperatingSystemMXBean mxbean =
+             (com.sun.management.OperatingSystemMXBean)
+             ManagementFactory.getOperatingSystemMXBean();
+     return mxbean.getTotalPhysicalMemorySize();
+   }
+
+   /**
+    * Returns a string representing the fully qualified domain name.
+    *
+    * @return A string representing the fully qualified domain name or the
+    * string "unknown" if an exception was thrown.
+    */
+   private static String getHostName() {
+     String host;
+     try {
+       host=InetAddress.getLocalHost().getCanonicalHostName();
+     }
+     catch (Exception e) {
+       host="Unknown (" + e + ")";
+     }
+     return host;
+   }
+
+   /**
+    * Returns string representing operating system name,
+    * version and architecture.
+    *
+    * @return String representing the operating system information the JVM is
+    * running under.
+    */
+   private static String getOSInfo() {
+    return System.getProperty("os.name") + " " +
+           System.getProperty("os.version") + " " +
+           System.getProperty("os.arch");
+   }
+
+   /**
+    * Return string representing the architecture of the JVM we are running
+    * under.
+    *
+    * @return A string representing the architecture of the JVM we are running
+    * under or "unknown" if the architecture cannot be determined.
+    */
+   private static String getArch() {
+     String sunOsArchDataModel = System.getProperty("sun.arch.data.model");
+     if (sunOsArchDataModel != null) {
+       if (! sunOsArchDataModel.toLowerCase().equals("unknown")) {
+         return (sunOsArchDataModel + "-bit");
+       }
+     }
+     return "unknown";
+   }
+
+   /**
+    * Write runtime information to error log.
+    */
+   public static void logInfo() {
+    logError(NOTE_JVM_INFO.get(System.getProperty("java.vm.version"),
+                               System.getProperty("java.vm.vendor"),
+                               getArch(),Runtime.getRuntime().maxMemory()));
+    logError(NOTE_JVM_HOST.get(getHostName(),getOSInfo(),
+                               getPhysicalMemorySize(),
+                               Runtime.getRuntime().availableProcessors()));
+    logError(NOTE_JVM_ARGS.get(getInputArguments()));
+   }
+ }

--
Gitblit v1.10.0