Skip to content
Permalink
Browse files

Cleanup in prep for release

  • Loading branch information...
JoeHegarty committed Oct 23, 2019
1 parent bd7ce00 commit ec7338df13c3f581364ea2774b552da40675c364
Showing with 14 additions and 39 deletions.
  1. +4 −3 settings.gradle.kts
  2. +1 −1 src/orbit-application/build.gradle.kts
  3. 0 src/{orbit-client-sdk → orbit-client}/build.gradle.kts
  4. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/OrbitClient.kt
  5. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/OrbitClientConfig.kt
  6. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/actor/Actor.kt
  7. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/actor/ActorProxyFactory.kt
  8. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/addressable/Addressable.kt
  9. 0 ...nt-sdk → orbit-client}/src/main/kotlin/orbit/client/addressable/AddressableDefinitionDirectory.kt
  10. 0 ...bit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/addressable/AddressableDefinitions.kt
  11. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/addressable/AddressableProxy.kt
  12. 0 ...{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/addressable/CapabilitiesScanner.kt
  13. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/addressable/InvocationSystem.kt
  14. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/addressable/MethodInvoker.kt
  15. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/execution/ExecutionHandle.kt
  16. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/execution/ExecutionLeases.kt
  17. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/execution/ExecutionSystem.kt
  18. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/mesh/AddressableLeaser.kt
  19. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/mesh/NodeLeaser.kt
  20. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/net/ClientAuthInterceptor.kt
  21. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/net/Completion.kt
  22. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/net/ConnectionHandler.kt
  23. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/net/GrpcClient.kt
  24. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/net/LocalNode.kt
  25. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/net/MessageHandler.kt
  26. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/net/OrbitServiceLocator.kt
  27. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/serializer/Serializer.kt
  28. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/util/DeferredWrappers.kt
  29. 0 src/{orbit-client-sdk → orbit-client}/src/main/kotlin/orbit/client/util/Exception.kt
  30. 0 src/{orbit-client-sdk → orbit-client}/src/test/kotlin/orbit/client/BaseIntegrationTest.kt
  31. 0 src/{orbit-client-sdk → orbit-client}/src/test/kotlin/orbit/client/BasicActorTests.kt
  32. 0 src/{orbit-client-sdk → orbit-client}/src/test/kotlin/orbit/client/actor/TestActors.kt
  33. 0 src/{orbit-etcd → orbit-server-etcd}/build.gradle.kts
  34. +3 −13 ...lin/orbit.etcd → orbit-server-etcd/src/main/kotlin/orbit/server/etcd}/EtcdAddressableDirectory.kt
  35. +2 −6 ...ain/kotlin/orbit.etcd → orbit-server-etcd/src/main/kotlin/orbit/server/etcd}/EtcdNodeDirectory.kt
  36. +1 −1 src/orbit-server/src/main/kotlin/orbit/server/OrbitServer.kt
  37. +0 −1 src/orbit-server/src/main/kotlin/orbit/server/mesh/LocalNodeInfo.kt
  38. +0 −1 src/orbit-server/src/main/kotlin/orbit/server/net/RemoteMeshNodeConnection.kt
  39. +1 −6 src/orbit-server/src/main/kotlin/orbit/server/router/Router.kt
  40. +2 −7 src/orbit-server/src/main/kotlin/orbit/server/service/ClientAuthInterceptor.kt
@@ -9,8 +9,9 @@ rootProject.name = "orbit"
include(":src:orbit-util")
include(":src:orbit-proto")
include(":src:orbit-shared")
include(":src:orbit-client-sdk")

include(":src:orbit-server")
include(":src:orbit-etcd")
include(":src:orbit-application")
include(":src:orbit-server-etcd")
include(":src:orbit-application")

include(":src:orbit-client")
@@ -16,7 +16,7 @@ plugins {

dependencies {
implementation(project(":src:orbit-server"))
implementation(project(":src:orbit-etcd"))
implementation(project(":src:orbit-server-etcd"))
implementation(project(":src:orbit-shared"))
implementation(project(":src:orbit-util"))

File renamed without changes.
File renamed without changes.
@@ -28,35 +28,27 @@ class EtcdAddressableDirectory(config: EtcdAddressableDirectoryConfig) : Address
override val instanceType: Class<out AddressableDirectory> = EtcdAddressableDirectory::class.java
}

init {
println("Starting etcd addressable directory at ${config.url}")
}

private val client = Client.builder().endpoints(config.url).build().kvClient

fun toKey(address: AddressableReference): ByteSequence {
return ByteSequence.from("addressable/${address.type}/${address.key}".toByteArray())
}

fun fromKey(key: ByteSequence): AddressableReference {
val keyString = key.toString(Charset.defaultCharset())
fun fromKey(keyBytes: ByteSequence): AddressableReference {
val keyString = keyBytes.toString(Charset.defaultCharset())

val (_, type, key) = keyString.split("/")

return AddressableReference(type, Key.of(key))
}

override suspend fun set(key: AddressableReference, value: AddressableLease) {
println("set val ${key}: ${value}")
client.put(toKey(key), ByteSequence.from(key.toAddressableReferenceProto().toByteArray())).await()
}

override suspend fun get(key: AddressableReference): AddressableLease? {
val response = client.get(toKey(key)).await()
val value = response.kvs.firstOrNull()?.value

println("get val ${key}: ${value}")

return if (value != null) Addressable.AddressableLeaseProto.parseFrom(value.bytes).toAddressableLease() else null
}

@@ -72,11 +64,9 @@ class EtcdAddressableDirectory(config: EtcdAddressableDirectoryConfig) : Address
): Boolean {
val byteKey = toKey(key)
val oldValue = client.get(byteKey).await().kvs.firstOrNull()?.value?.bytes?.let {
if (it != null) Addressable.AddressableLeaseProto.parseFrom(it).toAddressableLease() else null
Addressable.AddressableLeaseProto.parseFrom(it).toAddressableLease()
}

println("compare and set ${key}: (i-${initialValue}, o-${oldValue}) -> ${newValue}")

if (initialValue == oldValue) {
if (newValue != null) {
client.put(byteKey, ByteSequence.from(newValue.toAddressableLeaseProto().toByteArray())).await()
@@ -27,10 +27,6 @@ class EtcdNodeDirectory(config: EtcdNodeDirectoryConfig) : NodeDirectory {
override val instanceType: Class<out NodeDirectory> = EtcdNodeDirectory::class.java
}

init {
println("Starting etcd node directory at ${config.url}")
}

private val client = Client.builder().endpoints(config.url).build().kvClient

override suspend fun set(key: NodeId, value: NodeInfo) {
@@ -94,8 +90,8 @@ class EtcdNodeDirectory(config: EtcdNodeDirectoryConfig) : NodeDirectory {
return ByteSequence.from("node/${nodeId.namespace}/${nodeId.key}".toByteArray())
}

fun fromKey(key: ByteSequence): NodeId {
val keyString = key.toString(Charset.defaultCharset())
fun fromKey(keyBytes: ByteSequence): NodeId {
val keyString = keyBytes.toString(Charset.defaultCharset())

val (_, namespace, key) = keyString.split("/")

@@ -189,7 +189,7 @@ class OrbitServer(private val config: OrbitServerConfig) {

remoteMeshNodeManager.tick()

router.tick(runtimeScopes.cpuScope)
router.tick()
}

@Suppress("UNUSED_PARAMETER")
@@ -37,7 +37,6 @@ class LocalNodeInfo(

suspend fun start() {
clusterManager.joinCluster(MANAGEMENT_NAMESPACE, NodeCapabilities(), this.hostInfo).also {
println("Connected local node ${it}")
infoRef.set(it)
}
}
@@ -26,7 +26,6 @@ class RemoteMeshNodeConnection(localNode: LocalNodeInfo, val id: NodeId, channel

init {
fun notify(channel: ManagedChannel) {
println("Channel state: ${id}: ${channel.getState(false)}")
channel.notifyWhenStateChanged(channel.getState(true)) { notify(channel) }
}

@@ -28,8 +28,6 @@ class Router(private val localNode: LocalNodeInfo, private val nodeDirectory: No
@Suppress("UNUSED_PARAMETER")
suspend fun findRoute(targetNode: NodeId, possibleRoute: Route? = null): Route {
val path = traverse(targetNode)

println("route found ${path}")
return Route(path.toList())
}

@@ -70,21 +68,18 @@ class Router(private val localNode: LocalNodeInfo, private val nodeDirectory: No

var nextUpdate = Instant.now().plusSeconds(10)

suspend fun tick(scope: CoroutineScope) {
suspend fun tick() {
if (nextUpdate < Instant.now()) {
buildGraph()
nextUpdate = Instant.now().plusSeconds(10)
}
}

suspend fun buildGraph(): ImmutableGraph<NodeInfo> {
println("updating route graph")

val foundNodes = HashSet<NodeId>()
val graph = GraphBuilder.undirected().allowsSelfLoops(true).immutable<NodeInfo>()

fun addNodes(node: NodeInfo) {
println("calling addNodes ${node.id}")
graph.addNode(node)
foundNodes.add(node.id)
runBlocking {
@@ -25,16 +25,11 @@ internal class ClientAuthInterceptor(private val localNode: LocalNodeInfo) : Cli
return object :
ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
override fun start(responseListener: Listener<RespT>?, headers: Metadata) {

val nodeId = localNode.info.id

if (nodeId == null) {
headers.put(NAMESPACE, localNode.info.id.namespace)
headers.put(NAMESPACE, nodeId.namespace)
headers.put(NODE_KEY, nodeId.key)

} else {
headers.put(NAMESPACE, nodeId.namespace)
headers.put(NODE_KEY, nodeId.key)
}
super.start(responseListener, headers)
}
}

0 comments on commit ec7338d

Please sign in to comment.
You can’t perform that action at this time.