我正在尝试使用某些自定义命名器插件运行linkerd但在启动时失败。 我已经获得了io.l5d.fs的源代码,并切断了所有的业务逻辑,以获得硬编码地址的简约示例。
初始化器:
package com.consg
import io.buoyant.namer.NamerInitializer
class MyInitializer extends NamerInitializer {
val configClass = classOf[MyConfig]
override def configId = "com.consg.MyConfig"
}
object MyInitializer extends MyInitializer
配置:
package com.consg
import com.fasterxml.jackson.annotation.JsonIgnore
import com.twitter.finagle.{Path, Stack}
import io.buoyant.config.types.Directory
import io.buoyant.namer.NamerConfig
case class MyConfig(rootDir: Directory) extends NamerConfig {
@JsonIgnore
override def defaultPrefix: Path = Path.read("/my.namer")
@JsonIgnore
def newNamer(params: Stack.Params) = {
println("params: " + params)
new MyNamer(rootDir.path, prefix)
}
}
纳默:
package com.consg
import java.nio.file.{Path => NioPath}
import com.twitter.finagle._
import com.twitter.util._
import io.buoyant.namer.EnumeratingNamer
class MyNamer(rootDir: NioPath, prefix: Path) extends EnumeratingNamer {
def lookup(path: Path): Activity[NameTree[Name]] = {
println("lookup path: " + path)
val address1 = Address("127.0.0.1", 7777)
val addr = Addr.Bound(Set(address1), Addr.Metadata.empty)
val varr = Var.apply(addr)
Activity.value(NameTree.Leaf(Name.Bound(varr, path, path)))
}
override def getAllNames: Activity[Set[Path]] = {
println("getAllNames!")
Activity.value(Set.apply(Path.read("animal")))
}
}
build.sbt
name := "plug"
version := "1"
scalaVersion := "2.12.1"
libraryDependencies += "io.buoyant" % "linkerd-core_2.12" % "1.3.2" % "provided"
我还在META-INF / services / io.buoyant.namer.NamerInitializer下公开了“com.consg.MyInitializer”服务
然后我构建了插件jar&把它放在插件下(linkerd-1.3.1 / plugins)
现在我正在尝试使用config运行linkerd:
namers:
- kind: com.consg.MyConfig
rootDir: disco
routers:
- protocol: http
dtab: /svc => /#/my.namer;
servers:
- port: 8080
结果我得到了:
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'com.consg.MyConfig' into a subtype of [simple type, class io.buoyant.namer.NamerConfig]: known type ids = [NamerConfig, io.l5d.consul, io.l5d.curator, io.l5d.dnssrv, io.l5d.fs, io.l5d.k8s, io.l5d.k8s.external, io.l5d.k8s.ns, io.l5d.marathon, io.l5d.rewrite, io.l5d.serversets, io.l5d.zkLeader]
所以看起来插件根本没有加载。需要一些帮助。
答案 0 :(得分:0)
看起来我的问题是未定义的$ L5D_HOME环境变量。 在我设置好后,插件已启用。