Giter Site home page Giter Site logo

Comments (1)

tsuna avatar tsuna commented on July 22, 2024

Here's a quick attempt to mitigate the issue. Not sure yet whether that's good enough. It seems like it was enough for a 28M data-point batch import that was running at about 150k edits/s on average, but I'm afraid there was a bit of luck involved in that attempt (splits didn't take regions offline for very long).

diff --git a/src/tools/TextImporter.java b/src/tools/TextImporter.java
index 8fbba3b..5766bef 100644
--- a/src/tools/TextImporter.java
+++ b/src/tools/TextImporter.java
@@ -92,6 +92,7 @@ final class TextImporter {
   }

   static volatile boolean throttle = false;
+  static final Object throttle_condition = new Object();

   private static int importFile(final HBaseClient client,
                                 final TSDB tsdb,
@@ -109,8 +110,14 @@ final class TextImporter {
             LOG.warn("Need to throttle, HBase isn't keeping up.", e);
             throttle = true;
             final HBaseRpc rpc = e.getFailedRpc();
-            if (rpc instanceof PutRequest) {
-              client.put((PutRequest) rpc);  // Don't lose edits.
+            if (rpc instanceof PutRequest) {  // Don't lose edits.
+              client.put((PutRequest) rpc).addCallbacks(new Callback<Object, Object>() {
+                public Object call(final Object arg) {
+                  throttle = false;
+                  throttle_condition.notifyAll();
+                  return arg;
+                }
+              }, new Errback());
             }
             return null;
           }
@@ -165,9 +172,11 @@ final class TextImporter {
           LOG.info("Throttling...");
           long throttle_time = System.nanoTime();
           try {
-            d.joinUninterruptibly();
-          } catch (Exception e) {
-            throw new RuntimeException("Should never happen", e);
+            while (throttle) {
+              throttle_condition.wait();
+            }
+          } catch (InterruptedException e) {
+            throw new RuntimeException("interrupted", e);
           }
           throttle_time = System.nanoTime() - throttle_time;
           if (throttle_time < 1000000000L) {
@@ -175,7 +184,6 @@ final class TextImporter {
             try { Thread.sleep(1000); } catch (InterruptedException e) { throw new RuntimeException("interrupted", e); }
           }
           LOG.info("Done throttling...");
-          throttle = false;
         }
       }
     } catch (RuntimeException e) {

from opentsdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.