Improve NodeTabView in DemoBench (#1639)

* Improve NodeTabView in DemoBench

Reflect recent changes with advertised services removal.

* Force selection of only one notary

* Update screenshots
This commit is contained in:
Katarzyna Streich 2017-09-28 15:01:08 +01:00 committed by GitHub
parent f8a43a8331
commit eb0e5ad417
11 changed files with 49 additions and 32 deletions

View File

@ -260,8 +260,8 @@ open class NodeStartup(val args: Array<String>) {
}
private fun printPluginsAndServices(node: Node) {
node.configuration.extraAdvertisedServiceIds.let {
if (it.isNotEmpty()) Node.printBasicNodeInfo("Providing network services", it.joinToString())
node.configuration.extraAdvertisedServiceIds.filter { it.startsWith("corda.notary.") || it.startsWith("corda.network_map") }.let {
if (it.isNotEmpty()) Node.printBasicNodeInfo("Providing additional services", it.joinToString())
}
Node.printBasicNodeInfo("Loaded CorDapps", node.cordappProvider.cordapps.map { it.name }.joinToString())
val plugins = node.pluginRegistries

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -54,7 +54,7 @@ class InstallFactory : Controller() {
}
private fun Config.parseExtraServices(path: String): MutableList<String> {
val services = serviceController.services.toSortedSet() + ServiceInfo(ServiceType.networkMap).toString()
val services = serviceController.services.values.toSortedSet() + ServiceInfo(ServiceType.networkMap).toString()
return this.getStringList(path)
.filter { !it.isNullOrEmpty() }
.map { svc ->

View File

@ -24,6 +24,7 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() {
private val jvm by inject<JVMConfig>()
private val pluginController by inject<PluginController>()
private val serviceController by inject<ServiceController>()
private var baseDir: Path = baseDirFor(ManagementFactory.getRuntimeMXBean().startTime)
private val cordaPath: Path = jvm.applicationDir.resolve("corda").resolve("corda.jar")
@ -63,7 +64,7 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() {
nodeData.rpcPort.value,
nodeData.webPort.value,
nodeData.h2Port.value,
nodeData.extraServices.toMutableList()
nodeData.extraServices.map { serviceController.services[it]!! }.toMutableList()
)
if (nodes.putIfAbsent(config.key, config) != null) {

View File

@ -8,31 +8,37 @@ import java.util.logging.Level
class ServiceController(resourceName: String = "/services.conf") : Controller() {
val services: List<String> = loadConf(resources.url(resourceName))
val services: Map<String, String> = loadConf(resources.url(resourceName))
val notaries: List<String> = services.filter { it.startsWith("corda.notary.") }.toList()
val notaries: Map<String, String> = services.filter { it.value.startsWith("corda.notary.") }
val issuers: Map<String, String> = services.filter { it.value.startsWith("corda.issuer.") }
/*
* Load our list of known extra Corda services.
*/
private fun loadConf(url: URL?): List<String> {
private fun loadConf(url: URL?): Map<String, String> {
return if (url == null) {
emptyList()
emptyMap()
} else {
try {
val set = sortedSetOf<String>()
val map = linkedMapOf<String, String>()
InputStreamReader(url.openStream()).useLines { sq ->
sq.forEach { line ->
val service = line.trim()
set.add(service)
log.info("Supports: $service")
val service = line.split(":").map { it.trim() }
if (service.size != 2) {
log.warning("Encountered corrupted line '$line' while reading services from config: $url")
}
else {
map[service[1]] = service[0]
log.info("Supports: $service")
}
}
map
}
set.toList()
} catch (e: IOException) {
log.log(Level.SEVERE, "Failed to load $url: ${e.message}", e)
emptyList<String>()
emptyMap<String, String>()
}
}
}

View File

@ -5,6 +5,7 @@ import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView
import de.jensd.fx.glyphs.fontawesome.utils.FontAwesomeIconFactory
import javafx.application.Platform
import javafx.beans.InvalidationListener
import javafx.collections.ListChangeListener
import javafx.geometry.Pos
import javafx.scene.control.ComboBox
import javafx.scene.image.Image
@ -61,7 +62,7 @@ class NodeTabView : Fragment() {
private val chooser = FileChooser()
private val model = NodeDataModel()
private val availableServices: List<String> = if (nodeController.hasNetworkMap()) serviceController.services else serviceController.notaries
private val availableServices: List<String> = if (nodeController.hasNetworkMap()) serviceController.issuers.keys.toList() else serviceController.notaries.keys.toList()
private val nodeTerminalView = find<NodeTerminalView>()
private val nodeConfigView = stackpane {
@ -109,7 +110,7 @@ class NodeTabView : Fragment() {
}
}
fieldset("Services") {
fieldset("Additional configuration") {
styleClass.addAll("services-panel")
val servicesList = CheckListView(availableServices.observable()).apply {
@ -117,6 +118,17 @@ class NodeTabView : Fragment() {
model.item.extraServices.set(checkModel.checkedItems)
if (!nodeController.hasNetworkMap()) {
checkModel.check(0)
checkModel.checkedItems.addListener(ListChangeListener { change ->
while (change.next()) {
if (change.wasAdded()) {
val item = change.addedSubList.last()
val idx = checkModel.getItemIndex(item)
checkModel.checkedIndices.forEach {
if (it != idx) checkModel.clearCheck(it)
}
}
}
})
}
}
add(servicesList)

View File

@ -1,8 +1,6 @@
corda.notary.validating
corda.notary.simple
corda.interest_rates
corda.issuer.USD
corda.issuer.GBP
corda.issuer.CHF
corda.issuer.EUR
corda.cash
corda.notary.validating : Validating Notary
corda.notary.simple : Non-validating Notary
corda.issuer.USD : Issuer USD
corda.issuer.GBP : Issuer GBP
corda.issuer.CHF : Issuer CHF
corda.issuer.EUR : Issuer EUR

View File

@ -21,14 +21,14 @@ class ServiceControllerTest {
fun `test duplicates`() {
val controller = ServiceController("/duplicate-services.conf")
assertNotNull(controller.services)
assertEquals(listOf("corda.example"), controller.services)
assertEquals(listOf("corda.example"), controller.services.map { it.value })
}
@Test
fun `test notaries`() {
val controller = ServiceController("/notary-services.conf")
assertNotNull(controller.notaries)
assertEquals(listOf("corda.notary.simple"), controller.notaries)
assertEquals(listOf("corda.notary.simple"), controller.notaries.map { it.value })
}
@Test

View File

@ -1,3 +1,3 @@
corda.example
corda.example
corda.example
corda.example : Example
corda.example : Example
corda.example : Example

View File

@ -1,2 +1,2 @@
corda.notary.simple
corda.example
corda.notary.simple : Notary Simple
corda.example : Example