Examples of Pool


Examples of ch.cmbntr.modulizer.bootstrap.util.Resources.Pool

      throws MojoExecutionException {

    final Map<Artifact, File> fromTo = compute(artifacts, resourceTargetFile(moduleDirectory));
    final Map<File, Future<String>> targetHashes = sha1async(fromTo.values());

    final Pool pool = Resources.getPoolHandle();
    final ExecutorService executor = pool.aquireExec();
    try {
      return collect(ImmutableList.copyOf(transform(fromTo.entrySet(),
          new Function<Entry<Artifact, File>, Future<String>>() {
            @Override
            public Future<String> apply(final Entry<Artifact, File> e) {
              final Artifact a = e.getKey();
              final File src = a.getFile();
              final File target = e.getValue();
              final Future<String> targetHash = targetHashes.get(target);
              checkState(src != null, "missing file for %s", a);
              return executor.submit(conditionalCopy(src, target, targetHash));
            }
          })));
    } catch (final ComputationException e) {
      throw new MojoExecutionException("failed to copy artifacts", e.getCause());
    } finally {
      pool.releaseExec(executor);
    }

  }
View Full Code Here

Examples of ch.cmbntr.modulizer.bootstrap.util.Resources.Pool

      throws ComputationException {
    return Maps.transformValues(submitCompute(items, f), ModulizerUtil.<T> futureCollector());
  }

  private static <F, T> Map<F, Future<T>> submitCompute(final Iterable<F> items, final Function<? super F, T> f) {
    final Pool pool = Resources.getPoolHandle();
    final ExecutorService exec = pool.aquireBlockableExec();
    try {
      final ImmutableMap.Builder<F, Future<T>> submits = ImmutableMap.builder();
      for (final F i : items) {
        submits.put(i, exec.submit(new Callable<T>() {
          @Override
          public T call() throws Exception {
            return f.apply(i);
          }
        }));
      }
      return submits.build();
    } finally {
      pool.releaseBlockableExec(exec);
    }
  }
View Full Code Here

Examples of ch.cmbntr.modulizer.bootstrap.util.Resources.Pool

      throws MojoExecutionException {

    final Map<Artifact, File> fromTo = compute(artifacts, resourceTargetFile(moduleDirectory));
    final Map<File, Future<String>> targetHashes = sha1async(fromTo.values());

    final Pool pool = Resources.getPoolHandle();
    final ExecutorService executor = pool.aquireExec();
    try {
      return collect(ImmutableList.copyOf(transform(fromTo.entrySet(),
          new Function<Entry<Artifact, File>, Future<String>>() {
            @Override
            public Future<String> apply(final Entry<Artifact, File> e) {
              final Artifact a = e.getKey();
              final File src = a.getFile();
              final File target = e.getValue();
              final Future<String> targetHash = targetHashes.get(target);
              checkState(src != null, "missing file for %s", a);
              return executor.submit(conditionalCopy(src, target, targetHash));
            }
          })));
    } catch (final ComputationException e) {
      throw new MojoExecutionException("failed to copy artifacts", e.getCause());
    } finally {
      pool.releaseExec(executor);
    }

  }
View Full Code Here

Examples of ch.cmbntr.modulizer.bootstrap.util.Resources.Pool

      throws MojoExecutionException {

    final Map<Artifact, File> fromTo = compute(artifacts, resourceTargetFile(moduleDirectory));
    final Map<File, Future<String>> targetHashes = sha1async(fromTo.values());

    final Pool pool = Resources.getPoolHandle();
    final ExecutorService executor = pool.aquireExec();
    try {
      return collect(ImmutableList.copyOf(transform(fromTo.entrySet(),
          new Function<Entry<Artifact, File>, Future<String>>() {
            @Override
            public Future<String> apply(final Entry<Artifact, File> e) {
              final Artifact a = e.getKey();
              final File src = a.getFile();
              final File target = e.getValue();
              final Future<String> targetHash = targetHashes.get(target);
              checkState(src != null, "missing file for %s", a);
              return executor.submit(conditionalCopy(src, target, targetHash));
            }
          })));
    } catch (final ComputationException e) {
      throw new MojoExecutionException("failed to copy artifacts", e.getCause());
    } finally {
      pool.releaseExec(executor);
    }

  }
View Full Code Here

Examples of ch.cmbntr.modulizer.bootstrap.util.Resources.Pool

  /**
   * {@inheritDoc}
   */
  @Override
  public void run() {
    final Pool handle = Resources.getPoolHandle();
    try {
      establishContext();
      performSecuritySettings();
      initializeLogging();

View Full Code Here

Examples of ch.cmbntr.modulizer.bootstrap.util.Resources.Pool

  }

  private static void copy(final InputStream input, final OutputStream output) throws IOException {
    final ReadableByteChannel in = inChannel(input);
    final WritableByteChannel out = outChannel(output);
    final Pool pool = Resources.getPoolHandle();
    final ByteBuffer buffer = pool.aquireBuffer();
    try {
      while (true) {
        if (in.read(buffer) == -1) {
          break;
        }
        buffer.flip();
        while (buffer.hasRemaining()) {
          final int n = out.write(buffer);
          if (n < 1) {
            throw new IOException("write stalled");
          }
        }
        buffer.clear();
      }
    } finally {
      pool.releaseBuffer(buffer);
    }
  }
View Full Code Here

Examples of ch.cmbntr.modulizer.bootstrap.util.Resources.Pool

    return sha1 == null ? null : sha1.append('.').append(extension(f.getName(), "dat")).toString();
  }

  public static LinkedHashMap<File, Future<String>> sha1async(final Iterable<File> files) {
    final LinkedHashMap<File, Future<String>> result = new LinkedHashMap<File, Future<String>>();
    final Pool pool = Resources.getPoolHandle();
    final ExecutorService exec = pool.aquireExec();
    try {
      for (final File f : files) {
        result.put(f, exec.submit(new Callable<String>() {
          @Override
          public String call() throws Exception {
            final StringBuilder sha1 = sha1(f);
            return sha1 == null ? null : sha1.toString();
          }
        }));
      }
      return result;
    } finally {
      pool.releaseExec(exec);
    }
  }
View Full Code Here

Examples of com.abiquo.ssm.model.Pool

    private Map<String, Pool> pools = new HashMap<String, Pool>();

    public InMemoryStoragePlugin()
    {
        // Add a default storage pool
        Pool pool = new Pool();
        pool.setName("In Memory");
        pool.setSizeInMB(51200L); // 50 GB
        pool.setUsedInMB(25600L); // 25 GB
        pool.setAvailableInMB(25600L); // 25 GB

        pools.put(pool.getName(), pool);
    }
View Full Code Here

Examples of com.axemblr.provisionr.api.pool.Pool

    public ExpectedException exception = ExpectedException.none();

    @Test
    public void testCreatePoolStartsTheManagementProcess() throws Exception {
        final Provisionr service = newProvisionrMockWithId(TEST_PROVISIONR_ID);
        final Pool pool = mock(Pool.class);

        final List<Provisionr> services = ImmutableList.of(service);
        final List<PoolTemplate> templates = ImmutableList.of();
        CreatePoolCommand command = new CreatePoolCommand(services, templates) {
            @Override
View Full Code Here

Examples of com.gemstone.gemfire.cache.client.Pool

    }
  }

  private void initQueryService() {
    if (StringUtils.hasText(poolName)) {
      Pool pool = PoolManager.find(poolName);
      Assert.notNull(pool, String.format("No GemFire Pool with name '%1$s' was found.", poolName));
      queryService = pool.getQueryService();
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.