Example usage for java.util Collection toString

List of usage examples for java.util Collection toString

Introduction

In this page you can find the example usage for java.util Collection toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.stratelia.webactiv.webSites.control.WebSiteSessionController.java

/**
 * dePublish/*from www .  j a  v  a  2s.c o m*/
 */
public synchronized void dePublish(Collection<String> listeSite) throws WebSitesException {
    try {
        webSiteEjb.dePublish(getComponentId(), listeSite);
    } catch (Exception re) {
        throw new WebSitesException("WebSiteSessionController.dePublish(listeSite)", SilverpeasException.ERROR,
                "webSites.EX_DEPUBLISH_SELECTED_FAILED", "listeSite =" + listeSite.toString(), re);
    }
}

From source file:com.stratelia.webactiv.webSites.control.WebSiteSessionController.java

/**
 * publish//from w  ww.  j a  v a  2 s .  com
 */
public synchronized void publish(Collection<String> listeSite) throws WebSitesException {
    /* Collection d'id de site */
    try {
        webSiteEjb.publish(getComponentId(), listeSite);
    } catch (Exception re) {
        throw new WebSitesException("WebSiteSessionController.publish(listeSite)", SilverpeasException.ERROR,
                "webSites.EX_PUBLISH_SELECTED_FAILED", "listeSite =" + listeSite.toString(), re);
    }
}

From source file:com.netflix.spinnaker.clouddriver.ecs.provider.agent.TaskCachingAgent.java

@Override
protected Map<String, Collection<CacheData>> generateFreshData(Collection<Task> tasks) {
    Collection<CacheData> dataPoints = new LinkedList<>();
    Map<String, CacheData> clusterDataPoints = new HashMap<>();

    for (Task task : tasks) {
        String taskId = StringUtils.substringAfterLast(task.getTaskArn(), "/");
        Map<String, Object> attributes = convertTaskToAttributes(task);

        String key = Keys.getTaskKey(accountName, region, taskId);
        dataPoints.add(new DefaultCacheData(key, attributes, Collections.emptyMap()));

        String clusterName = StringUtils.substringAfterLast(task.getClusterArn(), "/");
        Map<String, Object> clusterAttributes = EcsClusterCachingAgent
                .convertClusterArnToAttributes(accountName, region, task.getClusterArn());
        key = Keys.getClusterKey(accountName, region, clusterName);
        clusterDataPoints.put(key, new DefaultCacheData(key, clusterAttributes, Collections.emptyMap()));
    }/*  www.  java  2 s .c  o  m*/

    log.info("Caching " + dataPoints.size() + " tasks in " + getAgentType());
    Map<String, Collection<CacheData>> dataMap = new HashMap<>();
    dataMap.put(TASKS.toString(), dataPoints);

    log.info("Caching " + clusterDataPoints.size() + " ECS clusters in " + getAgentType());
    dataMap.put(ECS_CLUSTERS.toString(), clusterDataPoints.values());

    return dataMap;
}

From source file:org.apache.aries.sample.twitter.itest.TwitterTest.java

/**
 * Test for ARIES-461/* w w  w. j  a  v a  2s  . c  om*/
 * Application that bring in dependency bundles from a bundle repository doesn't deploy
 * 
 * @throws Exception
 */
@Test
public void testTwitter() throws Exception {
    // provision against the local runtime
    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");

    deleteRepos();

    MavenArtifactUrlReference twitterEbaUrl = maven("org.apache.aries.samples.twitter",
            "org.apache.aries.samples.twitter.eba").versionAsInProject().type("eba");
    MavenArtifactUrlReference twitterCommonLangJar = maven("commons-lang", "commons-lang").versionAsInProject();
    MavenArtifactUrlReference twitterJar = maven("org.apache.aries.samples.twitter",
            "org.apache.aries.samples.twitter.twitter4j").versionAsInProject();

    // add the repository xml to the repository admin
    String repositoryXML = getRepoContent("/obr/twitter/TwitterRepository.xml");
    // replace the jar file url with the real url related to the environment
    String repo = repositoryXML.replaceAll("commons.lang.location", twitterCommonLangJar.getURL())
            .replaceAll("twitter4j.location", twitterJar.getURL());

    URL url = getRepoUrl(repo);
    repositoryAdmin.addRepository(url);

    AriesApplication app = manager.createApplication(new URL(twitterEbaUrl.getURL()));
    app = manager.resolve(app);
    DeploymentMetadata depMeta = app.getDeploymentMetadata();
    List<DeploymentContent> provision = depMeta.getApplicationProvisionBundles();
    Collection<DeploymentContent> useBundles = depMeta.getDeployedUseBundle();
    Collection<DeploymentContent> appContent = depMeta.getApplicationDeploymentContents();
    // We cannot be sure whether there are two or three provision bundles pulled in by Felix OBR as there is an outstanding defect
    // https://issues.apache.org/jira/browse/FELIX-2672
    // The workaround is to check we get the two bundles we are looking for, instead of insisting on just having two bundles.

    List<String> provisionBundleSymbolicNames = new ArrayList<String>();
    for (DeploymentContent dep : provision) {
        provisionBundleSymbolicNames.add(dep.getContentName());
    }
    String provision_bundle1 = "org.apache.commons.lang";
    String provision_bundle2 = "twitter4j";
    assertTrue("Bundle " + provision_bundle1 + " not found.",
            provisionBundleSymbolicNames.contains(provision_bundle1));
    assertTrue("Bundle " + provision_bundle2 + " not found.",
            provisionBundleSymbolicNames.contains(provision_bundle2));
    assertEquals(useBundles.toString(), 0, useBundles.size());
    assertEquals(appContent.toString(), 1, appContent.size());
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
}

From source file:fr.mby.saml2.sp.impl.handler.BasicSamlDataAdaptor.java

@Override
public Collection<Entry<String, String>> buildHttpPostBindingParams(final IOutgoingSaml outgoingData) {
    Collection<Entry<String, String>> samlDataParams = new ArrayList<Entry<String, String>>();

    String relayState = outgoingData.getRelayState();
    if (StringUtils.hasText(relayState)) {
        Entry<String, String> entry = new SimpleEntry<String, String>(SamlHelper.RELAY_STATE_PARAM_KEY,
                relayState);//from  w  w  w  . j  a v a2s.  c om
        samlDataParams.add(entry);
    }

    String samlMessage = outgoingData.getSamlMessage();

    // Encoding
    final String encodedMessage;
    try {
        encodedMessage = SamlHelper.httpPostEncode(samlMessage);
    } catch (Exception e) {
        BasicSamlDataAdaptor.LOGGER.error("Error while Redirect encoding SAML message !", e);
        throw new IllegalStateException("Error while Redirect encoding SAML message !", e);
    }

    if (StringUtils.hasText(encodedMessage)) {
        Entry<String, String> entry = new SimpleEntry<String, String>(
                BasicSamlDataAdaptor.getSamlMessageParamName(outgoingData), encodedMessage);
        samlDataParams.add(entry);
    }

    BasicSamlDataAdaptor.LOGGER
            .debug(String.format("Basic HTTP-POST params built: [%s]", samlDataParams.toString()));

    return samlDataParams;
}

From source file:de.huberlin.wbi.hiway.am.WorkflowDriver.java

protected void finish() {
    /* log */ logger.writeEntryToLog(new JsonReportEntry(getRunId(), null, null, null, null, null,
            HiwayDBI.KEY_WF_TIME, Long.toString(System.currentTimeMillis() - amRMClient.getStartTime())));

    // Join all launched threads needed for when we time out and we need to release containers
    for (Thread launchThread : launchThreads) {
        try {/* ww  w.  j a va 2 s.  c o m*/
            launchThread.join(10000);
        } catch (InterruptedException e) {
            Logger.writeToStdout("Exception thrown in thread join: " + e.getMessage());
            e.printStackTrace(System.out);
            System.exit(-1);
        }
    }

    // When the application completes, it should stop all running containers
    Logger.writeToStdout("Application completed. Stopping running containers");
    nmClientAsync.stop();

    // When the application completes, it should send a finish application signal to the RM
    Logger.writeToStdout("Application completed. Signalling finish to RM");

    FinalApplicationStatus appStatus;
    String appMessage = null;
    success = true;

    WorkflowDriver.Logger.writeToStdout("Failed Containers: " + logger.numFailedContainers.get());
    WorkflowDriver.Logger.writeToStdout("Completed Containers: " + logger.numCompletedContainers.get());

    int numTotalContainers = scheduler.getNumberOfTotalTasks();

    // WorkflowDriver.writeToStdout("Total Scheduled Containers: " + numTotalContainers);

    if (logger.getNumFailedContainers().get() == 0
            && logger.getNumCompletedContainers().get() == numTotalContainers) {
        appStatus = FinalApplicationStatus.SUCCEEDED;
    } else {
        appStatus = FinalApplicationStatus.FAILED;
        appMessage = "Diagnostics." + ", total=" + numTotalContainers + ", completed="
                + logger.getNumCompletedContainers().get() + ", allocated="
                + logger.getNumAllocatedContainers().get() + ", failed=" + logger.getNumFailedContainers().get()
                + ", killed=" + logger.getNumKilledContainers().get();
        success = false;
    }

    Collection<String> output = getOutput();
    Collection<Data> outputFiles = getOutputFiles();
    if (outputFiles.size() > 0) {
        String outputs = outputFiles.toString();
        logger.writeEntryToLog(new JsonReportEntry(getRunId(), null, null, null, null, null,
                HiwayDBI.KEY_WF_OUTPUT, outputs.substring(1, outputs.length() - 1)));
    }

    try {
        logger.statLog.close();
        logger.federatedReport.stageOut();
        if (summaryPath != null) {
            String stdout = hdfsApplicationDirectory + "/AppMaster.stdout";
            String stderr = hdfsApplicationDirectory + "/AppMaster.stderr";
            String statlog = hdfsApplicationDirectory + "/" + appId + ".log";

            try (BufferedWriter writer = new BufferedWriter(new FileWriter(summaryPath.toString()))) {
                JSONObject obj = new JSONObject();
                try {
                    obj.put("output", output);
                    obj.put("stdout", stdout);
                    obj.put("stderr", stderr);
                    obj.put("statlog", statlog);
                } catch (JSONException e) {
                    e.printStackTrace(System.out);
                    System.exit(-1);
                }
                writer.write(obj.toString());
            }
            new Data("AppMaster.stdout").stageOut();
            new Data("AppMaster.stderr").stageOut();
            new Data(summaryPath).stageOut();
        }
    } catch (IOException e) {
        Logger.writeToStdout("Error when attempting to stage out federated output log.");
        e.printStackTrace(System.out);
        System.exit(-1);
    }

    try {
        amRMClient.unregisterApplicationMaster(appStatus, appMessage, null);
    } catch (YarnException | IOException e) {
        Logger.writeToStdout("Failed to unregister application");
        e.printStackTrace(System.out);
        System.exit(-1);
    }

    amRMClient.stop();

    if (timelineClient != null)
        timelineClient.stop();

}

From source file:org.trnltk.morphology.contextless.parser.PredefinedPaths.java

private Root findRoot(final String strRoot, final PrimaryPos primaryPos, final SecondaryPos secondaryPos) {
    if (!this.rootMap.containsKey(strRoot))
        throw new RuntimeException("Unable to find root " + strRoot);

    final Collection<? extends Root> roots = this.rootMap.get(strRoot);
    final Collection<? extends Root> filteredRoots = Collections2.filter(roots, new Predicate<Root>() {
        @Override/*from w w w. ja v a  2s .  c o m*/
        public boolean apply(final Root root) {
            return Objects.equal(root.getLexeme().getPrimaryPos(), primaryPos)
                    && Objects.equal(root.getLexeme().getSecondaryPos(), secondaryPos);
        }
    });

    Validate.isTrue(filteredRoots.size() == 1,
            "Found more than once roots for given parameters :" + filteredRoots.toString());
    return filteredRoots.iterator().next();
}

From source file:org.apache.hadoop.raid.DirectoryTraversal.java

public DirectoryTraversal(String friendlyName, Collection<Path> roots, FileSystem fs, Filter filter,
        int numThreads, boolean doShuffle, boolean allowUseStandby, boolean checkLeafDir) throws IOException {
    this.output = new ArrayBlockingQueue<FileStatus>(OUTPUT_QUEUE_SIZE);
    this.directories = new LinkedBlockingDeque<Path>();
    this.fs = fs;
    if (ENABLE_AVATAR_STANDBY && allowUseStandby && fs instanceof DistributedAvatarFileSystem) {
        avatarFs = (DistributedAvatarFileSystem) fs;
    } else {//w ww .java2 s .  c  o m
        avatarFs = null;
    }
    this.filter = filter;
    this.totalDirectories = new AtomicInteger(roots.size());
    this.processors = new Processor[numThreads];
    this.activeThreads = new AtomicInteger(numThreads);
    this.doShuffle = doShuffle;
    this.allowStandby = allowUseStandby;
    if (doShuffle) {
        List<Path> toShuffleAndAdd = new ArrayList<Path>();
        toShuffleAndAdd.addAll(roots);
        Collections.shuffle(toShuffleAndAdd);
        this.directories.addAll(toShuffleAndAdd);
    } else {
        this.directories.addAll(roots);
    }
    LOG.info("Starting with directories:" + roots.toString() + " numThreads:" + numThreads);
    if (roots.isEmpty()) {
        try {
            output.put(FINISH_TOKEN);
        } catch (InterruptedException e) {
            throw new IOException(e);
        }
        return;
    }
    for (int i = 0; i < processors.length; ++i) {
        if (checkLeafDir) {
            processors[i] = new LeafDirectoryProcessor();
        } else {
            processors[i] = new Processor();
        }
        processors[i].setName(friendlyName + i);
    }
    for (int i = 0; i < processors.length; ++i) {
        processors[i].start();
    }
}

From source file:com.ibm.jaggr.service.impl.AggregatorImpl.java

/**
 * Loads and initializes the resource factory, module builder and
 * http transport extensions specified in the configuration 
 * element for this aggregator/*from  w w w .j a va 2s  .c  om*/
 * 
 * @param configElem The configuration element
 * @throws CoreException
 * @throws NotFoundException
 */
protected void initExtensions(IConfigurationElement configElem) throws CoreException, NotFoundException {
    /*
     *  Init the resource factory extensions
     */
    Collection<String> resourceFactories = getInitParams().getValues(InitParams.RESOURCEFACTORIES_INITPARAM);
    if (resourceFactories.size() == 0) {
        resourceFactories.add(DEFAULT_RESOURCEFACTORIES);
    }
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    for (String resourceFactory : resourceFactories) {
        IExtension extension = registry.getExtension(IResourceFactoryExtensionPoint.NAMESPACE,
                IResourceFactoryExtensionPoint.NAME, resourceFactory);
        if (extension == null) {
            throw new NotFoundException(resourceFactory);
        }
        for (IConfigurationElement member : extension.getConfigurationElements()) {
            IResourceFactory factory = (IResourceFactory) member.createExecutableExtension("class"); //$NON-NLS-1$
            Properties props = new Properties();
            for (String name : member.getAttributeNames()) {
                props.put(name, member.getAttribute(name));
            }
            registerResourceFactory(new AggregatorExtension(extension, factory, props), null);
        }
    }

    /*
     *  Init the module builder extensions
     */
    Collection<String> moduleBuilders = getInitParams().getValues(InitParams.MODULEBUILDERS_INITPARAM);
    if (moduleBuilders.size() == 0) {
        moduleBuilders.add(DEFAULT_MODULEBUILDERS);
    }
    for (String moduleBuilder : moduleBuilders) {
        IExtension extension = registry.getExtension(IModuleBuilderExtensionPoint.NAMESPACE,
                IModuleBuilderExtensionPoint.NAME, moduleBuilder);
        if (extension == null) {
            throw new NotFoundException(moduleBuilder);
        }
        for (IConfigurationElement member : extension.getConfigurationElements()) {
            IModuleBuilder builder = (IModuleBuilder) member.createExecutableExtension("class"); //$NON-NLS-1$
            Properties props = new Properties();
            for (String name : member.getAttributeNames()) {
                props.put(name, member.getAttribute(name));
            }
            registerModuleBuilder(new AggregatorExtension(extension, builder, props), null);
        }
    }

    /*
     * Init the http transport extension
     */
    Collection<String> transports = getInitParams().getValues(InitParams.TRANSPORT_INITPARAM);
    if (transports.size() == 0) {
        transports.add(DEFAULT_HTTPTRANSPORT);
    }
    if (transports.size() != 1) {
        throw new IllegalStateException(transports.toString());
    }
    String transportName = transports.iterator().next();
    IExtension extension = registry.getExtension(IHttpTransportExtensionPoint.NAMESPACE,
            IHttpTransportExtensionPoint.NAME, transportName);
    if (extension == null) {
        throw new NotFoundException(transportName);
    }
    IConfigurationElement member = extension.getConfigurationElements()[0];
    Properties props = new Properties();
    IHttpTransport transport = (IHttpTransport) member.createExecutableExtension("class"); //$NON-NLS-1$
    for (String attrname : member.getAttributeNames()) {
        props.put(attrname, member.getAttribute(attrname));
    }
    registerHttpTransport(new AggregatorExtension(extension, transport, props));

    /*
     *  Now call setAggregator on the loaded extensions starting with the
     *  transport and then the rest of the extensions.
     */
    ExtensionRegistrar reg = new ExtensionRegistrar();
    callExtensionInitializers(Arrays.asList(new IAggregatorExtension[] { getHttpTransportExtension() }), reg);
    callExtensionInitializers(getResourceFactoryExtensions(), reg);
    callExtensionInitializers(getModuleBuilderExtensions(), reg);
    reg.open = false;
}

From source file:com.github.helenusdriver.driver.impl.PersistedMap.java

/**
 * {@inheritDoc}/*  ww w. j  a v a 2  s  .c  o  m*/
 *
 * @author paouelle
 *
 * @see java.util.Map#values()
 */
@Override
public Collection<T> values() {
    if (vcol == null) {
        final Collection<PersistedValue<T, PT>> vcol = map.values();

        this.vcol = new AbstractCollection<T>() {
            @Override
            public int size() {
                return vcol.size();
            }

            @Override
            public boolean isEmpty() {
                return vcol.isEmpty();
            }

            @Override
            public Iterator<T> iterator() {
                return new TransformIterator<PersistedValue<T, PT>, T>(vcol.iterator()) {
                    @Override
                    protected T transform(PersistedValue<T, PT> pv) {
                        return pv.getDecodedValue();
                    }
                };
            }

            @Override
            public Stream<T> stream() {
                return vcol.stream().map(pv -> pv.getDecodedValue());
            }

            @Override
            public Stream<T> parallelStream() {
                return vcol.parallelStream().map(pv -> pv.getDecodedValue());
            }

            @Override
            public void clear() {
                vcol.clear();
            }

            @Override
            public String toString() {
                return vcol.toString();
            }
        };
    }
    return vcol;
}