use of java.util.concurrent.ForkJoinPool in project hadoop by apache.
the class FSDirectory method updateCountForQuota.
/**
* Update the count of each directory with quota in the namespace.
* A directory's count is defined as the total number inodes in the tree
* rooted at the directory.
*
* This is an update of existing state of the filesystem and does not
* throw QuotaExceededException.
*/
void updateCountForQuota(int initThreads) {
writeLock();
try {
int threads = (initThreads < 1) ? 1 : initThreads;
LOG.info("Initializing quota with " + threads + " thread(s)");
long start = Time.now();
QuotaCounts counts = new QuotaCounts.Builder().build();
ForkJoinPool p = new ForkJoinPool(threads);
RecursiveAction task = new InitQuotaTask(getBlockStoragePolicySuite(), rootDir.getStoragePolicyID(), rootDir, counts);
p.execute(task);
task.join();
p.shutdown();
LOG.info("Quota initialization completed in " + (Time.now() - start) + " milliseconds\n" + counts);
} finally {
writeUnlock();
}
}
use of java.util.concurrent.ForkJoinPool in project buck by facebook.
the class PythonLibraryDescriptionTest method versionedSrcs.
@Test
public void versionedSrcs() throws Exception {
BuildTarget target = BuildTargetFactory.newInstance("//foo:lib");
SourcePath matchedSource = new FakeSourcePath("foo/a.py");
SourcePath unmatchedSource = new FakeSourcePath("foo/b.py");
GenruleBuilder transitiveDepBuilder = GenruleBuilder.newGenruleBuilder(BuildTargetFactory.newInstance("//:tdep")).setOut("out");
VersionedAliasBuilder depBuilder = new VersionedAliasBuilder(BuildTargetFactory.newInstance("//:dep")).setVersions(ImmutableMap.of(Version.of("1.0"), transitiveDepBuilder.getTarget(), Version.of("2.0"), transitiveDepBuilder.getTarget()));
AbstractNodeBuilder<?, ?, ?> builder = new PythonLibraryBuilder(target).setVersionedSrcs(VersionMatchedCollection.<SourceList>builder().add(ImmutableMap.of(depBuilder.getTarget(), Version.of("1.0")), SourceList.ofUnnamedSources(ImmutableSortedSet.of(matchedSource))).add(ImmutableMap.of(depBuilder.getTarget(), Version.of("2.0")), SourceList.ofUnnamedSources(ImmutableSortedSet.of(unmatchedSource))).build());
TargetGraph targetGraph = VersionedTargetGraphBuilder.transform(new FixedVersionSelector(ImmutableMap.of(builder.getTarget(), ImmutableMap.of(depBuilder.getTarget(), Version.of("1.0")))), TargetGraphAndBuildTargets.of(TargetGraphFactory.newInstance(transitiveDepBuilder.build(), depBuilder.build(), builder.build()), ImmutableSet.of(builder.getTarget())), new ForkJoinPool()).getTargetGraph();
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
PythonLibrary library = (PythonLibrary) resolver.requireRule(builder.getTarget());
assertThat(library.getPythonPackageComponents(PythonTestUtils.PYTHON_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORM).getModules().values(), Matchers.contains(matchedSource));
}
use of java.util.concurrent.ForkJoinPool in project jdk8u_jdk by JetBrains.
the class Integrate method main.
/**
* Usage: Integrate [procs=N] [reps=N] forkPolicy=serial|dynamic|fork
*/
public static void main(String[] args) throws Exception {
final int procs = intArg(args, "procs", Runtime.getRuntime().availableProcessors());
final int forkPolicy = policyArg(args, "forkPolicy", DYNAMIC);
ForkJoinPool g = new ForkJoinPool(procs);
System.out.println("Integrating from " + start + " to " + end + " forkPolicy = " + forkPolicy);
long lastTime = System.nanoTime();
for (int reps = intArg(args, "reps", 10); reps > 0; reps--) {
double a;
if (forkPolicy == SERIAL)
a = SQuad.computeArea(g, start, end);
else if (forkPolicy == FORK)
a = FQuad.computeArea(g, start, end);
else
a = DQuad.computeArea(g, start, end);
long now = System.nanoTime();
double s = (double) (now - lastTime) / NPS;
lastTime = now;
System.out.printf("Calls/sec: %12d", (long) (calls / s));
System.out.printf(" Time: %7.3f", s);
System.out.printf(" Area: %12.1f", a);
System.out.println();
}
System.out.println(g);
g.shutdown();
}
use of java.util.concurrent.ForkJoinPool in project jdk8u_jdk by JetBrains.
the class SubmissionTest method main.
public static void main(String[] args) throws Throwable {
final ForkJoinPool e = new ForkJoinPool(1);
final AtomicBoolean b = new AtomicBoolean();
final Runnable setFalse = () -> b.set(false);
for (int i = 0; i < 100000; i++) {
b.set(true);
e.execute(setFalse);
long st = System.nanoTime();
while (b.get()) {
if (System.nanoTime() - st >= TimeUnit.SECONDS.toNanos(10)) {
throw new RuntimeException("Submitted task failed to execute");
}
}
}
}
use of java.util.concurrent.ForkJoinPool in project java8-tutorial by winterbe.
the class Streams12 method test1.
private static void test1() {
// -Djava.util.concurrent.ForkJoinPool.common.parallelism=5
ForkJoinPool commonPool = ForkJoinPool.commonPool();
System.out.println(commonPool.getParallelism());
}
Aggregations