Add additional java api for updated for ORMap (#25926)
* Add additional java api for updated for ORMap Existing updated is ambiguous from Java with the Scala API. * Remove warnings from DurablePruningSpec
This commit is contained in:
parent
1a25c8a5ad
commit
14377ae8cf
4 changed files with 52 additions and 3 deletions
|
|
@ -250,9 +250,20 @@ final class ORMap[A, B <: ReplicatedData] private[akka] (
|
|||
* If there is no current value for the `key` the `initial` value will be
|
||||
* passed to the `modify` function.
|
||||
*/
|
||||
@Deprecated
|
||||
@deprecated("use update for the Java API as updated is ambiguous with the Scala API", "2.5.19")
|
||||
def updated(node: Cluster, key: A, initial: B, modify: java.util.function.Function[B, B]): ORMap[A, B] =
|
||||
updated(node, key, initial)(value ⇒ modify.apply(value))
|
||||
|
||||
/**
|
||||
* Java API: Replace a value by applying the `modify` function on the existing value.
|
||||
*
|
||||
* If there is no current value for the `key` the `initial` value will be
|
||||
* passed to the `modify` function.
|
||||
*/
|
||||
def update(node: Cluster, key: A, initial: B, modify: java.util.function.Function[B, B]): ORMap[A, B] =
|
||||
updated(node, key, initial)(value ⇒ modify.apply(value))
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ package akka.cluster.ddata
|
|||
import scala.concurrent.duration._
|
||||
|
||||
import akka.cluster.Cluster
|
||||
import akka.cluster.ClusterEvent.InitialStateAsEvents
|
||||
import akka.cluster.ClusterEvent.MemberUp
|
||||
import akka.remote.testconductor.RoleName
|
||||
import akka.remote.testkit.MultiNodeConfig
|
||||
import akka.remote.testkit.MultiNodeSpec
|
||||
|
|
@ -157,7 +155,7 @@ class DurablePruningSpec extends MultiNodeSpec(DurablePruningSpec) with STMultiN
|
|||
val cluster3 = Cluster(sys3)
|
||||
val replicator3 = startReplicator(sys3)
|
||||
val probe3 = TestProbe()(sys3)
|
||||
Cluster(sys3).join(node(first).address)
|
||||
cluster3.join(node(first).address)
|
||||
|
||||
within(10.seconds) {
|
||||
var values = Set.empty[Int]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.cluster.ddata;
|
||||
|
||||
import akka.cluster.Cluster;
|
||||
|
||||
public class ORMapTest {
|
||||
|
||||
public void compileOnlyORMapTest() {
|
||||
// primarily to check API accessibility with overloads/types
|
||||
Cluster node1 = null;
|
||||
|
||||
ORMap<String, PNCounterMap<String>> orMap = ORMap.create();
|
||||
// updated needs a cast
|
||||
ORMap<String, PNCounterMap<String>> updated = orMap.update(node1, "key", PNCounterMap.create(), curr -> curr.decrement(node1, "key", 10));
|
||||
updated.getEntries();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.cluster.ddata;
|
||||
|
||||
import akka.cluster.Cluster;
|
||||
|
||||
public class ORMultiMapTest {
|
||||
|
||||
public void compileOnlyORMultiMapTest() {
|
||||
// primarily to check API accessibility with overloads/types
|
||||
Cluster node = null;
|
||||
ORMultiMap<String, String> orMultiMap = ORMultiMap.create();
|
||||
orMultiMap.addBinding(node, "a", "1");
|
||||
orMultiMap.removeBinding(node, "a", "1");
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue