> -----Original Message-----
> From: IBM Mainframe Discussion List 
> [mailto:IBM-MAIN@bama.ua.edu] On Behalf Of Farley, Peter x23353
> Sent: Friday, April 20, 2012 8:02 AM
> To: IBM-MAIN@bama.ua.edu
> Subject: Re: USS File Integrity
> 
> The OP originally stated that he had two STC processes that 
> updated the same z/Unix file at the same time and wanted to 
> prevent this.  Are two STC's both considered z/Unix processes 
> under the same kernel when they are running on the same LPAR? 
>  If so, ISTM that locking and unlocking the file around the 
> write code will work as a mechanism to prevent simultaneous writes.
> 
> But what about two STC's running on different LPAR's in the 
> same sysplex?  Does z/Unix file locking work across LPAR's, 
> or only within the same LPAR?
> 
> Just curious.
> 
> ISTR that simultaneous writes to a common file are 
> classically solved in most unix systems by implementing a 
> daemon process that is the only process allowed to write to 
> the file, and other processes send messages to the daemon to 
> accomplish the write function, like the syslog daemon for 
> system messages.
> 
> The new question is whether Java on z/Unix provides access to 
> any file locking mechanism at all, as the OP also just said 
> it was a Java application and he wants to share the file 
> among tasks of the *same* program.  That would argue that 
> using whatever the Java equivalent of the C flockfile 
> function is would be the solution to use.

I will disagree with you on this point. I would use the z/OS ENQ facility. It 
is fully supported by the ZFILE portion of the JZOS software, which is a part 
of the IBM supplied Java language on z/OS. And we all, hopefully, know that 
using ENQ allows for sysplex-wide serialization.

http://www.ibm.com/developerworks/java/zos/javadoc/jzos/index.html

> 
> But can z/Unix Java do that?  Or does he have to write a JNI 
> function to be called from his z/Unix Java code to implement 
> a file lock?  Or should he just implement a third 
> process/task under the same program for the file writes and 
> have both of the other tasks just send messages to the write process?

Yes, it can:

http://docs.oracle.com/javase/6/docs/api/java/nio/channels/FileLock.html
Of possible interest is the statement:
This file-locking API is intended to map directly to the native locking 
facility of the underlying operating system. Thus the locks held on a file 
should be visible to all programs that have access to the file, regardless of 
the language in which those programs are written. 

> 
> Peter

-- 
John McKown 
Systems Engineer IV
IT

Administrative Services Group

HealthMarkets(r)

9151 Boulevard 26 * N. Richland Hills * TX 76010
(817) 255-3225 phone * 
john.mck...@healthmarkets.com * www.HealthMarkets.com

Confidentiality Notice: This e-mail message may contain confidential or 
proprietary information. If you are not the intended recipient, please contact 
the sender by reply e-mail and destroy all copies of the original message. 
HealthMarkets(r) is the brand name for products underwritten and issued by the 
insurance subsidiaries of HealthMarkets, Inc. -The Chesapeake Life Insurance 
Company(r), Mid-West National Life Insurance Company of TennesseeSM and The 
MEGA Life and Health Insurance Company.SM

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: INFO IBM-MAIN

Reply via email to