Merge pull request #483 from adamretter/restructure-java-build

Restructure java build
This commit is contained in:
Yueh-Hsuan Chiang 2015-02-09 14:53:11 +08:00
commit bbb52b21f3
124 changed files with 414 additions and 427 deletions

2
.gitignore vendored
View File

@ -35,6 +35,8 @@ unity
tags tags
java/out java/out
java/target
java/test-libs
java/*.log java/*.log
java/include/org_rocksdb_*.h java/include/org_rocksdb_*.h

View File

@ -635,35 +635,40 @@ libsnappy.a:
rocksdbjavastatic: libz.a libbz2.a libsnappy.a rocksdbjavastatic: libz.a libbz2.a libsnappy.a
OPT="-fPIC -DNDEBUG -O2" $(MAKE) $(LIBRARY) -j OPT="-fPIC -DNDEBUG -O2" $(MAKE) $(LIBRARY) -j
cd java;$(MAKE) javalib; cd java;$(MAKE) javalib;
rm -f ./java/$(ROCKSDBJNILIB) rm -f ./java/target/$(ROCKSDBJNILIB)
$(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC -o ./java/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) $(LIBOBJECTS) $(COVERAGEFLAGS) libz.a libbz2.a libsnappy.a $(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC -o ./java/target/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) $(LIBOBJECTS) $(COVERAGEFLAGS) libz.a libbz2.a libsnappy.a
cd java;strip -S -x $(ROCKSDBJNILIB) cd java/target;strip -S -x $(ROCKSDBJNILIB)
cd java;jar -cf $(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class HISTORY*.md $(ROCKSDBJNILIB) cd java;jar -cf target/$(ROCKSDB_JAR) HISTORY*.md
cd java/javadoc;jar -cf ../$(ROCKSDB_JAVADOCS_JAR) * cd java/target;jar -uf $(ROCKSDB_JAR) $(ROCKSDBJNILIB)
cd java;jar -cf $(ROCKSDB_SOURCES_JAR) org cd java/target/classes;jar -uf ../$(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class
cd java/target/apidocs;jar -cf ../$(ROCKSDB_JAVADOCS_JAR) *
cd java/src/main/java;jar -cf ../../../target/$(ROCKSDB_SOURCES_JAR) org
rocksdbjavastaticrelease: rocksdbjavastatic rocksdbjavastaticrelease: rocksdbjavastatic
cd java/crossbuild && vagrant destroy -f && vagrant up linux32 && vagrant halt linux32 && vagrant up linux64 && vagrant halt linux64 cd java/crossbuild && vagrant destroy -f && vagrant up linux32 && vagrant halt linux32 && vagrant up linux64 && vagrant halt linux64
cd java;jar -cf $(ROCKSDB_JAR_ALL) org/rocksdb/*.class org/rocksdb/util/*.class HISTORY*.md librocksdbjni-*.so librocksdbjni-*.jnilib cd java;jar -cf target/$(ROCKSDB_JAR_ALL) HISTORY*.md
cd java/target;jar -uf $(ROCKSDB_JAR_ALL) librocksdbjni-*.so librocksdbjni-*.jnilib
cd java/target/classes;jar -uf ../$(ROCKSDB_JAR_ALL) org/rocksdb/*.class org/rocksdb/util/*.class
rocksdbjavastaticpublish: rocksdbjavastaticrelease rocksdbjavastaticpublish: rocksdbjavastaticrelease
mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-javadoc.jar -Dclassifier=javadoc mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-javadoc.jar -Dclassifier=javadoc
mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-sources.jar -Dclassifier=sources mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-sources.jar -Dclassifier=sources
mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-linux64.jar -Dclassifier=linux64 mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-linux64.jar -Dclassifier=linux64
mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-linux32.jar -Dclassifier=linux32 mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-linux32.jar -Dclassifier=linux32
mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-osx.jar -Dclassifier=osx mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-osx.jar -Dclassifier=osx
mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH).jar mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH).jar
rocksdbjava: rocksdbjava:
OPT="-fPIC -DNDEBUG -O2" $(MAKE) $(LIBRARY) -j32 OPT="-fPIC -DNDEBUG -O2" $(MAKE) $(LIBRARY) -j32
cd java;$(MAKE) javalib; cd java;$(MAKE) javalib;
rm -f ./java/$(ROCKSDBJNILIB) rm -f ./java/target/$(ROCKSDBJNILIB)
$(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC -o ./java/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) $(LIBOBJECTS) $(JAVA_LDFLAGS) $(COVERAGEFLAGS) $(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC -o ./java/target/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) $(LIBOBJECTS) $(JAVA_LDFLAGS) $(COVERAGEFLAGS)
cd java;jar -cf $(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class HISTORY*.md $(ROCKSDBJNILIB) cd java;jar -cf target/$(ROCKSDB_JAR) HISTORY*.md
cd java/target;jar -uf $(ROCKSDB_JAR) $(ROCKSDBJNILIB)
cd java/target/classes;jar -uf ../$(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class
jclean: jclean:
cd java;$(MAKE) clean; cd java;$(MAKE) clean;
rm -f $(ROCKSDBJNILIB)
jtest: jtest:
cd java;$(MAKE) sample;$(MAKE) test; cd java;$(MAKE) sample;$(MAKE) test;

View File

@ -36,12 +36,13 @@ NATIVE_JAVA_CLASSES = org.rocksdb.AbstractComparator\
org.rocksdb.StringAppendOperator\ org.rocksdb.StringAppendOperator\
org.rocksdb.WriteBatch\ org.rocksdb.WriteBatch\
org.rocksdb.WriteBatch.Handler\ org.rocksdb.WriteBatch.Handler\
org.rocksdb.test.WriteBatchInternal\ org.rocksdb.WriteOptions\
org.rocksdb.test.WriteBatchTest\
org.rocksdb.WriteOptions\
org.rocksdb.WriteBatchWithIndex\ org.rocksdb.WriteBatchWithIndex\
org.rocksdb.WBWIRocksIterator org.rocksdb.WBWIRocksIterator
NATIVE_JAVA_TEST_CLASSES = org.rocksdb.WriteBatchTest\
org.rocksdb.WriteBatchTestInternalHelper
ROCKSDB_MAJOR = $(shell egrep "ROCKSDB_MAJOR.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3) ROCKSDB_MAJOR = $(shell egrep "ROCKSDB_MAJOR.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3)
ROCKSDB_MINOR = $(shell egrep "ROCKSDB_MINOR.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3) ROCKSDB_MINOR = $(shell egrep "ROCKSDB_MINOR.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3)
ROCKSDB_PATCH = $(shell egrep "ROCKSDB_PATCH.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3) ROCKSDB_PATCH = $(shell egrep "ROCKSDB_PATCH.[0-9]" ../include/rocksdb/version.h | cut -d ' ' -f 3)
@ -53,98 +54,125 @@ ifeq ($(PLATFORM), OS_MACOSX)
ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-osx.jar ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-osx.jar
endif endif
JAVA_TESTS = org.rocksdb.test.BackupableDBOptionsTest\ JAVA_TESTS = org.rocksdb.BackupableDBOptionsTest\
org.rocksdb.test.BackupableDBTest\ org.rocksdb.BackupableDBTest\
org.rocksdb.test.BlockBasedTableConfigTest\ org.rocksdb.BlockBasedTableConfigTest\
org.rocksdb.test.CheckPointTest\ org.rocksdb.CheckPointTest\
org.rocksdb.test.ColumnFamilyOptionsTest\ org.rocksdb.ColumnFamilyOptionsTest\
org.rocksdb.test.ColumnFamilyTest\ org.rocksdb.ColumnFamilyTest\
org.rocksdb.test.ComparatorOptionsTest\ org.rocksdb.ComparatorOptionsTest\
org.rocksdb.test.ComparatorTest\ org.rocksdb.ComparatorTest\
org.rocksdb.test.CompressionOptionsTest\ org.rocksdb.CompressionOptionsTest\
org.rocksdb.test.DBOptionsTest\ org.rocksdb.DBOptionsTest\
org.rocksdb.test.DirectComparatorTest\ org.rocksdb.DirectComparatorTest\
org.rocksdb.test.DirectSliceTest\ org.rocksdb.DirectSliceTest\
org.rocksdb.test.EnvironmentTest\ org.rocksdb.util.EnvironmentTest\
org.rocksdb.test.FilterTest\ org.rocksdb.FilterTest\
org.rocksdb.test.FlushTest\ org.rocksdb.FlushTest\
org.rocksdb.test.InfoLogLevelTest\ org.rocksdb.InfoLogLevelTest\
org.rocksdb.test.KeyMayExistTest\ org.rocksdb.KeyMayExistTest\
org.rocksdb.test.MemTableTest\ org.rocksdb.MemTableTest\
org.rocksdb.test.MergeTest\ org.rocksdb.MergeTest\
org.rocksdb.test.MixedOptionsTest\ org.rocksdb.MixedOptionsTest\
org.rocksdb.test.OptionsTest\ org.rocksdb.OptionsTest\
org.rocksdb.test.PlainTableConfigTest\ org.rocksdb.PlainTableConfigTest\
org.rocksdb.test.ReadOnlyTest\ org.rocksdb.ReadOnlyTest\
org.rocksdb.test.ReadOptionsTest\ org.rocksdb.ReadOptionsTest\
org.rocksdb.test.RocksDBTest\ org.rocksdb.RocksDBTest\
org.rocksdb.test.RocksEnvTest\ org.rocksdb.RocksEnvTest\
org.rocksdb.test.RocksIteratorTest\ org.rocksdb.RocksIteratorTest\
org.rocksdb.test.SizeUnitTest\ org.rocksdb.util.SizeUnitTest\
org.rocksdb.test.SliceTest\ org.rocksdb.SliceTest\
org.rocksdb.test.SnapshotTest\ org.rocksdb.SnapshotTest\
org.rocksdb.test.TransactionLogIteratorTest\ org.rocksdb.TransactionLogIteratorTest\
org.rocksdb.test.TtlDBTest\ org.rocksdb.TtlDBTest\
org.rocksdb.test.StatisticsCollectorTest\ org.rocksdb.StatisticsCollectorTest\
org.rocksdb.test.WriteBatchHandlerTest\ org.rocksdb.WriteBatchHandlerTest\
org.rocksdb.test.WriteBatchTest\ org.rocksdb.WriteBatchTest\
org.rocksdb.test.WriteOptionsTest\ org.rocksdb.WriteOptionsTest\
org.rocksdb.test.WriteBatchWithIndexTest org.rocksdb.WriteBatchWithIndexTest
JAVA_TEST_LIBDIR = ./test-libs/ MAIN_SRC = src/main/java
JAVA_JUNIT_JAR = $(JAVA_TEST_LIBDIR)junit-4.12-beta-2.jar TEST_SRC = src/test/java
JAVA_HAMCR_JAR = $(JAVA_TEST_LIBDIR)hamcrest-core-1.3.jar OUTPUT = target
JAVA_MOCKITO_JAR = $(JAVA_TEST_LIBDIR)mockito-all-1.9.5.jar MAIN_CLASSES = $(OUTPUT)/classes
JAVA_CGLIB_JAR = $(JAVA_TEST_LIBDIR)cglib-2.2.2.jar TEST_CLASSES = $(OUTPUT)/test-classes
JAVA_ASSERTJ_JAR = $(JAVA_TEST_LIBDIR)assertj-core-1.7.0.jar JAVADOC = $(OUTPUT)/apidocs
JAVA_TESTCLASSPATH = $(ROCKSDB_JAR):$(JAVA_JUNIT_JAR):$(JAVA_HAMCR_JAR):$(JAVA_MOCKITO_JAR):$(JAVA_CGLIB_JAR):$(JAVA_ASSERTJ_JAR):.:./*
BENCHMARK_MAIN_SRC = benchmark/src/main/java
BENCHMARK_OUTPUT = benchmark/target
BENCHMARK_MAIN_CLASSES = $(BENCHMARK_OUTPUT)/classes
SAMPLES_MAIN_SRC = samples/src/main/java
SAMPLES_OUTPUT = samples/target
SAMPLES_MAIN_CLASSES = $(SAMPLES_OUTPUT)/classes
JAVA_TEST_LIBDIR = test-libs
JAVA_JUNIT_JAR = $(JAVA_TEST_LIBDIR)/junit-4.12.jar
JAVA_HAMCR_JAR = $(JAVA_TEST_LIBDIR)/hamcrest-core-1.3.jar
JAVA_MOCKITO_JAR = $(JAVA_TEST_LIBDIR)/mockito-all-1.10.19.jar
JAVA_CGLIB_JAR = $(JAVA_TEST_LIBDIR)/cglib-2.2.2.jar
JAVA_ASSERTJ_JAR = $(JAVA_TEST_LIBDIR)/assertj-core-1.7.1.jar
JAVA_TESTCLASSPATH = $(JAVA_JUNIT_JAR):$(JAVA_HAMCR_JAR):$(JAVA_MOCKITO_JAR):$(JAVA_CGLIB_JAR):$(JAVA_ASSERTJ_JAR)
clean: clean:
-find . -name "*.class" -exec rm {} \;
rm -rf include/* rm -rf include/*
rm -rf javadoc/*
rm -rf test-libs/ rm -rf test-libs/
rm -rf target rm -rf $(OUTPUT)
rm -rf librocksdbjni* rm -rf $(BENCHMARK_OUTPUT)
rm -f rocksdbjni* rm -rf $(SAMPLES_OUTPUT)
javadocs: javadocs:
mkdir -p javadoc; javadoc -d javadoc -sourcepath . -subpackages org -exclude org.rocksdb.test mkdir -p $(JAVADOC)
javadoc -d $(JAVADOC) -sourcepath $(MAIN_SRC) -subpackages org
javalib: java javadocs javalib: java java_test javadocs
java: resolve_test_deps java:
javac org/rocksdb/util/*.java org/rocksdb/*.java mkdir -p $(MAIN_CLASSES)
javac -cp $(JAVA_TESTCLASSPATH) org/rocksdb/test/*.java javac -d $(MAIN_CLASSES)\
$(MAIN_SRC)/org/rocksdb/util/*.java\
$(MAIN_SRC)/org/rocksdb/*.java
@cp ../HISTORY.md ./HISTORY-CPP.md @cp ../HISTORY.md ./HISTORY-CPP.md
@rm -f ./HISTORY-CPP.md @rm -f ./HISTORY-CPP.md
javah -d $(NATIVE_INCLUDE) -jni $(NATIVE_JAVA_CLASSES) javah -cp $(MAIN_CLASSES) -d $(NATIVE_INCLUDE) -jni $(NATIVE_JAVA_CLASSES)
sample: java sample: java
javac -cp $(ROCKSDB_JAR) RocksDBSample.java mkdir -p $(SAMPLES_MAIN_CLASSES)
javac -cp $(MAIN_CLASSES) -d $(SAMPLES_MAIN_CLASSES) $(SAMPLES_MAIN_SRC)/RocksDBSample.java
@rm -rf /tmp/rocksdbjni @rm -rf /tmp/rocksdbjni
@rm -rf /tmp/rocksdbjni_not_found @rm -rf /tmp/rocksdbjni_not_found
java -ea -Djava.library.path=.:../ -cp ".:./*" -Xcheck:jni RocksDBSample /tmp/rocksdbjni java -ea -Xcheck:jni -Djava.library.path=target -cp $(MAIN_CLASSES):$(SAMPLES_MAIN_CLASSES) RocksDBSample /tmp/rocksdbjni
@rm -rf /tmp/rocksdbjni @rm -rf /tmp/rocksdbjni
@rm -rf /tmp/rocksdbjni_not_found @rm -rf /tmp/rocksdbjni_not_found
column_family_sample: java column_family_sample: java
javac -cp $(ROCKSDB_JAR) RocksDBColumnFamilySample.java mkdir -p $(SAMPLES_MAIN_CLASSES)
javac -cp $(MAIN_CLASSES) -d $(SAMPLES_MAIN_CLASSES) $(SAMPLES_MAIN_SRC)/RocksDBColumnFamilySample.java
@rm -rf /tmp/rocksdbjni @rm -rf /tmp/rocksdbjni
java -ea -Djava.library.path=.:../ -cp ".:./*" -Xcheck:jni RocksDBColumnFamilySample /tmp/rocksdbjni java -ea -Xcheck:jni -Djava.library.path=target -cp $(MAIN_CLASSES):$(SAMPLES_MAIN_CLASSES) RocksDBColumnFamilySample /tmp/rocksdbjni
@rm -rf /tmp/rocksdbjni @rm -rf /tmp/rocksdbjni
resolve_test_deps: resolve_test_deps:
mkdir -p "$(JAVA_TEST_LIBDIR)" mkdir -p "$(JAVA_TEST_LIBDIR)"
test -s "$(JAVA_JUNIT_JAR)" || curl -k -L -o $(JAVA_JUNIT_JAR) http://search.maven.org/remotecontent?filepath=junit/junit/4.12-beta-2/junit-4.12-beta-2.jar test -s "$(JAVA_JUNIT_JAR)" || curl -k -L -o $(JAVA_JUNIT_JAR) http://search.maven.org/remotecontent?filepath=junit/junit/4.12/junit-4.12.jar
test -s "$(JAVA_HAMCR_JAR)" || curl -k -L -o $(JAVA_HAMCR_JAR) http://search.maven.org/remotecontent?filepath=org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar test -s "$(JAVA_HAMCR_JAR)" || curl -k -L -o $(JAVA_HAMCR_JAR) http://search.maven.org/remotecontent?filepath=org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
test -s "$(JAVA_MOCKITO_JAR)" || curl -k -L -o "$(JAVA_MOCKITO_JAR)" http://search.maven.org/remotecontent?filepath=org/mockito/mockito-all/1.9.5/mockito-all-1.9.5.jar test -s "$(JAVA_MOCKITO_JAR)" || curl -k -L -o "$(JAVA_MOCKITO_JAR)" http://search.maven.org/remotecontent?filepath=org/mockito/mockito-all/1.10.19/mockito-all-1.10.19.jar
test -s "$(JAVA_CGLIB_JAR)" || curl -k -L -o "$(JAVA_CGLIB_JAR)" http://search.maven.org/remotecontent?filepath=cglib/cglib/2.2.2/cglib-2.2.2.jar test -s "$(JAVA_CGLIB_JAR)" || curl -k -L -o "$(JAVA_CGLIB_JAR)" http://search.maven.org/remotecontent?filepath=cglib/cglib/2.2.2/cglib-2.2.2.jar
test -s "$(JAVA_ASSERTJ_JAR)" || curl -k -L -o "$(JAVA_ASSERTJ_JAR)" http://central.maven.org/maven2/org/assertj/assertj-core/1.7.0/assertj-core-1.7.0.jar test -s "$(JAVA_ASSERTJ_JAR)" || curl -k -L -o "$(JAVA_ASSERTJ_JAR)" http://central.maven.org/maven2/org/assertj/assertj-core/1.7.1/assertj-core-1.7.1.jar
test: java resolve_test_deps java_test: resolve_test_deps
java -ea -Xcheck:jni -Djava.library.path=.:../ -cp "$(JAVA_TESTCLASSPATH)" org.rocksdb.test.RocksJunitRunner $(JAVA_TESTS) mkdir -p $(TEST_CLASSES)
javac -cp $(MAIN_CLASSES):$(JAVA_TESTCLASSPATH) -d $(TEST_CLASSES)\
$(TEST_SRC)/org/rocksdb/test/*.java\
$(TEST_SRC)/org/rocksdb/util/*.java\
$(TEST_SRC)/org/rocksdb/*.java
javah -cp $(MAIN_CLASSES):$(TEST_CLASSES) -d $(NATIVE_INCLUDE) -jni $(NATIVE_JAVA_TEST_CLASSES)
test: java resolve_test_deps java_test
java -ea -Xcheck:jni -Djava.library.path=target -cp "$(MAIN_CLASSES):$(TEST_CLASSES):$(JAVA_TESTCLASSPATH)" org.rocksdb.test.RocksJunitRunner $(JAVA_TESTS)
db_bench: java db_bench: java
javac org/rocksdb/benchmark/*.java mkdir -p $(BENCHMARK_MAIN_CLASSES)
javac -cp $(MAIN_CLASSES) -d $(BENCHMARK_MAIN_CLASSES) $(BENCHMARK_MAIN_SRC)/org/rocksdb/benchmark/*.java

View File

@ -18,6 +18,6 @@ export JAVA_HOME=/usr/lib/jvm/java-1.7.0
cd /rocksdb cd /rocksdb
scl enable devtoolset-1.1 'make jclean clean' scl enable devtoolset-1.1 'make jclean clean'
scl enable devtoolset-1.1 'make -j 4 rocksdbjavastatic' scl enable devtoolset-1.1 'make -j 4 rocksdbjavastatic'
cp /rocksdb/java/librocksdbjni-* /rocksdb-build cp /rocksdb/java/target/librocksdbjni-* /rocksdb-build
cp /rocksdb/java/rocksdbjni-* /rocksdb-build cp /rocksdb/java/target/rocksdbjni-* /rocksdb-build

View File

@ -8,7 +8,7 @@ export JAVA_HOME=$(echo /usr/lib/jvm/java-7-openjdk*)
cd /rocksdb cd /rocksdb
make jclean clean make jclean clean
make -j 4 rocksdbjavastatic make -j 4 rocksdbjavastatic
cp /rocksdb/java/librocksdbjni-* /rocksdb-build cp /rocksdb/java/target/librocksdbjni-* /rocksdb-build
cp /rocksdb/java/rocksdbjni-* /rocksdb-build cp /rocksdb/java/target/rocksdbjni-* /rocksdb-build
sudo shutdown -h now sudo shutdown -h now

View File

@ -3,5 +3,8 @@ if [ `getconf LONG_BIT` != "64" ]
then then
PLATFORM=32 PLATFORM=32
fi fi
ROCKS_JAR=`find target -name rocksdbjni*.jar`
echo "Running benchmark in $PLATFORM-Bit mode." echo "Running benchmark in $PLATFORM-Bit mode."
java -server -d$PLATFORM -XX:NewSize=4m -XX:+AggressiveOpts -Djava.library.path=.:../ -cp "rocksdbjni.jar:.:./*" org.rocksdb.benchmark.DbBenchmark $@ java -server -d$PLATFORM -XX:NewSize=4m -XX:+AggressiveOpts -Djava.library.path=target -cp "${ROCKS_JAR}:benchmark/target/classes" org.rocksdb.benchmark.DbBenchmark $@

View File

@ -38,87 +38,29 @@
</developers> </developers>
<properties> <properties>
<project.build.source>1.7</project.build.source>
<project.build.target>1.7</project.build.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<build> <build>
<!-- Use custom maven folder layout -->
<!-- Set folder for src root -->
<sourceDirectory>${project.basedir}</sourceDirectory>
<!-- main resources, nothing shall be excluded -->
<resources>
<resource>
<directory>${project.basedir}</directory>
<excludes>
<exclude>**/*</exclude>
</excludes>
</resource>
</resources>
<!-- Set folder for test root -->
<testSourceDirectory>${project.basedir}</testSourceDirectory>
<!-- Bring libraries on classpath -->
<testResources>
<testResource>
<directory>${project.basedir}</directory>
<includes>
<include>*.so</include>
<include>*.jar</include>
<include>*.jnilib</include>
</includes>
</testResource>
</testResources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version> <version>3.2</version>
<configuration> <configuration>
<source>1.7</source> <source>${project.build.source}</source>
<target>1.7</target> <target>${project.build.target}</target>
<!-- Exclude all tests from classes --> <encoding>${project.build.sourceEncoding}</encoding>
<excludes>
<!-- Exclude Sample -->
<exclude>*.java</exclude>
<!-- Exclude Benchmark -->
<exclude>org/rocksdb/benchmark/*.java</exclude>
<!-- Exclude Tests -->
<exclude>org/rocksdb/test/*.java</exclude>
<exclude>org/rocksdb/WriteBatchTest.java</exclude>
</excludes>
</configuration> </configuration>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<configuration>
<!-- Include only tests in test-classes -->
<testExcludes>
<!-- Exclude everything but WriteBatchTest -->
<exclude>%regex[org/rocksdb/[^WriteBatchTest].*java]</exclude>
<!-- Exclude WriteBatchTest -->
<exclude>*.java</exclude>
<!-- Exclude Benchmark -->
<exclude>org/rocksdb/benchmark/*.java</exclude>
<!-- Exclude Utilities -->
<exclude>org/rocksdb/util/*.java</exclude>
</testExcludes>
<testIncludes>
<!-- Include Tests -->
<include>org/rocksdb/test/*.java</include>
</testIncludes>
</configuration>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version> <version>2.18.1</version>
<configuration> <configuration>
<argLine>${argLine} -Xcheck:jni</argLine> <argLine>-ea -Xcheck:jni -Djava.library.path=${project.build.directory}</argLine>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@ -179,19 +121,19 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12-beta-2</version> <version>4.12</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.assertj</groupId> <groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId> <artifactId>assertj-core</artifactId>
<version>1.7.0</version> <version>1.7.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-all</artifactId>
<version>1.9.5</version> <version>1.10.19</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -9,8 +9,6 @@
#include "include/org_rocksdb_WriteBatch.h" #include "include/org_rocksdb_WriteBatch.h"
#include "include/org_rocksdb_WriteBatch_Handler.h" #include "include/org_rocksdb_WriteBatch_Handler.h"
#include "include/org_rocksdb_test_WriteBatchInternal.h"
#include "include/org_rocksdb_test_WriteBatchTest.h"
#include "rocksjni/portal.h" #include "rocksjni/portal.h"
#include "rocksjni/writebatchhandlerjnicallback.h" #include "rocksjni/writebatchhandlerjnicallback.h"
#include "rocksdb/db.h" #include "rocksdb/db.h"
@ -217,48 +215,6 @@ void Java_org_rocksdb_WriteBatch_disposeInternal(
delete reinterpret_cast<rocksdb::WriteBatch*>(handle); delete reinterpret_cast<rocksdb::WriteBatch*>(handle);
} }
/*
* Class: org_rocksdb_test_WriteBatchInternal
* Method: setSequence
* Signature: (Lorg/rocksdb/WriteBatch;J)V
*/
void Java_org_rocksdb_test_WriteBatchInternal_setSequence(
JNIEnv* env, jclass jclazz, jobject jobj, jlong jsn) {
rocksdb::WriteBatch* wb = rocksdb::WriteBatchJni::getHandle(env, jobj);
assert(wb != nullptr);
rocksdb::WriteBatchInternal::SetSequence(
wb, static_cast<rocksdb::SequenceNumber>(jsn));
}
/*
* Class: org_rocksdb_test_WriteBatchInternal
* Method: sequence
* Signature: (Lorg/rocksdb/WriteBatch;)J
*/
jlong Java_org_rocksdb_test_WriteBatchInternal_sequence(
JNIEnv* env, jclass jclazz, jobject jobj) {
rocksdb::WriteBatch* wb = rocksdb::WriteBatchJni::getHandle(env, jobj);
assert(wb != nullptr);
return static_cast<jlong>(rocksdb::WriteBatchInternal::Sequence(wb));
}
/*
* Class: org_rocksdb_test_WriteBatchInternal
* Method: append
* Signature: (Lorg/rocksdb/WriteBatch;Lorg/rocksdb/WriteBatch;)V
*/
void Java_org_rocksdb_test_WriteBatchInternal_append(
JNIEnv* env, jclass jclazz, jobject jwb1, jobject jwb2) {
rocksdb::WriteBatch* wb1 = rocksdb::WriteBatchJni::getHandle(env, jwb1);
assert(wb1 != nullptr);
rocksdb::WriteBatch* wb2 = rocksdb::WriteBatchJni::getHandle(env, jwb2);
assert(wb2 != nullptr);
rocksdb::WriteBatchInternal::Append(wb1, wb2);
}
/* /*
* Class: org_rocksdb_WriteBatch_Handler * Class: org_rocksdb_WriteBatch_Handler
* Method: createNewHandler0 * Method: createNewHandler0
@ -280,83 +236,3 @@ void Java_org_rocksdb_WriteBatch_00024Handler_disposeInternal(
JNIEnv* env, jobject jobj, jlong handle) { JNIEnv* env, jobject jobj, jlong handle) {
delete reinterpret_cast<rocksdb::WriteBatchHandlerJniCallback*>(handle); delete reinterpret_cast<rocksdb::WriteBatchHandlerJniCallback*>(handle);
} }
/*
* Class: org_rocksdb_test_WriteBatchTest
* Method: getContents
* Signature: (Lorg/rocksdb/WriteBatch;)[B
*/
jbyteArray Java_org_rocksdb_test_WriteBatchTest_getContents(
JNIEnv* env, jclass jclazz, jobject jobj) {
rocksdb::WriteBatch* b = rocksdb::WriteBatchJni::getHandle(env, jobj);
assert(b != nullptr);
// todo: Currently the following code is directly copied from
// db/write_bench_test.cc. It could be implemented in java once
// all the necessary components can be accessed via jni api.
rocksdb::InternalKeyComparator cmp(rocksdb::BytewiseComparator());
auto factory = std::make_shared<rocksdb::SkipListFactory>();
rocksdb::Options options;
rocksdb::WriteBuffer wb(options.db_write_buffer_size);
options.memtable_factory = factory;
rocksdb::MemTable* mem = new rocksdb::MemTable(
cmp, rocksdb::ImmutableCFOptions(options),
rocksdb::MutableCFOptions(options, rocksdb::ImmutableCFOptions(options)),
&wb);
mem->Ref();
std::string state;
rocksdb::ColumnFamilyMemTablesDefault cf_mems_default(mem);
rocksdb::Status s =
rocksdb::WriteBatchInternal::InsertInto(b, &cf_mems_default);
int count = 0;
rocksdb::Arena arena;
rocksdb::ScopedArenaIterator iter(mem->NewIterator(
rocksdb::ReadOptions(), &arena));
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
rocksdb::ParsedInternalKey ikey;
memset(reinterpret_cast<void*>(&ikey), 0, sizeof(ikey));
ASSERT_TRUE(rocksdb::ParseInternalKey(iter->key(), &ikey));
switch (ikey.type) {
case rocksdb::kTypeValue:
state.append("Put(");
state.append(ikey.user_key.ToString());
state.append(", ");
state.append(iter->value().ToString());
state.append(")");
count++;
break;
case rocksdb::kTypeMerge:
state.append("Merge(");
state.append(ikey.user_key.ToString());
state.append(", ");
state.append(iter->value().ToString());
state.append(")");
count++;
break;
case rocksdb::kTypeDeletion:
state.append("Delete(");
state.append(ikey.user_key.ToString());
state.append(")");
count++;
break;
default:
assert(false);
break;
}
state.append("@");
state.append(rocksdb::NumberToString(ikey.sequence));
}
if (!s.ok()) {
state.append(s.ToString());
} else if (count != rocksdb::WriteBatchInternal::Count(b)) {
state.append("CountMismatch()");
}
delete mem->Unref();
jbyteArray jstate = env->NewByteArray(static_cast<jsize>(state.size()));
env->SetByteArrayRegion(jstate, 0, static_cast<jsize>(state.size()),
reinterpret_cast<const jbyte*>(state.c_str()));
return jstate;
}

View File

@ -0,0 +1,148 @@
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
// This file implements the "bridge" between Java and C++ and enables
// calling c++ rocksdb::WriteBatch methods testing from Java side.
#include <memory>
#include "db/memtable.h"
#include "db/write_batch_internal.h"
#include "db/writebuffer.h"
#include "include/org_rocksdb_WriteBatch.h"
#include "include/org_rocksdb_WriteBatch_Handler.h"
#include "include/org_rocksdb_WriteBatchTest.h"
#include "include/org_rocksdb_WriteBatchTestInternalHelper.h"
#include "rocksdb/db.h"
#include "rocksdb/env.h"
#include "rocksdb/immutable_options.h"
#include "rocksdb/memtablerep.h"
#include "rocksdb/status.h"
#include "rocksdb/write_batch.h"
#include "rocksjni/portal.h"
#include "util/logging.h"
#include "util/scoped_arena_iterator.h"
#include "util/testharness.h"
/*
* Class: org_rocksdb_WriteBatchTest
* Method: getContents
* Signature: (Lorg/rocksdb/WriteBatch;)[B
*/
jbyteArray Java_org_rocksdb_WriteBatchTest_getContents(
JNIEnv* env, jclass jclazz, jobject jobj) {
rocksdb::WriteBatch* b = rocksdb::WriteBatchJni::getHandle(env, jobj);
assert(b != nullptr);
// todo: Currently the following code is directly copied from
// db/write_bench_test.cc. It could be implemented in java once
// all the necessary components can be accessed via jni api.
rocksdb::InternalKeyComparator cmp(rocksdb::BytewiseComparator());
auto factory = std::make_shared<rocksdb::SkipListFactory>();
rocksdb::Options options;
rocksdb::WriteBuffer wb(options.db_write_buffer_size);
options.memtable_factory = factory;
rocksdb::MemTable* mem = new rocksdb::MemTable(
cmp, rocksdb::ImmutableCFOptions(options),
rocksdb::MutableCFOptions(options, rocksdb::ImmutableCFOptions(options)),
&wb);
mem->Ref();
std::string state;
rocksdb::ColumnFamilyMemTablesDefault cf_mems_default(mem);
rocksdb::Status s =
rocksdb::WriteBatchInternal::InsertInto(b, &cf_mems_default);
int count = 0;
rocksdb::Arena arena;
rocksdb::ScopedArenaIterator iter(mem->NewIterator(
rocksdb::ReadOptions(), &arena));
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
rocksdb::ParsedInternalKey ikey;
memset(reinterpret_cast<void*>(&ikey), 0, sizeof(ikey));
ASSERT_TRUE(rocksdb::ParseInternalKey(iter->key(), &ikey));
switch (ikey.type) {
case rocksdb::kTypeValue:
state.append("Put(");
state.append(ikey.user_key.ToString());
state.append(", ");
state.append(iter->value().ToString());
state.append(")");
count++;
break;
case rocksdb::kTypeMerge:
state.append("Merge(");
state.append(ikey.user_key.ToString());
state.append(", ");
state.append(iter->value().ToString());
state.append(")");
count++;
break;
case rocksdb::kTypeDeletion:
state.append("Delete(");
state.append(ikey.user_key.ToString());
state.append(")");
count++;
break;
default:
assert(false);
break;
}
state.append("@");
state.append(rocksdb::NumberToString(ikey.sequence));
}
if (!s.ok()) {
state.append(s.ToString());
} else if (count != rocksdb::WriteBatchInternal::Count(b)) {
state.append("CountMismatch()");
}
delete mem->Unref();
jbyteArray jstate = env->NewByteArray(static_cast<jsize>(state.size()));
env->SetByteArrayRegion(jstate, 0, static_cast<jsize>(state.size()),
reinterpret_cast<const jbyte*>(state.c_str()));
return jstate;
}
/*
* Class: org_rocksdb_WriteBatchTestInternalHelper
* Method: setSequence
* Signature: (Lorg/rocksdb/WriteBatch;J)V
*/
void Java_org_rocksdb_WriteBatchTestInternalHelper_setSequence(
JNIEnv* env, jclass jclazz, jobject jobj, jlong jsn) {
rocksdb::WriteBatch* wb = rocksdb::WriteBatchJni::getHandle(env, jobj);
assert(wb != nullptr);
rocksdb::WriteBatchInternal::SetSequence(
wb, static_cast<rocksdb::SequenceNumber>(jsn));
}
/*
* Class: org_rocksdb_WriteBatchTestInternalHelper
* Method: sequence
* Signature: (Lorg/rocksdb/WriteBatch;)J
*/
jlong Java_org_rocksdb_WriteBatchTestInternalHelper_sequence(
JNIEnv* env, jclass jclazz, jobject jobj) {
rocksdb::WriteBatch* wb = rocksdb::WriteBatchJni::getHandle(env, jobj);
assert(wb != nullptr);
return static_cast<jlong>(rocksdb::WriteBatchInternal::Sequence(wb));
}
/*
* Class: org_rocksdb_WriteBatchTestInternalHelper
* Method: append
* Signature: (Lorg/rocksdb/WriteBatch;Lorg/rocksdb/WriteBatch;)V
*/
void Java_org_rocksdb_WriteBatchTestInternalHelper_append(
JNIEnv* env, jclass jclazz, jobject jwb1, jobject jwb2) {
rocksdb::WriteBatch* wb1 = rocksdb::WriteBatchJni::getHandle(env, jwb1);
assert(wb1 != nullptr);
rocksdb::WriteBatch* wb2 = rocksdb::WriteBatchJni::getHandle(env, jwb2);
assert(wb2 != nullptr);
rocksdb::WriteBatchInternal::Append(wb1, wb2);
}

View File

@ -15,7 +15,9 @@ public class NativeLibraryLoader {
private static final NativeLibraryLoader instance = new NativeLibraryLoader(); private static final NativeLibraryLoader instance = new NativeLibraryLoader();
private static boolean initialized = false; private static boolean initialized = false;
private static final String sharedLibraryName = Environment.getJniLibraryName("rocksdb"); private static final String sharedLibraryName = Environment.getSharedLibraryName("rocksdb");
private static final String jniLibraryName = Environment.getJniLibraryName("rocksdb");
private static final String jniLibraryFileName = Environment.getJniLibraryFileName("rocksdb");
private static final String tempFilePrefix = "librocksdbjni"; private static final String tempFilePrefix = "librocksdbjni";
private static final String tempFileSuffix = "." + Environment.getJniLibraryExtension(); private static final String tempFileSuffix = "." + Environment.getJniLibraryExtension();
@ -28,6 +30,34 @@ public class NativeLibraryLoader {
return instance; return instance;
} }
/**
* Firstly attempts to load the library from <i>java.library.path</i>,
* if that fails then it falls back to extracting
* the library from the classpath
* {@link org.rocksdb.NativeLibraryLoader#loadLibraryFromJar(java.lang.String)}
*
* @param tmpDir A temporary directory to use
* to copy the native library to when loading from the classpath.
* If null, or the empty string, we rely on Java's
* {@link java.io.File#createTempFile(String, String)}
* function to provide a temporary location.
* The temporary file will be registered for deletion
* on exit.
*
* @throws java.io.IOException if a filesystem operation fails.
*/
public synchronized void loadLibrary(final String tmpDir) throws IOException {
try {
System.loadLibrary(sharedLibraryName);
} catch(final UnsatisfiedLinkError ule1) {
try {
System.loadLibrary(jniLibraryName);
} catch(final UnsatisfiedLinkError ule2) {
loadLibraryFromJar(tmpDir);
}
}
}
/** /**
* Attempts to extract the native RocksDB library * Attempts to extract the native RocksDB library
* from the classpath and load it * from the classpath and load it
@ -42,14 +72,14 @@ public class NativeLibraryLoader {
* *
* @throws java.io.IOException if a filesystem operation fails. * @throws java.io.IOException if a filesystem operation fails.
*/ */
public synchronized void loadLibraryFromJar(final String tmpDir) private void loadLibraryFromJar(final String tmpDir)
throws IOException { throws IOException {
if (!initialized) { if (!initialized) {
final File temp; final File temp;
if (tmpDir == null || tmpDir.equals("")) { if (tmpDir == null || tmpDir.equals("")) {
temp = File.createTempFile(tempFilePrefix, tempFileSuffix); temp = File.createTempFile(tempFilePrefix, tempFileSuffix);
} else { } else {
temp = new File(tmpDir, sharedLibraryName); temp = new File(tmpDir, jniLibraryFileName);
} }
if (!temp.exists()) { if (!temp.exists()) {
@ -60,9 +90,9 @@ public class NativeLibraryLoader {
// attempt to copy the library from the Jar file to the temp destination // attempt to copy the library from the Jar file to the temp destination
try (final InputStream is = getClass().getClassLoader(). try (final InputStream is = getClass().getClassLoader().
getResourceAsStream(sharedLibraryName)) { getResourceAsStream(jniLibraryFileName)) {
if (is == null) { if (is == null) {
throw new RuntimeException(sharedLibraryName + " was not found inside JAR."); throw new RuntimeException(jniLibraryFileName + " was not found inside JAR.");
} else { } else {
Files.copy(is, temp.toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(is, temp.toPath(), StandardCopyOption.REPLACE_EXISTING);
} }

View File

@ -44,7 +44,7 @@ public class RocksDB extends RocksObject {
} }
try try
{ {
NativeLibraryLoader.getInstance().loadLibraryFromJar(tmpDir); NativeLibraryLoader.getInstance().loadLibrary(tmpDir);
} }
catch (IOException e) catch (IOException e)
{ {
@ -66,7 +66,7 @@ public class RocksDB extends RocksObject {
} }
for (String path : paths) { for (String path : paths) {
try { try {
System.load(path + "/" + Environment.getSharedLibraryName( System.load(path + "/" + Environment.getSharedLibraryFileName(
compressionType.getLibraryName())); compressionType.getLibraryName()));
break; break;
} catch (UnsatisfiedLinkError e) { } catch (UnsatisfiedLinkError e) {
@ -78,7 +78,7 @@ public class RocksDB extends RocksObject {
UnsatisfiedLinkError err = null; UnsatisfiedLinkError err = null;
for (String path : paths) { for (String path : paths) {
try { try {
System.load(path + "/" + Environment.getJniLibraryName("rocksdbjni")); System.load(path + "/" + Environment.getJniLibraryFileName("rocksdbjni"));
success = true; success = true;
break; break;
} catch (UnsatisfiedLinkError e) { } catch (UnsatisfiedLinkError e) {

View File

@ -23,20 +23,32 @@ public class Environment {
} }
public static String getSharedLibraryName(String name) { public static String getSharedLibraryName(String name) {
return name + "jni";
}
public static String getSharedLibraryFileName(String name) {
return appendLibOsSuffix("lib" + getSharedLibraryName(name), true);
}
public static String getJniLibraryName(final String name) {
if (isUnix()) { if (isUnix()) {
return String.format("lib%sjni.so", name); final String arch = (is64Bit()) ? "64" : "32";
return String.format("%sjni-linux%s", name, arch);
} else if (isMac()) { } else if (isMac()) {
return String.format("lib%sjni.dylib", name); return String.format("%sjni-osx", name);
} }
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public static String getJniLibraryName(String name) { public static String getJniLibraryFileName(final String name) {
return appendLibOsSuffix("lib" + getJniLibraryName(name), false);
}
private static String appendLibOsSuffix(final String libraryFileName, final boolean shared) {
if (isUnix()) { if (isUnix()) {
String arch = (is64Bit()) ? "64" : "32"; return libraryFileName + ".so";
return String.format("lib%sjni-linux%s.so", name, arch);
} else if (isMac()) { } else if (isMac()) {
return String.format("lib%sjni-osx.jnilib", name); return libraryFileName + (shared ? ".dylib" : ".jnilib");
} }
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -3,9 +3,7 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.rocksdb.*;
import java.io.IOException; import java.io.IOException;
import java.nio.file.*; import java.nio.file.*;
@ -14,8 +12,8 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.rocksdb.test.Types.byteToInt; import static org.rocksdb.Types.byteToInt;
import static org.rocksdb.test.Types.intToByte; import static org.rocksdb.Types.intToByte;
/** /**
* Abstract tests for both Comparator and DirectComparator * Abstract tests for both Comparator and DirectComparator

View File

@ -3,13 +3,12 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.rocksdb.BackupableDBOptions;
import java.util.Random; import java.util.Random;

View File

@ -3,13 +3,12 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.rocksdb.*;
import java.util.List; import java.util.List;

View File

@ -3,11 +3,10 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.rocksdb.*;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;

View File

@ -1,14 +1,10 @@
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.rocksdb.Checkpoint;
import org.rocksdb.Options;
import org.rocksdb.RocksDB;
import org.rocksdb.RocksDBException;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;

View File

@ -3,11 +3,10 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.rocksdb.*;
import java.util.Properties; import java.util.Properties;
import java.util.Random; import java.util.Random;

View File

@ -3,7 +3,7 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -14,7 +14,6 @@ import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.rocksdb.*;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;

View File

@ -3,11 +3,10 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.rocksdb.ComparatorOptions;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;

View File

@ -3,13 +3,12 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.rocksdb.*;
import java.io.IOException; import java.io.IOException;
import java.nio.file.FileSystems; import java.nio.file.FileSystems;

View File

@ -3,10 +3,9 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.Test; import org.junit.Test;
import org.rocksdb.CompressionType;
public class CompressionOptionsTest public class CompressionOptionsTest

View File

@ -3,11 +3,10 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.rocksdb.*;
import java.util.Properties; import java.util.Properties;
import java.util.Random; import java.util.Random;

View File

@ -3,13 +3,12 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.rocksdb.*;
import java.io.IOException; import java.io.IOException;
import java.nio.file.FileSystems; import java.nio.file.FileSystems;

View File

@ -2,11 +2,10 @@
// This source code is licensed under the BSD-style license found in the // This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.rocksdb.DirectSlice;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;

View File

@ -3,11 +3,10 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.rocksdb.*;
public class FilterTest { public class FilterTest {

View File

@ -2,13 +2,12 @@
// This source code is licensed under the BSD-style license found in the // This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.rocksdb.*;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;

View File

@ -1,10 +1,9 @@
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.rocksdb.*;
import java.io.IOException; import java.io.IOException;

View File

@ -2,13 +2,12 @@
// This source code is licensed under the BSD-style license found in the // This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.rocksdb.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@ -3,11 +3,10 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.rocksdb.*;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;

View File

@ -3,7 +3,7 @@
// LICENSE file in the root directory of this source tree. An additional grant // LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory. // of patent rights can be found in the PATENTS file in the same directory.
package org.rocksdb.test; package org.rocksdb;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
@ -12,7 +12,6 @@ import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.rocksdb.*;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;

Some files were not shown because too many files have changed in this diff Show More