Last active
January 2, 2016 04:39
-
-
Save arielvalentin/8252168 to your computer and use it in GitHub Desktop.
Starting MiniAccumuloCluster via JRuby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
→ jruby manually_add_to_classpath.rb | |
/var/folders/4m/jqf69nlx38s5hyqp10y9_bvc0000gp/T/d20140107-525-wdgmbz | |
grabbed zookeeper | |
crated table | |
wrote record | |
created a scanner | |
anger | |
wtf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
logging_configuration = "file://#{File.expand_path('../../config', __FILE__)}/log4j.xml" | |
java.lang.System.properties['log4j.configuration'] = logging_configuration | |
Dir[File.expand_path('../../vendor/jars-test', __FILE__) + '/*.jar'].each_with_object([]) do |jar, classpath| | |
require jar | |
end | |
full_classpath = [java.lang.System.properties['java.class.path'], File.join(File.expand_path('../../vendor/jars-test', __FILE__), '*')] | |
java.lang.System.properties['java.class.path'] = full_classpath.join(':') | |
require 'tmpdir' | |
module AccumuloImport | |
include_package 'org.apache.accumulo.core.client' | |
java_import 'java.io.File' | |
java_import 'org.apache.accumulo.core.client.security.tokens.PasswordToken' | |
java_import 'org.apache.accumulo.core.data.Key' | |
java_import 'org.apache.accumulo.core.data.Mutation' | |
java_import 'org.apache.accumulo.core.data.Range' | |
java_import 'org.apache.accumulo.core.data.Value' | |
java_import 'org.apache.accumulo.core.security.Authorizations' | |
java_import 'org.apache.accumulo.minicluster.MiniAccumuloCluster' | |
java_import 'org.apache.hadoop.io.Text' | |
end | |
temp = Dir.mktmpdir | |
puts temp | |
temp_directory = AccumuloImport::File.new(temp) | |
accumulo = AccumuloImport::MiniAccumuloCluster.new(temp_directory, "password") | |
accumulo.start | |
instance = AccumuloImport::ZooKeeperInstance.new(accumulo.instance_name, accumulo.zoo_keepers) | |
puts "grabbed zookeeper" | |
conn = instance.get_connector("root", AccumuloImport::PasswordToken.new("password")) | |
conn.table_operations.create("foo") | |
puts "crated table" | |
writer = conn.create_batch_writer("foo", AccumuloImport::BatchWriterConfig.new()) | |
mutation = AccumuloImport::Mutation.new(AccumuloImport::Text.new("anger")) | |
mutation.put("bar", "baz", AccumuloImport::Value.new("wtf".to_java.bytes)) | |
writer.add_mutation(mutation) | |
writer.close | |
puts "wrote record" | |
scan = conn.create_scanner("foo", AccumuloImport::Authorizations.new()) | |
scan.range = AccumuloImport::Range.new("anger","john") | |
scan.fetch_column(AccumuloImport::Text.new("bar"), AccumuloImport::Text.new("baz")) | |
puts "created a scanner" | |
scan.entries.each do |entry| | |
puts entry.key.row | |
puts entry.value | |
end | |
scan.close | |
accumulo.stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
logging_configuration = "file://#{File.expand_path('../../config', __FILE__)}/log4j.xml" | |
java.lang.System.properties['log4j.configuration'] = logging_configuration | |
Dir[File.expand_path('../../vendor/jars-test', __FILE__) + '/*.jar'].each do |jar| | |
require jar | |
end | |
require 'tmpdir' | |
module AccumuloImport | |
include_package 'org.apache.accumulo.core.client' | |
java_import 'java.io.File' | |
java_import 'org.apache.accumulo.core.client.security.tokens.PasswordToken' | |
java_import 'org.apache.accumulo.core.data.Key' | |
java_import 'org.apache.accumulo.core.data.Mutation' | |
java_import 'org.apache.accumulo.core.data.Range' | |
java_import 'org.apache.accumulo.core.data.Value' | |
java_import 'org.apache.accumulo.core.security.Authorizations' | |
java_import 'org.apache.accumulo.minicluster.MiniAccumuloCluster' | |
java_import 'org.apache.hadoop.io.Text' | |
end | |
temp = Dir.mktmpdir | |
puts temp | |
temp_directory = AccumuloImport::File.new(temp) | |
accumulo = AccumuloImport::MiniAccumuloCluster.new(temp_directory, "password") | |
accumulo.start | |
instance = AccumuloImport::ZooKeeperInstance.new(accumulo.instance_name, accumulo.zoo_keepers) | |
puts "grabbed zookeeper" | |
conn = instance.get_connector("root", AccumuloImport::PasswordToken.new("password")) | |
conn.table_operations.create("foo") | |
puts "crated table" | |
writer = conn.create_batch_writer("foo", AccumuloImport::BatchWriterConfig.new()) | |
mutation = AccumuloImport::Mutation.new(AccumuloImport::Text.new("anger")) | |
mutation.put("bar", "baz", AccumuloImport::Value.new("wtf".to_java.bytes)) | |
writer.add_mutation(mutation) | |
writer.close | |
puts "wrote record" | |
scan = conn.create_scanner("foo", AccumuloImport::Authorizations.new()) | |
scan.range = AccumuloImport::Range.new("anger","john") | |
scan.fetch_column(AccumuloImport::Text.new("bar"), AccumuloImport::Text.new("baz")) | |
puts "created a scanner" | |
scan.entries.each do |entry| | |
puts entry.key.row | |
puts entry.value | |
end | |
scan.close | |
accumulo.stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export A_JAR="$HOME/jars-test" | |
export CLASSPATH="$A_JAR/accumulo-core-1.5.0.jar:$A_JAR/accumulo-fate-1.5.0.jar:$A_JAR/accumulo-minicluster-1.5.0.jar:$A_JAR/accumulo-server-1.5.0.jar:$A_JAR/accumulo-start-1.5.\ | |
0.jar:$A_JAR/accumulo-trace-1.5.0.jar:$A_JAR/activation-1.1.jar:$A_JAR/commons-beanutils-1.7.0.jar:$A_JAR/commons-beanutils-core-1.8.0.jar:$A_JAR/commons-codec-1.4.jar:$A_JAR/co\ | |
mmons-collections-3.2.1.jar:$A_JAR/commons-configuration-1.6.jar:$A_JAR/commons-digester-1.8.jar:$A_JAR/commons-io-2.4.jar:$A_JAR/commons-lang-2.4.jar:$A_JAR/commons-logging-1.1\ | |
.1.jar:$A_JAR/commons-vfs2-2.0.jar:$A_JAR/gson-2.2.2.jar:$A_JAR/hadoop-core-1.0.1.jar:$A_JAR/hamcrest-core-1.3.jar:$A_JAR/httpclient-4.1.3.jar:$A_JAR/httpcore-4.1.3.jar:$A_JAR/j\ | |
commander-1.30.jar:$A_JAR/jline-0.9.94.jar:$A_JAR/junit-4.11.jar:$A_JAR/libthrift-0.9.0.jar:$A_JAR/log4j-1.2.15.jar:$A_JAR/mail-1.4.jar:$A_JAR/netty-3.2.2.Final.jar:$A_JAR/slf4j\ | |
-api-1.6.1.jar:$A_JAR/slf4j-log4j12-1.6.1.jar:$A_JAR/zookeeper-3.4.5.jar" | |
CLASSPATH=$CLASSPATH jruby nightmare.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
→ sh nightmare.sh | |
/var/folders/4m/jqf69nlx38s5hyqp10y9_bvc0000gp/T/d20140104-1881-1bula5x | |
grabbed zookeeper | |
crated table | |
wrote record | |
created a scanner | |
anger | |
wtf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment