<commit_before>package gov.nih.nci.nbia.remotesearch;

import gov.nih.nci.cagrid.discovery.client.DiscoveryClient;
import gov.nih.nci.cagrid.metadata.MetadataUtils;
import gov.nih.nci.cagrid.metadata.ServiceMetadata;
import gov.nih.nci.cagrid.ncia.client.NCIACoreServiceClient;
import gov.nih.nci.nbia.util.NCIAConfig;
import gov.nih.nci.nbia.util.Util;
import gov.nih.nci.ncia.search.AvailableSearchTerms;
import gov.nih.nci.ncia.search.UsAvailableSearchTerms;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.axis.message.addressing.EndpointReferenceType;

/**
 * This object is responsible for talking to the index server and capturing
 * which nodes are out there to be searched.
 */
public class RemoteNodes {

	public static RemoteNodes getInstance() {
		return instance;
	}

	/**
	 * The meat of this object.  This talks to the index server to
	 * find all the NCIACoreService instances with the version 1.3.
	 * Further, it will solicit available search terms for each endpoint
	 * and save them per node.
	 *
	 * <P>This impl iterates over the list from the index service in serial.
	 * Might get a performance boost to send out all available search term
	 * requests in parallel.
	 */
	public void discoverNodes() throws Exception {
		System.out.println("************** INVOKING DISCOVER NODES******************** at "+Util.currrentDateTimeString());
		List<RemoteNode> newRemoteNodes = new ArrayList<RemoteNode>();

		EndpointReferenceType[] endpoints = discoveryClient.discoverServicesByName("NCIACoreService");
		if(endpoints==null) {
			System.out.println("Discovery service returns null endpoint array which I guess means no matches.");
			return;
		}

		System.out.println("Number of NCIACoreService endpoints found in index server:"+endpoints.length);

		for(EndpointReferenceType endpoint : endpoints) {
			try {
				ServiceMetadata serviceMetadata = MetadataUtils.getServiceMetadata(endpoint);
				String version = serviceMetadata.getServiceDescription().getService().getVersion();
	    		String url = endpoint.getAddress().toString();

				if(!version.equals("1.3") ||<commit_msg>allowing DISCOVER NODES for caGrid 1.4 along with 1.3<commit_after>package gov.nih.nci.nbia.remotesearch;

import gov.nih.nci.cagrid.discovery.client.DiscoveryClient;
import gov.nih.nci.cagrid.metadata.MetadataUtils;
import gov.nih.nci.cagrid.metadata.ServiceMetadata;
import gov.nih.nci.cagrid.ncia.client.NCIACoreServiceClient;
import gov.nih.nci.nbia.util.NCIAConfig;
import gov.nih.nci.nbia.util.Util;
import gov.nih.nci.ncia.search.AvailableSearchTerms;
import gov.nih.nci.ncia.search.UsAvailableSearchTerms;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.axis.message.addressing.EndpointReferenceType;

/**
 * This object is responsible for talking to the index server and capturing
 * which nodes are out there to be searched.
 */
public class RemoteNodes {

	public static RemoteNodes getInstance() {
		return instance;
	}

	/**
	 * The meat of this object.  This talks to the index server to
	 * find all the NCIACoreService instances with the version 1.3.
	 * Further, it will solicit available search terms for each endpoint
	 * and save them per node.
	 *
	 * <P>This impl iterates over the list from the index service in serial.
	 * Might get a performance boost to send out all available search term
	 * requests in parallel.
	 */
	public void discoverNodes() throws Exception {
		System.out.println("************** INVOKING DISCOVER NODES******************** at "+Util.currrentDateTimeString());
		List<RemoteNode> newRemoteNodes = new ArrayList<RemoteNode>();

		EndpointReferenceType[] endpoints = discoveryClient.discoverServicesByName("NCIACoreService");
		if(endpoints==null) {
			System.out.println("Discovery service returns null endpoint array which I guess means no matches.");
			return;
		}

		System.out.println("Number of NCIACoreService endpoints found in index server:"+endpoints.length);

		for(EndpointReferenceType endpoint : endpoints) {
			try {
				ServiceMetadata serviceMetadata = MetadataUtils.getServiceMetadata(endpoint);
				String version = serviceMetadata.getServiceDescription().getService().getVersion();
	    		String url = endpoint.getAddress().toString();
	    		System.out.println("url - version" + url + version);
				if((!version.equals("1.3") && !version.equals("1.4")) ||
{'fraction_non_alphanumeric': 0.11271741585723967, 'fraction_numerical': 0.003162412468940592, 'mean_word_length': 4.818659658344284, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2772687', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1259, 'n_words': 357}