I want to change the automatically saved filename of a HDFS block on a cluster. So when I upload a file to the HDFS and it'll divided into blocks, they get generated names with several numbers.
I searched the code but couldn't find it.
It should be somewhere in the java code, not a configuration file, right?
Can someone may tell me in which classes this creation or definition of the filename happens?
Thanks a lot!
edit:
Ok found it.
FSNameSystem.randBlockId.nextLong()
Ok found it.
FSNameSystem.randBlockId.nextLong()
Related
Sup!
I'm trying to understand the concepts and differences between them to load and save files, and trying to figure out the best way to load files with a program I'm making (a database). I'm using Java, but try to help me in a more general way, if possible. Whatever help I get is a lot welcome and I thank you already for it.
I know there is "File Reader" in Java and a lot of programs use files in .txt format. I tried to open a .doc file with Notepad, just to see what would happen, and NOTHING was a text. I expected that, not everything though.
I just don't know how to make a file that is not a .txt. How that happens?
This is a big one. When I load a file, should I load all its content and let it ready for use, or should I just keep the file path and read from it as I use, using offsets and pointers starting from the file path? How should I do this either way?
In this database program of mine, some things will be images (for example), and if I were to use a .txt, I would give each image a label that the program would read and then interpret it like the label of the image, and then get the image. How could I do that?
I was sure I had more questions. If I do I ask again.
Once more, thanks in advance for the attention and help.
When it comes to the .txt bit, all "plain text" will work. Just change the file extension to .ini or .sql (if sql is installed) and change it in your filepath too.
I'm in doubt about something. I'm developing a Java Desktop application and I have a problem.
I need to get the current local folder that my application (jar file) is in user system. And after this, to search inside of this same folder for some files (like all .txt file, for example). And finally, get the name of only one of this files and converts to string.
Someone can help me?
Antecipate thanks.
May be the getCanonicalPath() and getProperty() functions could help you, since you don't show any code I can't make you any example, but may be looking this could help you a little.
And also there is a similar question here
I have a jar file which have 15 classes. I have to call some methods of this jar from web application. Some of the methods read .plist file.
In the jar code I have coded in such a way that all the plist files are readed once and uses multiple times(I have used some static map which hold all the properties of .plist files), but this is not happening.
Every time there is a call it is reading all .plist files again. And because of this there is "Too Many Open File Exception."
Is there any way to stop the file reading again and again. Please help me.
Can you post your code or stack trace. it looks like a logical problem . If you want to read file once just have a static flag and after reading it set it true and before reading it just check....If this is not the desired answer just let me know .
I asked a question earlier about unzip/zip using windows cmd command in Java. That turn out to be not good for a program and one would suggest using the java.util.zip to unzip/zip. After looking through some tutorial, I found out usually they just loop through the content of the zip file. If I know the name of the file I want, can I extract it explicitly without looping through the whole zip file?? Here in my case, my zip file have 2300+ entries, and I would only want one of them. Do you guys happen to know some tricks? Thank you very much!
You will find hot to decompress files at: http://java.sun.com/developer/technicalArticles/Programming/compression/
Instead of looping and extracting all files just locate file you are interested in with ZipFile.getEntry() method.
You can get a ZipEntry -object for the specific file from ZipFile-object via the getEntry-method. To access the file contents, use ZipFile's getInputStream with the ZipEntry-object.
If this is for yourself and not your program, have you considered using the jar command in the JDK for this?
I have been using JDOM library to read and write XML files through Java Servlets.
Problem is that when I send many requests using AJAX to my servlets which read and write data in XML files, many times it fails displaying error: Premature end of file. How can I synchronize all these read/writes to files or is there any other way to prevent these problem? Let me know if more details are required.
Will use of threads do any good in this situation?
Thanks a lot!
Two possible solutions are:
Write your files to thename.xml.part and then once done/closed to a rename to thename.xml, which makes the write closer to being atomic -- the reader can't read it until it's surely done so long as it is looking for ".xml" files only.
or, use a Database, atomicity is what they do.
I have faced such type of problem but exactly not the same. I am sharing my experience about this error. Please, sorry for any inconvenience.
I have faced the following problem
I have to form a xml file with dynamic variable data. And post that xml to a URL by PostMethod in java.
Normally It works. But when dynamic variable data is null. Then it shows the “Premature end of file".
Solution:
Just checking the variable is null or not. And it works for me.
Try adding all the write requests to a Process Queue and then build/append XML by those elements of Queue.
I have also faced this problem. My experience is...
Clean Project
Rebuild Project
then it will run successfully....