[ 
https://issues.apache.org/jira/browse/BEAM-12260?focusedWorklogId=612032&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-612032
 ]

ASF GitHub Bot logged work on BEAM-12260:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Jun/21 21:12
            Start Date: 18/Jun/21 21:12
    Worklog Time Spent: 10m 
      Work Description: danthev commented on a change in pull request #14713:
URL: https://github.com/apache/beam/pull/14713#discussion_r653845400



##########
File path: 
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/datastore/RampupThrottlingFn.java
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.gcp.datastore;
+
+import java.io.IOException;
+import java.io.Serializable;
+import org.apache.beam.sdk.metrics.Counter;
+import org.apache.beam.sdk.metrics.Metrics;
+import org.apache.beam.sdk.transforms.DoFn;
+import org.apache.beam.sdk.transforms.Sum;
+import org.apache.beam.sdk.transforms.display.DisplayData;
+import org.apache.beam.sdk.util.BackOff;
+import org.apache.beam.sdk.util.FluentBackoff;
+import org.apache.beam.sdk.util.MovingFunction;
+import org.apache.beam.sdk.util.Sleeper;
+import 
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An implementation of a client-side throttler that enforces a gradual 
ramp-up, broadly in line
+ * with Datastore best practices. See also
+ * https://cloud.google.com/datastore/docs/best-practices#ramping_up_traffic.
+ */
+public class RampupThrottlingFn<T> extends DoFn<T, T> implements Serializable {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(RampupThrottlingFn.class);
+  private static final double BASE_BUDGET = 500.0;
+  private static final Duration RAMP_UP_INTERVAL = Duration.standardMinutes(5);
+  private static final FluentBackoff fluentBackoff = FluentBackoff.DEFAULT;
+
+  private final int numWorkers;
+  private final Counter throttlingMsecs =
+      Metrics.counter(RampupThrottlingFn.class, "throttling-msecs");
+
+  // Initialized on Beam setup.

Review comment:
       Done.

##########
File path: 
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/datastore/RampupThrottlingFnTest.java
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.gcp.datastore;
+
+import static org.junit.Assert.assertThrows;
+
+import java.util.Map;
+import org.apache.beam.sdk.transforms.DoFnTester;
+import org.apache.beam.sdk.transforms.DoFnTester.CloningBehavior;
+import org.apache.beam.sdk.util.Sleeper;
+import 
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableMap;
+import org.joda.time.DateTimeUtils;
+import org.joda.time.Duration;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.mockito.MockitoAnnotations;
+
+/** Tests for {@link RampupThrottlingFn}. */
+@RunWith(JUnit4.class)
+public class RampupThrottlingFnTest {

Review comment:
       Done. (Had to make `throttlingMsecs` visible for testing)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 612032)
    Time Spent: 1.5h  (was: 1h 20m)

> Java - Backport FirestoreIO connector's ramp-up to DatastoreIO connector
> ------------------------------------------------------------------------
>
>                 Key: BEAM-12260
>                 URL: https://issues.apache.org/jira/browse/BEAM-12260
>             Project: Beam
>          Issue Type: Improvement
>          Components: io-java-gcp
>            Reporter: Daniel Thevessen
>            Assignee: Daniel Thevessen
>            Priority: P2
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> The FirestoreIO connector 
> ([BEAM-8376|https://issues.apache.org/jira/browse/BEAM-8376]) for the Java 
> SDK is currently out for review.  
> Some of the features for the Firestore connector are new relative to the 
> Datastore connector, so the Firestore team would like to add them there as 
> well. Most notably the Firestore connector has a gradual ramp-up feature that 
> slowly increases throughput in line with Datastore/Firestore best practices.  
> Some minor adjustments to constants for batch sizing and backoff may also be 
> worth looking at.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to