1

Note I am using the Java client in Scala. case class annotations are slightly different. I have the following POJO:

case class User(
  @(JsonProperty@field)("guid")
  @(RiakKey@field)
  val guid: String,

  @(JsonProperty@field)("email")
  @(JsonSerialize@field)(using=classOf[util.serialization.StringToUrlSerializer])
  @(JsonDeserialize@field)(using=classOf[util.serialization.StringToUrlDeserializer])
  @(RiakIndex@field)(name = "email")
  val email: String,

  @(JsonProperty@field)("passwordHash")
  val passwordHash: String
)

Suddenly, Riak stopped storing a secondary index for my User. We can still create secondary indexes manually if we use the raw HTTP API via a REST client but in the code I am at a loss to explain why it is failing.

Here is how we store Riak Objects:

/**
   * Riak database operations
   */
  val bucketName = "accounts-user"
  val bucket = DB.client.createBucket(bucketName).enableForSearch().execute()
  val converter = {
    val c = new JSONConverter[User](classOf[User], bucketName)
    c.getObjectMapper().registerModule(DefaultScalaModule)
    c
  }

  def store(o: User) = bucket.store(o).withConverter(converter).withRetrier(DB.retrier).execute()

The Jackson imports we're using are as follows:

import com.fasterxml.jackson.annotation._
import com.fasterxml.jackson.databind.annotation._

import com.fasterxml.jackson.module.scala._

The objects are being stored successfully and errors are not being thrown. What might be the cause to the issue? Does the DefaultScalaModule for Jackson possibly interfere with annotations? FYI I did try removing the custom converter but it did not solve the issue (did not remove any Scala Module imports, however). Thanks.

Edit

Possibly related: recently we started proxying Riak via NGINX. Do I need to do both HTTP and TCP proxy_pass?

4

1 回答 1

0

正如我所怀疑的那样,使用 NGINX 进行代理是罪魁祸首。尽管我使用 HTTP 客户端来访问存储桶,但 Riak Java 客户端实际上是使用较低级别的(可能是 PBC)协议来创建二级索引。不知道为什么它会静默失败(可能是由于设计造成的),但是一旦我将 NGINX 从 HTTP 切换到 TCP 转发,问题就立即得到解决。

于 2013-04-30T16:47:03.183 回答