Apache Pig, Suppress "Output Location Validation Failed" "Output directory ... already exists" - java

After getting help from orangeoctopus with this question, I now need to suppress the message "Output Location Validation Failed" "Output directory ... already exists". I know the directory exists, I want it that way. I am pretty sure this will be a matter of overriding something in my Storage UDF, but I am having trouble figuring out what. Totally new to Java so bear with me. Thanks in advance.

as far as i know, you cannot reuse a direct output directory. Hadoop prevents it. if i understand correctly, you're dealing with daily logs, therefore, i suggest you set a parent output directory say called output, and set your output directory in the script to be output/daily_date.

Delete your output directory before the store operation:
rmf $outpath;

Related

Empty Output file after doing the mapreduce (hadoop)

Hi so I got this problem that happened when I tried to use a jar on hadoop. But my Output folder is empty and I got this error message. I was wondering how can I fix this problem ? I saw some post on stack that said that I needed to change a property to this one -> mapreduce.map.failures.maxpercent. But I can't find where it's located I tried to see in mapred-site.xml but there is no line similar to this one. Also I am not really sure if this line would fix anything.
From the screenshot, it is evident that the job failed. The map task has failed (Failedmap tasks=4). Check additional logs to correct the issue with the code.
A folder with the same application ID will be created in the logs/userlogs of your Hadoop installation directory. For example:
HADOOP_INSTALLATION_DIR/logs/userlogs/application_xxxxxxxxxxxxxxx_xxxx
You can check the syslog and sysout messages.

CVS appends a ,v at end of file

I am using eclipse Luna with CVS for its synchronization and committing. However I keep getting a weird outcome from using it. For example my java class and file is named PrimeSieve. So when I commit the change, the file goes from being called PrimeSieve.java to PrimeSieve.java,v (the ,v gets appended). I don't quite understand or know where to get the resources to get the information to fix this. The reason I am trying to fix this is because when I run javac the ,v at the end gives me a bad flag warning with the compiler. Can anyone help me with this?
With CVS at the end of each file it appends a ,v because that is indication of the type of file it is. Any file with a ,v at the end of it is a history file.
For you to be able to make use of the .java class you would have to checkout the history file like so:
co yourJavaFile.java,v
This leaves you with
yourJavaFile.java
Hopefully this helps someone.

processing for android: AssetManager and list() not working

I've been developing for android using processing but have come to a halt when I wanted to retrieve a list of files within a given directory. Below is a screenshot of the code I have been trying.
I have tried different variations of this (such as getbaseContext().getAssets();) and nothing seems to work. Whenever the code tries to execute the list() part it has an error and there is nothing in 'fileNames'.
Am I missing anything? Is this a problem with processing?
Thanks
EDIT: The direction I am trying to access is "assets/Levels/" which I can see from my project view in eclipse.
I experienced a similar issue because I used folder names with a trailing / character.
So for others experiencing this issue, you need to make sure the folder name you use are just the folder name with no trailing / (so "movies" instead of "movies/")
You do not need any additional permissions in order to run the code that you have. I just compiled it on my device and it works fine. You mention you are attempting to list the files in a given directory. What you are doing is listing the files in the Levels folder, which should be a sub folder of assets. What you will get back is an array of all file names in that folder.
If you are actually looking to get a list of files from a given directory, it has nothing to do with the assets folder and I suggest you check out a tutorial on Android external and internal storage. The information directly on the android page was very helpful to me.
http://developer.android.com/guide/topics/data/data-storage.html
If that's not what you are looking for though, I suggest rewording your question.
So I got it to work!
Turns out it was a problem with where I was placing the 'String[] fileNames;' code before trying to put data into it. The below code works fine:
Thanks for the help!
*Note : Individual folder should not empty.. It will return zero for folder with no files. *
void getFolderDetais(String folder_name)
{
// pass folder_name empty to get detail of root that means assets folder details
String[] filelistInSubfolder = assetManager.list(folder_name);
Log.v("Floder Details ----- >", " Length --- "
+ filelistInSubfolder.length);
}

Java File can't open certain files

I'm trying to open files from within Java with something like this:
java.awt.Desktop.getDesktop().open(new File("c:\\coolfile.txt");
Of course it all works fine and dandy in most cases.
HOWEVER!
When I have a file with the unicode character u3000, I cannot open it! Even if the file exists.
For example:
java.awt.Desktop.getDesktop().open(new File("c:\\coolfile\u3000withweirdname.txt");
I get an Exception, EVEN WHEN THE FILE EXISTS
[java] java.io.IOException: Failed to open file:/E:/_prog/test%E3%80%80.txt. Error message: The system cannot find the path specified.
Please help me i tried pretty much everything. This is driving me insane :/
Edit:
To give some more info:
I can easily create file with this name from Java.
It seems it has something to do with whitespace
I don't know if it applies to other characters; I didn't find any yet. But of course if there's 1 there could easily be 100.
I'm pretty sure I can't read from the file or write to it from Java, but I haven't tested that since it isn't my main concern.
java.awt.Desktop.getDesktop().open(new File("c:\\coolfile\u3000withweirdname.txt");
That doesn't compile. Clearly it isn't your real code.
[java] java.io.IOException: Failed to open
file:/E:/_prog/test%E3%80%80.txt
And there is proof. Clearly you passed a URL to new FileInputStream(). It doesn't take a URL string, it takes a file name.
Ok i think i actually found a kind of solution to my question and i post it here to help any people that may have similar problems.
This fix only works for Windows (XP and up i think) BUT i don't even know if this problem exist in other OS. And even if it does a similar fix should be possible.
I am using the following code to succesfully open a file with the character:
Process p = new ProcessBuilder("cmd", "/c start \"\" \"E:\_prog\test\u3000.txt\"").start();
Which opens the file 'E:_prog\testu3000.txt'
As far as i know \u3000 is ideographic space character. To test your code I created a file with name CompanyAlt+3000Address.
Note: when you press Alt+3000, windows will create an ideographic space character. Then I copied the file name, to my java program and it worked for me.
Desktop.getDesktop().open(new File("C:\\Users\\Chandru\\Desktop\\Companyâ••Address.txt"));

Regarding Help File in JAVA

I'm new to help file creation in java. I have created a help file "sample.chm" with a 3rd party tool, added it to a java program with package name as "help" calling with runtime class and build the jar. When I run the jar file it is giving me an error that the "file cannot be found, null pointer Exception". I have given a relative path to identify the file like "../help/sample.chm" still it is not working and I tried with various classes to ientify the path. But still the same error.
Request you to please help me in fixing it.
The jar can be placed in different systems and should open this help file with out any issues.
I hope my explanation is sufficient you to identify the problem.
Regards,
Chandu
If you have a file inside a jar, you can't access it as you normally would. You can access it like this:
URL helpFile=Thread.currentThread().getContextClassLoader().getResource("help/sample.chm");
The method used above (getResource) will return a URL; if you want, you can get it as an InputStream as well by using getResourceAsStream instead.
At least a workaround unless a better solution pops up. Use the this.getClass().getClassLoader().getResource way to get an inputstream to the help file inside the jar.
Copy the bytes to a new help file in the target systems temp folder and use this extracted file with the external help file viewer.

Categories

Resources