小编Lev*_*sey的帖子

飞行路线迁移无法正常工作,需要修复

我正在使用 Flyway 进行迁移。Flyway 版本是 Boxfuse 的 Flyway 3.2.1。当我执行时

./flyway migrate -url=jdbc:postgresql://$FLYWAY_DATABASE_HOST/$FLYWAY_DATABASE_NAME -password=$FLYWAY_DATABASE_PASSWORD -user=$FLYWAY_DATABASE_USER
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

"ERROR: Validate failed. Migration Checksum mismatch for migration 80
 Applied to database : -401430104
 Resolved locally    : -485639995
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

flyway

9
推荐指数
1
解决办法
1万
查看次数

如何让我的传入 websocket 连接始终保持打开状态?

我使用此示例代码客户端连接到我的 websocket 服务,但目前它只是连接然后关闭。

我怎样才能保持这个连接打开并且永远不会关闭它?

一旦建立连接,我希望它保持打开状态,直到我关闭应用程序。

package docs.http.scaladsl

import akka.actor.ActorSystem
import akka.Done
import akka.http.scaladsl.Http
import akka.stream.scaladsl._
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.ws._

import scala.concurrent.Future

object WebSocketClientFlow {
  def main(args: Array[String]): Unit = {
    implicit val system = ActorSystem()
    import system.dispatcher

    // Future[Done] is the materialized value of Sink.foreach,
    // emitted when the stream completes
    val incoming: Sink[Message, Future[Done]] =
      Sink.foreach[Message] {
        case message: TextMessage.Strict =>
          println(message.text)
        case _ =>
        // ignore other message types
      }

    // send this as a message over the …
Run Code Online (Sandbox Code Playgroud)

scala akka-stream akka-http

3
推荐指数
1
解决办法
465
查看次数

Flink作业失败,原因为:java.io.IOException:rpc调用大小超出最大akka帧大小

Flink作业失败,错误信息如下

2020-12-02 09:37:27
java.util.concurrent.CompletionException: java.lang.reflect.UndeclaredThrowableException
    at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273)
    at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1592)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.UndeclaredThrowableException
    at com.sun.proxy.$Proxy41.submitTask(Unknown Source)
    at org.apache.flink.runtime.jobmaster.RpcTaskManagerGateway.submitTask(RpcTaskManagerGateway.java:77)
    at org.apache.flink.runtime.executiongraph.Execution.lambda$deploy$9(Execution.java:735)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
    ... 7 more
Caused by: java.io.IOException: The rpc invocation size exceeds the maximum akka framesize.
    at org.apache.flink.runtime.rpc.akka.AkkaInvocationHandler.createRpcInvocationMessage(AkkaInvocationHandler.java:270)
    at org.apache.flink.runtime.rpc.akka.AkkaInvocationHandler.invokeRpc(AkkaInvocationHandler.java:200)
    at org.apache.flink.runtime.rpc.akka.AkkaInvocationHandler.invoke(AkkaInvocationHandler.java:129)
    ... 11 more

Run Code Online (Sandbox Code Playgroud)

这个作业的逻辑很简单,Kafka的消费数据保存到Clickhouse中。

启动命令

2020-12-02 09:37:27
java.util.concurrent.CompletionException: java.lang.reflect.UndeclaredThrowableException
    at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273)
    at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1592)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at …
Run Code Online (Sandbox Code Playgroud)

apache-flink

2
推荐指数
1
解决办法
2655
查看次数

泛型类型如何与 Scala 中的继承一起工作?

我试图了解泛型如何与 Scala 中的继承一起工作。我有以下代码:

sealed trait Model {}
case class Model1() extends Model
case class Model2() extends Model

trait Repo[A <: Model] {
  def doSomething(model: A)
}
class Repo1 extends Repo[Model1] {
  override def doSomething(model: Model1): Unit = {
    println("Model 1")
  }
}
class Repo2 extends Repo[Model2] {
  override def doSomething(model: Model2): Unit = {
    println("Model 2")
  }
}

object Play extends App {
  def getModel(i: Int): Model =
    i match {
      case 1 => Model1()
      case 2 => Model2()
      case …
Run Code Online (Sandbox Code Playgroud)

scala

0
推荐指数
1
解决办法
124
查看次数

正确的做法是不使用 Scala 进行理解

背景

我正在尝试将 Scala 的推导式与Either类型结合使用,即使用Right. 然而,尽管我付出了努力,我还是收到错误并且没有任何效果。

代码

我正在使用 scala 的 repl 进行一些测试。这是我能想到的最简单的用例:

scala> for {
     |   x <- Right(1)
     |   y <- Right(2)
     |   z <- Right(3)
     | } yield x + y + z
Run Code Online (Sandbox Code Playgroud)

您会看到它基本上是此页面的副本:

https://www.scala-lang.org/api/2.12.7/scala/util/Either.html

问题

但是,此操作失败并出现以下错误:

<console>:13: error: value flatMap is not a member of scala.util.Right[Nothing,Int]
         x <- Right(1)
                   ^
<console>:14: error: value flatMap is not a member of scala.util.Right[Nothing,Int]
         y <- Right(2)
                   ^
<console>:15: error: value map is not a member of scala.util.Right[Nothing,Int] …
Run Code Online (Sandbox Code Playgroud)

monads scala either

0
推荐指数
1
解决办法
208
查看次数

无法在 Scala 程序中创建带有逻辑的构造函数?

我有以下程序:

 class Rational(n: Int, d: Int) {
  require(d != 0)
  private val g = gcd(n.abs, d.abs)
  val numer = n / g
  val denom = d / g
  def this(n: Int) = this(n, 1)
  def this(s: String) = {
    val regex: Regex = "^([+-]?(\\d+|\\d*\\.?\\d+)|\\d*\\/?\\d+)$".r
    if (!regex.matches(s)) throw new NumberFormatException()
    val input: Array[String] = s.split("\\.|\\/")
    val num: Int = input(0).toInt
    if (input.length equals 1)
      this(num, 1) // problem here
    else
      this(num, input(1).toInt) // problem here
  }
}
Run Code Online (Sandbox Code Playgroud)

我尝试用一​​些逻辑创建构造函数。但是,我不能因为

“Rational”不带参数

有什么问题?

constructor scala

0
推荐指数
1
解决办法
81
查看次数