From 1da9a9518bec348ae2186966e6f8880a2887fb6d Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Tue, 6 Jul 2021 16:02:26 -0700 Subject: [PATCH 1/6] Update GRPC libraries for security updates --- pom.xml | 2 +- sdk-actors/pom.xml | 1 + sdk-autogen/pom.xml | 9 ++++----- sdk-tests/pom.xml | 2 +- sdk/pom.xml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 54b6ed0528..120b8fb2e3 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ UTF-8 - 1.33.1 + 1.39.0 3.13.0 https://raw.githubusercontent.com/dapr/dapr/v1.2.0-rc.3/dapr/proto 1.6.2 diff --git a/sdk-actors/pom.xml b/sdk-actors/pom.xml index 605027969f..4d012c90f8 100644 --- a/sdk-actors/pom.xml +++ b/sdk-actors/pom.xml @@ -74,6 +74,7 @@ io.grpc grpc-testing + 1.39.0 test diff --git a/sdk-autogen/pom.xml b/sdk-autogen/pom.xml index a375f40f42..4b74addcda 100644 --- a/sdk-autogen/pom.xml +++ b/sdk-autogen/pom.xml @@ -32,26 +32,25 @@ io.grpc grpc-netty-shaded + 1.39.0 runtime io.grpc grpc-protobuf + 1.39.0 io.grpc grpc-stub + 1.39.0 io.grpc grpc-testing + 1.39.0 test - - io.grpc - grpc-stub - 1.33.1 - diff --git a/sdk-tests/pom.xml b/sdk-tests/pom.xml index eb75d40d30..2ecaedd199 100644 --- a/sdk-tests/pom.xml +++ b/sdk-tests/pom.xml @@ -28,7 +28,7 @@ 1.2.0-SNAPSHOT ${project.build.directory}/generated-sources ${project.basedir}/proto - 1.33.1 + 1.39.0 3.13.0 0.14.0 diff --git a/sdk/pom.xml b/sdk/pom.xml index c12bd15459..bdc6f4a89b 100644 --- a/sdk/pom.xml +++ b/sdk/pom.xml @@ -107,7 +107,7 @@ io.grpc grpc-testing - 1.33.1 + 1.39.0 test From 1c5185b237eb1796a58f8d920e07d75e50079285 Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Tue, 6 Jul 2021 18:06:09 -0700 Subject: [PATCH 2/6] AdConfigurable actor reminder storage patitions --- .../actors/runtime/ActorObjectSerializer.java | 3 +++ .../actors/runtime/ActorRuntimeConfig.java | 22 +++++++++++++++++++ .../dapr/actors/runtime/ActorRuntimeTest.java | 7 ++++++ 3 files changed, 32 insertions(+) diff --git a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorObjectSerializer.java b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorObjectSerializer.java index d45bd78d54..257cb3d551 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorObjectSerializer.java +++ b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorObjectSerializer.java @@ -136,6 +136,9 @@ private byte[] serialize(ActorRuntimeConfig config) throws IOException { if (config.getDrainBalancedActors() != null) { generator.writeBooleanField("drainBalancedActors", config.getDrainBalancedActors()); } + if (config.getRemindersStoragePartitions() != null) { + generator.writeNumberField("remindersStoragePartitions", config.getRemindersStoragePartitions()); + } generator.writeEndObject(); generator.close(); writer.flush(); diff --git a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java index 64aec99c6d..849d17dee0 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java +++ b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java @@ -26,6 +26,8 @@ public class ActorRuntimeConfig { private volatile Boolean drainBalancedActors; + private volatile Integer remindersStoragePartitions; + /** * Instantiates a new config for the Actor Runtime. */ @@ -135,4 +137,24 @@ public ActorRuntimeConfig setDrainBalancedActors(Boolean drainBalancedActors) { return this; } + /** + * Gets the number of storage partitions for Actor reminders. + * + * @return The number of Actor reminder storage partitions. + */ + public Integer getRemindersStoragePartitions() { + return remindersStoragePartitions; + } + + /** + * Sets the number of storage partitions for Actor reminders. + * + * @param actorScanInterval The number of storage partitions for Actor reminders. + * @return This instance. + */ + public ActorRuntimeConfig setRemindersStoragePartitions(Integer remindersStoragePartitions) { + this.remindersStoragePartitions = remindersStoragePartitions; + return this; + } + } diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java index 5073ec4656..30e4fa27b4 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java @@ -157,6 +157,13 @@ public void setDrainOngoingCallTimeout() throws Exception { new String(this.runtime.serializeConfig())); } + @Test + public void setRemindersStoragePartitions() throws Exception { + this.runtime.getConfig().setRemindersStoragePartitions(12); + Assert.assertEquals("{\"entities\":[],\"remindersStoragePartitions\": 12\"}", + new String(this.runtime.serializeConfig())); + } + @Test public void invokeActor() throws Exception { String actorId = UUID.randomUUID().toString(); From ebfa575c45ff42735d518c56dad46e15ef4c9462 Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Tue, 6 Jul 2021 18:20:18 -0700 Subject: [PATCH 3/6] autoformat code --- .../actors/runtime/ActorObjectSerializer.java | 3 +-- .../actors/runtime/ActorRuntimeConfig.java | 6 ++++-- .../dapr/actors/runtime/ActorRuntimeTest.java | 21 +++++++------------ 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorObjectSerializer.java b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorObjectSerializer.java index 257cb3d551..58a04f62e7 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorObjectSerializer.java +++ b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorObjectSerializer.java @@ -53,7 +53,6 @@ public byte[] serialize(Object state) throws IOException { return super.serialize(state); } - /** * Faster serialization for params of Actor's timer. * @@ -216,7 +215,7 @@ private ActorReminderParams deserializeActorReminder(byte[] value) throws IOExce private static Duration extractDurationOrNull(JsonNode node, String name) { JsonNode valueNode = node.get(name); if (valueNode == null) { - return null; + return null; } return DurationUtils.convertDurationFromDaprFormat(valueNode.asText()); diff --git a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java index 849d17dee0..8e8fec52c3 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java +++ b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java @@ -36,6 +36,7 @@ public class ActorRuntimeConfig { /** * Adds a registered actor to the list of registered actors. + * * @param actorTypeName Actor type that was registered. * @return This instance. */ @@ -137,7 +138,7 @@ public ActorRuntimeConfig setDrainBalancedActors(Boolean drainBalancedActors) { return this; } - /** + /** * Gets the number of storage partitions for Actor reminders. * * @return The number of Actor reminder storage partitions. @@ -149,7 +150,8 @@ public Integer getRemindersStoragePartitions() { /** * Sets the number of storage partitions for Actor reminders. * - * @param actorScanInterval The number of storage partitions for Actor reminders. + * @param actorScanInterval The number of storage partitions for Actor + * reminders. * @return This instance. */ public ActorRuntimeConfig setRemindersStoragePartitions(Integer remindersStoragePartitions) { diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java index 30e4fa27b4..4851b6ca04 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java @@ -27,6 +27,7 @@ public class ActorRuntimeTest { public interface MyActor { String say(); + int count(); } @@ -94,13 +95,10 @@ public int count() { @BeforeClass public static void beforeAll() throws Exception { constructor = (Constructor) Arrays.stream(ActorRuntime.class.getDeclaredConstructors()) - .filter(c -> c.getParameters().length == 2) - .map(c -> { - c.setAccessible(true); - return c; - }) - .findFirst() - .get(); + .filter(c -> c.getParameters().length == 2).map(c -> { + c.setAccessible(true); + return c; + }).findFirst().get(); } @Before @@ -146,8 +144,7 @@ public void setActorScanInterval() throws Exception { @Test public void setDrainBalancedActors() throws Exception { this.runtime.getConfig().setDrainBalancedActors(true); - Assert.assertEquals("{\"entities\":[],\"drainBalancedActors\":true}", - new String(this.runtime.serializeConfig())); + Assert.assertEquals("{\"entities\":[],\"drainBalancedActors\":true}", new String(this.runtime.serializeConfig())); } @Test @@ -201,10 +198,8 @@ public void lazyDeactivate() throws Exception { deactivateCall.block(); this.runtime.invoke(ACTOR_NAME, actorId, "say", null) - .doOnError(e -> Assert.assertTrue(e.getMessage().contains("Could not find actor"))) - .doOnSuccess(s -> Assert.fail()) - .onErrorReturn("".getBytes()) - .block(); + .doOnError(e -> Assert.assertTrue(e.getMessage().contains("Could not find actor"))) + .doOnSuccess(s -> Assert.fail()).onErrorReturn("".getBytes()).block(); } @Test From a9a3cc2f6014e2cea1a957e44bf6e766208e93f7 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 8 Jul 2021 16:59:11 +0000 Subject: [PATCH 4/6] Fix test and linter error --- .../main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java | 4 ++-- .../test/java/io/dapr/actors/runtime/ActorRuntimeTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java index 8e8fec52c3..2db04a4e39 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java +++ b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java @@ -150,8 +150,8 @@ public Integer getRemindersStoragePartitions() { /** * Sets the number of storage partitions for Actor reminders. * - * @param actorScanInterval The number of storage partitions for Actor - * reminders. + * @param remindersStoragePartitions The number of storage partitions for Actor + * reminders. * @return This instance. */ public ActorRuntimeConfig setRemindersStoragePartitions(Integer remindersStoragePartitions) { diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java index 4851b6ca04..cbb0e1dfe2 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java @@ -157,7 +157,7 @@ public void setDrainOngoingCallTimeout() throws Exception { @Test public void setRemindersStoragePartitions() throws Exception { this.runtime.getConfig().setRemindersStoragePartitions(12); - Assert.assertEquals("{\"entities\":[],\"remindersStoragePartitions\": 12\"}", + Assert.assertEquals("{\"entities\":[],\"remindersStoragePartitions\":12}", new String(this.runtime.serializeConfig())); } From ed7f4e6dbc10e0d2a6a30fcdbfaa1aa50d3b6c40 Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Thu, 8 Jul 2021 10:10:01 -0700 Subject: [PATCH 5/6] more autoformatting --- .../actors/runtime/ActorRuntimeConfig.java | 6 ++--- .../dapr/actors/runtime/ActorRuntimeTest.java | 23 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java index 2db04a4e39..fe8a44ab89 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java +++ b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java @@ -31,8 +31,7 @@ public class ActorRuntimeConfig { /** * Instantiates a new config for the Actor Runtime. */ - ActorRuntimeConfig() { - } + ActorRuntimeConfig() {} /** * Adds a registered actor to the list of registered actors. @@ -150,8 +149,7 @@ public Integer getRemindersStoragePartitions() { /** * Sets the number of storage partitions for Actor reminders. * - * @param remindersStoragePartitions The number of storage partitions for Actor - * reminders. + * @param remindersStoragePartitions The number of storage partitions for Actor reminders. * @return This instance. */ public ActorRuntimeConfig setRemindersStoragePartitions(Integer remindersStoragePartitions) { diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java index cbb0e1dfe2..6a8b62b9c2 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorRuntimeTest.java @@ -94,11 +94,12 @@ public int count() { @BeforeClass public static void beforeAll() throws Exception { - constructor = (Constructor) Arrays.stream(ActorRuntime.class.getDeclaredConstructors()) - .filter(c -> c.getParameters().length == 2).map(c -> { - c.setAccessible(true); - return c; - }).findFirst().get(); + constructor = + (Constructor) Arrays.stream(ActorRuntime.class.getDeclaredConstructors()) + .filter(c -> c.getParameters().length == 2).map(c -> { + c.setAccessible(true); + return c; + }).findFirst().get(); } @Before @@ -114,17 +115,20 @@ public void registerActorNullClass() { @Test(expected = IllegalArgumentException.class) public void registerActorNullFactory() { - this.runtime.registerActor(MyActorImpl.class, null, new DefaultObjectSerializer(), new DefaultObjectSerializer()); + this.runtime.registerActor(MyActorImpl.class, null, new DefaultObjectSerializer(), + new DefaultObjectSerializer()); } @Test(expected = IllegalArgumentException.class) public void registerActorNullSerializer() { - this.runtime.registerActor(MyActorImpl.class, new DefaultActorFactory<>(), null, new DefaultObjectSerializer()); + this.runtime.registerActor(MyActorImpl.class, new DefaultActorFactory<>(), null, + new DefaultObjectSerializer()); } @Test(expected = IllegalArgumentException.class) public void registerActorNullStateSerializer() { - this.runtime.registerActor(MyActorImpl.class, new DefaultActorFactory<>(), new DefaultObjectSerializer(), null); + this.runtime.registerActor(MyActorImpl.class, new DefaultActorFactory<>(), + new DefaultObjectSerializer(), null); } @Test @@ -144,7 +148,8 @@ public void setActorScanInterval() throws Exception { @Test public void setDrainBalancedActors() throws Exception { this.runtime.getConfig().setDrainBalancedActors(true); - Assert.assertEquals("{\"entities\":[],\"drainBalancedActors\":true}", new String(this.runtime.serializeConfig())); + Assert.assertEquals("{\"entities\":[],\"drainBalancedActors\":true}", + new String(this.runtime.serializeConfig())); } @Test From 148adcc8b21f426fa9430d88c7ad5316af8407b2 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 8 Jul 2021 17:14:20 +0000 Subject: [PATCH 6/6] competing style checker :( --- .../main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java index fe8a44ab89..da66f255e5 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java +++ b/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorRuntimeConfig.java @@ -31,7 +31,8 @@ public class ActorRuntimeConfig { /** * Instantiates a new config for the Actor Runtime. */ - ActorRuntimeConfig() {} + ActorRuntimeConfig() { + } /** * Adds a registered actor to the list of registered actors.