mirror of https://github.com/facebook/rocksdb.git
Merge pull request #483 from adamretter/restructure-java-build
Restructure java build
This commit is contained in:
commit
bbb52b21f3
|
@ -35,6 +35,8 @@ unity
|
|||
tags
|
||||
|
||||
java/out
|
||||
java/target
|
||||
java/test-libs
|
||||
java/*.log
|
||||
java/include/org_rocksdb_*.h
|
||||
|
||||
|
|
39
Makefile
39
Makefile
|
@ -635,35 +635,40 @@ libsnappy.a:
|
|||
rocksdbjavastatic: libz.a libbz2.a libsnappy.a
|
||||
OPT="-fPIC -DNDEBUG -O2" $(MAKE) $(LIBRARY) -j
|
||||
cd java;$(MAKE) javalib;
|
||||
rm -f ./java/$(ROCKSDBJNILIB)
|
||||
$(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC -o ./java/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) $(LIBOBJECTS) $(COVERAGEFLAGS) libz.a libbz2.a libsnappy.a
|
||||
cd java;strip -S -x $(ROCKSDBJNILIB)
|
||||
cd java;jar -cf $(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class HISTORY*.md $(ROCKSDBJNILIB)
|
||||
cd java/javadoc;jar -cf ../$(ROCKSDB_JAVADOCS_JAR) *
|
||||
cd java;jar -cf $(ROCKSDB_SOURCES_JAR) org
|
||||
rm -f ./java/target/$(ROCKSDBJNILIB)
|
||||
$(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/target;strip -S -x $(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
|
||||
cd java/target/apidocs;jar -cf ../$(ROCKSDB_JAVADOCS_JAR) *
|
||||
cd java/src/main/java;jar -cf ../../../target/$(ROCKSDB_SOURCES_JAR) org
|
||||
|
||||
rocksdbjavastaticrelease: rocksdbjavastatic
|
||||
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
|
||||
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/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/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/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)-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)-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)-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)-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)-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).jar
|
||||
|
||||
rocksdbjava:
|
||||
OPT="-fPIC -DNDEBUG -O2" $(MAKE) $(LIBRARY) -j32
|
||||
cd java;$(MAKE) javalib;
|
||||
rm -f ./java/$(ROCKSDBJNILIB)
|
||||
$(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC -o ./java/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) $(LIBOBJECTS) $(JAVA_LDFLAGS) $(COVERAGEFLAGS)
|
||||
cd java;jar -cf $(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class HISTORY*.md $(ROCKSDBJNILIB)
|
||||
rm -f ./java/target/$(ROCKSDBJNILIB)
|
||||
$(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC -o ./java/target/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) $(LIBOBJECTS) $(JAVA_LDFLAGS) $(COVERAGEFLAGS)
|
||||
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:
|
||||
cd java;$(MAKE) clean;
|
||||
rm -f $(ROCKSDBJNILIB)
|
||||
|
||||
jtest:
|
||||
cd java;$(MAKE) sample;$(MAKE) test;
|
||||
|
|
164
java/Makefile
164
java/Makefile
|
@ -36,12 +36,13 @@ NATIVE_JAVA_CLASSES = org.rocksdb.AbstractComparator\
|
|||
org.rocksdb.StringAppendOperator\
|
||||
org.rocksdb.WriteBatch\
|
||||
org.rocksdb.WriteBatch.Handler\
|
||||
org.rocksdb.test.WriteBatchInternal\
|
||||
org.rocksdb.test.WriteBatchTest\
|
||||
org.rocksdb.WriteOptions\
|
||||
org.rocksdb.WriteOptions\
|
||||
org.rocksdb.WriteBatchWithIndex\
|
||||
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_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)
|
||||
|
@ -53,98 +54,125 @@ ifeq ($(PLATFORM), OS_MACOSX)
|
|||
ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-osx.jar
|
||||
endif
|
||||
|
||||
JAVA_TESTS = org.rocksdb.test.BackupableDBOptionsTest\
|
||||
org.rocksdb.test.BackupableDBTest\
|
||||
org.rocksdb.test.BlockBasedTableConfigTest\
|
||||
org.rocksdb.test.CheckPointTest\
|
||||
org.rocksdb.test.ColumnFamilyOptionsTest\
|
||||
org.rocksdb.test.ColumnFamilyTest\
|
||||
org.rocksdb.test.ComparatorOptionsTest\
|
||||
org.rocksdb.test.ComparatorTest\
|
||||
org.rocksdb.test.CompressionOptionsTest\
|
||||
org.rocksdb.test.DBOptionsTest\
|
||||
org.rocksdb.test.DirectComparatorTest\
|
||||
org.rocksdb.test.DirectSliceTest\
|
||||
org.rocksdb.test.EnvironmentTest\
|
||||
org.rocksdb.test.FilterTest\
|
||||
org.rocksdb.test.FlushTest\
|
||||
org.rocksdb.test.InfoLogLevelTest\
|
||||
org.rocksdb.test.KeyMayExistTest\
|
||||
org.rocksdb.test.MemTableTest\
|
||||
org.rocksdb.test.MergeTest\
|
||||
org.rocksdb.test.MixedOptionsTest\
|
||||
org.rocksdb.test.OptionsTest\
|
||||
org.rocksdb.test.PlainTableConfigTest\
|
||||
org.rocksdb.test.ReadOnlyTest\
|
||||
org.rocksdb.test.ReadOptionsTest\
|
||||
org.rocksdb.test.RocksDBTest\
|
||||
org.rocksdb.test.RocksEnvTest\
|
||||
org.rocksdb.test.RocksIteratorTest\
|
||||
org.rocksdb.test.SizeUnitTest\
|
||||
org.rocksdb.test.SliceTest\
|
||||
org.rocksdb.test.SnapshotTest\
|
||||
org.rocksdb.test.TransactionLogIteratorTest\
|
||||
org.rocksdb.test.TtlDBTest\
|
||||
org.rocksdb.test.StatisticsCollectorTest\
|
||||
org.rocksdb.test.WriteBatchHandlerTest\
|
||||
org.rocksdb.test.WriteBatchTest\
|
||||
org.rocksdb.test.WriteOptionsTest\
|
||||
org.rocksdb.test.WriteBatchWithIndexTest
|
||||
JAVA_TESTS = org.rocksdb.BackupableDBOptionsTest\
|
||||
org.rocksdb.BackupableDBTest\
|
||||
org.rocksdb.BlockBasedTableConfigTest\
|
||||
org.rocksdb.CheckPointTest\
|
||||
org.rocksdb.ColumnFamilyOptionsTest\
|
||||
org.rocksdb.ColumnFamilyTest\
|
||||
org.rocksdb.ComparatorOptionsTest\
|
||||
org.rocksdb.ComparatorTest\
|
||||
org.rocksdb.CompressionOptionsTest\
|
||||
org.rocksdb.DBOptionsTest\
|
||||
org.rocksdb.DirectComparatorTest\
|
||||
org.rocksdb.DirectSliceTest\
|
||||
org.rocksdb.util.EnvironmentTest\
|
||||
org.rocksdb.FilterTest\
|
||||
org.rocksdb.FlushTest\
|
||||
org.rocksdb.InfoLogLevelTest\
|
||||
org.rocksdb.KeyMayExistTest\
|
||||
org.rocksdb.MemTableTest\
|
||||
org.rocksdb.MergeTest\
|
||||
org.rocksdb.MixedOptionsTest\
|
||||
org.rocksdb.OptionsTest\
|
||||
org.rocksdb.PlainTableConfigTest\
|
||||
org.rocksdb.ReadOnlyTest\
|
||||
org.rocksdb.ReadOptionsTest\
|
||||
org.rocksdb.RocksDBTest\
|
||||
org.rocksdb.RocksEnvTest\
|
||||
org.rocksdb.RocksIteratorTest\
|
||||
org.rocksdb.util.SizeUnitTest\
|
||||
org.rocksdb.SliceTest\
|
||||
org.rocksdb.SnapshotTest\
|
||||
org.rocksdb.TransactionLogIteratorTest\
|
||||
org.rocksdb.TtlDBTest\
|
||||
org.rocksdb.StatisticsCollectorTest\
|
||||
org.rocksdb.WriteBatchHandlerTest\
|
||||
org.rocksdb.WriteBatchTest\
|
||||
org.rocksdb.WriteOptionsTest\
|
||||
org.rocksdb.WriteBatchWithIndexTest
|
||||
|
||||
JAVA_TEST_LIBDIR = ./test-libs/
|
||||
JAVA_JUNIT_JAR = $(JAVA_TEST_LIBDIR)junit-4.12-beta-2.jar
|
||||
JAVA_HAMCR_JAR = $(JAVA_TEST_LIBDIR)hamcrest-core-1.3.jar
|
||||
JAVA_MOCKITO_JAR = $(JAVA_TEST_LIBDIR)mockito-all-1.9.5.jar
|
||||
JAVA_CGLIB_JAR = $(JAVA_TEST_LIBDIR)cglib-2.2.2.jar
|
||||
JAVA_ASSERTJ_JAR = $(JAVA_TEST_LIBDIR)assertj-core-1.7.0.jar
|
||||
JAVA_TESTCLASSPATH = $(ROCKSDB_JAR):$(JAVA_JUNIT_JAR):$(JAVA_HAMCR_JAR):$(JAVA_MOCKITO_JAR):$(JAVA_CGLIB_JAR):$(JAVA_ASSERTJ_JAR):.:./*
|
||||
MAIN_SRC = src/main/java
|
||||
TEST_SRC = src/test/java
|
||||
OUTPUT = target
|
||||
MAIN_CLASSES = $(OUTPUT)/classes
|
||||
TEST_CLASSES = $(OUTPUT)/test-classes
|
||||
JAVADOC = $(OUTPUT)/apidocs
|
||||
|
||||
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:
|
||||
-find . -name "*.class" -exec rm {} \;
|
||||
rm -rf include/*
|
||||
rm -rf javadoc/*
|
||||
rm -rf test-libs/
|
||||
rm -rf target
|
||||
rm -rf librocksdbjni*
|
||||
rm -f rocksdbjni*
|
||||
rm -rf $(OUTPUT)
|
||||
rm -rf $(BENCHMARK_OUTPUT)
|
||||
rm -rf $(SAMPLES_OUTPUT)
|
||||
|
||||
|
||||
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
|
||||
javac org/rocksdb/util/*.java org/rocksdb/*.java
|
||||
javac -cp $(JAVA_TESTCLASSPATH) org/rocksdb/test/*.java
|
||||
java:
|
||||
mkdir -p $(MAIN_CLASSES)
|
||||
javac -d $(MAIN_CLASSES)\
|
||||
$(MAIN_SRC)/org/rocksdb/util/*.java\
|
||||
$(MAIN_SRC)/org/rocksdb/*.java
|
||||
@cp ../HISTORY.md ./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
|
||||
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_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_not_found
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
resolve_test_deps:
|
||||
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_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_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 -ea -Xcheck:jni -Djava.library.path=.:../ -cp "$(JAVA_TESTCLASSPATH)" org.rocksdb.test.RocksJunitRunner $(JAVA_TESTS)
|
||||
java_test: resolve_test_deps
|
||||
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
|
||||
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
|
||||
|
|
|
@ -18,6 +18,6 @@ export JAVA_HOME=/usr/lib/jvm/java-1.7.0
|
|||
cd /rocksdb
|
||||
scl enable devtoolset-1.1 'make jclean clean'
|
||||
scl enable devtoolset-1.1 'make -j 4 rocksdbjavastatic'
|
||||
cp /rocksdb/java/librocksdbjni-* /rocksdb-build
|
||||
cp /rocksdb/java/rocksdbjni-* /rocksdb-build
|
||||
cp /rocksdb/java/target/librocksdbjni-* /rocksdb-build
|
||||
cp /rocksdb/java/target/rocksdbjni-* /rocksdb-build
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ export JAVA_HOME=$(echo /usr/lib/jvm/java-7-openjdk*)
|
|||
cd /rocksdb
|
||||
make jclean clean
|
||||
make -j 4 rocksdbjavastatic
|
||||
cp /rocksdb/java/librocksdbjni-* /rocksdb-build
|
||||
cp /rocksdb/java/rocksdbjni-* /rocksdb-build
|
||||
cp /rocksdb/java/target/librocksdbjni-* /rocksdb-build
|
||||
cp /rocksdb/java/target/rocksdbjni-* /rocksdb-build
|
||||
sudo shutdown -h now
|
||||
|
||||
|
|
|
@ -3,5 +3,8 @@ if [ `getconf LONG_BIT` != "64" ]
|
|||
then
|
||||
PLATFORM=32
|
||||
fi
|
||||
|
||||
ROCKS_JAR=`find target -name rocksdbjni*.jar`
|
||||
|
||||
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 $@
|
||||
|
|
|
@ -38,87 +38,29 @@
|
|||
</developers>
|
||||
|
||||
<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>
|
||||
</properties>
|
||||
|
||||
<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>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<version>3.2</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<!-- Exclude all tests from classes -->
|
||||
<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>
|
||||
<source>${project.build.source}</source>
|
||||
<target>${project.build.target}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</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>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<version>2.18.1</version>
|
||||
<configuration>
|
||||
<argLine>${argLine} -Xcheck:jni</argLine>
|
||||
<argLine>-ea -Xcheck:jni -Djava.library.path=${project.build.directory}</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
@ -179,19 +121,19 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12-beta-2</version>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>1.7.0</version>
|
||||
<version>1.7.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.9.5</version>
|
||||
<version>1.10.19</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
#include "include/org_rocksdb_WriteBatch.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/writebatchhandlerjnicallback.h"
|
||||
#include "rocksdb/db.h"
|
||||
|
@ -217,48 +215,6 @@ void Java_org_rocksdb_WriteBatch_disposeInternal(
|
|||
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
|
||||
* Method: createNewHandler0
|
||||
|
@ -280,83 +236,3 @@ void Java_org_rocksdb_WriteBatch_00024Handler_disposeInternal(
|
|||
JNIEnv* env, jobject jobj, jlong 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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -15,7 +15,9 @@ public class NativeLibraryLoader {
|
|||
private static final NativeLibraryLoader instance = new NativeLibraryLoader();
|
||||
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 tempFileSuffix = "." + Environment.getJniLibraryExtension();
|
||||
|
||||
|
@ -28,6 +30,34 @@ public class NativeLibraryLoader {
|
|||
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
|
||||
* from the classpath and load it
|
||||
|
@ -42,14 +72,14 @@ public class NativeLibraryLoader {
|
|||
*
|
||||
* @throws java.io.IOException if a filesystem operation fails.
|
||||
*/
|
||||
public synchronized void loadLibraryFromJar(final String tmpDir)
|
||||
private void loadLibraryFromJar(final String tmpDir)
|
||||
throws IOException {
|
||||
if (!initialized) {
|
||||
final File temp;
|
||||
if (tmpDir == null || tmpDir.equals("")) {
|
||||
temp = File.createTempFile(tempFilePrefix, tempFileSuffix);
|
||||
} else {
|
||||
temp = new File(tmpDir, sharedLibraryName);
|
||||
temp = new File(tmpDir, jniLibraryFileName);
|
||||
}
|
||||
|
||||
if (!temp.exists()) {
|
||||
|
@ -60,9 +90,9 @@ public class NativeLibraryLoader {
|
|||
|
||||
// attempt to copy the library from the Jar file to the temp destination
|
||||
try (final InputStream is = getClass().getClassLoader().
|
||||
getResourceAsStream(sharedLibraryName)) {
|
||||
getResourceAsStream(jniLibraryFileName)) {
|
||||
if (is == null) {
|
||||
throw new RuntimeException(sharedLibraryName + " was not found inside JAR.");
|
||||
throw new RuntimeException(jniLibraryFileName + " was not found inside JAR.");
|
||||
} else {
|
||||
Files.copy(is, temp.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
|
@ -44,7 +44,7 @@ public class RocksDB extends RocksObject {
|
|||
}
|
||||
try
|
||||
{
|
||||
NativeLibraryLoader.getInstance().loadLibraryFromJar(tmpDir);
|
||||
NativeLibraryLoader.getInstance().loadLibrary(tmpDir);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ public class RocksDB extends RocksObject {
|
|||
}
|
||||
for (String path : paths) {
|
||||
try {
|
||||
System.load(path + "/" + Environment.getSharedLibraryName(
|
||||
System.load(path + "/" + Environment.getSharedLibraryFileName(
|
||||
compressionType.getLibraryName()));
|
||||
break;
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
|
@ -78,7 +78,7 @@ public class RocksDB extends RocksObject {
|
|||
UnsatisfiedLinkError err = null;
|
||||
for (String path : paths) {
|
||||
try {
|
||||
System.load(path + "/" + Environment.getJniLibraryName("rocksdbjni"));
|
||||
System.load(path + "/" + Environment.getJniLibraryFileName("rocksdbjni"));
|
||||
success = true;
|
||||
break;
|
||||
} catch (UnsatisfiedLinkError e) {
|
|
@ -23,20 +23,32 @@ public class Environment {
|
|||
}
|
||||
|
||||
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()) {
|
||||
return String.format("lib%sjni.so", name);
|
||||
final String arch = (is64Bit()) ? "64" : "32";
|
||||
return String.format("%sjni-linux%s", name, arch);
|
||||
} else if (isMac()) {
|
||||
return String.format("lib%sjni.dylib", name);
|
||||
return String.format("%sjni-osx", name);
|
||||
}
|
||||
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()) {
|
||||
String arch = (is64Bit()) ? "64" : "32";
|
||||
return String.format("lib%sjni-linux%s.so", name, arch);
|
||||
return libraryFileName + ".so";
|
||||
} else if (isMac()) {
|
||||
return String.format("lib%sjni-osx.jnilib", name);
|
||||
return libraryFileName + (shared ? ".dylib" : ".jnilib");
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
|
@ -3,9 +3,7 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
|
||||
import org.rocksdb.*;
|
||||
package org.rocksdb;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
|
@ -14,8 +12,8 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.rocksdb.test.Types.byteToInt;
|
||||
import static org.rocksdb.test.Types.intToByte;
|
||||
import static org.rocksdb.Types.byteToInt;
|
||||
import static org.rocksdb.Types.intToByte;
|
||||
|
||||
/**
|
||||
* Abstract tests for both Comparator and DirectComparator
|
|
@ -3,13 +3,12 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.rocksdb.BackupableDBOptions;
|
||||
|
||||
import java.util.Random;
|
||||
|
|
@ -3,13 +3,12 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -3,11 +3,10 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
@ -1,14 +1,10 @@
|
|||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
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;
|
||||
|
|
@ -3,11 +3,10 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
|
@ -3,7 +3,7 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -14,7 +14,6 @@ import org.junit.ClassRule;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
@ -3,11 +3,10 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.ComparatorOptions;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
@ -3,13 +3,12 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
|
@ -3,10 +3,9 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.CompressionType;
|
||||
|
||||
|
||||
public class CompressionOptionsTest
|
|
@ -3,11 +3,10 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
|
@ -3,13 +3,12 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
|
@ -2,11 +2,10 @@
|
|||
// 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.
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.DirectSlice;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
@ -3,11 +3,10 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.*;
|
||||
|
||||
public class FilterTest {
|
||||
|
|
@ -2,13 +2,12 @@
|
|||
// 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.
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -2,13 +2,12 @@
|
|||
// 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.
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -3,11 +3,10 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
// 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.
|
||||
|
||||
package org.rocksdb.test;
|
||||
package org.rocksdb;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
@ -12,7 +12,6 @@ import org.junit.ClassRule;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.rocksdb.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue