<commit_before>
package org.fcrepo.services.functions;

import static com.google.common.base.Preconditions.checkArgument;
import static org.slf4j.LoggerFactory.getLogger;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.jcr.Repository;

import org.infinispan.Cache;
import org.infinispan.manager.DefaultCacheManager;
import org.modeshape.jcr.JcrRepository;
import org.modeshape.jcr.value.binary.BinaryStore;
import org.modeshape.jcr.value.binary.infinispan.InfinispanBinaryStore;
import org.slf4j.Logger;

import com.google.common.base.Function;

public class GetClusterConfiguration implements
		Function<Repository, Map<String, String>> {

	private static final Logger logger =
			getLogger(GetClusterConfiguration.class);

	public static final String CLUSTER_NAME = "clusterName";
	public static final String CACHE_MODE = "clusterCacheMode";
	public static final String NODE_ADDRESS = "clusterNodeAddress";
	public static final String PHYSICAL_ADDRESS = "clusterPhysicalAddress";
	public static final String NODE_VIEW = "clusterNodeView";
	public static final String CLUSTER_SIZE = "clusterSize";
	public static final String CLUSTER_MEMBERS = "clusterMembers";

	/**
	 * Extract the BinaryStore out of Modeshape (infinspan, jdbc, file, transient, etc)
	 * @return
	 */
	@Override
	public Map<String, String> apply(final Repository input) {
		checkArgument(input != null, "null cannot have a BinaryStore!");

		LinkedHashMap<String, String> result =
				new LinkedHashMap<String, String>();
		try {
			BinaryStore store =
					((JcrRepository) input).getConfiguration()
							.getBinaryStorage().getBinaryStore();

            if (!(store instanceof InfinispanBinaryStore)) {
                return result;

            }
			InfinispanBinaryStore ispnStore = (InfinispanBinaryStore) store;

			List<Cache<?, ?>> caches = ispnStore.getCaches();
			DefaultCacheManager cm =
					(DefaultCacheManager) caches.get(0).getCacheManager();

			if (cm == null) {
				logger.debug("Could not get cluster configuration information");<commit_msg>use the GetBinaryStore method to pull out the binary store<commit_after>
package org.fcrepo.services.functions;

import static com.google.common.base.Preconditions.checkArgument;
import static org.slf4j.LoggerFactory.getLogger;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.jcr.Repository;

import org.fcrepo.utils.FedoraTypesUtils;
import org.infinispan.Cache;
import org.infinispan.manager.DefaultCacheManager;
import org.modeshape.jcr.GetBinaryStore;
import org.modeshape.jcr.JcrRepository;
import org.modeshape.jcr.value.binary.BinaryStore;
import org.modeshape.jcr.value.binary.infinispan.InfinispanBinaryStore;
import org.slf4j.Logger;

import com.google.common.base.Function;

public class GetClusterConfiguration implements
		Function<Repository, Map<String, String>> {

	private static final Logger logger =
			getLogger(GetClusterConfiguration.class);

	public static final String CLUSTER_NAME = "clusterName";
	public static final String CACHE_MODE = "clusterCacheMode";
	public static final String NODE_ADDRESS = "clusterNodeAddress";
	public static final String PHYSICAL_ADDRESS = "clusterPhysicalAddress";
	public static final String NODE_VIEW = "clusterNodeView";
	public static final String CLUSTER_SIZE = "clusterSize";
	public static final String CLUSTER_MEMBERS = "clusterMembers";

    private GetBinaryStore getBinaryStore = new GetBinaryStore();

	/**
	 * Extract the BinaryStore out of Modeshape (infinspan, jdbc, file, transient, etc)
	 * @return
	 */
	@Override
	public Map<String, String> apply(final Repository input) {
		checkArgument(input != null, "null cannot have a BinaryStore!");

		LinkedHashMap<String, String> result =
				new LinkedHashMap<String, String>();
		try {
            BinaryStore store = getBinaryStore.apply(input);

            if (!(store instanceof InfinispanBinaryStore)) {
                return result;

            }
			InfinispanBinaryStore ispnStore = (InfinispanBinaryStore) store;

			List<Cache<?, ?>> caches = ispnStore.getCaches();
			DefaultCacheManager cm =
					(DefaultCacheManager) caches.get(0).getCacheManager();

			if (cm == null) {
				logger.debug("Could not get cluster configuration information");
{'fraction_non_alphanumeric': 0.0944186046511628, 'fraction_numerical': 0.0013953488372093023, 'mean_word_length': 4.924242424242424, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1698843', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1229, 'n_words': 317}