Tabnine Logo
Engine.blockingRun
Code IndexAdd Tabnine to your IDE (free)

How to use
blockingRun
method
in
com.linkedin.parseq.Engine

Best Java code snippets using com.linkedin.parseq.Engine.blockingRun (Showing top 7 results out of 315)

origin: linkedin/parseq

@Override
public void runTask(Engine engine, Task<?> t) {
 engine.blockingRun(t);
}
origin: linkedin/parseq

/**
 * Runs the given task. Task passed in as a parameter becomes a root on a new Plan.
 * All tasks created and started as a consequence of a root task will belong to that plan and will share a Trace.
 * <p>
 * This method blocks until Engine has a capacity to run the task. Engine's capacity is
 * specified by a {@value #MAX_CONCURRENT_PLANS} configuration property. Use
 * {@link EngineBuilder#setEngineProperty(String, Object)} to set this property.
 * For the sake of backwards compatibility default value for a {@value #MAX_CONCURRENT_PLANS} is
 * {@value #DEFUALT_MAX_CONCURRENT_PLANS} which essentially means "unbounded capacity".
 *
 * @param task the task to run
 */
public void blockingRun(final Task<?> task) {
 blockingRun(task, defaultPlanClass(task));
}
origin: linkedin/parseq

@Test
public void testBlockingRunWithinCapacity() throws InterruptedException {
 final AtomicInteger counter = new AtomicInteger(0);
 Task<?>[] tasks = new Task<?>[10];
 for (int i = 0; i < 10; i++) {
  tasks[i] = Task.action(counter::incrementAndGet);
 }
 for (int i = 0; i < 10; i++) {
  _engine.blockingRun(tasks[i], (i % 2 == 0) ? "evenPlan" : "oddPlan");
 }
 assertTrue(awaitAll(tasks));
 assertEquals(10, counter.get());
}
origin: linkedin/parseq

@Test
public void testBlockingRunOverCapacity() throws InterruptedException {
 final CountDownLatch latch = new CountDownLatch(1);
 Task<?>[] tasks = new Task<?>[10];
 for (int i = 0; i < 10; i++) {
  tasks[i] = Task.action(latch::await);
 }
 //within capacity
 for (int i = 0; i < 10; i++) {
  _engine.blockingRun(tasks[i], (i % 2 == 0) ? "evenPlan" : "oddPlan");
 }
 final CountDownLatch blockedTaskLatch = new CountDownLatch(1);
 final CountDownLatch blockedThreadLatch = new CountDownLatch(1);
 new Thread(() -> {
  blockedThreadLatch.countDown();
  _engine.blockingRun(Task.action(() -> { blockedTaskLatch.countDown(); }), "oddPlan");
 }).start();
 //first wait for a background thread to reach _engine.run()
 assertTrue(blockedThreadLatch.await(5, TimeUnit.SECONDS));
 //sleep for 200ms to make sure background thread executed _engine.run()
 Thread.sleep(200);
 //verify background tasks didn't run
 assertEquals(1L, blockedTaskLatch.getCount());
 //release tasks
 latch.countDown();
 //background thread should be unblocked and background task should eventually run
 assertTrue(blockedTaskLatch.await(5, TimeUnit.SECONDS));
}
origin: linkedin/parseq

@Test
public void testBlockingRunOverCapacity() throws InterruptedException {
 final CountDownLatch latch = new CountDownLatch(1);
 Task<?>[] tasks = new Task<?>[10];
 for (int i = 0; i < 10; i++) {
  tasks[i] = Task.action(latch::await);
 }
 //within capacity
 for (int i = 0; i < 10; i++) {
  _engine.blockingRun(tasks[i]);
 }
 final CountDownLatch blockedTaskLatch = new CountDownLatch(1);
 final CountDownLatch blockedThreadLatch = new CountDownLatch(1);
 new Thread(() -> {
  blockedThreadLatch.countDown();
  _engine.blockingRun(Task.action(() -> { blockedTaskLatch.countDown(); }));
 }).start();
 //first wait for a background thread to reach _engine.run()
 assertTrue(blockedThreadLatch.await(5, TimeUnit.SECONDS));
 //sleep for 200ms to make sure background thread executed _engine.run()
 Thread.sleep(200);
 //verify background tasks didn't run
 assertEquals(1L, blockedTaskLatch.getCount());
 //release tasks
 latch.countDown();
 //background thread should be unblocked and background task should eventually run
 assertTrue(blockedTaskLatch.await(5, TimeUnit.SECONDS));
}
origin: linkedin/parseq

@Test
public void testBlockingRunWithinCapacity() throws InterruptedException {
 final AtomicInteger counter = new AtomicInteger(0);
 Task<?>[] tasks = new Task<?>[10];
 for (int i = 0; i < 10; i++) {
  tasks[i] = Task.action(counter::incrementAndGet);
 }
 for (int i = 0; i < 10; i++) {
  _engine.blockingRun(tasks[i]);
 }
 assertTrue(awaitAll(tasks));
 assertEquals(10, counter.get());
}
origin: com.linkedin.parseq/parseq

/**
 * Runs the given task. Task passed in as a parameter becomes a root on a new Plan.
 * All tasks created and started as a consequence of a root task will belong to that plan and will share a Trace.
 * <p>
 * This method blocks until Engine has a capacity to run the task. Engine's capacity is
 * specified by a {@value #MAX_CONCURRENT_PLANS} configuration property. Use
 * {@link EngineBuilder#setEngineProperty(String, Object)} to set this property.
 * For the sake of backwards compatibility default value for a {@value #MAX_CONCURRENT_PLANS} is
 * {@value #DEFUALT_MAX_CONCURRENT_PLANS} which essentially means "unbounded capacity".
 *
 * @param task the task to run
 */
public void blockingRun(final Task<?> task) {
 blockingRun(task, defaultPlanClass(task));
}
com.linkedin.parseqEngineblockingRun

Javadoc

Runs the given task. Task passed in as a parameter becomes a root on a new Plan. All tasks created and started as a consequence of a root task will belong to that plan and will share a Trace.

This method blocks until Engine has a capacity to run the task. Engine's capacity is specified by a #MAX_CONCURRENT_PLANS configuration property. Use EngineBuilder#setEngineProperty(String,Object) to set this property. For the sake of backwards compatibility default value for a #MAX_CONCURRENT_PLANS is #DEFUALT_MAX_CONCURRENT_PLANS which essentially means "unbounded capacity".

Popular methods of Engine

  • run
    Runs the given task. Task passed in as a parameter becomes a root on a new Plan. All tasks created a
  • shutdown
    If the engine is currently running, this method will initiate an orderly shutdown. No new tasks will
  • tryRun
    Runs the given task if Engine has a capacity to start new plan as specified by #MAX_CONCURRENT_PLANS
  • <init>
  • acquirePermit
  • createTaskQueueFactory
  • defaultPlanClass
  • getProperty
  • runWithPermit
    Runs the given task with its own context. Use Tasks.seq and Tasks.par to create and run composite ta
  • tryAcquirePermit
  • tryTransitionShutdown
  • tryTransitionTerminate
  • tryTransitionShutdown,
  • tryTransitionTerminate,
  • awaitTermination,
  • isShutdown,
  • isTerminated

Popular in Java

  • Making http post requests using okhttp
  • getApplicationContext (Context)
  • startActivity (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now