<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>DataStax Support Forums &#187; Topic: Java code to perform CFS file operations from remote system is not working</title>
		<link>http://www.datastax.com/support-forums/topic/java-code-to-perform-cfs-file-operations-from-remote-system-is-not-working</link>
		<description>Software, Support, and Training for Apache Cassandra</description>
		<language>en-US</language>
		<pubDate>Wed, 22 May 2013 02:54:48 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.3</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.datastax.com/support-forums/search.php</link>
		</textInput>
		<atom:link href="http://www.datastax.com/support-forums/rss/topic/java-code-to-perform-cfs-file-operations-from-remote-system-is-not-working" rel="self" type="application/rss+xml" />

		<item>
			<title>tambalavanar on "Java code to perform CFS file operations from remote system is not working"</title>
			<link>http://www.datastax.com/support-forums/topic/java-code-to-perform-cfs-file-operations-from-remote-system-is-not-working#post-6902</link>
			<pubDate>Fri, 12 Oct 2012 14:30:01 +0000</pubDate>
			<dc:creator>tambalavanar</dc:creator>
			<guid isPermaLink="false">6902@http://www.datastax.com/support-forums/</guid>
			<description>&#60;p&#62;Thank you!&#60;br /&#62;
Finally it worked.&#60;br /&#62;
I missed file:/ in the URI.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;Code Changes&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
System.setProperty(&#34;cassandra.config&#34;, &#34;file:/C:/Data/Java/EDS-CFS-Util/conf/cassandra.yaml&#34;);&#60;br /&#62;
System.setProperty(&#34;dse.config&#34;, &#34;file:/C:/Data/Java/EDS-CFS-Util/conf/dse.yaml&#34;);&#60;/p&#62;
&#60;p&#62;Configuration conf = new Configuration();&#60;br /&#62;
conf.addResource(new Path(URI.create(&#34;file:/C:/Data/Java/EDS-CFS-Util/conf/core-site.xml&#34;)));&#60;br /&#62;
&#60;/code&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>vsavkov on "Java code to perform CFS file operations from remote system is not working"</title>
			<link>http://www.datastax.com/support-forums/topic/java-code-to-perform-cfs-file-operations-from-remote-system-is-not-working#post-6899</link>
			<pubDate>Fri, 12 Oct 2012 12:41:10 +0000</pubDate>
			<dc:creator>vsavkov</dc:creator>
			<guid isPermaLink="false">6899@http://www.datastax.com/support-forums/</guid>
			<description>&#60;p&#62;Adding paths to &#34;conf/cassandra.yaml&#34; and &#34;conf/dse.yaml&#34; to java -cp switch also works.&#60;br /&#62;
If yaml files locations are /path/to/cassandra-conf/conf/cassandra.yaml and /path/to/dse-conf/conf/dse.yaml then&#60;/p&#62;
&#60;p&#62;$ java -cp &#38;lt;existing paths&#38;gt;:/path/to/cassandra-conf:/path/to/dse-conf
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Piotr Kołaczkowski on "Java code to perform CFS file operations from remote system is not working"</title>
			<link>http://www.datastax.com/support-forums/topic/java-code-to-perform-cfs-file-operations-from-remote-system-is-not-working#post-6896</link>
			<pubDate>Fri, 12 Oct 2012 10:43:40 +0000</pubDate>
			<dc:creator>Piotr Kołaczkowski</dc:creator>
			<guid isPermaLink="false">6896@http://www.datastax.com/support-forums/</guid>
			<description>&#60;p&#62;You need to specify URL to the file:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;System.setProperty(&#38;quot;cassandra.config&#38;quot;, &#38;quot;file:/absolute/path/conf/cassandra.yaml&#38;quot;);
System.setProperty(&#38;quot;dse.config&#38;quot;, &#38;quot;file:/absolute/path/conf/dse.yaml&#38;quot;);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;After changing to absolute paths, your code works for me.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tambalavanar on "Java code to perform CFS file operations from remote system is not working"</title>
			<link>http://www.datastax.com/support-forums/topic/java-code-to-perform-cfs-file-operations-from-remote-system-is-not-working#post-6878</link>
			<pubDate>Thu, 11 Oct 2012 19:16:57 +0000</pubDate>
			<dc:creator>tambalavanar</dc:creator>
			<guid isPermaLink="false">6878@http://www.datastax.com/support-forums/</guid>
			<description>&#60;p&#62;The below error gets display in the console while running &#34;&#60;code&#62;o = cfs.create(new Path(&#34;/folder/testfile.txt&#34;), true);&#60;/code&#62;&#34;&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
Cannot locate conf/cassandra.yaml&#60;br /&#62;
Fatal configuration error; unable to start server. See log for stacktrace.&#60;br /&#62;
&#60;/code&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Piotr Kołaczkowski on "Java code to perform CFS file operations from remote system is not working"</title>
			<link>http://www.datastax.com/support-forums/topic/java-code-to-perform-cfs-file-operations-from-remote-system-is-not-working#post-6874</link>
			<pubDate>Thu, 11 Oct 2012 16:41:36 +0000</pubDate>
			<dc:creator>Piotr Kołaczkowski</dc:creator>
			<guid isPermaLink="false">6874@http://www.datastax.com/support-forums/</guid>
			<description>&#60;p&#62;The approach is correct. Currently connecting to CFS from remote machines is not officially supported, but generally copying the config files and appropriate jars should work.&#60;/p&#62;
&#60;p&#62;Where do you get that &#34;unable to start server&#34; error from?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>tambalavanar on "Java code to perform CFS file operations from remote system is not working"</title>
			<link>http://www.datastax.com/support-forums/topic/java-code-to-perform-cfs-file-operations-from-remote-system-is-not-working#post-6851</link>
			<pubDate>Wed, 10 Oct 2012 19:03:34 +0000</pubDate>
			<dc:creator>tambalavanar</dc:creator>
			<guid isPermaLink="false">6851@http://www.datastax.com/support-forums/</guid>
			<description>&#60;p&#62;I'm writing a java program to read &#38;amp; write files to CFS from a remote system (non DSE machine). As suggested in the &#60;a href=&#34;http://www.datastax.com/dev/blog/new-in-datastax-enterprise-2-0-support-for-appending-files-in-cassandra-file-system&#34;&#62;DataStax Site&#60;/a&#62;, I wrote the following piece of code.&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
import java.net.URI;&#60;br /&#62;
import org.apache.hadoop.conf.Configuration;&#60;br /&#62;
import org.apache.hadoop.fs.*;&#60;br /&#62;
import org.apache.hadoop.security.UserGroupInformation;&#60;/p&#62;
&#60;p&#62;import com.datastax.bdp.hadoop.cfs.CassandraFileSystem;&#60;/p&#62;
&#60;p&#62;public class CassandraFileHelper {&#60;/p&#62;
&#60;p&#62;	public static void main(String[] args) throws Exception {&#60;/p&#62;
&#60;p&#62;		FSDataOutputStream o = null;&#60;br /&#62;
		CassandraFileSystem cfs = null;&#60;br /&#62;
		String content = &#34;some text content..&#34;;&#60;/p&#62;
&#60;p&#62;		try {&#60;br /&#62;
			System.setProperty(&#34;cassandra.config&#34;, &#34;conf/cassandra.yaml&#34;);&#60;br /&#62;
			System.setProperty(&#34;dse.config&#34;, &#34;conf/dse.yaml&#34;);&#60;/p&#62;
&#60;p&#62;			Configuration conf = new Configuration();&#60;br /&#62;
			conf.addResource(new Path(&#34;conf/core-site.xml&#34;));&#60;/p&#62;
&#60;p&#62;			UserGroupInformation.createUserForTesting(&#34;unixuserid&#34;, new String[] { &#34;usergroupname&#34; });&#60;br /&#62;
			UserGroupInformation.setConfiguration(conf);&#60;/p&#62;
&#60;p&#62;			cfs = new CassandraFileSystem();&#60;br /&#62;
			cfs.initialize(URI.create(&#34;cfs://hostname:9160/&#34;), conf);&#60;/p&#62;
&#60;p&#62;			o = cfs.create(new Path(&#34;/folder/testfile.txt&#34;), true);&#60;br /&#62;
			o.write(content.getBytes());&#60;br /&#62;
			o.flush();&#60;/p&#62;
&#60;p&#62;		} catch (Exception err) {&#60;br /&#62;
			System.out.println(&#34;Error: &#34; + err.toString());&#60;br /&#62;
		} finally {&#60;br /&#62;
			if (o != null)&#60;br /&#62;
				o.close();&#60;br /&#62;
			if (cfs != null)&#60;br /&#62;
				cfs.close();&#60;br /&#62;
		}&#60;br /&#62;
	}&#60;br /&#62;
}&#60;br /&#62;
&#60;/code&#62;&#60;br /&#62;
&#60;br /&#62;
I've included the listed configuration files and jar from DSE package.&#60;/p&#62;
&#60;ul&#62;
&#60;li&#62;cassandra.yaml
&#60;/li&#62;
&#60;li&#62;core-site.xml
&#60;/li&#62;
&#60;li&#62;dse.yaml
&#60;/li&#62;
&#60;/ul&#62;
&#60;ul&#62;
&#60;li&#62;cassandra-all-1.0.10.jar
&#60;/li&#62;
&#60;li&#62;cassandra-clientutil-1.0.10.jar
&#60;/li&#62;
&#60;li&#62;cassandra-thrift-1.0.10.jar
&#60;/li&#62;
&#60;li&#62;commons-cli-1.1.jar
&#60;/li&#62;
&#60;li&#62;commons-codec-1.2.jar
&#60;/li&#62;
&#60;li&#62;commons-configuration-1.6.jar
&#60;/li&#62;
&#60;li&#62;commons-lang-2.4.jar
&#60;/li&#62;
&#60;li&#62;commons-logging-1.1.1.jar
&#60;/li&#62;
&#60;li&#62;compress-lzf-0.8.4.jar
&#60;/li&#62;
&#60;li&#62;dse.jar
&#60;/li&#62;
&#60;li&#62;guava-r08.jar
&#60;/li&#62;
&#60;li&#62;hadoop-core-1.0.2-dse-20120707.200359-5.jar
&#60;/li&#62;
&#60;li&#62;libthrift-0.6.1.jar
&#60;/li&#62;
&#60;li&#62;log4j-1.2.16.jar
&#60;/li&#62;
&#60;li&#62;slf4j-api-1.6.1.jar
&#60;/li&#62;
&#60;li&#62;snakeyaml-1.6.jar
&#60;/li&#62;
&#60;li&#62;snappy-java-1.0.4.1.jar
&#60;/li&#62;
&#60;li&#62;speed4j-0.9.jar
&#60;/li&#62;
&#60;/ul&#62;
&#60;p&#62;
When I run the program, I get the following error&#60;br /&#62;
&#60;code&#62;&#60;br /&#62;
org.apache.thrift.TApplicationException: Internal error processing batch_mutate&#60;br /&#62;
&#60;/code&#62;&#60;br /&#62;
&#60;/p&#62;
&#60;p&#62;I copied all the config files from a DSE machine and when I added them I get the following error.&#60;br /&#62;
&#60;code&#62;&#60;br /&#62;
Cannot locate conf/cassandra.yaml&#60;br /&#62;
Fatal configuration error; unable to start server.  See log for stacktrace.&#60;br /&#62;
&#60;/code&#62;&#60;br /&#62;
&#60;/p&#62;
&#60;p&#62;Could anyone please validate my approach and let me know whether this is possible?&#60;br /&#62;
Thanks.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
