Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' into pub_dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
rain-on authored Sep 13, 2019
2 parents a2840e8 + e815cae commit 7d401f3
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void startNode(final PantheonNode node) {

final KeyValueStorageProvider storageProvider =
new KeyValueStorageProviderBuilder()
.withStorageFactory(storageService.getByName("rocksdb"))
.withStorageFactory(storageService.getByName("rocksdb").get())
.withCommonConfiguration(commonPluginConfiguration)
.withMetricsSystem(metricsSystem)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
import tech.pegasys.pantheon.plugin.services.PantheonEvents;
import tech.pegasys.pantheon.plugin.services.PicoCLIOptions;
import tech.pegasys.pantheon.plugin.services.StorageService;
import tech.pegasys.pantheon.plugin.services.exception.StorageException;
import tech.pegasys.pantheon.plugin.services.metrics.MetricCategory;
import tech.pegasys.pantheon.plugin.services.storage.rocksdb.RocksDBPlugin;
import tech.pegasys.pantheon.services.PantheonConfigurationImpl;
Expand Down Expand Up @@ -1263,7 +1264,11 @@ private PrivacyParameters privacyParameters() throws IOException {

private KeyValueStorageProvider keyStorageProvider(final String name) {
return new KeyValueStorageProviderBuilder()
.withStorageFactory(storageService.getByName(name))
.withStorageFactory(
storageService
.getByName(name)
.orElseThrow(
() -> new StorageException("No KeyValueStorageFactory found for key: " + name)))
.withCommonConfiguration(pluginCommonConfiguration)
.withMetricsSystem(getMetricsSystem())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import tech.pegasys.pantheon.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import tech.pegasys.pantheon.plugin.services.StorageService;
import tech.pegasys.pantheon.plugin.services.exception.StorageException;
import tech.pegasys.pantheon.plugin.services.storage.KeyValueStorageFactory;
import tech.pegasys.pantheon.plugin.services.storage.SegmentIdentifier;

Expand Down Expand Up @@ -43,9 +42,8 @@ public List<SegmentIdentifier> getAllSegmentIdentifiers() {
return segments;
}

public KeyValueStorageFactory getByName(final String name) {
return Optional.ofNullable(factories.get(name))
.orElseThrow(
() -> new StorageException("No KeyValueStorageFactory found for key: " + name));
@Override
public Optional<KeyValueStorageFactory> getByName(final String name) {
return Optional.ofNullable(factories.get(name));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void initMocks() throws Exception {
when(mockRunnerBuilder.staticNodes(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.build()).thenReturn(mockRunner);

when(storageService.getByName("rocksdb")).thenReturn(rocksDBStorageFactory);
when(storageService.getByName("rocksdb")).thenReturn(Optional.of(rocksDBStorageFactory));

when(mockPantheonPluginContext.getService(PicoCLIOptions.class))
.thenReturn(Optional.of(cliOptions));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2473,7 +2473,8 @@ public void fullCLIOptionsShownWhenNotInDockerContainer() {

@Test
public void mustUseEnclaveUriAndOptions() {
when(storageService.getByName("rocksdb-privacy")).thenReturn(rocksDBSPrivacyStorageFactory);
when(storageService.getByName("rocksdb-privacy"))
.thenReturn(Optional.of(rocksDBSPrivacyStorageFactory));
final URL configFile = this.getClass().getResource("/orion_publickey.pub");

parseCommand(
Expand Down
2 changes: 1 addition & 1 deletion plugin-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Calculated : ${currentHash}
tasks.register('checkAPIChanges', FileStateChecker) {
description = "Checks that the API for the Plugin-API project does not change without deliberate thought"
files = sourceSets.main.allJava.files
knownHash = 'sRinlNFG0IbW1DXvVnpa/a4puB5WD0g2GReAGkIl6dc='
knownHash = 'FzYuZLAwab2uzCEqdVvkpUL5lih3M4MUKT+qXgGmB7I='
}
check.dependsOn('checkAPIChanges')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import tech.pegasys.pantheon.plugin.services.storage.SegmentIdentifier;

import java.util.List;
import java.util.Optional;

/** This service allows plugins to register as an available storage engine. */
@Unstable
Expand All @@ -35,4 +36,13 @@ public interface StorageService {
* @return full set of possible segments required from the storage service.
*/
List<SegmentIdentifier> getAllSegmentIdentifiers();

/**
* Retrieves a registered factory corresponding to the supplied factory name
*
* @param name The name of the factory to retrieve
* @return an optional containing the instance of the registered factory, or empty if the factory
* hasn't been registered.
*/
Optional<KeyValueStorageFactory> getByName(String name);
}

0 comments on commit 7d401f3

Please sign in to comment.