diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/db/DefaultMutableBlockchain.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/db/DefaultMutableBlockchain.java index d5b9bcd7c6..07e96fa0a3 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/db/DefaultMutableBlockchain.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/db/DefaultMutableBlockchain.java @@ -28,9 +28,9 @@ import tech.pegasys.pantheon.ethereum.core.BlockHeader; import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.ethereum.core.Transaction; import tech.pegasys.pantheon.ethereum.core.TransactionReceipt; -import tech.pegasys.pantheon.ethereum.util.InvalidConfigurationException; import tech.pegasys.pantheon.metrics.MetricCategory; import tech.pegasys.pantheon.metrics.MetricsSystem; +import tech.pegasys.pantheon.util.InvalidConfigurationException; import tech.pegasys.pantheon.util.Subscribers; import tech.pegasys.pantheon.util.bytes.BytesValues; import tech.pegasys.pantheon.util.uint.UInt256; diff --git a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/db/GenesisBlockMismatchTest.java b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/db/GenesisBlockMismatchTest.java index bb03ca0147..62cc2f6251 100644 --- a/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/db/GenesisBlockMismatchTest.java +++ b/ethereum/core/src/test/java/tech/pegasys/pantheon/ethereum/db/GenesisBlockMismatchTest.java @@ -24,10 +24,10 @@ import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.ethereum.core.LogsBloomFilter; import tech.pegasys.pantheon.ethereum.mainnet.MainnetBlockHashFunction; import tech.pegasys.pantheon.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage; -import tech.pegasys.pantheon.ethereum.util.InvalidConfigurationException; import tech.pegasys.pantheon.metrics.noop.NoOpMetricsSystem; import tech.pegasys.pantheon.services.kvstore.InMemoryKeyValueStorage; import tech.pegasys.pantheon.services.kvstore.KeyValueStorage; +import tech.pegasys.pantheon.util.InvalidConfigurationException; import tech.pegasys.pantheon.util.bytes.Bytes32; import tech.pegasys.pantheon.util.bytes.BytesValue; import tech.pegasys.pantheon.util.uint.UInt256; diff --git a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java index bd91c7a141..d958e21dab 100644 --- a/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java +++ b/pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java @@ -38,11 +38,11 @@ import tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration; import tech.pegasys.pantheon.ethereum.p2p.peers.DefaultPeer; import tech.pegasys.pantheon.ethereum.p2p.peers.Peer; import tech.pegasys.pantheon.ethereum.permissioning.PermissioningConfiguration; -import tech.pegasys.pantheon.ethereum.util.InvalidConfigurationException; import tech.pegasys.pantheon.metrics.MetricsSystem; import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; import tech.pegasys.pantheon.metrics.prometheus.PrometheusMetricsSystem; import tech.pegasys.pantheon.util.BlockImporter; +import tech.pegasys.pantheon.util.InvalidConfigurationException; import tech.pegasys.pantheon.util.bytes.BytesValue; import java.io.File; diff --git a/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDbKeyValueStorage.java b/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDbKeyValueStorage.java index efe09c7ec9..7fd757fc1e 100644 --- a/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDbKeyValueStorage.java +++ b/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDbKeyValueStorage.java @@ -16,6 +16,7 @@ import tech.pegasys.pantheon.metrics.Counter; import tech.pegasys.pantheon.metrics.MetricCategory; import tech.pegasys.pantheon.metrics.MetricsSystem; import tech.pegasys.pantheon.metrics.OperationTimer; +import tech.pegasys.pantheon.util.InvalidConfigurationException; import tech.pegasys.pantheon.util.bytes.BytesValue; import java.io.Closeable; @@ -54,15 +55,26 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable { private final OperationTimer commitLatency; private final Counter rollbackCount; - static { - RocksDB.loadLibrary(); - } - public static KeyValueStorage create( final Path storageDirectory, final MetricsSystem metricsSystem) throws StorageException { + loadNativeLibrary(); return new RocksDbKeyValueStorage(storageDirectory, metricsSystem); } + private static void loadNativeLibrary() { + try { + RocksDB.loadLibrary(); + } catch (final ExceptionInInitializerError e) { + if (e.getCause() instanceof UnsupportedOperationException) { + LOG.info("Unable to load RocksDB library", e); + throw new InvalidConfigurationException( + "Unsupported platform detected. On Windows, ensure you have 64bit Java installed."); + } else { + throw e; + } + } + } + private RocksDbKeyValueStorage(final Path storageDirectory, final MetricsSystem metricsSystem) { try { options = new Options().setCreateIfMissing(true); diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/util/InvalidConfigurationException.java b/util/src/main/java/tech/pegasys/pantheon/util/InvalidConfigurationException.java similarity index 94% rename from ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/util/InvalidConfigurationException.java rename to util/src/main/java/tech/pegasys/pantheon/util/InvalidConfigurationException.java index 3ed799045a..dbe65455ab 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/util/InvalidConfigurationException.java +++ b/util/src/main/java/tech/pegasys/pantheon/util/InvalidConfigurationException.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package tech.pegasys.pantheon.ethereum.util; +package tech.pegasys.pantheon.util; public class InvalidConfigurationException extends IllegalArgumentException { public InvalidConfigurationException(final String message) {