NonStop Server For Java 7.0 Programmer's Reference Non Stop Programmers Guide
User Manual:
Open the PDF directly: View PDF
.
Page Count: 132
| Download | |
| Open PDF In Browser | View PDF |
NonStop Server for Java 7.0
Programmer's Reference
Part Number: 693949-007
Published: April 2017
Edition: L15.02, J06.15, and H06.26 and all subsequent L-series, J-series, and H-series RVUs
© Copyright 2013, 2017 Hewlett Packard Enterprise Development LP
The information contained herein is subject to change without notice. The only warranties for Hewlett Packard Enterprise products and services
are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting
an additional warranty. Hewlett Packard Enterprise shall not be liable for technical or editorial errors or omissions contained herein.
Confidential computer software. Valid license from Hewlett Packard Enterprise required for possession, use, or copying. Consistent with FAR
12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed
to the U.S. Government under vendor's standard commercial license.
Links to third-party websites take you outside the Hewlett Packard Enterprise website. Hewlett Packard Enterprise has no control over and is not
responsible for information outside the Hewlett Packard Enterprise website.
Acknowledgments
Microsoft®, Windows®, and Windows NT® are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or
other countries.
Intel®, Intel Itanium®, Pentium®, and Celeron® are trademarks of Intel Corporation in the United States and other countries.
Java® and Oracle® are registered trademarks of Oracle and/or its affiliates.
UNIX® is a registered trademark of The Open Group. Motif, OSF, the OSF logo, OSF1, OSF/Motif, IT DialTone, The Open Group, and Open
Software Foundation are trademarks of The Open Group.
OSF MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THE OSF MATERIAL PROVIDED HEREIN, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. OSF shall not be liable for errors
contained herein or for incidental consequential damages in connection with the furnishing, performance, or use of this material.
© 1990, 1991, 1992, 1993 Open Software Foundation, Inc. The OSF documentation and the OSF software to which it relates are derived in part
from materials supplied by the following:© 1987, 1988, 1989 Carnegie-Mellon University. © 1989, 1990, 1991 Digital Equipment Corporation. ©
1985, 1988, 1989, 1990 Encore Computer Corporation. © 1988 Free Software Foundation, Inc. © 1987, 1988, 1989, 1990, 1991 Hewlett-Packard
Company. © 1985, 1987, 1988, 1989, 1990, 1991, 1992 International Business Machines Corporation. © 1988, 1989 Massachusetts Institute of
Technology. © 1988, 1989, 1990 Mentat Inc. © 1988 Microsoft Corporation. © 1987, 1988, 1989, 1990, 1991, 1992 SecureWare, Inc. © 1990,
1991 Siemens Nixdorf Informationssysteme AG. © 1986, 1989, 1996, 1997 Sun Microsystems, Inc. © 1989, 1990, 1991 Transarc Corporation.
OSF software and documentation are based in part on the Fourth Berkeley Software Distribution under license from The Regents of the University
of California. OSF acknowledges the following individuals and institutions for their role in its development: Kenneth C.R.C. Arnold, Gregory S.
Couch, Conrad C. Huang, Ed James, Symmetric Computer Systems, Robert Elz. © 1980, 1981, 1982, 1983, 1985, 1986, 1987, 1988, 1989
Regents of the University of California.
Contents
About this manual...................................................................................................8
Manual information...............................................................................................................................8
Intended audience................................................................................................................................8
New and changed information..............................................................................................................9
Document organization.......................................................................................................................10
Notation conventions..........................................................................................................................11
Related information.............................................................................................................................12
Publishing history................................................................................................................................15
1 Introduction to NSJ7..........................................................................................16
Features..............................................................................................................................................16
Java HotSpot server virtual machine..................................................................................................18
Java standard edition development kit (JDK).....................................................................................18
Java naming and directory interface (JNDI).......................................................................................19
IPv6 support........................................................................................................................................19
Associated Java based products........................................................................................................19
JDBC drivers for NonStop SQL database access.........................................................................20
JToolkit for NonStop servers..........................................................................................................21
NonStop servlets for JavaServer pages........................................................................................21
NonStop server for Java message service (JMS).........................................................................21
NonStop Tuxedo: Jolt client...........................................................................................................22
Stored procedures in Java.............................................................................................................22
2 Installation and configuration.............................................................................23
Summary of installation and configuration tasks................................................................................23
Installation requirements.....................................................................................................................23
Preinstallation tasks............................................................................................................................23
Preinstallation tasks for installing 64–bit NSJ7..............................................................................23
Installing NSJ7....................................................................................................................................23
Placing the new software on the NonStop system using DSM/SCM............................................24
Extract script and PAX files of NSJ7 32-bit....................................................................................24
Extract script and PAX files of NSJ7 64-bit....................................................................................25
Install NSJ7 32–bit.........................................................................................................................25
Install NSJ7 64–bit.........................................................................................................................25
Post-installation tasks.........................................................................................................................26
Verifying the Java installation.............................................................................................................26
Configuring NonStop system for NSJ7...............................................................................................27
Creating larger or additional swap file...........................................................................................27
Setting environment variables.......................................................................................................28
Symbolic link..................................................................................................................................30
Configuring TCP/IP and DNS for RMI...........................................................................................30
Memory considerations: Moving QIO to KSEG2................................................................................30
NSJ7 directory structure.....................................................................................................................32
Directory contents..........................................................................................................................32
Demonstration programs...............................................................................................................33
3 Getting started...................................................................................................34
Tutorial: Running a simple program, HelloWorld................................................................................34
Specifying the CPU and process name..............................................................................................35
Configuring a Java Pathway serverclass............................................................................................36
ARGLIST.......................................................................................................................................36
PROCESSTYPE............................................................................................................................36
ENV...............................................................................................................................................36
PROGRAM....................................................................................................................................37
Contents
3
4 Implementation specifics...................................................................................38
Headless support................................................................................................................................38
Additional files.....................................................................................................................................39
Additional environment variable..........................................................................................................39
Java native interface (JNI)..................................................................................................................39
Calling C or C++ routines from Java.............................................................................................40
Calling Java methods from C or C++............................................................................................41
Linker and compiler options...........................................................................................................42
How to create your own library of native code..............................................................................43
Floating-point implementation.............................................................................................................43
Floating-point values.....................................................................................................................43
Double-precision values................................................................................................................44
Calling TNS floating-point functions from JNI code.......................................................................44
Multi-threaded programming...............................................................................................................45
Thread scheduling.........................................................................................................................45
Threading considerations for Java code.......................................................................................48
Threading considerations for native code.....................................................................................48
ThreadDumpPath support..................................................................................................................49
Java print service................................................................................................................................49
Using the Guardian printer..................................................................................................................50
Dynamic saveabend file creation........................................................................................................50
Saveabend file generation..................................................................................................................51
FastExec option support.....................................................................................................................51
Java getLocalHost() caching..............................................................................................................51
Java authentication and authorization service....................................................................................51
JavaBeans..........................................................................................................................................52
Debugging Java programs..................................................................................................................52
Debugging overview......................................................................................................................52
Transports......................................................................................................................................53
Java command-line options to run a debuggee............................................................................53
Starting the Java debugger (JDB) tool..........................................................................................54
Debugging JNI code......................................................................................................................55
Debugging Java and JNI code......................................................................................................55
Deviations in JVM specification options..............................................................................................55
java: Java application launcher command-line option deviations..................................................55
jdb: Java debugger command-line option deviations....................................................................56
Garbage collection (GC).....................................................................................................................56
General information on garbage collection....................................................................................56
Heap Layout..................................................................................................................................56
Managing generation size.............................................................................................................58
Implementation of garbage collector types....................................................................................59
Memory management considerations.................................................................................................62
JVM data segment for 32–bit JDK7...............................................................................................62
JVM data segment for 64–bit JDK7...............................................................................................63
Java heap size with 32–bit JDK7..................................................................................................64
Java heap size with 64–bit JDK7..................................................................................................64
Native heap size with 32–bit JDK7................................................................................................64
Native heap size with 64–bit JDK7................................................................................................64
Java garbage collector tuning for application performance................................................................64
javagc.................................................................................................................................................65
GC profiling.........................................................................................................................................66
GC log rotation..............................................................................................................................66
—XX:+HeapDump and _JAVA_HEAPDUMP environment variable.............................................67
ZapInitialHeap option..........................................................................................................................69
4
Contents
64–bit process support.......................................................................................................................69
-d64 option.....................................................................................................................................69
Using 64–bit java launcher............................................................................................................70
32–bit process support.......................................................................................................................70
Large heap support.............................................................................................................................71
Version command-line option.............................................................................................................71
Posting signals to GC process............................................................................................................72
Java signal handlers...........................................................................................................................72
Unhandled exception..........................................................................................................................73
Error file..............................................................................................................................................73
ErrorFile with %p option................................................................................................................74
System property..................................................................................................................................75
LogVMOutput option...........................................................................................................................75
UseCompressedOops........................................................................................................................76
SecureRandom startup enhancement................................................................................................76
VirtualMachine.list() support...............................................................................................................76
Change in loading of .hotspot_compiler and .hotspotrc files..............................................................76
5 Java infrastructure.............................................................................................77
Architecture.........................................................................................................................................79
Socket or ServerSocket in java.net package.................................................................................79
SelectableChannels in java.nio.channelspackage........................................................................80
Selector.........................................................................................................................................81
Enabling JI.....................................................................................................................................81
Mapping file...................................................................................................................................82
Key................................................................................................................................................82
Value..............................................................................................................................................82
Installing Java infrastructure...............................................................................................................85
Installation requirements...............................................................................................................85
Preinstallation tasks.......................................................................................................................85
Installing JI.....................................................................................................................................85
Verifying the JI installation.............................................................................................................86
Establishing a connection...................................................................................................................87
Modes of communication....................................................................................................................87
BI-DIRECTIONAL mode................................................................................................................88
Request-response mode...............................................................................................................88
Communicating with non JI components............................................................................................88
JI client with a legacy TS/MP serverclass for context-free communication...................................89
JI client with a legacy TS/MP serverclass for dialog based communication.................................89
Legacy client with a JI server........................................................................................................89
6 Transactions......................................................................................................90
Controlling maximum concurrent transactions...................................................................................90
Current Class methods.......................................................................................................................90
Java transaction API...........................................................................................................................91
javax.transaction interfaces...........................................................................................................91
javax.transaction exceptions.........................................................................................................92
Examples.......................................................................................................................................92
7 Application tuning and profiling.........................................................................94
Profiling application performance.......................................................................................................94
Monitoring live Java applications...................................................................................................94
Collecting profile data for analysis.................................................................................................95
The HPROF profiler.......................................................................................................................96
—Xeprof versus —agentlib:hprof (HPROF)..................................................................................96
Obtaining garbage collection data for analysis..............................................................................96
Contents
5
Other profiling options...................................................................................................................97
Tuning application performance.........................................................................................................97
Determining the heap size setting.................................................................................................97
8 Migrating applications........................................................................................99
Summary of migration changes..........................................................................................................99
Installation changes.....................................................................................................................100
Public library directory.................................................................................................................100
Java based JAR file locations.....................................................................................................100
Dynamic link libraries...................................................................................................................101
Makefile to link native libraries....................................................................................................101
Compiling C++ native code.........................................................................................................101
Floating-point support..................................................................................................................102
Using AWT classes.....................................................................................................................103
POSIX threads.............................................................................................................................103
Directories of binary files moved.................................................................................................103
JAAS enhancement.....................................................................................................................104
Miscellaneous changes for migration to TNS/E..........................................................................104
Java stack size............................................................................................................................104
JNI application consideration......................................................................................................105
Dynamic snapshot.......................................................................................................................105
Migrating from serial GC to parallel GC............................................................................................105
Application start-up time overhead..............................................................................................105
Swap space consideration..........................................................................................................105
Resident space consideration.....................................................................................................106
Using _RLD_FIRST_LIB_PATH..................................................................................................106
Migrating to TNS/X ..........................................................................................................................106
Other considerations.........................................................................................................................106
Default Java heap size and stack size........................................................................................106
Java process name.....................................................................................................................107
Debugging Java process.............................................................................................................107
9 Support and other resources...........................................................................109
Accessing Hewlett Packard Enterprise Support...............................................................................109
Accessing updates............................................................................................................................109
Websites...........................................................................................................................................109
Customer self repair.........................................................................................................................110
Remote support................................................................................................................................110
Documentation feedback..................................................................................................................110
A Supported and unsupported features of NSJ7................................................111
Java SE 7.0 features not implemented in NSJ7...............................................................................111
B Addendum to HPjmeter 4.3 user's guide........................................................112
Completing installation of HPjmeter..................................................................................................112
Agent requirements.....................................................................................................................112
File locations................................................................................................................................112
Configuring your application to use HPjmeter command—line options......................................113
Attaching to the JVM Agent of a running application...................................................................113
Monitoring applications.....................................................................................................................113
Managing node agents................................................................................................................113
Diagnosing errors when monitoring running applications............................................................113
Profiling applications.........................................................................................................................113
Collecting profile data..................................................................................................................114
Analyzing garbage collection data....................................................................................................114
Using visualizer functions............................................................................................................114
Troubleshooting................................................................................................................................115
6
Contents
Identifying version numbers........................................................................................................115
Installation...................................................................................................................................115
Node agent..................................................................................................................................115
Quick references...............................................................................................................................115
Determining which HPjmeter features are available with a specific JVM version.......................115
C Warranty and regulatory information...............................................................117
Warranty information.........................................................................................................................117
Regulatory information......................................................................................................................117
Belarus Kazakhstan Russia marking...........................................................................................117
Turkey RoHS material content declaration..................................................................................118
Ukraine RoHS material content declaration................................................................................118
Glossary.............................................................................................................119
Index...................................................................................................................131
Contents
7
About this manual
NonStop Server for Java 7.0 Programmer's Reference manual identifies the changes in the
Hewlett Packard Enterprise adaptation of the reference Java implementation, emphasizing the
differences between the reference implementation and NSJ7. For more information on the
standard architecture, see Oracle Java documentation.
Manual information
Abstract
This manual describes the HPE Nonstop Server for Java, based on Java Platform
Standard Edition 7.0, a Java environment that supports compact, concurrent,
dynamic, and portable programs for the enterprise server. The NonStop Server
for Java 7.0 (NSJ7) uses the HPE NonStop operating system to add scalability
and program persistence to the Java environment.
Product version
NonStop Server for Java 7.0
Supported hardware
All HPE Integrity NonStop NS-series (TNS/E) servers and HPE Integrity NonStop
L-series (TNS/X) servers.
Supported release version updates (RVUs)
This manual supports L15.02 and subsequent L-series RVUs, J06.15 and all
subsequent J-series RVUs, and H06.26 and all subsequent H-series RVUs until
otherwise indicated by its replacement publications.
Intended audience
This NonStop Server for Java 7.0 Programmer's Reference manual is for the Java programmers
who want to use Java on NonStop systems.
Programmers developing Java applications on NonStop systems must be familiar with:
•
NonStop System fundamentals applicable to NSJ7
•
The Open System Services (OSS) environment
For more information, see “Related information” (page 12).
This manual does not provide information about the following:
•
The Java language and tools. For details about the Java language and tools, see Oracle
Java documentation.
•
Accessing SQL/MP and SQL/MX databases. For information on accessing the NonStop
SQL/MP and SQL/MX databases, see JDBC Driver for SQL/MP Programmer's Reference
and JDBC Type 4 Driver Programmer's Reference for SQL/MX Release x.x.
NonStop Server for Java 7.0 Programmer's Reference manual identifies the changes in the
Hewlett Packard Enterprise adaptation of the reference Java implementation, emphasizing the
differences between the reference implementation and NSJ7. For more information on the
standard architecture, see Oracle Java documentation.
8
New and changed information
Changes to 693949-007 manual are as follows:
•
Installation instructions are updated.
Changes to 693949-006R manual are as follows:
•
Updated Hewlett Packard Enterprise references.
Changes to 693949-006 manual are as follows:
•
Removed the RVU support information notes from features section.
Changes to 693949-005 manual are as follows:
•
Features pertaining to NSJ7 Update 2 are added in the section “Features” (page 16).
•
“Multi-threaded programming” (page 45) is updated to reflect general availability thread time
slice option.
•
Added a note in the section “FastExec option support” (page 51).
•
Added the section “Java getLocalHost() caching” (page 51).
•
Added the section “Heap layout for G1GC” (page 57).
•
Added G1GC to the section “Implementation of garbage collector types” (page 59).
•
Added a warning message in the section “Implementation of garbage collector types”
(page 59).
•
Added code samples for thread time slice feature in the section “Thread scheduling”
(page 45).
•
Added the section “G1GC collector” (page 61).
•
Updated vproc information in the section “Verifying the JI installation” (page 86).
Changes to 693949-004 manual are as follows:
•
Updated the entire manual with L-series specific information.
•
Updated unsupported options for the C3 compiler.
•
Updated the migration considerations for NSJ7 applications to L-series.
•
Updated the “Java infrastructure” (page 77) section to reflect the L-series updates.
Changes to 693949–002 manual are as follows:
•
“Feature changes” (page 9)
•
“Document changes” (page 10)
Feature changes
1.
2.
3.
4.
SecureRandom Startup enhancement: An improved version of random number
generation is introduced, which reduces the time taken for a CPU to generate
the first random number in a Java application.
JVM data segment allocation: Two command line options are added for better
utilization of the virtual memory. One each for 32–bit and 64–bit NSJ7.
VirtualMachine.list() support: A method that is used to return the list
of Java processes in the target machine.
Handling large GC files: A command line option is introduced to support GC
log file rotation.
New and changed information
9
Document changes
•
Added a note in the section “Installation requirements” (page 23).
•
Updated version procedure information in the section “Verifying the Java
installation” (page 26).
•
Added a section “Handling large GC log files” (page 62).
•
Updated the section “JVM data segment for 32–bit JDK7” (page 62).
•
Updated the section “JVM data segment for 64–bit JDK7” (page 63).
•
Added a section “Java signal handlers” (page 72).
•
Added a section “SecureRandom startup enhancement” (page 76).
•
Added a section “VirtualMachine.list() support” (page 76).
•
Client_socket is modified to client-socket and server_socket to
server-socket in the section “Key” (page 82).
•
Added a section “Analyzing garbage collection data” (page 114).
•
Added a section “Change in loading of .hotspot_compiler and
.hotspotrc files” (page 76).
•
Updated the section “Node agent” (page 115).
Changes to 693949–001 manual are as follows:
This is a new manual.
NOTE: This manual is valid for H-series and J-series systems. However, “Garbage collection
(GC)” (page 56) implementation enhancements are applicable only for J-series systems.
Document organization
This manual is structured as follows:
Table 1 Organization of chapters
10
Section
Description
“Introduction to NSJ7” (page 16)
Explains NonStop software fundamentals applicable to
NSJ7, describes associated Java products on the NonStop
system, lists the J2SE and JDK features supported by
NSJ7.
“Installation and configuration” (page 23)
Explains installation and configuration requirements, NSJ7
directory structure, procedures to run Java tools and to
verify the installation.
“Getting started” (page 34)
Explains the procedure to run a sample Java program.
“Implementation specifics” (page 38)
Explains the NSJ7 implementation specifics.
“Java infrastructure” (page 77)
Java Infrastructure provides Java abstraction to NonStop
FS and TS/MP API.
“Transactions” (page 90)
Explains the transaction behavior in NSJ7.
“Application tuning and profiling” (page 94)
Describes the application profiling environment, HPROF
(that is Xeprof), and HPROF agent. Also, describes
HPjmeter profile data analysis tool.
“Migrating applications” (page 99)
Explains migration details for earlier NSJ applications.
Table 1 Organization of chapters (continued)
Section
Description
“Supported and unsupported features of NSJ7” (page 111) Summarizes the supported and unsupported features of
NSJ7.
“Addendum to HPjmeter 4.3 user's guide” (page 112)
Provides instructions for using the HPjmeter tool on the
NonStop system.
Notation conventions
Bold type
Bold type within text indicates terms defined in the Glossary.
For example, abstract class
Computer type
Computer type letters within text indicate keywords, reserved words, command
names, class names, and method names; enter these items exactly as shown.
For example:
myfile.c
Italic computer type
Italic computer type letters in syntax descriptions or text indicate variable
items that you supply. For example:
pathname
[ ] Brackets
Brackets enclose optional syntax items. For example:
jdb [options]
A group of items enclosed in brackets is a list from which you can choose one
item or none. Items are separated by vertical lines. For example:
where [threadID|all]
{ } Braces
A group of items enclosed in braces is a list from which you must choose one
item. For example:
-c identity {true|false}
| Vertical line
A vertical line separates alternatives in a list that is enclosed in brackets or braces.
For example:
where [threadID|all]
... Ellipsis
An ellipsis immediately following a pair of brackets or braces indicates that you
can repeat the enclosed sequence of syntax items any number of times. For
example:
print {objectID|objectName} ...
Notation conventions
11
An ellipsis immediately following a single syntax item indicates that you can repeat
that syntax item any number of times. For example:
dump objectID ...
Punctuation
Parentheses, commas, equal signs, and other symbols not previously described
must be entered as shown. For example:
-D propertyName=newValue
Item spacing
Spaces shown between items are required unless one of the items is a punctuation
symbol such as a parenthesis or comma. If there is no space between two items,
spaces are not permitted. In the following example, spaces are not permitted
before or after the period:
subvolume-name.filename
Line spacing
If the syntax of a command is too long to fit on a single line, each line that is to
be continued on the next line ends with a back slash ( \ ) and each continuation
line begins with a greater-than symbol ( > ). For example:
/usr/bin/c89 -c -g -I /usr/tandem/java/include \
> -I /usr/tandem/java/include/oss -I . \
> -Wextensions -D_XOPEN_SOURCE_EXTENDED=1 jnative01.c
Related information
For background information about the features described in this manual, see following documents:
12
•
“NonStop server for Java library” (page 13)
•
“NonStop system computing documents” (page 13)
•
“Oracle Java documents” (page 14)
•
Various white papers on NonStop Server for Java.
NonStop server for Java library
In addition to this manual, the NonStop Server for Java library includes:
•
NonStop Server for Java 7.0 Tools Reference
•
NonStop Server for Java API Reference Pages
NonStop system computing documents
The following NonStop system computing documents are available in the HPE NonStop Technical
Library at Hewlett Packard Enterprise Support Center (HPESC).
•
Additional Java Based Products
◦
JDBC Driver for SQL/MP Programmer's Reference
◦
JDBC Driver for SQL/MX Programmer's Reference
◦
JToolkit for Java API Reference Pages
This documentation describes how to access:
–
JToolkit for NonStop Server for Java Programmer's Reference and API
•
C/C++ Programmer's Guide
•
DLL Programmer's Guide for TNS/E Systems
•
eld Manual
•
iTP Secure WebServer System Administrator's Guide
•
Kernel-Managed Swap Facility (KMSF) Manual
•
Native Inspect Manual
•
NonStop Servlets for JavaServer Pages (NSJSP) System Administrator’s Guide
•
ODBC (Open Database Connectivity) Documents
◦
ODBC Server Reference Manual
◦
SQL/MX Connectivity Service Manual
•
Open System Services Installation Guide
•
Open System Services Porting Guide
•
Open System Services Programmer's Guide
•
Spooler FASTP Network Print Processes Manual
•
Spooler Utilities Reference Manual
•
SQL/MP Manuals
◦
Introduction to NonStop SQL/MP
◦
SQL/MP Reference Manual
◦
SQL/MP Installation and Management Guide
◦
SQL/MP Query Guide
◦
SQL/MP Report Writer Guide
◦
SQL/MP Version Management Guide
Related information
13
•
◦
SQL/MP Messages Manual
◦
SQL/MP Programming Manual for C
◦
SQL/MP Programming Manual for COBOL
◦
See also SQL Supplement for H-series RVUs.
SQL/MX Manuals
NonStop Server for Java includes JDBC drivers that enable Java programs to interact with
NonStop SQL databases with SQL/MX.
◦
SQL Supplement for H-series RVUs
◦
SQL/MX Guide to Stored Procedures in Java
◦
SQL/MX Quick Start
◦
SQL/MX Comparison Guide for SQL/MP Users
◦
SQL/MX Installation and Management Guide
◦
SQL/MX Glossary
◦
SQL/MX Query Guide
◦
SQL/MX Reference Manual
◦
SQL/MX Messages Manual
Describes SQL/MX messages.
◦
SQL/MX Programming Manual for C and COBOL
◦
SQL/MX Data Mining Guide
◦
SQL/MX Queuing and Publish/Subscribe Services
•
TCP/IP Configuration and Management Manual
•
TCP/IPv6 Configuration and Management Manual
•
TMF Manuals
◦
TMF Introduction
◦
TMF Application Programmer's Guide
•
TS/MP Pathsend and Server Programming Manual
•
TS/MP System Management Manual
Oracle Java documents
For Java SE 7 documentation, visit the Oracle web site Java Platform Standard Edition 7
Documentation.
The following documents are available on Oracle web site at the time of this manual's publication.
However, Hewlett Packard Enterprise cannot guarantee their current availability. If a link to an
14
Oracle document fails, use the Oracle documentation, which is available in ZIP format in the
distribution CD.
•
JNDI document
•
JDBC documents
•
Java Print Service (JPS) document
•
Java Transaction API (JTA) document
•
Java Transaction Service (JTS) document
•
Java Remote Method Invocation (RMI) document
Publishing history
Part number
Product version
Published
693949-003
NonStop Server for Java 7.0
February 2015
693949-004
NonStop Server for Java 7.0
February 2015
693949-005
NonStop Server for Java 7.0
May 2015
693949-006
NonStop Server for Java 7.0
August 2015
693949-006R
NonStop Server for Java 7.0
November 2015
693949-007
NonStop Server for Java 7.0
April 2017
Publishing history
15
1 Introduction to NSJ7
NonStop Server for Java 7.0 (NSJ7) provides a Java environment that supports compact,
concurrent, and dynamic portable programs for the NonStop systems. NSJ7 is supported on the
NonStop Open System Services (OSS) environment. NSJ7 uses the NonStop operating system
to provide scalability and program persistence to the Java environment. NSJ7 is based on the
Java Platform Standard Edition (Java SE) 7.0 reference, which is a Java implementation for
Solaris. NSJ7 contains two product components, 32–bit NSJ7 (T2766) and 64–bit NSJ7 (T2866).
NSJ7 is a fully compliant headless JDK. This section discusses the following topics:
•
“Features” (page 16)
•
“Java HotSpot server virtual machine” (page 18)
•
“Java standard edition development kit (JDK)” (page 18)
•
“Java naming and directory interface (JNDI)” (page 19)
•
“IPv6 support” (page 19)
•
“Associated Java based products” (page 19)
Features
Starting with J06.19 RVU, NSJ7 (SPR IDs T2766H70^ACN and T2866H70^ACN) provide the
following new features, which are applicable for both 32–bit and 64–bit NSJ7:
•
Support for G1GC
This release contains a new Garbage Collector (GC) algorithm called Garbage First Garbage
Collector (G1GC) that is supported by Oracle. This version of G1GC is a beta version.
For more information, see http://www.oracle.com/technetwork/java/javase/tech/
g1-intro-jsp-135488.html.
•
Thread Pre-emption Changes
In earlier releases of NSJ7, thread pre-emption feature was used as a beta version. Starting
with J06.19, thread pre-emption option is made available as a general availability function.
Using this option, Java user threads can be pre-empted and the JVM daemon threads are
not pre-empted.
-XX:ThreadTimeSlice option is enhanced to meet the product quality. The default
timeslice for one Java thread is 400 ms. The Java thread is pre-empted only when it is
executing code from Java code cache and has completed its allotted time slice. This includes
execution in both Java interpreted code and Java Hotspot compiled code. This option benefits
only a multithreaded Java application, which ensures that there is an equal amount of time
slice for all the Java threads. This reduces the starvation of runnable threads waiting for
CPU time as other Java thread may not yield the CPU.
NOTE: The timeslice mentioned is the minimum time used by a thread. The actual
time used by a thread depends on which mode the thread is executed, privileged mode or
native code. If the thread is executed in privilege mode or native code, and when the
timeslice expires, the thread gets another timeslice to run.
•
EMS Templates Installation Changes
During the installation of NSJ7 (T2766H70^ACN and T2866H70^ACN), DSM/SCM installs
EMS templates for Java. To achieve this, a separate configuration for EMS templates file is
distributed along with the PAX file.
•
16
Java Infrastructure
Introduction to NSJ7
NOTE: Currently, the product number, installation path, and configuration path refers to
H70 in this manual. If JI is being installed and configured on L-series RVUs, then consider
H70 as L70.
Java Infrastructure (JI) is available as a separate product with the T number T2966H70. JI
must be installed at the same location as that of NSJ7. By default, JI is installed at the location
/usr/tandem/nssjava/jdk170_h70. JI contains the following components:
ji.jar
the jar file is available at the location $JREHOME/lib.
libji.so
the native library is available at location $JREHOME/lib/oss (for 32-bit) and
$JREHOME/lib/oss64 (for 64-bit).
Features released in the earlier versions of NSJ7 are as follows:
•
Support for 64–bit Java application
Using 64–bit NSJ7, it is possible to develop or port applications that require Java heaps
greater than 1276 MB, which is the limit with 32–bit NSJ7. The theoretical maximum Java
heap available with 64–bit NSJ7 is 484 GB. For more information, see “Managing generation
size” (page 58) and “64–bit process support” (page 69).
NOTE:
•
64–bit NSJ7 (T2866) cannot be installed as a standalone product.
Support for nonblocking I/O for regular and non-regular OSS files
NSJ7 uses the new Pthreads library called POSIX User Thread Model (PUT) library. As a
result, NSJ7 provides nonblocking I/O support for both regular and non-regular OSS files.
For more information, see “Pthread library changes” (page 49).
•
Support for parallel and CMS GC
NSJ7 supports parallel and CMS GC which provide reduced GC pause times.
64–bit JDK enables you to port or develop large Java applications on NSJ7. If an application
uses large Java heap and serial GC, the application pause time due to GC may be high.
Hence, to reduce application pause time during garbage collection, NSJ7 provides parallel
and concurrent garbage collectors. This implementation differs from other platforms. However,
the functionality remains same. The difference is due to the absence of Kernel threads on
NonStop systems.
On other platforms, Kernel threads allow GC threads to run in parallel on multi core systems.
On Nonstop, in the absence of Kernel threads only one thread runs at any time, and is
managed in the user space by the Pthreads library. As a result, a multi-threaded application
on Nonstop cannot utilize the parallelism in execution offered by multi core systems.
To introduce parallelism in garbage collection, the garbage collector threads are converted
to processes, when parallel and CMS garbage collectors and G1GC are enabled.
For more information, see “Migrating from serial GC to parallel GC” (page 105).
NOTE:
◦
For user thread limitation see Open System Services Programmer's Guide.
◦
Parallel, CMS GC, and G1GC are not supported on single core machines.
Features
17
•
NSJ7 continues to provide headless support
NSJ7 is a headless JVM that conforms to the Oracle's headless support standards regarding
Java Abstract Window Toolkit (AWT) classes and methods. For implementation-specific
information, see “Headless support” (page 38).
•
Support for JPDA
JPDA consists of three interfaces designed for debuggers in development environments for
desktop systems. For more information, see Oracle Java documentation for JPDA.
Java HotSpot server virtual machine
NSJ7 implements the HotSpot server compiler and the runtime Java HotSpot virtual machine.
The HotSpot Server Java virtual machine provides a fast, reliable technology for the enterprise
server environment. For more information, see The Java HotSpot Server VM and Java Virtual
Machines.
Java standard edition development kit (JDK)
NSJ7 consists of the following standard Java components (and the Hewlett Packard Enterprise
extensions described else where in this manual):
•
Java virtual machine (VM) based on the Java SE Runtime Environment (JRE) 7.0
•
Core Packages of the Java™ SE Development Kit (JDK) 7.0
•
Standard Java SE 7.0 tools as documented in the NonStop Server for Java 7.0 Tools
Reference Pages. All standard tools are supported, except graphical user interface (GUI)
such as appletviewer, policytool, and jconsole, and client-side tools such as
javaws and HtmlConverter. Experimental tools are not supported.
•
JDK 7.0 API packages such as java, javax, and org packages described in the Java
Platform Standard Edition 7.0 API Specification.
Table 2 (page 18) lists the packages which NSJ7 supports according to Headless Support.
Table 2 List of packages with headless support on NSJ7
Package
Description
java.awt and AWT-related packages
Contains the classes used for creating user
interfaces, and for painting graphics and images.
javax.accessibility
Defines a contract between user interface
components and technology that provides access
to these components.
javax.sound and Sound-related packages
Provides an API for capturing, processing, and
playing back audio and MIDI (Musical Instrument
Digital Interface) data. This API is supported by a
sound engine that provides high-quality audio mixing
and MIDI synthesis capabilities for the platform.
javax.swing and Swing-related packages
Provides a set of Java components, which works in
the similar mode on all platforms.
If a call is made to the code that depends on a keyboard, display, mouse, or sound processing,
NSJ7 throws a java.awt.HeadlessException.
For more information on the core packages of Java SE Development Kit 7.0, see “Oracle Java
documents” (page 14).
18
Introduction to NSJ7
Java naming and directory interface (JNDI)
The JNDI provides naming and directory functionality to Java programs. It is independent of any
specific directory service implementation; therefore, it allows a variety of directories to be accessed
in a common way.
The JNDI architecture consists of an Application Programming Interface (API) and a Service
Provider Interface (SPI). Java programs use the JNDI API to access a variety of naming and
directory services. The JNDI SPI enables a variety of naming and directory services to be plugged
in transparently, allowing Java programs that use the JNDI API to access their services.
NonStop Server for Java supports JNDI, which is a standard interface in Java implementations.
For more information about the JNDI, see Oracle Java documentation Java Naming and
Directory Interface 1.1.1 Specification.
IPv6 support
The Java SE JRE 7.0 release includes Internet Protocol version (IPv6) support in Java Networking.
For more information, see Oracle Java Documentation Networking IPv6 User Guide.
NOTE: IPv6 support is provided only if you use the NonStop TCP/IPv6 or CIP subsystem with
NonStop Server for Java.
Associated Java based products
Consider a scenario in which you develop a standard Java application and then deploy and run
them on NonStop servers. You can develop these applications by using a wide-range of associated
Java based products that can use the NSJ7 runtime. The products are as follows:
•
“JDBC drivers for NonStop SQL database access” (page 20)
•
“JToolkit for NonStop servers” (page 21)
•
“NonStop servlets for JavaServer pages” (page 21)
•
“NonStop server for Java message service (JMS)” (page 21)
•
“NonStop Tuxedo: Jolt client” (page 22)
•
“Stored procedures in Java” (page 22)
Figure 1 (page 20) illustrates the high-level middleware products that appear working with NSJ7
and NonStop SQL databases.
Java naming and directory interface (JNDI)
19
Figure 1 Java based products on NonStop systems
JDBC drivers for NonStop SQL database access
JDBC drivers implement JDBC API and provide access to NonStop SQL databases. You can
use JDBC API calls in your Java programs to access SQL tables on NonStop systems. The
following are the available drivers and the access they provide are:
•
•
Type 2, which is native API driver to use in Java programs running with NonStop Server for
Java on a NonStop system. The type 2 driver is installed using SUT.
◦
JDBC Driver for NonStop SQL/MX (JDBC/MX) for use with SQL/MX
◦
JDBC Driver for NonStop SQL/MP (JDBC/MP) for use with SQL/MP
JDBC Type 4, which uses network protocols built in the database engine. Type 4 driver
communicates directly to the database using Java sockets. You can use the HPE NonStop
JDBC Type 4 Driver in Java programs running on PCs, HP-UX systems, and other platforms
for access to NonStop SQL/MX. For the latest list of supported platforms, see current JDBC
Type 4 Softdoc, which can be found online by accessing Scout for NonStop Servers.
To obtain detailed information on the standard JDBC API, you can download the JDBC API
documentation provided by Oracle documentation.
For information on Hewlett Packard Enterprise drivers that are provided to access SQL/MX or
SQL/MP, see JDBC driver manuals at http://www.hpe.com/info/nonstop-docs.
20
Introduction to NSJ7
JToolkit for NonStop servers
The HPE JToolkit for NonStop Servers includes three APIs as tools for using Java programs to
access legacy applications on NonStop servers. JToolkit also includes Scalable TCP/IP (SIP)
for developing network servers written in Java. For more information, see JToolkit for Java API
Reference Pages.
Enscribe API for Java
The Enscribe API for Java allows access to the Enscribe Database Manager, supported by the
Guardian file system. This access is typically used to interact with legacy applications.
Pathway API for Java
The Pathway API for Java provides access to a file called $RECEIVE, which is required to enable
a process to act as a Pathway server. These servers are typically used in legacy applications.
Pathway server programs read requests from requestor programs and act on those requests.
The Guardian requestor or server model is described in the TS/MP 2.5 Pathsend and Server
Programming Manual.
A process sends a message to another process by opening the recipient process file and writing
a message to it. Because a process might not know in advance which processes send messages
to it and in which order, all messages to a process arrive using a single file system connection.
Reading from $RECEIVE a process receives a message whether the message is a request from
another user process or a system message.
Pathsend API for Java
The NonStop TS/MP product supports the use of Pathway servers to access NonStop SQL or
Enscribe databases in an online transaction processing (OLTP) environment. Using the Pathsend
API for Java, programs can send requests to these Pathway servers and receive replies from
them. Pathway servers are written in C, COBOL, or Java.
Scalable TCP/IP
Scalable TCP/IP (SIP) for the NonStop Server for Java provides a transparent way to provide
the NonStop fundamentals of scalability and persistence to a network server (SIP server) written
in Java. Existing servers written in Java and their clients can take advantage of SIP without being
changed.
NonStop servlets for JavaServer pages
NonStop Servlets for JavaServer Pages (NSJSP) are platform-independent server-side programs
that programmatically extend the functionality of web-based applications by providing dynamic
content from a Web Server to a client browser over the HTTP protocol. NSJSP is an extension
of that servlet functionality, primarily supplying a template of static content to be modified with
dynamic content from a servlet or another programmable resource.
NSJSP requires the use of the iTP Secure WebServer, which is based on Tomcat. Tomcat
implements the Java Servlet and JavaServer Pages specifications. For more information about
NSJSP, see NonStop Servlets for JavaServer Pages (NSJSP) System Administrator's Guide.
For more information about the iTP Secure WebServer, see iTP WebServer System Administrator's
Guide.
NonStop server for Java message service (JMS)
NonStop Server for Java Message Service (NSJMS) is the JMS provider that implements Oracle's
Java Message Service (JMS) API, on NonStop servers. NSJMS uses the performance and
reliability inherent in SQL/MX products to provide standard-based messaging for local clients
running on NonStop servers. NSJMS enables scalability and load distribution through horizontal
partitioning and fault-tolerance through process-pair technology.
Associated Java based products
21
The following are the features and functions of NSJMS:
•
Implements the JMS API on NonStop systems.
•
Uses the publish and subscribe features of NonStop SQL/MX.
•
Uses a Java Naming and Directory Interface (JNDI) environment that allows access to
NSJMS connection factories, and queue objects or topic objects.
•
Enables use of a persistent, reliable bridge environment to allow interoperability between
NSJMS and a locally hosted foreign JMS provider.
•
Supports the NSJMS C++ API, which implements a subset of the functionality provided by
the Oracle JMS API, and is used by C++ client applications running on a NonStop system
to interoperate with other JMS clients.
•
Uses the NSJMS administrative utility to manage the NSJMS environment. You can invoke
the utility through a command-line interface or XML interface.
NSJMS conforms to Oracle's published specification, Java Message Service, except as noted
in NSJMS documentation. The specification is available at Java Message Service (JMS). For
more information about NSJMS, see NonStop JMS User's Manual.
NonStop Tuxedo: Jolt client
The Jolt product is a Java based interface to the HPE NonStop Tuxedo system that extends
Tuxedo services to the Internet. Jolt allows you to build client programs and applets that can
remotely invoke existing NonStop Tuxedo services allowing application messaging, component
management, and distributed transaction processing.
With Jolt, you can leverage existing Tuxedo services and extend your transaction environment
to the corporate intranet or worldwide Internet. The key feature of the Jolt architecture is its
simplicity. Using Jolt, you can build, deploy, and maintain robust, modular, and scalable electronic
commerce systems that operate over the Internet.
The Jolt product includes the JoltBeans toolkit, which provides a JavaBeans compliant interface
to Jolt for NonStop Tuxedo. The JoltBeans toolkit contains beans that wrap the existing Jolt class
library in reusable bean components such as, the JoltSessionBean or the JoltServiceBean.
These beans can be customized easily by giving application specific values to properties and
connecting them with other bean components. You can use the JoltBeans toolkit with your
Integrated Development Environment (IDE) to create Jolt clients that can access a Tuxedo
application.
The Jolt product includes the Jolt Web Application Services Toolkit, which is an extension to the
Jolt 1.1 Java class library. The Toolkit allows the Jolt client class library to be used in a Web
Server to provide an interface between HTML clients or browsers, and Tuxedo services.
For more information, see TUXEDO product documentation at http://www.hpe.com/info/
nonstop-docs.
Stored procedures in Java
Stored procedures in Java (SPJs) provide an efficient and secure way to implement business
logic in an SQL/MX database. They allow you to write portable applications in Java and access
an industry-standard SQL database.
An SPJ is a type of user-defined routine (UDR) that operates within a database server. A UDR
can be either a stored procedure, which does not return a value directly to the caller, or a
user-defined function, which does return a value directly to the caller. (A stored procedure returns
a value only to a host variable or dynamic parameter in its parameter list.)
In the SQL/MX database, an SPJ is a Java method contained in a Java class, registered in
SQL/MX, and invoked by SQL/MX when an application issues a CALL statement to the method.
For more information on using SPJs, see SQL/MX Guide to Stored Procedures in Java.
22
Introduction to NSJ7
2 Installation and configuration
NOTE: Currently, the installation path and configuration path refer to H70 in this manual. If the
product is being installed on L-series RVUs, then consider H70 as L70.
Summary of installation and configuration tasks
•
Perform the installation requirements task described in “Installation requirements” (page 23).
•
Perform the preinstallation tasks described in “Preinstallation tasks” (page 23).
•
Perform the installation tasks described in “Installing NSJ7” (page 23).
•
Perform the post-installation tasks described in “Post-installation tasks” (page 26) as per
your requirement.
•
Perform the verification tasks described in “Verifying the Java installation” (page 26) as per
your requirement.
•
Perform the configuration tasks described in “Configuring NonStop system for NSJ7”
(page 27) as per your requirement.
•
Perform the verification of the NSJ7 directory structure shown in “NSJ7 directory structure”
(page 32).
Installation requirements
•
NSJ7 can be installed only on NonStop systems running on H06.26 and J06.15 or later
RVUs.
•
The software requirements list the earlier compatible versions of the required software for
installing NSJ7.
•
Read the Softdoc before installing the product as the software requirements are described
in NSJ7 product Softdoc.
NOTE: The current version of NSJ7 can coexist with earlier version of NSJ as long as the
earlier version of NSJ and the current version of NSJ7 are installed in different directories.
Preinstallation tasks
•
If this is the first installation of NSJ7, ignore this step. Back up all the files, including security
certificates (cacerts) and other user created files in the NSJ7 installation directory for
H-series (/usr/tandem/nssjava/jdk170_h70).
Preinstallation tasks for installing 64–bit NSJ7
•
The installation directory selected for 64–bit NSJ7 (T2866H70) must contain the 32–bit NSJ7
(T2766H70) installation.
•
Before proceeding to the 64–bit NSJ7 installation, follow the instructions provided in “Installing
NSJ7” (page 23) for 32–bit NSJ7, and complete the installation.
Installing NSJ7
Installation of 32–bit and 64–bit NSJ7 is a three step process and is described in the following
topics:
1. “Placing the new software on the NonStop system using DSM/SCM” (page 24)
2. Extracting script and PAX files for 32–bit and 64–bit NSJ7.
3. Installing 32–bit and 64–bit by using NSJ7 installation script.
Summary of installation and configuration tasks
23
IMPORTANT: If you intend to use 32–bit NSJ7, installing 32–bit NSJ7 is sufficient. If you intend
to use 64–bit features provided by NSJ7, then both 32–bit and 64–bit NSJ7 must be installed.
Placing the new software on the NonStop system using DSM/SCM
NOTE:
The following procedure is applicable for both 32–bit and 64–bit NSJ7.
•
Receive the SPR from disk or tape.
•
Copy the SPR to a new revision of the software configuration you want to update.
•
Build and apply the configuration revision.
•
Run ZPHIRNM to perform the rename step.
DSM/SCM places the pax file in $tsvvol.ZOSSUTL subvolume, where, tsvvol is the disk
volume in which the DSM/SCM places the target subvolumes (TSVs).
For more information, see DSM/SCM User's Guide.
NOTE: Installation of NSJ7 does not require a system generation, and therefore does not
require a cold-load.
Extract script and PAX files of NSJ7 32-bit
1.
The DSM/SCM planner interface with the Manage OSS Files check box selected. Using
this method NSJ7 JDK files are extracted to the default or standard location.
For example, /usr/tandem/nssjava/javainstall/$(VPROC_STR)
VPROC_STR
is the VPROC of the product.
For example, the VPROC of T2766H70^ADG is T2766H70_11MAR2017_jdk170_ADG.
The following files are extracted:
2.
•
NSJavaInstall32 - an installation script to install JDK from the JDK PAX file.
•
T2766IPAX - JDK installation PAX file.
If Manage OSS Files is not selected, DSM/SCM places the PAX file to the TSV
($tsvvol.ZOSSUTL). Then, using PINSTALL you must manually extract the contents of
the pax file to the NSJ7 installation directory.
For more information on PINSTALL, see DSM/SCM User's Guide.
NOTE:
24
•
DSM/SCM extracts only the installation files, you must run the scripts mentioned in
Install NSJ7 32-bit to complete the installation.
•
If the extracted files are deleted, you must re-extract the files.
Installation and configuration
Extract script and PAX files of NSJ7 64-bit
1.
The DSM/SCM planner interface with the Manage OSS Files check box selected. Using
this method NSJ7 JDK files are extracted to the default or standard location.
For example, /usr/tandem/nssjava/javainstall/$(VPROC_STR)
VPROC_STR
is the VPROC of the product.
For example, the VPROC of T2866H70^ADG is T2866H70_11MAR2017_jdk170_ADG.
The following files are extracted:
2.
•
NSJavaInstall64 - an installation script to install JDK from the JDK PAX file.
•
T2866IPAX - JDK installation PAX file.
If Manage OSS Files is not selected, DSM/SCM places the PAX file to the TSV
($tsvvol.ZOSSUTL). Then, using PINSTALL you must manually extract the contents of
the pax file to the NSJ7 installation directory.
For more information on PINSTALL, see DSM/SCM User's Guide.
NOTE:
•
DSM/SCM extracts only the installation files, you must run the scripts mentioned in
Install NSJ7 64-bit to complete the installation.
•
If the extracted files are deleted, you must re-extract the files.
Install NSJ7 32–bit
You can install 32-bit NSJ7 either in the standard location or custom location.
1. Issue the following command to install 32-bit NSJ7 at the standard location:
>sh $(SCRIPT_LOCATION)/NSJavaInstall32
$(SCRIPT_LOCATION)
is the default location, /usr/tandem/nssjava/javainstall/$(VPROC_STR)
The contents of T2766IPAX are delivered to the OSS directory at:
/usr/tandem/nssjava/jdk170_l70
2.
Issue the following command to install 32-bit NSJ7 at the custom location:
>sh $(SCRIPT_LOCATION)/NSJavaInstall32
$(SCRIPT_LOCATION)
is the default location, /usr/tandem/nssjava/javainstall/$(VPROC_STR)
The contents of T2766IPAX are delivered to the OSS directory at the specified custom
location.
Example 1 To install 32-bit NSJ7 in a custom location /h/myjava
Issue the following command:
>sh $(SCRIPT_LOCATION)/NSJavaInstall32
where,
SCRIPT_LOCATION is /usr/tandem/nssjava/javainstall/$(VPROC_STR)
The contents of T2766IPAX are delivered to the following location:
/h/myjava/nssjava/jdk170_l70
Install NSJ7 64–bit
You can install 64-bit NSJ7 either in the standard location or custom location.
Installing NSJ7
25
1.
Issue the following command to install 64-bit NSJ7 at the standard location:
>sh $(SCRIPT_LOCATION)/NSJavaInstall64
$(SCRIPT_LOCATION)
is the default location, /usr/tandem/nssjava/javainstall/$(VPROC_STR)
The contents of T2866IPAX are delivered to the OSS directory at:
/usr/tandem/nssjava/jdk170_l70
2.
Issue the following command to install 64-bit NSJ7 at the custom location:
>sh $(SCRIPT_LOCATION)/NSJavaInstall64
$(SCRIPT_LOCATION)
is the default location, /usr/tandem/nssjava/javainstall/$(VPROC_STR)
The contents of T2866IPAX are delivered to the OSS directory at the specified custom
location.
Example 2 To install 64-bit NSJ7 in a custom location /h/myjava
Issue the following command:
>sh $(SCRIPT_LOCATION)/NSJavaInstall64
where,
SCRIPT_LOCATION is /usr/tandem/nssjava/javainstall/$(VPROC_STR)
The contents of T2866IPAX are delivered to the following location:
/h/myjava/nssjava/jdk170_l70
Post-installation tasks
•
Installation of NSJ7 does not automatically create the softlink /usr/tandem/java
softlink. If required, that softlink must be manually created to point to the NSJ7 JDK/JRE
installation for H-series (/usr/tandem/nssjava/jdk170_h70) after the installation is
completed.
◦
Ensure to remove the existing softlink.
◦
As required, create the softlink /usr/tandem/java to point to the NSJ7 home directory
as follows:
For H-series $ ln –s /usr/tandem/nssjava/jdk170_h70 /usr/tandem/java
NOTE: Consider the possibility of /usr/tandem/java softlink already being set
and used to launch previous versions of NSJ. Redirecting it as shown here, causes all
future invocations of /usr/tandem/java/bin/java to launch NSJ7 Java. This can
lead to failure of applications which are not migrated to NSJ7 or are not intended to be
run with NSJ7.
•
Restore the files backed up during the pre-installation phase.
Verifying the Java installation
Check with your system administrator for the installed NSJ7 (32–bit and 64–bit) software locations,
and verify the installation and the environment. This example assumes that NSJ7 is installed in
a nonstandard location for H–series /home/lee/nssjava/jdk170_h70 directory:
NOTE: For more information about the operating system requirements, see T2766H70 or
T2866H70 Softdoc file.
1.
26
Set the PATH environment variable by using the following command at the OSS prompt:
Installation and configuration
For 32–bit NSJ7:
$ export PATH=/home/lee/nssjava/jdk170_h70/bin:$PATH
For 64–bit NSJ7:
$ export PATH=/home/lee/nssjava/jdk170_h70/bin/oss64:$PATH
2.
Confirm that the path is set correctly by typing the whence command:
For 32–bit NSJ7:
whence java
/home/lee/nssjava/jdk170_h70/bin/java
For 64–bit NSJ7:
whence java
/home/lee/nssjava/jdk170_h70/bin/oss64/java
3.
Determine the version of the Java virtual machine (JVM) by typing the vproc command,
which displays the product versions of the java binary file and any products bound in the
java binary.
The version identifier has the following form:
T2766Hnn or T2866Hnn
A vproc example is:
Version procedure: T2766H70_17APR2015_jdk170_ACN...
or
Version procedure: T2866H70_17APR2015_jdk170_ACN...
NOTE: JREHOME shell variable need not be set for NSJ7. However, if this variable is set,
NSJ7 will accept it. If this variable is set, then you must ensure that it points to the correct JDK.
Configuring NonStop system for NSJ7
This subsection explains how to configure your system for the Java SE JDK by:
•
“Creating larger or additional swap file” (page 27)
•
“Setting environment variables” (page 28)
•
“Configuring TCP/IP and DNS for RMI” (page 30)
•
“Memory considerations: Moving QIO to KSEG2” (page 30)
NOTE: Do not install any JAR or native library files in the NonStop Server for Java installation
directory.
Creating larger or additional swap file
Hewlett Packard Enterprise recommends that the swap file size must be equal to the physical
memory size, for each processor that runs the Java virtual machine (JVM). If you plan to run
multiple large processes in the same processor, you might need to create additional swap files
because processes running in the same processor share the same swap file.
Your system administrator can use the NSKCOM tool to create additional swap files.
To add swap files, you must log on to your NonStop operating system as a super.super user.
Then, from the Guardian TACL prompt, run the NSKCOM tool. From the NSKCOM tool, use the
help add and help start commands to get more information. For further information, see
Kernel-Managed Swap Facility (KMSF) Manual.
Configuring NonStop system for NSJ7
27
NOTE: When using the large Java heap feature provided by 64–bit NSJ7, Hewlett Packard
Enterprise recommends that a contiguous block of Kernel-managed swap space that is at least
greater than the Java heap size be available.
Setting environment variables
The following topics describe the variables that define the environment in which Java operates:
PATH
The environment variable PATH enables Open System Services (OSS) to find the Java executable
files. Add the absolute path of the bin directory to the PATH environment variable.
To add the absolute path, use the following command:
For 32–bit NSJ7:
export PATH=/install_dir/nssjava/jdk170_h70/bin:$PATH
For 64–bit NSJ7:
export PATH=/install_dir/nssjava/jdk170_h70/bin/oss64:$PATH
where, install_dir is the directory in which the NSJ7 is installed. By default, for H-series this
is /usr/tandem/nssjava/jdk170_h70.
The PATH shell variable must be created in each shell in which you plan to run java or one of
its tools. For this reason, it is a good idea to set the PATH in the .profile file in your home
directory that is executed each time you logon to an OSS shell. For more information on how to
set the PATH in your startup file, see Open System Services User's Guide.
CLASSPATH
The class search path (class path) is the path where the Java run time environment searches
for classes and other resource files. The class path notifies the JDK tools and applications to
find third-party and user-defined classes. The class path is set either by using the -classpath
option when calling a JDK tool (such as, java or javac), or by setting the CLASSPATH
environment variable.
The preferred method is using the -classpath option because you can set that option individually
for each application without affecting other applications and without other applications modifying
the option's value.
NOTE: You can use either —classpath or —cp option on the command line. Both the options
are valid.
Syntax
jdkTool -classpath classpath1:classpath2...
-orexport CLASSPATH=classpath1:classpath2...
jdkTool
A command-line tool, such as java or javac. For the tools list, see NonStop
Server for Java 7.0 Tools Reference.
classpath1:classpath2
28
Installation and configuration
Class paths to the .jar, .zip, or .class files. Each class path must end with
a filename or directory name depending on the specific setting.
•
For a .jar or .zip file that contains .class files, the class path ends with
the name of the .jar or .zip file.
•
For .class files in an unnamed package, the class path ends with the
directory name that contains the .class files.
•
For .class files in a named package, the class path ends with the directory
name that contains the "root" package (the first package in the full package
name).
Multiple path entries are separated by colons.
The default class path is the current directory. Setting the CLASSPATH variable or using the
-classpath command-line option overrides the default class path, so if you want to include
the current directory in the search path, you must include a dot (.) in the new settings.
Class path entries that are not directories or archives (.zip or .jar files) are ignored. For
example,
Example 3 Setting CLASSPATH in a java command
If you want the Java runtime to find a class named Cool.class in the package utility.myapp.
If the path to that directory is /java/MyClasses/utility/myapp, you must set the class
path so that it contains /java/MyClasses.
To run that application, use the following java command:
$java -classpath /java/MyClasses utility.myapp.Cool
Example 4 Setting the CLASSPATH environment variable
Using the same situation as in the preceding example, except that you want to set the CLASSPATH
environment variable so that the Java runtime can find the class named Cool.class, you can
use the following command to set and export the CLASSPATH environment variable and then
run Java.
To run that application, use the following commands:
$ export CLASSPATH=/java/MyClasses
$ java utility.myapp.Cool
For more information about setting the classpath, see documentation available in Oracle web
site (http://docs.oracle.com/javase/7/docs/technotes/tools/index.html).
NOTE: When you are referring Oracle documentation for NSJ7, you must follow the instructions
provided for sh and ksh instead of csh and tcsh. Instructions for the setenv and unsetenv
commands do not apply to NSJ7.
JREHOME
JREHOME shell variable need not be set for NSJ7. However, if this variable is set, NSJ7 accepts
it. If this variable is set, then you must ensure that it points to the correct JDK.
For example, $ export JREHOME=/install_dir/nssjava/jdk170_h70/jre.
_RLD_LIB_PATH
The _RLD_LIB_PATH environment variable specifies the library path for DLLs. You need to use
this environment variable if you use user DLLs. You can specify one or more directories as
Configuring NonStop system for NSJ7
29
required. Separate each directory in the list by using a colon (:). Set this environment variable
as follows:
export _RLD_LIB_PATH=dll_path[:dll_pathn]...
where,
dll-path and dll-pathn are the directories where the user DLLs reside.
For example,
export _RLD_LIB_PATH=/home/me/mydll
Symbolic link
NSJ7 is installed in a default directory. The default directory is unique for each release, and is
of the following format:
/usr/tandem/nssjava/jdk_h
where,
•
x refers to the version number of Oracle Java update
•
yy refers to the product version of NonStop Server for Java
For example, for NSJ7, based on Java SE 1.7.0, the installation directory is:
/usr/tandem/nssjava/jdk170_h70.
For ease of reference, a symbolic link /usr/tandem/java was being created to point to the
installation directory as a part of JDK installation in Java versions released prior to NSJ7.
Since, NSJ7 is installed and managed using DSM/SCM, the installation of NSJ7 does not
automatically create the symbolic link (soft link) /usr/tandem/java to point to the NSJ7
installation directory for H-series (/usr/tandem/nssjava/jdk170_h70). You must create
the soft link manually if required.
Configuring TCP/IP and DNS for RMI
TCP/IP and its components along with DNS must be configured properly. This has to be done
for Remote Method Invocation (RMI) to function.
A network administrator usually configures TCP/IP and DNS, but you can determine if an incorrect
TCP/IP configuration is causing a JVM problem. To check the TCP/IP configuration, use the Java
Checker (javachk) which is available in the /usr/tandem/nssjava/jdk170_h70/install
directory for H-series. Execute javachk in the same environment as JVM (that is, using the
same defines that were used to run the JVM). The javachk identifies failing socket routine calls.
When you know which calls are failing, you can troubleshoot the problems.
For information about javachk, see file
/usr/tandem/nssjava/jdk170_h70/install/README_javachk for H-series.
Memory considerations: Moving QIO to KSEG2
In NSJ7, the memory for Java heap and JVM memory is allocated from flat segments. The effects
of this memory allocation for 32–bit and 64–bit JDKs are as follows:
•
For 32–bit application the flat segments are allocated from the end of the user allocatable
space. Hence the QIO segment must be moved to KSEG2 region if the memory requirement
of the Java process cannot be met with the available user memory. If the application gets
out of memory error, QIO segment must be moved to KSEG2 region.
•
For 64–bit application the flat segments are allocated from the 64–bit space and hence QIO
segment need not be moved to KSEG2 region.
Java server-side applications are typically configured with large Java heap sizes, larger than 128
MB. In addition, the JVM and its native components (for example, NSJSP transport library, JDBC
30
Installation and configuration
Driver for SQL/MP, JDBC Driver for SQL/MX, SQL/MX call-level interface, and potentially any
custom-user JNI code) allocate memory for their own use. Thus, the overall heap space required
by a JVM process is considerably higher than the configured Java heap space.
When a process uses the parallel TCP/IP transport provider for socket operations (like the iTP
Secure WebServer httpd daemon Server process instance), the process becomes a QIO client.
For NonStop Server QIO shared-memory segments, when a QIO client process makes a socket
request, a portion of the process address space is reserved for the QIO segment. This reserved
space limits the maximum usable heap size for the JVM process.
The size of the QIO segment is determined by the configured physical memory for a processor
(CPU) on the NonStop system. For a processor on a NonStop system configured with 4 GB of
physical memory, 512 MB are used for the QIO segment. In addition, 512 MB of the user address
space is reserved for the QIO segment, if the process is also a QIO client.
To overcome the problem of losing user address space to QIO, you can configure the QIO
segment so that the segment is moved to a special region of the privileged address space, called
the KSEG2 region. Moving the QIO segment to the KSEG2 region means that the default size
of the QIO segment is reduced to 256 MB (instead of the default 512 MB in user address space).
However, the maximum possible QIO segment size in KSEG2 region is 512 MB and so the QIO
segment in KSEG2 region can be increased to 512 MB (same as in user space). For more
information about configuring QIO segment, see QIO Configuration and Management Manual.
Example: Determining the QIO segment size in use
To determine the QIO segment size usage, use the following SCF command from the TACL
prompt:
TACL> scf
SCF - T9082G02 - (30APR03) (01APR03) - 03/19/2004 02:20:31 System \NAVAE1
(C) 1986 Tandem (C) 2003 Hewlett Packard Development Company, L.P.
(Invoking \NAVAE1.$DATA11.RAMR.SCFCSTM)
1-> status segment $ZM00, detail.
QIO Detailed Status SEGMENT \NAVAE1.$ZM00
State..................
Segment State..........
Segment Type...........
Segment Size...........
MDs in Use.............
Max MDs Used...........
Last Fail Size.........
Current Pool Size......
Max Pool Size..........
Current Pool Alloc.....
Current Pool Frags.....
DEFINED
STARTED
FLAT_UA
536870912
1258
1589
0
16774788 Initial Pool Size......
16776992 Min Pool Size..........
5039616 Max Pool Alloc..........
12 Max Pool Frags...............
16776992
16776992
5128320
18
The maximum pool size used in this case is 16 MB, which is well below the 128 MB limit, so QIO
can be moved to KSEG2.
Example: QIO segment moved to KSEG2
The following SCF output shows the QIO segment as moved to KSEG2.
TACL> scf
SCF - T9082G02 - (30APR03) (01APR03) - 03/19/2004 02:20:00 System \GOBLIN
(C) 1986 Tandem (C) 2003 Hewlett Packard Development Company, L.P.
(Invoking \GOBLIN.$DATA11.RAMR.SCFCSTM)
1-> status segment $ZM00, detail
QIO Detailed Status SEGMENT \GOBLIN.$ZM00
State..................
Segment State..........
Segment Type...........
Segment Size...........
DEFINED
STARTED
KSEG2
268435456
Memory considerations: Moving QIO to KSEG2
31
MDs in Use.............
Max MDs Used...........
Last Fail Size.........
Current Pool Size......
Max Pool Size..........
Current Pool Alloc.....
Current Pool Frags.....
1248
2357
0
16774788 Initial Pool Size......
16776992 Min Pool Size..........
4516992 Max Pool Alloc..........
375 Max Pool Frags..............
16776992
16776992
4715520
382
•
The QIO segments on this system (\GOBLIN) are moved to KSEG2 based on the value of
the segment type.
•
The value is KSEG2 if QIO is moved to KSEG2.
•
The first SCF output for \NAVAE1 shows QIO to be in FLAT_UA, which means that QIO is
not moved to KSEG2.
NSJ7 directory structure
This section provides information about the directory structure of NSJ7 and it explains the following
topics:
•
“Directory contents” (page 32)
•
“Demonstration programs” (page 33)
Directory contents
For H-series, the directory /usr/tandem/nssjava/jdk170_h70 contains release documents
and subdirectories contains release documents and subdirectories. Table 3 (page 32) lists the
subdirectories and describes their contents.
Table 3 Subdirectories of the /usr/tandem/nssjava/jdk170_h70 and
/usr/tandem/nssjava/jdk170_l70 Directories
Subdirectory
Contents
/bin
Executable 32–bit and 64–bit binary files that are present in the JDK. These files
include tools that are not part of the Java SE Runtime Environment, such as javac
and javah.
/demo
Additional subdirectories, each containing a README file and a complete example.
/include
C-language header files that support native code programming using the Java
Native Interface and Java Virtual Machine Interface.
/install
The javachk file. Only 32–bit version of javachk is available.
/jre
The root directory of the Java SE Runtime Environment of 32–bit and 64–bit NSJ7.
Includes the Java classes supplied by Hewlett Packard Enterprise, core Java
classes, and runtime libraries for 32–bit and 64–bit NSJ7. The core Java classes
are in the lib/rt.jar file.
/lib
Includes the classes other than core classes to support the tools and utilities bundled
in the JDK software.
NOTE:
32
•
For each 32–bit binary or library found in NSJ JDK/JRE a corresponding 64–bit version of
binary or library is provided in NSJ7 JDK/JRE.
•
In NSJ7, the libhpi.so library is removed and the functionality provided by libhpi.so
is moved to libjvm.so library.
Installation and configuration
Demonstration programs
The /demo directory contains subdirectories, each of which contains a demonstration program
and a README file that documents how the demonstration program must be used. Table 4
(page 33) lists the demonstrations programs available in NSJ7:
Table 4 Demonstration programs
Demonstration Program
Description
/demo/invocation_api/oss
How to properly build an executable that can create its own Java virtual machine
(JVM). Contains source and Makefile to create 32–bit invocation API demo.
/demo/invocation_api/oss64 How to properly build an executable that can create its own Java virtual machine
(JVM). Contains source and Makefile to create 64–bit invocation API demo.
/demo/javahjni/oss
How to create a native library. Contains source and Makefile to create 32–bit
javahjni demo.
/demo/javahjni/oss64
How to create a native library and how to use IEEE floating-point. Contains
source and Makefile to create 64–bit javahjni demo.
Many of the demonstration programs require you to edit some files before the demonstration
programs can be run, as described in the README file.
Additional demonstration programs are provided if you install a JDBC Driver for NonStop SQL
product. These programs can be found with the driver software.
NSJ7 directory structure
33
3 Getting started
Although this manual assumes that you are familiar with using Java and HPE NonStop Open
System Services (OSS), this section provides background information for those who are not
familiar with these products. Additionally, this section explains how to perform common tasks
that are characteristic to running Java applications on NonStop systems. The topics are:
•
“Tutorial: Running a simple program, HelloWorld” (page 34)
•
“Specifying the CPU and process name” (page 35)
•
“Configuring a Java Pathway serverclass” (page 36)
Tutorial: Running a simple program, HelloWorld
After NSJ7 is installed, use the following steps to create and run the HelloWorld program.
1. Create a Java source file.
Perform either steps a, b, and c or step d only.
a. Using an editor, create a file that contains the following source code.
b. Name the file HelloWorld.java.
c. Place the file in the OSS file space by using FTP.
/**
* The HelloWorld application implements a java class that
* displays "Hello World!" to the standard output.
*/
class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
d.
Alternatively, at the OSS prompt, use the cat command to create the
HelloWorld.java file and type the contents of the HelloWorld program listed
previously.
$cat> HelloWorld.java
type-contents-of-the-file
(Ctrl+y)
2.
Set the PATH environment variable.
Add the directory where the NSJ7 executable file is installed to your PATH environment
variable.
For the standard installation, type the following command at the OSS prompt:
$export PATH=/usr/tandem/nssjava/jdk170_h70/bin/:$PATH
If the NSJ7 is installed in a nonstandard location, /home/lee, type:
$export PATH=/home/lee/nssjava/jdk170_h70/bin/:$PATH
3.
Check your path settings.
Optionally, you can check whether your path is set correctly by using the whence command.
Type:
$whence -v java
34
Getting started
This command must display the fully qualified name of the java executable found in your
path. If no Java executable is found, the command displays the message, java not found.
4.
Compile the Java source code by using the javac tool.
a. Ensure you have performed step 3 so that javac is in your current path.
b. At the OSS prompt, change the directory (cd command) to where your Java source file
is stored.
c. Compile the Java source code by using the Java compiler, javac, which is part of the
installed NSJ7 product. Type the following command on OSS prompt :
$javac HelloWorld.java
If compilation is successful, the compiler produces a Java class file called
HelloWorld.class. Once you have the class file, your program is ready to run.
d.
Check to see that the HelloWorld.class file has been created by typing:
$ls -l HelloWorld.class
If the file is not present or if you received an error message, check for typographical
errors in your source code. Fix the errors, and perform the steps c and d until class file
is created.
5.
Run the program by using the Java tool.
a. Go to the directory where your class file is created.
b. To run the HelloWorld program (also called an application), type the following command
at the OSS prompt:
$java HelloWorld
NOTE: You must not type java HelloWorld.class. All Java classes have the
.class extension. Typing .class at the end causes an error message.
Your Java application displays the message, "Hello World!".
Specifying the CPU and process name
You can specify which CPU an application process runs in and its process name by using options
of the run utility. The run utility starts OSS programs with specific attributes.
Use the following command to specify the CPU where a Java application is to run:
run -cpu=cpu_number java class_name
For example, the command to run Java in CPU 3 is:
$run -cpu=3 java HelloWorld
Use the following command to provide a java process a process name:
run -name=/G/process_name java class_name
For example, the command to provide Java the process name $APPJ is:
$run -name=/G/appj java HelloWorld
where,
the /G directory identifies the Guardian fileset.
For information about the /G directory, see Open System Services User's Guide.
The following example combines more than one run option in a single command:
$run -name=/G/japp -cpu=3 java HelloWorld
Specifying the CPU and process name
35
For more information on using -name option with 32–bit JDK and 64–bit JDK, see “Java process
name” (page 107).
For more information about the run(1) utility, see Open System Services Shell and Utilities
Reference Manual.
Configuring a Java Pathway serverclass
Following is a brief overview of the specific Java requirements for configuring a Java program
to run as a Pathway serverclass. Complete information about the topic is available in the TS/MP
2.5 System Management Manual.
The serverclass attributes that have specific Java requirements follow. Typically, the attribute
settings are available in a configuration file, but the examples show how to set the attributes in
the OSS environment.
ARGLIST
The ARGLIST must be in the form:
-Xabend,class-name[,arguments]
where, [,arguments] is an optional, comma-separated list of arguments that are passed to
the named serverclass.
For example, from the OSS prompt, start a PATHMON (process monitor) named $foo and set
the ARGLIST at the PATHCOM prompt:
$gtacl -p pathcom \$foo
PATHCOM .....
=set serverclass ARGLIST -Xabend,MyClass,3000
This is similar to entering java -Xabend MyClass 3000 at an OSS shell prompt. The -Xabend
argument to the java executable causes java to abend instead of exiting with a non-zero exit
code. Pathway servers must abend rather than merely stop when a fatal error occurs, so that
the PATHMON process can restart them. MyClass is the name of the Java class to be invoked,
and "3000" is an argument to the MyClass class.
NOTE: In the OSS environment, the dollar sign ($) has special meaning; therefore, the process
name $foo must be preceded by a backslash (\), the escape character.
PROCESSTYPE
Set this attribute to OSS.
ENV
Environment variables are set using the ENV serverclass attribute. For Java use, you must set
the CLASSPATH environment variable so that the Java runtime can find your classes. For a
CLASSPATH example, the following set server command is entered at the PATHCOM prompt.
$gtacl -p pathcom \$foo
PATHCOM .....
=set server ENV CLASSPATH=/myclasspath
where, /myclasspath is the location where all the classes are available.
NOTE: JREHOME shell variable need not be set for NSJ7. However, if this variable is set,
NSJ7 will accept it. If this variable is set, you must ensure that it points to the correct JDK.
36
Getting started
PROGRAM
Set the PROGRAM attribute to the java executable. For H-series, the java executable is located
by default in /usr/tandem/nssjava/jdk170_h70/bin.
For example, from the OSS prompt, start a PATHMON (process monitor) named $foo and set
the PROGRAM attribute at the PATHCOM prompt:
$gtacl -p pathcom \$foo
PATHCOM .....
=set server PROGRAM /usr/tandem/nssjava/jdk170_h70/bin
Configuring a Java Pathway serverclass
37
4 Implementation specifics
This section explains the various topics pertaining to the implementation specifics of NonStop
Server for Java:
•
“Headless support” (page 38)
•
“Additional files” (page 39)
•
“Additional environment variable” (page 39)
•
“Java native interface (JNI)” (page 39)
•
“Floating-point implementation” (page 43)
•
“Multi-threaded programming” (page 45)
•
“Java print service” (page 49)
•
“Using the Guardian printer” (page 50)
•
“Java authentication and authorization service” (page 51)
•
“JavaBeans” (page 52)
•
“Debugging Java programs” (page 52)
•
“Deviations in JVM specification options” (page 55)
•
“Garbage collection (GC)” (page 56)
•
“Java garbage collector tuning for application performance” (page 64)
•
“GC profiling” (page 66)
•
“ZapInitialHeap option” (page 69)
•
“64–bit process support” (page 69)
•
“32–bit process support” (page 70)
•
“Version command-line option” (page 71)
•
“Posting signals to GC process” (page 72)
•
“Unhandled exception” (page 73)
•
“Error file” (page 73)
•
“System property” (page 75)
•
“LogVMOutput option” (page 75)
•
“UseCompressedOops” (page 76)
•
“SecureRandom startup enhancement” (page 76)
•
“VirtualMachine.list() support” (page 76)
See also, “Application tuning and profiling” (page 94).
Headless support
Since NonStop operating system does not provide support for GUI operations, NSJ7 is a headless
JVM that conforms to the Oracle's headless support standards regarding Java Abstract Window
Toolkit (AWT) classes and methods. For similar reasons, NSJ7 does not support the
AppletViewer tool.
Class data sharing (CDS) is a feature intended to reduce application startup time and footprint,
which is available only with a Java HotSpot client VM. Hence this is not supported in NSJ.
38
Implementation specifics
When GraphicsEnvironment.isHeadless returns true, and if your Java programs use
classes and methods that require a display, keyboard, sound, or mouse operation, the class or
method throws a HeadlessException. This value is always true in NSJ7.
Classes and methods that support printing, fonts, and imaging are fully supported in a headless
JVM.
While the Oracle documentation for the reference implementation states that you must set the
system property –Djava.awt.headless=true to run a headless JVM, setting this system
property is not required for NSJ7.
Additional files
In addition to the standard Java packages, NSJ7 provides the following files:
•
jtatmf.jar
File containing classes for the version of NonStop Java Transaction Agent that uses TMF.
For more information, see “Transactions” (page 90).
•
javachk
The Java Checker program, which determines whether a problem with the JVM is caused
by an incorrect TCP/IP configuration.
Additional environment variable
NSJ7 contains an implementation-specific environment variable that you can use to control the
runtime environment. The JAVA_PTHREAD_MAX_TRANSACTIONS environment variable specifies
the maximum number of TMF transactions allowed per process. The default number of transactions
allowed are 200. For more information, see “Controlling maximum concurrent transactions”
(page 90).
Java native interface (JNI)
The Oracle Java Native Interface (JNI) standard defines the C language APIs that enable Java
routines to call C and C++ routines. JNI defines the way that these routines can start and interact
with a Java Virtual Machine (JVM). It also allows you to load the JVM into native applications to
integrate Java functionality with native applications.
NSJ7 supports JNI and Invocation API with the following modifications:
•
Set the _RLD_LIB_PATH environment variable to point to the User DLL location.
export _RLD_LIB_PATH=dll-path[:dll_pathn]...
where, dll-path and dll-pathn are the User DLL directories.
For example, if the user DLLs are in the directory /home/mydll
export _RLD_LIB_PATH=/home/mydll
•
NSJ7 supports only the POSIX User Thread library (PUT). As a result of this, additional
migration considerations arise while migrating threaded native code to NSJ7. There are two
kinds of native applications that require changes:
1. Applications that dynamically load libjvm.so and invoke JVM using Invocation APIs.
For more information, see “Calling Java methods from C or C++” (page 41).
2. Applications that use Pthread library to create multi-threaded application. For more
information, see “Threading considerations for native code” (page 48).
•
If native C or C++ routines invoke Transaction Management Facility (TMF) calls, you must
use TMF transaction jacket routines defined in “TMF Transaction Jacket Routines” in the
Additional files
39
“Using the POSIX User Thread (PUT) Model Library” section in the Open System Services
Programmer's Guide. The calls are:
◦
PUT_ABORTTRANSACTION()
◦
PUT_BEGINTRANSACTION()
◦
PUT_ENDTRANSACTION()
◦
PUT_RESUMETRANSACTION()
NOTE: OSS supports a maximum of 1000 concurrent transactions in a process.
However, JVM is an exception where the maximum transactions allowed are 200 as
described in “Controlling maximum concurrent transactions” (page 90).
•
NSJ7 performs no conversion when calling a C or C++ routine where the function passes
or returns parameters of type float or double. All float and double values remain in
IEEE floating-point format when crossing the JNI boundary. For more information, see
“Floating-point implementation” (page 43).
•
When using the JNI_OnLoad function, use the following format:
jint JNI_OnLoad(JavaVM *vm, void *reserved);
•
The JNI_OnUnload function is supported.
•
Conform to the following rules when naming user DLLs:
◦
Do not use names that begin with Tandem, tandem, or tdm.
◦
NSJ7 requires that all DLLs be named with a prefix lib and a suffix .so. Hence you
must name your DLL as follows:
libname.so
where, (name) signifies the string that is passed to the System.loadLibrary
() call.
The remainder of this subsection explains:
•
“Calling C or C++ routines from Java” (page 40)
•
“Calling Java methods from C or C++” (page 41)
•
“Linker and compiler options” (page 42)
For more information about JNI, see Oracle JNI document.
Calling C or C++ routines from Java
To call C or C++ routines from Java, conform to the following steps:
1. Compile the Java code.
2. Use javah to generate header files— The function declarations listed in the generated
header file are those that must be exported by the user-JNI DLL.
To export functions, either specify export$ in the function definition or use the linker option
-export_all.
3.
Compile the C or C++ code— C++ code must be compiled using the compiler command-line
options as explained in “Linker and compiler options” (page 42).
For example:
/usr/bin/c89 -g -I /usr/tandem/nssjava/jdk170_h70/include -I /usr/tandem/nssjava/jdk170_h70/include/oss
-I. -I /G/system/system -Wallow_cplusplus_comments -Wlp64 -Wextensions -D_XOPEN_SOURCE_EXTENDED=1
-Wnowarn=141,209 -Wcall_shared -Wsystype=oss -Wtarget=tns/e -c SystemInfo.c
40
Implementation specifics
NOTE: If the native code has large variables on the stack, then calling this native code
might exceed the default stack space provided for each thread. If the native code exceeds
the amount of stack space allocated for it, then it results SIGSTK.
To prevent overflowing the available stack space, consider allocating large variables on the
heap rather than using the stack. Otherwise, you can increase the default stack size for each
thread by specifying the -Xss option when starting java. This option increases the stack
size for every thread.
For more information about the -Xss option, see java in the NonStop Server for Java 7.0
Tools Reference Pages.
4.
Create a DLL file (.so file type) and specify the linker option as explained in “Linker and
compiler options” (page 42).
After specifying the linker option, set the _RLD_LIB_PATH environment variable to point to
where the created DLL file resides by using the following command:
export _RLD_LIB_PATH=dll-path
where, dll-path is the directory where the user DLL resides.
For example:
/usr/bin/eld TandemWrap.o SystemInfo.o -o libCompanySysInfo.so -set SYSTYPE OSS -set HIGHPIN ON -set
data_model lp64 -set CPlusPlusDialect neutral -dll -lcre -lcrtl -export_all
For more information, see “_RLD_LIB_PATH” (page 29).
NOTE: Using neutral data type DLL may not work with 64–bit JDK as JVM pass true 64–bit
pointers that is not sign-extended value of a 32–bit pointer.
The javahjni demo shows an example of how to create a library file, see Table 4 (page 33)
to view the directory location of the demo programs. The demo also shows the conversion between
the TNS and IEEE floating-point.
Calling Java methods from C or C++
You can create your own C or C++ program. Follow these guidelines to use the Invocation API
to load the JVM in an arbitrary native program:
•
NSJ7 supports only the POSIX User Thread library. As a result, the following issues must
be considered when migrating to NSJ7:
◦
Java application which uses the Invocation API must necessarily link with the POSIX
User Thread library. An application must link with either ZPUTDLL or YPUTDLL depending
on whether it is a 32–bit or 64–bit application.
Set the _RLD_LIB_PATH environment variable to the location of libjvm.so as shown:
For 32–bit NSJ7: $ export _RLD_LIB_PATH=$JREHOME/lib/oss/server/
For 64–bit NSJ7: $ export _RLD_LIB_PATH=$JREHOME/lib/oss64/server/
•
A native application can use the JNI_CreateJavaVM() call to become a Java process,
and such applications are called JNI applications. The native application can be either
multi-threaded or single threaded. If an application calls the JNI_CreateJavaVM() on the
main thread, then the main thread becomes the Java thread after creating the virtual machine.
If an application already contains a VM, another thread can become a Java thread by invoking
AttachCurrentThread(). In either case, if the calling thread is the main thread and if
distributed GC is enabled, the main thread stack must be shared by GC processes. As the
main thread stack cannot be shared across GC processes, the distributed GC cannot be
enabled when the main thread is the Java thread. Hence, JNI_CreateJavaVM() and
Java native interface (JNI)
41
AttachCurrentThread() return JNI_EUNSUPPORTED error if they are called from the
main thread with distributed GC enabled.
NOTE:
All the instances of distributed GC in this manual refer to parallel and CMS GC.
•
Compile code written in C++ by using the compiler command-line options as explained in
“Linker and compiler options” (page 42).
•
NSJ7 provides DLLs. Therefore, you can build your own executable and link it to the JVM
DLL, libjvm.so.
For more information, see invocation_api demo provided with the NSJ7 installation.
•
•
Do not set signal handlers for the following signals:
◦
SIGSEGV
◦
SIGPIPE
◦
SIGCHLD
◦
SIGINT
◦
SIGQUIT
◦
SIGTERM
◦
SIGHUP
◦
SIGWINCH
◦
SIGALRM
◦
SIGSTK
◦
SIGILL
◦
SIGTIMEOUT
Set the executable to use IEEE floating-point.
NSJ7 does not support the signal-chaining facility implemented in some other vendors' JVMs.
When a program uses the Invocation API to start a JVM, its function returns parameters of type
float or double that are in IEEE floating-point format. Any parameters of type float or double
that are passed to NSJ7 must be in IEEE floating-point format. If such a program requires
conversion between TNS floating-point format and IEEE floating-point format, the Guardian
Procedure Calls Reference Manual documents a series of procedures with names beginning
with NSK_FLOAT_ that can be used to convert float and double data between the two formats.
To run the Invocation API demo, follow the instructions in the README file in directory
/usr/tandem/nssjava/jdk170_h70/demo/invocation_api. Directory location of
invocation_api (for 32–bit and 64–bit NSJ7) demo programs are listed in Table 4 (page 33).
Linker and compiler options
Compiler options
You can use C++ code compiled using either a dialect of version 2 or version 3 for user DLLs
because NSJ7 is built with a C++ version neutral flag (the —set CPlusPlusDialect neutral
option for the linker). To compile using version 2, the following compiler option must be used:
—Wversion2.
42
Implementation specifics
—Wversion3 is the default version for TNS/E native compilers, and hence it is not needed to be
defined in the compile command-line.
In addition, a compilation unit containing JNI code that has any floating-point parameters being
passed across the JNI boundary and that is directly called by the JVM, must use the IEEE
floating-point arithmetic. IEEE floating-point format is the default for TNS/E native compilers, and
hence it is not needed to be defined in the compile command-line.
Any compilation units not called directly by the JVM can be compiled without conforming to the
IEEE floating-point format. However, the complications that can occur while using such mixed
modes are beyond the scope of this manual.
The javahjni demo shows an example of mixed modes. For information on demos, see
“Demonstration programs” (page 33).
If you want to call the C/C++ routines from 64–bit java applications, then you must compile the
routines using the following complier command-line option:
-Wlp64
Linker options
IEEE floating-point is the default format for TNS/E native compilers, and hence it is not needed
to be specified during linking.
When building 64–bit native libraries, the following additional linker option must also be used:
-set data_model lp64
How to create your own library of native code
The javahjni demonstration program shows how to create a native library for 32–bit and 64–bit
NSJ7. In order to use a native library for 32–bit JDK, it must be a 32–bit library, and for use with
64–bit JDK, it must be 64–bit library.
Directory location of javahjni (for 32–bit and 64–bit NSJ7) demo programs are listed in Table 4
(page 33).
Floating-point implementation
Java uses IEEE floating-point arithmetic for computation. This subsection explains the following
topics:
•
“Floating-point values” (page 43)
•
“Double-precision values” (page 44)
•
“Calling TNS floating-point functions from JNI code” (page 44)
Incompatibilities between the IEEE floating-point and TNS floating-point representations might
cause loss of precision or accuracy when you convert between TNS float or double and IEEE
float or double.
NOTE:
In NSJ7, you cannot specify whether your Java classes use TNS format.
Floating-point values
For floating-point values, TNS floating-point representations have larger exponents (hence a
larger range) than IEEE floating-point representations, but they are less precise, which is
demonstrated in Table 5 (page 44):
Floating-point implementation
43
Table 5 Floating-point ranges
Floating-point representation
Minimum positive decimal value
Maximum decimal value
TNS
1.7272337e-77F
1.1579208e77F
IEEE
1.40239846e-45F
3.40282347e+38F
Double-precision values
For double-precision values, TNS floating-point representations have smaller exponents (hence
a smaller range) than IEEE floating-point representations, but they are more precise, which is
demonstrated in Table 6 (page 44):
Table 6 Double-precision ranges
Floating-Point representation
Minimum positive decimal value
Maximum decimal value
TNS
1.7272337110188889e-77
1.15792089237316192e77
IEEE
4.94065645841246544e-324
1.79769313486231570e+308/
Calling TNS floating-point functions from JNI code
This section describes the procedure to call a TNS floating-point function from an IEEE
floating-point function.
Perform the following when using TNS floating-point compiled functions in native code linked in
the java executable:
•
Do not call the Common Runtime Environment (CRE) functions with TNS floating-point
values because CRE functions are expecting IEEE floating-point values.
•
Do not pass floating-point values (float and double) across mixed float compilation units.
When passing or returning floating-point values between IEEE floating-point compiled
functions and TNS floating-point compiled functions, pass or return the following:
•
◦
A float as one of the 32–bit structures defined in $SYSTEM.SYSTEM.KFPCONVH
(NSK_float_ieee32, NSK_float_tns32) or /usr/include/kfpconv.h.
◦
A double as one of the 64–bit structures defined in $SYSTEM.SYSTEM.KFPCONVH
(NSK_float_ieee64, NSK_float_tns64) or /usr/include/kfpconv.h.
You can call a native function that accepts or returns a TNS float or double value if you
create an intermediate function. The intermediate function assembles between the IEEE
floating-point compiled JNI method that the JVM calls and the native function that accepts
or returns the float or double value.
Either the JNI method or intermediate method can be responsible for calling one of the
NSK_float_* procedures to convert between IEEE and TNS floating-point formats.
The intermediate function:
44
◦
Is compiled with TNS floating-point.
◦
Accepts float and double arguments as one of the special structures defined in the
$SYSTEM.SYSTEM.KFPCONVH or /usr/include/kfpconv.h file.
◦
Calls the TNS compiled native function passing TNS float or double arguments.
◦
Converts any float or double return value to an IEEE floating-point value, which the
JNI caller expects.
◦
Returns the float or double in one of the special structures defined in the
$SYSTEM.SYSTEM.KFPCONVH or /usr/include/kfpconv.h file.
Implementation specifics
For an example, see javahjni “Demonstration programs” (page 33).
Multi-threaded programming
The Java virtual machine for the NSJ7 is multi-threaded and uses POSIX User Thread (PUT)
library, which conforms to the IEEE POSIX Standard 1003.1, 2004. With PUT library enabled on
NonStop systems, CPU intensive thread that does not invoke an I/O, sleep, or wait can never
be pre-empted by another thread unless -XX:ThreadTimeSlice option is used.
This section includes the following topics:
•
“Thread scheduling” (page 45)
•
“Threading considerations for Java code” (page 48)
•
“Threading considerations for native code” (page 48)
•
“ThreadDumpPath support” (page 49)
Thread scheduling
When a Java thread is created, the thread inherits its priority from the parent thread. The priority
of the thread varies from MIN_PRIORITY to MAX_PRIORITY, where the default priority is
NORM_PRIORITY. After a thread is created, the setPriority method can be used to alter the
priority of the thread.
Java application developers must be aware of the following consideration while designing or
enabling multi-threaded Java applications for Nonstop systems:
•
A selfish thread is a thread that executes in a tight loop without giving up control either by
explicitly yielding or by invoking a blocking operation.
•
Since the thread-scheduling algorithm on Nonstop is non-preemptive and does not time
slice, it is possible for such a thread to prevent other threads from getting access to CPU
time. Theoretically, such a thread can run forever. However, after a while, the operating
system periodically reduces the priority of the process in stages, until its priority reaches a
very low value.
For a demonstration of scheduling on a NonStop system, review the results and output of the
following programs:
Multi-threaded programming
45
Example 5 Snnipet for ThreadTimeSlice feature
import java.io.*;
import java.lang.*;
class LoopThread extends Thread {
private Thread t;
private int threadNum;
private static int tick = 1;
private static volatile int numThreadsStillRunning = 0;
private static int maxThreads = -1;
private static volatile int numThreadsCreated = 0;
public static void setMaxThreads(int num) { maxThreads = num; }
LoopThread( int num){
if ( num <= 0 || num > maxThreads ) {
System.out.println("Invalid thread number: " + num);
System.exit(1);
}
threadNum = num;
System.out.println("Creating " + threadNum );
numThreadsCreated++;
numThreadsStillRunning++;
}
public void run() {
if ( threadNum == 1 ) {
// First thread. Execute until other threads terminates
while ( numThreadsCreated < maxThreads ||
numThreadsStillRunning > 1 ) {
tick++;
}
} else {
// Sleep some time to guarantee first thread runs
try {
Thread.sleep(10);
} catch ( InterruptedException e ) {
System.out.println("Sleep interrupted.");
}
for (int i=0; i < 10000; i++ ) {
tick++;
}
}
System.out.println("Thread " + threadNum + " exiting.");
numThreadsStillRunning--;
}
}
public class ThreadPreemptionDemo {
public static void main(String args[])
{
int numThreadsToCreate = 2;
// LoopThread[] threads;
if ( args.length > 0 ) {
// User has specified number of threads to create
numThreadsToCreate = Integer.parseInt(args[0]);
if ( numThreadsToCreate < 2 ) {
System.out.println("Invalid argument. Minimum value = 2");
System.exit(1);
}
}
LoopThread[] threads = new LoopThread[numThreadsToCreate];
LoopThread.setMaxThreads(numThreadsToCreate);
for (int i = 0; i < numThreadsToCreate; i++) {
threads[i] = new LoopThread(i+1);
46
Implementation specifics
threads[i].start();
}
try {
for (int i = 0; i < numThreadsToCreate; i++) {
threads[i].join();
}
} catch (InterruptedException ex) {
System.out.println("Exception " + ex);
}
}
}
On the NonStop system, the execution of threads is not time sliced. When a thread gets a chance
to run, it enters the loop and starves the other thread. Hence, the application hangs.
Output when thread time slice is not enabled:
java -cp . ThreadPreemptionDemo
Creating 1
Creating 2
WARNING! You will observe a hang when thread time slice option is not specified. Therefore,
“Creating 2” in the output may or may not be printed.
The Java runtime supports a simple, deterministic, scheduling algorithm known as fixed-priority
scheduling. The Java runtime does not time-slice. For the NonStop system, the thread-scheduling
algorithm is not preemptive; that is, a thread continues to run until it explicitly yields or otherwise
causes a yield by invoking a blocking operation on the thread. When a thread gives up control,
the runnable threads of the highest priority are run in first-in-first-out order. A lower priority thread
is run (also in first-in-first-out order) only when no runnable threads of a higher priority are
available.
NSJ7 (SPR IDs T2766H70^ACN and T2866H70^ACN) release includes a JVM-forced, preemptive
thread scheduling feature. This feature also provides an option to specify the time slice for threads.
A thread will run for the specified time slice, after which another thread gets dispatched from the
ready queue. This helps in force-yielding a thread which consumes large processor time so that
the other ready threads also get the processor time to run.
To enable pre-emptive user threads, use the following option:
-XX:ThreadTimeSlice[=T]
where,
T specifies the time in milliseconds.
•
T is an optional argument.
•
The default value of T is 400 milliseconds.
•
The value of T can range between 1 to 32767.
If the specified value of T is above 32767, the value is time-sliced to 32767.
If the specified value of T is 0, the value is time-sliced to 400.
Following is the output for the snippet provided in Example 5 (page 46):
Output when thread time slice is enabled
java -cp
Creating
Creating
Thread 2
Thread 1
. -XX:ThreadTimeSlice=10 ThreadPreemptionDemo
1
2
exiting
exiting
Multi-threaded programming
47
Threading considerations for Java code
A thread-aware function blocks only the thread calling that function, rather than blocking the
entire process. NSJ7 uses the PUT library in which all I/O are nonblocking.
JToolkit provides a thread-aware API for performing I/O to Enscribe files, $RECEIVE, and Pathway
servers by using Pathsend procedure calls. For more information, see JToolkit for Java API
Reference Pages.
Thread-aware I/O Support
In NSJ7, I/O operators are always nonblocking for OSS files. Earlier versions of NSJ, provided
an option —Dnsk.java.nonblocking to switch between the blocking and nonblocking I/O
operation. This option is no longer supported on NSJ7.
Threading considerations for native code
NSJ7 supports only the POSIX User Thread library. As a result, the following issues must be
considered when migrating to NSJ7:
•
The JNI or C/C++ code in a Java application that uses the Pthread API must be ported to
use the _PUT_MODEL_ as described in the Open System Services Programmer's Guide.
•
The PUT library Z/YPUTDLL must be linked statically to the application . This impacts JNI
applications that currently (pre-NSJ7) load ZSPTDLL dynamically.
1
2
In NSJ7, the application must be linked with Z/YPUTDLL depending on whether it is a 32–bit
or 64–bit application.
If a user native library linked into Java creates a thread, non thread-aware operations executed
in the user library might impact the operation of the Java virtual machine. If the user library creates
multiple user threads, the program needs to be more careful to ensure that the operations
performed in the user threads are thread-safe on the NonStop system. All threaded code preferably
written in Java rather than native code.
You need to consider the following issues when using threads in native code linked to a Java
program on a NonStop system:
•
NSJ7 uses the POSIX User Thread Library from the standard location.
Your code must include the POSIX User Thread header files in the standard location. You
must use the header files from the standard location /usr/include/.
•
Creating a thread for a task does not make the task run faster.
The NonStop system does not have an implementation of native threads since threads run
at a user level. Even on a multiprocessor NonStop system, all native threads (user threads)
in a process are executed in the same processor as the process. If you create user threads
whose only purpose is to run a certain task, the thread creation overhead makes the task
run slower than the same task being performed without creating the thread.
•
The thread-scheduling algorithm is not preemptive.
A thread executes until it explicitly yields. For more information, see discussion of “Thread
scheduling” (page 45).
•
In a very long-running, CPU-intensive thread, having your native code occasionally invokes
the yield() method which allows timer and I/O completions to be detected. Invocation of
1. For L15.02, applications must be linked with X/WPUTDLL.
2. For L15.02, applications must be linked with X/WPUTDLL.
48
Implementation specifics
timer callbacks and detection of I/O completions can be severely impacted by long-running
threads.
•
You must be careful when using thread-aware interfaces.
The Open System Services Programmer’s Guide lists thread-aware equivalents of NonStop
system-specific interfaces. These interfaces have an explicit put_ prefix.
For example, when using a thread-aware function, do not attempt to control the set of files
that are enabled for completion or directly attempt to wait for a completion on a file registered
with Pthreads (FILE_COMPLETE_SET_, FILE_COMPLETE_, AWAITIO, or AWAITIOX
procedure).
Pthread library changes
Pthreads library provides the following functionality:
•
The PUT library converts all I/O calls as nonblocking calls. If a thread invokes an I/O, the
call blocks only the calling thread and not the application. This enables porting of Java
applications to NSJ7.
•
The PUT library provides features that allow Java applications to be more robust are described
as follows:
◦
Protected thread stack – In earlier versions of NSJ, the Java thread stack was
unprotected and hence the JVM only detected stack overflow caused by Java methods.
This was done by stack boundary checking code in interpreted and hotspot compiled
code. It was possible for native methods to overflow the stack space erroneously and
corrupt the program data. In NSJ7, the PUT library protects the thread stacks by using
guard pages. JVM uses this Pthread feature to catch stack overflow from native methods.
A stack overflow from native method causes a SIGSTK signal.
◦
Signal handler uses new stack called alternate signal stack - This enables JVM to
execute the signal handler code for SIGSTK signal.
•
Provides standard POSIX thread API names and calling sequences which adhere to IEEE
standard 1003.1, 2004. For more information, see Open System Services Programmer's
Guide.
For more information on Pthread library, see Open System Services Porting Guide.
ThreadDumpPath support
The thread dump lists all threads in the Java process. If any of the distributed GC options are
enabled, GC threads are converted into processes. Hence, the GC threads are prefixed with *
to indicate that it is a process if the application enables distributed GC.
The execution stack trace of all Java threads in a NSJ7 process can be dumped by sending a
SIGQUIT signal to the Java process using the following OSS command:
$ kill -QUIT
NOTE:
GC thread stack trace is not printed.
By default, the thread stack dump is written in text format on the stdout. NSJ7 provides the
ability to redirect this output to a user-defined file using the following Java command:
-XX:ThreadDumpPath=
Java print service
The Java Print Service (JPS) implemented in NSJ7 uses the headless version of the javax.print
API. JPS allows you to print on printers directly to NonStop systems and to network printers
attached to a local area network (LAN) or wide area network (WAN). For information on configuring
ThreadDumpPath support
49
network printers, see Spooler FASTP Network Print Processes Manual. For information on the
Spooler subsystem, see Spooler Utilities Reference Manual.
All printing features and attributes in the JPS classes listed below work when the NonStop spooler
and printer support the API. However, the NonStop operating system requirement for sending
text and postscript files to separate printers also applies when printing in JPS. The following are
the JPS classes:
•
javax.print
•
javax.print.attribute
•
javax.print.attribute.standard
•
javax.print.event
For applications using the java.awt.print.PrinterJob class, the printer must be postscript
enabled. For information on enabling postscript printing, see Spooler FASTP Network Print
Processes Manual.
Using the Guardian printer
NonStop Java API accepts the Guardian printer filenames.
The following code fragment shows how to set the Guardian printer filename and print the
print.txt file:
..
String printer = "$s.#p255";
FileInputStream stream = new FileInputStream("print.txt"); // file to print
..
PrintServiceAttributeSet prAttr = new HashPrintServiceAttributeSet();
prAttr.add(new PrinterName(printer, null));
PrintServiceLookup lookup = new UnixPrintServiceLookup();
PrintService[] services = null;
..
services = lookup.getPrintServices(null, prAttr);
..
DocPrintJob job = services[0].createPrintJob();
SimpleDoc doc = new SimpleDoc(stream, DocFlavor.INPUT_STREAM.AUTOSENSE, null);
..
job.print(doc, null);
..
..
NOTE: In the above example, $s.#p255 is the name of the configured printer. If there is no
printer configured with this name, then print output is routed to Spooler with location #p255. To
print the document, you need to explicitly reroute the document to the configured printer location.
For more information, see Spooler Utilities Reference Manual.
Dynamic saveabend file creation
NOTE: Dynamic saveabend file creation works only with Java processes. It will not work with
GC processes.
Dynamic saveabend file creation helps to create a saveabend file of a running Java process
without aborting (abending) the Java process, and by issuing a signal to the process. This allows
the Java process to continue execution even after the abend file is created. The time taken to
create the abend file, that is the application pause time is low (measurable in milliseconds).
The saveabend file enables you to analyze any observed Java runtime problems, such as
observed high memory consumption, and low responsiveness without impacting the running
Java process.
To create a saveabend file in the working directory of the process, perform the following steps:
50
Implementation specifics
1.
2.
3.
Export DUMP_CORE=1.
Start the Java application.
Press Ctrl+break while the process is running.
Saveabend file generation
If distributed GC is enabled, then the saveabend files are generated differently. The Java process
or GC process can encounter a problem and terminate abnormally. When one process in the
Java process group terminates abnormally, then the other processes detect the abnormal
termination and also terminate abnormally.
The first process that terminates abnormally dumps the entire user address space (full dump),
and the other processes do the partial dump of the address space. To analyze the problem, load
the saveabend file independently in eInspect for analysis. As the partial snapshot files do not
contain all the data, the full dump needs to be used to get the data.
CAUTION: The saveabend flag must be turned on for both Java launcher executable file and
the javagc executable file for creation of saveabend files for both the Java and GC processes.
You can collect the snapshot files of the Java process and GC process and send it to Hewlett
Packard Enterprise support for analysis. You must collect all the saveabend files.
FastExec option support
For applications that use the Runtime.exec method to create a child process, NSJ7 provides
a faster method to create a child process using the -Dnsk.java.fastExec=true option. The
Runtime.exec method forks a child process and overlays its image with the new executable.
Forking the child process duplicates the parent process image, which is discarded when the exec
is executed. The -Dnsk.java.fastExec=true option builds the child process image from
the executable. It does not inherit the parent process image, thus reduces the time required to
create a child process.
NOTE: The same result can be achieved by using
-Djdk.lang.Process.launchMechanism="posix_spawn" option introduced by Oracle,
which is supported from NSJAVA H70^ACN onwards.
Java getLocalHost() caching
Java getLocalHost() has to make a call to the Kernel API to obtain the desired results, which
is a time consuming factor. Java caches results only for five seconds that is not useful for
applications which run for a longer time.
Starting with T2766H70^ACN or T2866H70^ACN, option
-Dnsk.java.cachegetLocalHost=true is used to overcome the unnecessary calls made
to the Kernel API, and cache the results of getLocalHost() until the application ends.
WARNING!
Do not change the IP address of the system while running the application.
Java authentication and authorization service
The Java Authentication and Authorization Service (JAAS) is integrated in NSJ7. JAAS augments
the core Java 2 platform which facilities to authenticate and enforce access controls. JAAS has
the ability to enforce access controls based on who runs the code.
JAAS implements a Java version of the standard Pluggable Authentication Module (PAM)
framework. This plug ability permits applications to remain independent from underlying
authentication technologies. New or updated authentication technologies can be plugged in
without requiring modifications to the application. Applications enable the authentication process
Saveabend file generation
51
by instantiating a LoginContext object, which in turn references a configuration to determine
the authentication technology, or LoginModule, that is to be used in performing the
authentication. The LoginModule interface provides developers the ability to implement different
kinds of authentication technologies that can be plugged in an application.
For example, one type of LoginModule might perform a username and password based form
of authentication. Other LoginModules might involve more sophisticated authentication
mechanisms.
NSJ7 product includes LoginModule interfaces implemented by Oracle, such as
JndiLoginModule and KeyStoreLoginModule, but does not provide a LoginModule that
interfaces to the Safeguard subsystem on NonStop systems. You can also develop your own
LoginModule implementation.
For more information on writing a LoginModule implementing an authentication technology,
see JAASLoginModule Developer's Guide.
JavaBeans
JavaBeans are reusable software components that can run in both a design environment (inside
a builder tool) and runtime environment.
The design environment is highly visual and requires that JavaBeans provide design information
to the programmer and to customize its behavior and appearance.
In the runtime environment, JavaBeans might be visible in the case of a Graphical User Interface
(GUI), or invisible in the case of a data feed control.
Because of the CLI nature of the NonStop operating system, NSJ7 supports only runtime execution
of invisible JavaBeans. The NSJ7 does not support design-time execution or runtime execution
that requires a GUI operation. In NSJ7, the Boolean expression java.beans.Beans
isGuiAvailable returns the value false.
For more information about JavaBeans, see Oracle JavaBeans document.
Debugging Java programs
This subsection discusses the debugger architecture and how to run the programs involved in
debugging Java applications, and also discusses the following topics:
•
“Debugging overview” (page 52)
•
“Transports” (page 53)
•
“Java command-line options to run a debuggee” (page 53)
•
“Starting the Java debugger (JDB) tool” (page 54)
•
“Debugging JNI code” (page 55)
•
“Debugging Java and JNI code” (page 55)
Debugging overview
NSJ7 supports Java Platform Debugger Architecture (JPDA) that provides debugging support
for the Java platform. For more information, see Oracle's Java Platform Debugger Architecture
Documentation.
NSJ7 ships a terminal oriented non-GUI debugging tool. This Java Debugger Tool (JDB) can be
used on a NonStop system to debug the Java applications running on the same NonStop system,
or on another NonStop system, or any other platform.
You can also use the non-GUI debugging JDB and other vendors' GUI debuggers running on
Microsoft Windows and other platforms to debug NSJ7 applications running on a NonStop system.
52
Implementation specifics
Transports
A JPDA transport is a form of inter-process communication used by a debugger application and
the debuggee. NSJ7 provides a socket transport that uses the standard TCP/IP sockets to
communicate between the debugger and debuggee.
By default, NSJ7 uses socket transport. NSJ7 does not support shared memory transport.
Java command-line options to run a debuggee
For remote debugging, you need to start the Java application to be debugged (debuggee) as a
server using the following command:
java -Xdebug -Xnoagent
-agentlib:jdwp=transport
-Xdebug
Enables debugging.
-Xnoagent
Disables the old Sun.tools.debug agent. This is the default value.
-agentlib:jdwp=sub-options
sub-options are specified in the following format:
name1[=value1],name2=[=value2]...
The sub-options are as follows:
transport
Indicates the name of the transport. The value is dt_socket, and by default,
NSJ7 uses dt_socket.
server=y
y means listen for a debugger application
address= transport-address-for-this-connection
The transport address is the port number in which the debuggee is listening for
the debugger or a range of port value from which the debuggee selects the first
available port to listen for the debugger. The following syntax is used:
address=[:] | -
where,
is the host name.
is the socket port number.
is the starting port number for a range of ports.
is the ending port number for a range of ports.
suspend=y
suspends the debuggee just before the main class loads.
Debugging Java programs
53
Optionally, you can specify the -Xint argument, by using only the interpreter and not the HotSpot
compiler.
NOTE:
Specifying a range of port numbers for address is specific to NonStop.
The subsequent examples show the various ways in which the connection address is specified:
Example 6 When the port number is specified
java -Xdebug -Xnoagent
-agentlib:jdwp=transport=dt_socket,server=y,address=4000,
suspend=y classname arguments
Example 7 When the range of ports are specified and hostname is implicit
java -Xdebug -Xnoagent
-agentlib:jdwp=transport=dt_socket,server=y,address=4000-4050,
suspend=y classname arguments
Example 8 When the machine name and port range are specified
java -Xdebug -Xnoagent
-agentlib:jdwp=transport=dt_socket,server=y,address=someMachine:4000-4050,
suspend=y classname arguments
Starting the Java debugger (JDB) tool
The Java Debugger (JDB) tool can be started so that it communicates with the debuggee by
using the jdb command as described for the following situations:
•
If you are using JDB on the same NonStop system where the debuggee runs, use the
following command:
jdb -attach portnum
•
If you are using JDB on a different NonStop system from where the debuggee runs, use the
following command:
jdb -attach host-name:portnum
•
If you are using JDB from Microsoft Windows or any other platform, use the following
command:
jdb -connect com.sun.jdi.SocketAttach:hostname=hostname,port=portnum
Additional information
If you are using a GUI debugger, refer to the vendors' documentation to configure the debugger
to communicate with the debuggee.
Remote debugging of NSJ7 applications are tested with Eclipse 3.7.2 of the Eclipse Project. For
information and software downloads, see http://www.eclipse.org/
For more details on command-line options, see Connection and Invocation Details
54
Implementation specifics
Debugging JNI code
Use the inspect debugger tool available on the NonStop system to debug the native code. This
native code is written by application developer, and is used with the Java program. Use Visual
Inspect (the preferred debugger) or Native Inspect to debug the native code. For more information,
see Native Inspect Manual.
You can use the following command to start java in an inspect debugger:
run -debug java java_options
To debug native code, wait until the DLL is loaded. Visual Inspect allows you to stop the program
after the DLL is loaded so that you can set breakpoints. For information on how to set the
breakpoints, see Native Inspect Manual.
You can view and debug the native routine to be debugged and other native routines that routine
calls. All other scopes above the native routine are either compiled or interpreted Java code,
which the inspect debugger has no knowledge about. For more information on debugging, see
“Debugging Java process” (page 107).
Using visual inspect to add an event breakpoint on DLL open event
Since Visual Inspect does not support deferred breakpoints, you need to ensure that a DLL is
loaded before setting a breakpoint. Visual Inspect supports the DLL open event breakpoint that
suspends the program just after a DLL is loaded, but before initialization routines are invoked.
Perform the following to add an event breakpoint on DLL open event:
1. In Visual Inspect, select View > Breakpoints in Application or Program Control view.
2. Click the Event tab.
3. Click Add Breakpoint and select DLL Open from Event Name menu.
4. Click Ok.
Debugging Java and JNI code
You can use the Native Inspect debugger tool to debug the native code and Java Debugger tool
to debug the Java code simultaneously. You need to start the Java debuggee process in a
debugger.
For example, type the following command:
run -debug java -Xdebug -Xnoagent -agentlib:jdwp=sub-options
You can then use the Java Debugger tool to communicate with the debuggee process as explained
in “Debugging overview” (page 52).
Deviations in JVM specification options
The compiler specification options for both the java and jdb tools deviate from standard Java
because NSJ7 implements only the HotSpot server VM and does not implement a client VM.
Accordingly, the options that specify running the client VM are not valid.
java: Java application launcher command-line option deviations
-client
Selects the Java HotSpot Client virtual machine (VM).
NOTE:
The -client option is not valid with NSJ7.
-server
Selects the Java HotSpot Server virtual machine (VM).
Deviations in JVM specification options
55
NOTE: The -server is the default option for NSJ7. Hence, specifying -server
is optional.
For more information about the java tool and additional deviations from standard Java, see
“Implementation of garbage collector types” (page 59) and java in the NonStop Java 7.0 Tools
Reference Pages.
jdb: Java debugger command-line option deviations
-tclient
Runs the application in the Java HotSpot client VM.
NOTE:
The -tclient option is not valid with NSJ7.
-tserver
Runs the application in the Java HotSpot server VM.
NOTE: The -tserver is the default option for NSJ7. Hence, specifying
-tserver is optional.
For more information about jdb and how to start a Java program so that jdb can attach to it,
see jdb in the NonStop Java 7.0 Tools Reference Pages.
Garbage collection (GC)
This section discusses the following implementation-specific topics about garbage collection for
NSJ7:
•
“General information on garbage collection” (page 56)
•
“Heap Layout” (page 56)
•
“Managing generation size” (page 58)
•
“Implementation of garbage collector types” (page 59)
General information on garbage collection
In general, the various GC algorithms, and modeling in NSJ7 are same as those implemented
by Oracle in their JVM. Accordingly, you must refer to the Java web site for details about garbage
collection. However, some of the information is not applicable to NSJ7. For more relevant
information, see the following links on Java web site:
•
Java SE 7 HotSpot Virtual Machine Garbage Collection Tuning
•
Improving Java Application Performance and Scalability by Reducing Garbage
Collection Times and Sizing Memory Using JDK 1.4.1 by Nagendra Nagarajayya and J.
Steven Mayer.
Although, this paper was written for JDK1.4.1, it contains information related to tuning
application behavior using data in verbose GC logs, which is applicable to JDK 7.0.
Heap Layout
The subsequent sections provide an overview about heap layouts managed in Parallel, CMS
GC, and G1GC.
56
Implementation specifics
Heap layout for G1GC
Heap layout for G1GC is organized in a different way — G1GC moves away from a contiguous
heap wherein the heap layout used to split into young and old generations. G1GC introduces a
concept of regions:
•
Java heap space is divided into fixed size regions.
•
Size of the region can span from 1 MB to 32 MB depending upon the total heap size.
•
The main goal of G1GC is to split the total heap into approximately 2048 regions.
•
G1GC tries to reclaim regions with least amount of live data and free regions are assigned
to new or old generations.
Figure 2 (page 57) illustrates the heap layout for regions:
Figure 2 Heap layout for regions
Contiguous Java Heap
S
E
S
S
S
E
E
S
S
H
E
E
S
S
H
E
H
S
E
E
S
E
Eden
S
Survivor
Young Generation
H
Humongous
Old Generation
Heap layout for Parallel and CMS GC
In NSJ7, the memory is managed in generations (or memory pools) based on objects at different
ages for Java objects. Figure 3 (page 58) illustrates the heap layout for generations.
Garbage collection (GC)
57
Figure 3 Layout for generations
The following list describes the various generations:
•
Young (also called new) generation—The JVM allocates objects in the young generation
pool. Minor garbage collection happens when this young generation is full and the JVM is
unable to allocate new objects. The young generation also includes two survivor spaces.
One survivor space is empty at any time and serves as a destination for the next GC
operation, and which also copies the collection of any live objects in the Eden and other
survivor space. Objects are copied between survivor spaces in this way until they are old
enough to be tenured—copied to the tenured generation.
•
Tenured (also called old) generation—The JVM moves objects that survived minor garbage
collections from the young generation to the old generation.
•
Permanent generation—Class objects and metadata objects are allocated in permanent
generation.
The young and tenured generations each have an area called RESERVED, which is allocated
at the initialization and is used when garbage collection does not have sufficient space to satisfy
the allocation request. In the Oracle implementation, the address range for reserved area is
reserved but memory space is not allocated until it is used. Whereas, in NSJ7 implementation,
the address range for reserved area is reserved and memory space is allocated during the
initialization.
Managing generation size
Several java command options allow you to manage the initial size and maximum size of the
combined young and tenured generations.
-Xms
Sets the initial size for the combined young and tenured generation. The default
initial size is 64 MB for 32–bit NSJ7, and 1024 MB for 64–bit NSJ7. Smaller values
lead to shorter but more frequent garbage collections, whereas larger values lead
to longer but less frequent garbage collections. For large server applications,
Hewlett Packard Enterprise recommends that the initial size be equal to the
maximum size.
-Xmx
Sets the maximum size for the combined young and tenured generation. The
default maximum size is 64 MB for 32–bit NSJ7, and 1024 MB for 64–bit NSJ7.
58
Implementation specifics
With 64–bit NSJ7, -Xmx can be set to values greater than 1276 MB (that is around
1.24 GB, which is the maximum heap size for 32–bit NSJ7).
NOTE: You must consider the amount of physical memory available on the system while
choosing a value for —Xmx. If the virtual memory of a process exceeds the physical memory,
then memory thrashing occurs and the application performance slows down.
NOTE: Hewlett Packard Enterprise recommends that the application specifies the same value
for —Xms and —Xmx. If only —Xmx is specified in the command-line, the default value used for
—Xms is the same value that is specified for —Xmx.
-XX:MaxPermSize
Sets the maximum size for the permanent generation. The default value for
MaxPermSize is 64 MB for both 32–bit and 64–bit NSJ7. The initial size of the
permanent generation PermSize option is ignored.
NOTE: At initialization time, the maximum size of the combined young and
tenured generations, and maximum size of permanent generation are allocated.
Implementation of garbage collector types
The available garbage collectors in NSJ7 are as follows:
•
Serial collector (default collector for young and tenured generations)
•
Parallel collector
•
Parallel compacting collector
•
Concurrent Mark-Sweep collector (or Concurrent low-pause collector)
•
G1GC
WARNING! When PUT_PROTECTED_STACK_DISABLE is set, the behavior of all implementation
of Garbage Collector types is undefined except Serial Collector.
Table 7 Summary of garbage collector implementations
Collector Type
Implementation Status
Serial collector
Default collector for the young and tenured generation
“Parallel collector” (page 59)
Allowed
“Concurrent Low-Pause collector”
(page 60)
Allowed
Parallel collector
The parallel collector (or throughput collector) uses the parallel version of the young generation
collector. The parallel collector is available only for J-series systems.
NOTE: To enable the appropriate GC, use the "+" option. To disable the appropriate GC, use
the "—" option.
The following are the valid java command options, that specify or apply to a parallel collector:
-XX:+UseParallelGC
This option enables parallel scavenge for the young generation.
NOTE:
The default GC is the serial GC.
Garbage collection (GC)
59
-XX:+UseParNewGC
This option enables new parallel scavenge for the young generation. The difference
between parallel GC and ParNewGC is that ParNewGC is optimized for use with
CMS GC. This is the default scavenge GC if CMS GC is specified.
-XX:+UseParallelOldGC
This option enables parallel GC for the old generation. This option automatically
enables parallel scavenge (for young generation).
–XX:+UseParallelOldGCCompacting
This option is used to enable parallel old compacting collector for the tenured
generation.
-XX:+UseAdaptiveSizePolicy
This option enables adaptive size policy for the Java heap. By default, this option
is disabled in NSJ7. However, if the parallel GC is enabled, this option is enabled
automatically unless it is disabled it in the command-line.
NOTE: AdaptiveSizePolicy on NSJ7 considers only the throughput and
pause time goal. The footprint goal is not considered.
-XX:+AggressiveHeap
Obtains the platform resources and configures the heap layout accordingly, uses
parallel collector, and enables AdaptiveSizePolicy option.
-XX:+AggressiveHeap option is not supported in NSJ7. However, if you specify
this option the JVM exits with the error:
—XX:+AggressiveHeap option is not supported on this platform.
-XX:GCHeapFreeLimit=space-limit
Specifies the lower limit on the amount of space freed during a garbage collection
in percentage of the maximum heap.
-XX:GCTimeLimit=time-limit
Specifies the upper limit on the amount of time spent in garbage collection in
percent of total time. Also, the following flags for a parallel collector are supported:
-XX:MaxGCPauseMillis=nnn
-XX:GCTimeRatio=nnn
These specify performance goals for the application.
–XX:ParallelGCThreads=
This option is used to specify the number of parallel GC threads for the parallel
garbage collection. The default number of GC threads created is equal to the
number of cores present in the processor. If a value greater than the number of
cores is specified, the following warning is displayed and the application continues
to run:
WARNING! Parallel GC thread count () cannot be greater than the number
of cores () in a CPU. Using for Parallel GC count.
Concurrent Low-Pause collector
A concurrent low-pause collector can be selected for tenured generation. This collector does
most of the collection concurrently with the application execution. This collector divides the
60
Implementation specifics
collection in different phases and operates specific phases concurrently with the application
execution, and others in stop the world mode.
The following java command options that specify a concurrent low-pause collector are valid for
NSJ7:
-XX:+UseConcMarkSweepGC
This option enables concurrent mark sweep GC for the old generation. Note that
the default GC is the serial GC for old generation, and hence this option must be
specified to enable concurrent mark sweep GC. By default, if this is selected,
UseParNewGC is selected for the young generation.
-Xconcgc
This option enables concurrent mark sweep GC.
–XX:+CMSIncrementalMode
This option enables running CMS GC for the old generation in the incremental
mode. Each time the GC is run, only the portion of the tenured generation is
collected. —XX:+UseConcMarkSweepGC must be specified to use this option.
–XX:ParallelMarkingThreads=
This option is used to specify the number of parallel marking threads for the CMS
garbage collection. The default value for this option is zero and this value cannot
be changed on the command-line.
If a value greater than zero is specified on the command-line, the following warning
message is displayed, and the application continues to run.
WARNING!
Java HotSpot(TM) Server VM warning:
Setting ConcGCThreads/
ParallelMarkingThreads/
ParallelCMSThreads greater than 1 is not allowed on this platform.
Setting it equal to default value that is zero.
–XX:ParallelCMSThreads=
This option is used to specify the number of parallel CMS threads for the CMS
garbage collection. The default value of this option is zero and this value cannot
be changed on the command-line.
If a value greater than zero is specified on the command-line, the following warning
message is displayed, and the application continues to run.
WARNING!
Java HotSpot(TM) Server VM warning:
Setting ConcGCThreads/
ParallelMarkingThreads/
ParallelCMSThreads greater than 1 is not allowed on this platform.
Setting it equal to default value that is zero.
G1GC collector
From NSJ7 SPR T2766H70^ACN or T2866H70^ACN, Oracle command line options support
G1GC. The options are as follows:
-XX:+UseG1GC
Garbage collection (GC)
61
This option enables G1GC. This option is enabled only on J06.19 RVU only. If it
is used on L15.02 and H-series RVU, JVM displays an error message and exits.
-XX:G1ReservePercent=
This option specifies the size of the heap to be reserved for reducing the possibility
of promotion failure. The default value is 10 percent.
-XX:G1HeapRegionSize=
This option specifies the size of the individual region. The minimum size of the
region is 1 MB and the maximum size is 32 MB. The default size is determined
ergonomically.
-XX:ConcGCThreads=
This option specifies the number of threads that are to be used for concurrent
phase of the garbage collector. The allowed value is 1.
Handling large GC log files
From NSJ7 SPR T2766H70^ACJ or T2866H70^ACJ and later versions, Oracle command line
options support GC log file rotation. The options are as follows:
•
—XX:+UseGCLogFileRotation —XX:NumberOfGCLogFiles=
•
—XX:GCLogFileSize=
NOTE:
—Xverbosegc supports the listed options.
Hewlett Packard Enterprise’s GC log rotation option, —XX:GCLogLimits, remains unchanged
and supports both —Xloggc and —Xverbosegc options.
NOTE: Hewlett Packard Enterprise’s LogRotation option —XX:GCLogLimits=M,N overrides
Javasoft’s LogRotation options. If Hewlett Packard Enterprise's —XX:GCLogLimits is specified,
GC logs rotate to new log file after N records.
Other CMS/Parallel GC options
In earlier versions of NSJ, JVM does not throw an error message if some of the parallel and CMS
GC related options are used. JVM ignores these options since parallel and CMS collectors are
not available. However, with NSJ7, these options are accepted by JVM since the above-mentioned
collectors are available. For a complete list of the options, see Oracle Java documentation.
Memory management considerations
This section provides information about memory management considerations for both 32–bit
and 64–bit JDK7.
JVM data segment for 32–bit JDK7
In 32–bit NSJ7, JDK/JRE allocates one or more flat segments (up to a maximum of six starting
from segment ID 1069 to 1074) for its internal dynamic memory requirement. These segments
are referred to as JVM data segments.
In earlier releases, during JVM initialization, the first JVM heap segment (1069) is allocated with
a segment size of 256 MB. When this segment is filled, the next available segment is allocated
with a size of 256 MB or less, depending on the virtual memory available during the time of
allocation. This process continues until all six segments or the virtual memory is filled. Since the
first segment size is 256 MB and there is no option to change the size, complete 256 MB is
reserved for JVM irrespective of whether the JVM uses the complete virtual memory (256 MB).
This space cannot be used for other purposes such as Java heap, native application heap, and
62
Implementation specifics
so on. Therefore, the maximum Java heap size available for an application is reduced by 256
MB from 1.3 GB on NSJ6 and in NSJ7 it is reduced to 1084 MB.
NSJ7 SPR T2766H70^ACJ provides a feature to overcome the limitation of earlier NSJ7 JDK/JRE
as explained in the preceded section. This feature frees up 192 MB of virtual memory for the
process to use Java heap, native application heap, and so on compared to earlier version of
NSJ7. Additionally, a command line option, MaxJVMHeapSize, is provided to customize the
JVM heap size depending on the application requirement. The syntax for this option is as follows:
–XX: MaxJVMHeapSize=
where, size can vary from 64 MB to 1.5 GB.
Default value of MaxJVMHeapSize is 1.5 GB.
Using this command line option, application can customize the amount of virtual memory utilized
by JVM heap segments. Also from NSJ7 SPR T2766H70^ACJ, the first segment size is always
64 MB. The remaining segments sizes vary depending on the MaxJVMHeapSize. If the
MaxJVMHeapsize is 1.5 GB, which is the default value, the remaining five segments varies from
128 MB to 512 MB. It must be noted that in earlier release, the maximum size of the JVM heap
segment is always 256 MB. However, from NSJ7 SPR T2766H70^ACJ, the maximum size of
the JVM heap segment is not a fixed value and it depends upon the MaxJVMHeapSize.
JVM always rounds-off the value of the segment size to the next higher multiple of 4 MB. It must
be noted that JVM allocates the complete memory specified in MaxJVMHeapSize only on
availability of memory. Hence, MaxJVMHeapSize may not be honored always.
Sample Invocation:
java –XX:MaxJVMHeapSize=256M -version
In the sample command invocation, the first JVM segment (segment ID 1069) size is 64 MB.
Then the remaining 192 MB memory is divided (calculated dynamically) among the next five
segments whose segment ID range is 1070–1074.
JVM data segment for 64–bit JDK7
64–bit NSJ7 JDK/JRE allocates one extensible flat segment for its internal dynamic memory
requirement. The initial size of this segment is 512 MB, and the maximum size is 12 GB. This
segment is referred as JVM data segment.
When the allocated portion of the segment is filled, and if the allocated size of the segment has
not reached the maximum value of 12 GB, then the segment is resized by increasing its size by
multiples of 512 MB. To avoid segment resize during the application runtime NSJ7 SPR
T2866H70^ACJ provides an option InitialJVMHeapSize, that can be used to specify the
maximum JVM heap size required by the application. If this option is specified during JVM
initialization, the JVM heap segment is resized with the value specified and it avoids the resize
of the JVM heap segment later when the application runs. It must be noted that the value specified
with the command line option is a suggestive value. If the application needs more virtual memory,
the segment can be resized until it reaches 12 GB. The syntax for this option is as follows:
–XX:InitialJVMHeapSize=
where, size can vary from 512 MB to 12 GB.
Default value of InitialJVMHeapSize is 512 MB.
Sample Invocation:
java –d64 XX:InitialJVMHeapSize=4G
In the sample command invocation, during JVM initialization, the JVM Heap segment is resized
to 4 GB.
NOTE:
Minimum size of the JVM heap segment cannot be less than 512 MB.
Memory management considerations
63
Java heap size with 32–bit JDK7
As a result of the JVM data segment(s) allocation as described in “JVM data segment for 32–bit
JDK7” (page 62), maximum Java heap available for a 32–bit Java application is 1276 MB.
With earlier versions of NSJ7, the maximum Java heap that can be allocated is 1084 MB.
Java heap size with 64–bit JDK7
The default initial and maximum Java heap size for 64–bit NSJ7 is 1 GB. The theoretical maximum
value of Java heap that can be specified is 484 GB. However, the actual maximum Java heap
size is limited by the available Kernel-managed swap space.
Native heap size with 32–bit JDK7
As a result of the JVM data segment(s) allocation, the size of the native heap available for JNI
components is lesser by the sum of the sizes of the JVM data segments and size of Java heap.
Native heap size with 64–bit JDK7
The native heap size is limited to 12 GB. Java does not have command-line option to modify the
value of the native heap size. If application requires more than 12 GB native heap size, then it
can be modified by using the eld -change heap_max option on Java launcher program.
Java garbage collector tuning for application performance
NSJ7 incorporates the HotSpot VM. This section discusses the options available for tuning the
JVM, suggests flags and values to tune the Java HotSpot VM, and points to the HotSpot tuning
information on the Internet. GC tuning is assisted by GC profile data which can be collected and
analyzed as explained in the subsequent sections.
Since GC occurs when generations fill up, the amount of available total heap memory has direct
impact on the performance. The parameters that affect the heap are as follows:
-Xms: The startup size of memory allocation pool (the Java heap)
-Xmx: The maximum memory allocation pool
The maximum value for Nonstop system depends on the location of QIO segment
when using 32–bit NSJ7. If the segment is moved to KSEG2, the maximum value
can be as high as 1276 MB, otherwise, the value might stay around 350 MB. For
information on QIO segment location, see “Memory considerations: Moving QIO
to KSEG2” (page 30). Also, see “Java heap size with 32–bit JDK7” (page 64).
When using 64–bit NSJ7, the theoretical maximum value is 484 GB. However,
the actual limit is constrained by the size of physical memory and swap space
available from the Kernel-managed swap space, and the number of processes
contending for these resources.
For more information, see “Java heap size with 64–bit JDK7” (page 64).
For larger server applications, the default values of the two options listed are usually inadequate.
In general, you must assign as much memory to the JVM.
Another important factor that affects performance is the proportion of the heap that is assigned
to the young generation. The parameters for the young generation heap are as follows:
-XX:NewRatio=nn
The ratio between the young and old.
-XX:NewSize=nn
The lower size bound.
-XX:MaxNewSize=nn
64
Implementation specifics
The upper size bound.
-XX:SurvivorRatio=nn
Tune the survivor spaces (illustrated in the Figure 3 (page 58)).
For example,
java -Xms512m -Xmx512m -XX:NewSize=256m -XX:MaxNewSize=256m \
-XX:SurvivorRatio=2
These options notify the JVM to set:
•
The initial size of the heap to 512 MB.
•
The maximum heap size to 512 MB.
•
The new generation to 256 MB (128 MB belongs to Eden and 2x64 MB survivor).
•
The old generation to 256 MB.
For more information about all these parameters, see Java HotSpot VM Options.
For more information about tuning garbage collection with the Java SE 7 HotSpot virtual machine,
and for general performance tuning information, see the following documentation:
•
Java SE 7 HotSpot Virtual Machine Garbage Collection Tuning.
•
The article Tuning Java I/O Performance.
•
The article, Turbo-charging Java HotSpot Virtual Machine, v1.4.x to Improve the
Performance and Scalability of Application Servers.
•
Java Performance Documentation.
NOTE:
•
The following options do not apply either for the NSJ7 or NonStop system:
-XX:-UseBoundThreads
-XX:+UseAltSigs
-XX:+AllowUserSignalHandlers
-XX:+MaxFDLimit
-XX:-UseLWPSynchronization
-XX:PreBlockSpin=nn
-XX:-UseMPSS
-XX:+UseSpinning
javagc
javagc is a executable file that is used by Java process to launch the GC process on J-series
systems. The GC process is a multi-threaded application. It interacts with Java application using
the standard NonStop Kernel IPC mechanism. The GC processes are launched on the same
processor on which the Java process is running. The maximum number for parallel GC processes
is equal to the number of cores in the processor. If CMS GC is enabled, the number of ParNewGC
processes created will be equal to the number of cores. In addition to these processes, there will
be one CMS GC task process. These processes are unnamed processes.
GC processes are bound to separate IPUs for improved performance. The IPU number to which
a GC process is bound is the ordinal number of that GC process. For example, if parallel GC is
enabled on a 4-core CPU, 4 GC processes are launched. The first GC process created binds to
IPU 0, second to IPU 1, third to IPU 2, and fourth to IPU 3.
javagc
65
You must not invoke javagc executable file directly, and if it is invoked directly, the process
displays the error message:
Internal Error: Cannot invoke directly!!!
NOTE:
64–bit.
There are two versions of javagc available in NSJ7, one for 32–bit and the other for
GC profiling
NSJ7 supports an Hewlett Packard Enterprise proprietary option, -Xverbosegc to capture the
Java application's GC activity. The output of this option can be used to view and analyze the
detailed statistics in an offline mode with HPjmeter. The following -Xverbosegc option generates
detailed information about the spaces within the Java heap before and after garbage collection:
-Xverbosegc[:help]|[0|1][:file=[stdout|stderr|]]
Fore more information on the syntax options of -Xverbosegc, see java in the NonStop Server
for Java 7.0 Tools Reference Pages.
For more information on application profiling, see “Application tuning and profiling” (page 94).
GC log rotation
When GC logging is enabled using the -Xverbosegc or -Xloggc option, by default, the GC
data is written to a single log file of unlimited size. NSJ7 allows you to control the size and number
of the GC log files. The GC log records are written in the specified number of GC log files in a
round-robin method. This allows GC data to be archived easily and thus helps to limit the amount
of disk space consumed by the GC log files. Log rotation is also supported when using
zero-preparation -Xverbosegc.
To enable log rotation, use the following option along with -Xverbosegc, -Xloggc, or
zero-preparation verbosegc:
-XX:GCLogLimits=M,N
where,
M is a non-negative integer that specifies the number of rotating GC log records
per file. A value of 0 specifies unlimited number of GC log records per file.
NOTE:
Each GC log record corresponds to a GC event.
N is a non-negative integer that specifies the maximum number of rotating GC log
files. A value of 0 specifies unlimited number of files.
You must use both M and N when you use the -XX:GCLogLimits=M,N option. If this option is
not specified, the default behavior is to write a single GC log file with unlimited size.
When rotation is in effect, a sequence number is appended to the GC filename (0 through N-1).
For example, filename.0, filename.1, and filename.2.
With log rotation, when the specified maximum number of files (N) is reached, logging cycles
back to the first file in the sequence (filename.0), thereby overwriting the old GC data with
new data. If the maximum number of files (N) is never reached, then no log rotation occurs.
Example
To rotate between two log files, each with a maximum of 100,000 GC records, use the following
command:
-XX:GCLogLimits=100000,2
To maintain an unlimited number of smaller files, each with a maximum of 1,000 GC records,
use the following command:
66
Implementation specifics
-XX:GCLogLimits=1000,0
—XX:+HeapDump and _JAVA_HEAPDUMP environment variable
The -XX:+HeapDump option can be used to examine memory allocation in a running Java
application by taking snapshots of the heap over time.
Another way to get heap dumps is to use the _JAVA_HEAPDUMP environment variable; setting
this environment variable enables you to take memory snapshots without making any modifications
to the Java command-line. To enable this functionality, either use the command-line option or
set the environment variable before starting the Java application.
For example, export _JAVA_HEAPDUMP=1
With the -XX:+HeapDump option enabled, each time the process is sent a SIGQUIT signal, the
JVM produces a snapshot of the Java heap in hprof ASCII format:
java___ Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.4 Linearized : No Keywords : NonStop, NSJ7, NonStop Server for Java 7.0, NSJ7 32–bit, NSJ7 64–bit, Java Infrastructure Author : Hewlett Packard Enterprise Trapped : False Create Date : 2017:04:25 16:54:46Z Modify Date : 2017:04:25 16:54:46Z Page Count : 132 Page Mode : UseOutlines Format : application/pdf Title : NonStop Server for Java 7.0 Programmer's Reference Creator : Hewlett Packard Enterprise Producer : XEP 4.24.444 Creator Tool : UnknownEXIF Metadata provided by EXIF.tools