zos | Autonomous operating system | Robotics library
kandi X-RAY | zos Summary
kandi X-RAY | zos Summary
Autonomous operating system
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- upgradeLoop runs the bootstrap loop
- registerNode is used to register a node
- AnalyseLink parses a link and returns the cfg configuration .
- main is the main function .
- configureZOS prepares the default ZOS
- Install creates a new mac address
- Get Environment from params
- CreateMACvTap creates a new macvtap interface .
- addressRender prints out the address table .
- action is the entrypoint command .
zos Key Features
zos Examples and Code Snippets
Community Discussions
Trending Discussions on zos
QUESTION
I have this Java code that creates and saves a zip file with a text file inside it:
...ANSWER
Answered 2022-Apr-07 at 22:20The try-with-resources
does close the ZipOutputStream
. It's just that it closes the zip stream after you copy its content to the FileOutputStream
. How do you expect work that happens after the file has been closed to affect the content of the file?
I recommend replacing the ByteArrayOutputStream
with the FileOutputStream
. What need do you have to buffer?
QUESTION
I'm working on generating a zip file that has to compress around 2000 documents that are around 1GB in total and after that to upload the zip file in s3 bucket.
I'm using net.lingala.zip4j which is a really nice Java library for handling Zip files. Based on the documentation:https://github.com/srikanth-lingala/zip4j I'm using the stream handling part of it. The code looks almost similar to the one from the documentation:
...ANSWER
Answered 2022-Mar-25 at 14:06Funny enough, this was on the local machine while I got OutOfMemoryError during the zip generation.
In testing environment, I got OutOfMemoryError during the retrieval of the documents. So Hibernate was complaining too. This was with a step before the generation. Probably this happened since local machine has 16GB and testing env only 1GB.
So the solution was build based on the following steps:
- retrieve the files in batches with Hibernate, and (flush/clean) transactional entityManager, in order to force Hibernate to not keep in memory all the files. The Batch size was: 50 documents.
- Adapt the code for the zip4j compression with Aws multipart upload, in order to compress and upload only one batch of files, and reset the buffers afterwards, to avoid OutOfMemory.
Step2 was designed and adapted based on: https://www.bennadel.com/blog/3971-generate-and-incrementally-stream-a-zip-archive-to-amazon-s3-using-multipart-uploads-in-lucee-cfml-5-3-7-47.htm
So the code from the initial question became as follows:
QUESTION
The memory allocation error specifically seems to occur once it hits the for loop and only for very large storesLists. I only able to hit the memory allocation error if storesList.size() is about 2 million. I've pasted a snipped of the for loop which is supposed to create a new row based off each object in the loop.
The function takes in a ZipOutputStream and a list of objects.
...ANSWER
Answered 2022-Mar-24 at 12:41Don't build a memory structure when you can stream the same data directly - as huge structures may hit OutOfMemoryError
on the toString()
or getBytes()
calls.
If you are dealing with platform line separators you can write out rows like this:
QUESTION
So, basically the title.
I got 2 microservices. One generates and sends a zip file and the other one receives it, then does some magic, converts it to an array[] of bytes and then sends it somewhere else. But it's just in theory - I coldn't make it work.
I need to download a Resource (https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/resources.html) that contains InputStream that my generated zip archive is wrapped into. Writing it inside OutputStream of a HttpServletResponse doesn't work for me since I can't use it - later on I need to manipulate the file and this approach is for browser download only (?)
So I did this in the first microservice:
...ANSWER
Answered 2022-Mar-11 at 09:48Ended up encoding byte array to base64 string then sent it as
QUESTION
I've setup a method that feeds in multiple data files from our S3 bucket in an attempt to zip them together and then pass them to the user querying via the browser. However, I can't open the file that gets sent back.
I've tested with a FileOutputStream and the zip files stores in a proper format there, so it looks like the process of pulling, zipping and writing are working.
My assumption that there's an issue passing it back via the ServletOutputStream, which is pulled using the getResponse().getOutputStream()
that you see below. I then call the write method on it, and this process seems to work fine for single files in byte[] format in other parts of the program, just not here.
Another piece to the puzzle, the file in zip format that I output and that worked via FileOutputStream was the same size as the file delivered via the browser and ServletOutputStream, so I think the data is getting over. Instead though I just get an (Error 79 - Inappropriate file type or format.)
Open to any suggestions or help!!
...ANSWER
Answered 2022-Jan-29 at 10:33You haven't closed the ZipOutputStream
correctly - the call to zos.close();
must occur before writing the bytes, not afterwards.
You can get much neater handling of the output if using try with resources block and Files.copy
:
QUESTION
I am creating a zip file with one directory and an single compressed text file inside of it.
Code to create the zip file
...ANSWER
Answered 2022-Jan-25 at 11:49After much research i was able to solve 70% of the problems. Others can't be solved given the nature of how an ZipOutputStream & ZipFile reads the data
Problem 1: Incorrect values returned by getSize() & getCompressedSize()
1) During Writing
I was blind to have not seen this earlier but ZipOutputStream already does compression for us and i was double compressing it by using my own inflater so i removed that code and i realized that you must specify these values only when you are using the method as STORED. else they are computed for you from the data. So refracting my zip writing code this is how it looks like
QUESTION
I'm written an method which is accepting a file and then after it's creating a zip file. once zip file creation is done, then it's trying to store that in GCS bucket and deleting those file from temp dir. Could anyone help me one this to write the test cases for this.
...ANSWER
Answered 2022-Jan-15 at 21:02As a general rule of thumb when designing test cases you want to consider both the expected behaviour if everything goes right and the expected behaviours for each way that things could go wrong.
For your particular problem, when everything goes right you should expect your method to compress the file given as argument, upload it and delete the file from the temp directory. You can do so by spying on your static GcpCloudStorageUtil method. Spies are instances of a class which retain their usual behaviour unless specified and which method calls you can monitor. You can read more on the topic here and here (for static method spying).
It's hard to give a thorough answer without access to the rest of your code but I'd suggest :
- creating a non empty file
- calling the createZip method on this file
- verifying that the GcpCloudStorageUtil.uploadFileToGcsBucket method was called
- verifying that the uploaded file content matches the file you created
- verifying that the temp directory is now empty
There are also a number of way that things could go wrong. For instance the file given as argument might not exist. You want to write a test case which ensures that a FileNotFoundException is thrown in this case. This article covers different ways to do this using JUnit4 or JUnit5.
Similarly you could design a test case where you mock the GcpCloudStorageUtil.uploadFileToGcsBucket and force it to throw an exception then verify that the expected exception was thrown. Mocking a method means forcing it to behave a certain way (here, throw an exception). Again you can read more on the topic here.
Edit : Here is a possible test class.
QUESTION
I have downloaded a VB binary file from zOS, with RDWs but without BDW.
When I try to send it back it treats the existing RDW as part of the data and adds new RDW.
Is there a known way to do it, except editing it manually?
...ANSWER
Answered 2021-Dec-22 at 13:41Switching the ftp transfer mode to block mode should do what you want:
QUESTION
If I connect using FTP to zOS, I can run rstatus
command and in 68 lines returned I get one of the two following human readable lines:
RDWs from variable format data sets are discarded.
RDWs from variable format data sets are retained as part of the data.
Is there a way for a program to understand what is the status regarding RDW without parsing the 68 lines returned by rstatus, and without evaluating text that is intended for a human reader? (and therefor might change in the future without notice)
Thanks
...ANSWER
Answered 2021-Nov-30 at 16:45I'm unaware of a programmatic interface but you can specify how you want RDWs handled so you don't have to parse the current state. This can be done with the SITE command from the client to the mainframe. See reference in this question
Note: The settings in FTP.DATA will determine the default behaviour. Review this reference in the documentation.
SITE RDW
Specifies that Variable Record Descriptors (RDW) are treated as if they were part of the record and not discarded during ftp transmission of VB or VBS data sets in other than block mode. RDW information is stored in a binary halfword. Transfer files in binary to avoid translation problems that can occur if you transfer this binary field in EBCDIC or ASCII.
SITE NORDW
Specifies that Variable Record Descriptors (RDW) are discarded during ftp transmission of VB or VBS data sets in other than block mode.
QUESTION
Recently I came across this micro article where the following is stated:
- In your C program, you can have only one "main" function, whether it is called "main" or otherwise. If you use IPA, IPA will terminate with an error message issued when more than one "main" function is detected.
Do I understand correctly that the main
name (or some other name which is explicitly defined as a replacement of int main()
for an entry point) is an important part and, for example, I can have int main(int argc, char **argv)
and int sub_main(int argc, char **argv)
at the same program?
If not, and if there is a main
as part of the functions' names and/or (int argc, char **argv)
as parameters I might have a problem, will changing the places of the parameters to int sub_main(char **argv, int argc)
make any difference?
I haven't had problems so far so assume int main(int argc, char **argv)
and int sub_main(int argc, char **argv)
can happily coexist. Still, might be handy to know for sure.
ANSWER
Answered 2021-Nov-26 at 11:12Only the exact name of the function "main" is important fot the compiler to know where the program starts.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install zos
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page