<commit_before>/* $Id: TspRequestSender.java,v 1.3 2004-11-14 17:16:36 sgalles Exp $
 * -----------------------------------------------------------------------
 * 
 * TSP Library - core components for a generic Transport Sampling Protocol.
 * 
 * Copyright (c) 2002 <NAME>, <NAME>, <NAME> and <NAME> 
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * -----------------------------------------------------------------------
 * 
 * Project    : TSP
 * SubProject : jTSP
 * Maintainer : <EMAIL>
 * Component  : Consumer
 * 
 * -----------------------------------------------------------------------
 * 
 * Purpose   : 
 * 
 * -----------------------------------------------------------------------
 */

package tsp.core.rpc;

import org.acplt.oncrpc.*;

import tsp.core.common.url.TspNoServerFoundException;
import tsp.core.common.url.TspURL;
import tsp.core.common.url.TspURLException;
import tsp.core.common.url.TspUnknownHostException;
import tsp.core.common.url.TspUnknownServerNameException;
import tsp.core.common.url.TspUnknownServerNumberException;
import tsp.core.config.TspConfig;

import java.net.InetAddress;
import java.net.UnknownHostException;

import java.io.IOException;

/**
 * The TSP Request Sender class is high level
 * wrapper to a lower layer which is able to send
 * TSP request. 
 *
 */
public class TspRequestSender {

	private TSP_rpcClientStub stub;

	/**
	 * Constructs a <code>TSP_rpcClientStub</code> client stub proxy object
	 * from which the TSP_RPC remote program can be accessed.
	 * 
	 * @param host
	 *                      Internet address of host where to contact the remote program.
	 * @param progid
	 *                      The remote program number.
	 * @throws TspUrlException
	 * @throws OncRpcException
	 *                       if an ONC/RPC error occurs.
	 * @throws IOException
	 *                       if an I/O error occurs.
	 */
	public TspRequestSender(TspURL url) throws TspCommandChannelException, TspURLException {
		
		/* TODO : manage stub connection leak */
		stub = null;
		
		if (url.getServerNumber() != null) {
			int serverNumber = url.getServerNumber().intValue();
			stub = createStub(url.getHost(), serverNumber, url.getServerName());
		} else {
			boolean oneServerExists = false;
			for(int serverNumber = 0 ; serverNumber < TspConfig.TSP_MAX_SERVERNUMBER_SCAN && stub == null; serverNumber++){
				try{
					System.out.println("Searching server for serverName=" + url.getServerName() + " and serverNumber=" + serverNumber);
					stub = createStub(url.getHost(), serverNumber, url.getServerName());
				} catch (TspUnknownServerNumberException e) {
					System.out.println("No server found for serverNumber=" + serverNumber);
					/* empty on purpose, retry */
				} catch (TspUnknownServerNameException e) {
					/* it is not the right server, bu at least there's one server */
					System.out.println("No server found for serverName=" + url.getServerName() + " and serverNumber=" + serverNumber);
					oneServerExists = true;	<commit_msg>Update to handle progid scanning<commit_after>/* $Id: TspRequestSender.java,v 1.4 2004-11-14 17:35:22 sgalles Exp $
 * -----------------------------------------------------------------------
 * 
 * TSP Library - core components for a generic Transport Sampling Protocol.
 * 
 * Copyright (c) 2002 <NAME>, <NAME>, <NAME> and <NAME> 
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * -----------------------------------------------------------------------
 * 
 * Project    : TSP
 * SubProject : jTSP
 * Maintainer : <EMAIL>
 * Component  : Consumer
 * 
 * -----------------------------------------------------------------------
 * 
 * Purpose   : 
 * 
 * -----------------------------------------------------------------------
 */

package tsp.core.rpc;

import org.acplt.oncrpc.*;

import tsp.core.common.url.TspNoServerFoundException;
import tsp.core.common.url.TspURL;
import tsp.core.common.url.TspURLException;
import tsp.core.common.url.TspUnknownHostException;
import tsp.core.common.url.TspUnknownServerNameException;
import tsp.core.common.url.TspUnknownServerNumberException;
import tsp.core.config.TspConfig;

import java.net.InetAddress;
import java.net.UnknownHostException;

import java.io.IOException;

/**
 * The TSP Request Sender class is high level
 * wrapper to a lower layer which is able to send
 * TSP request. 
 *
 */
public class TspRequestSender {

	private TSP_rpcClientStub stub;

	/**
	 * Constructs a <code>TSP_rpcClientStub</code> client stub proxy object
	 * from which the TSP_RPC remote program can be accessed.
	 * 
	 * @param host
	 *                      Internet address of host where to contact the remote program.
	 * @param progid
	 *                      The remote program number.
	 * @throws TspUrlException
	 * @throws OncRpcException
	 *                       if an ONC/RPC error occurs.
	 * @throws IOException
	 *                       if an I/O error occurs.
	 */
	public TspRequestSender(TspURL url) throws TspCommandChannelException, TspURLException {
		
		/* TODO : manage stub connection leak */
		stub = null;
		
		if (url.getServerNumber() != null) {
			int serverNumber = url.getServerNumber().intValue();
			stub = createStub(url.getHost(), serverNumber, url.getServerName());
		} else {
			boolean oneServerExists = false;
			for(int serverNumber = 0 ; serverNumber < TspConfig.TSP_MAX_SERVERNUMBER_SCAN && stub == null; serverNumber++){
				try{
					System.out.println("Searching server for serverName=" + url.getServerName() + " and serverNumber=" + serverNumber);
					stub = createStub(url.getHost(), serverNumber, url.getServerName());
				} catch (TspUnknownServerNumberException e) {
					System.out.println("No server found for serverNumber=" + serverNumber);
					/* empty on purpose, retry */
				} catch (TspCommandChannelException e) {
					System.out.println("No server found for serverNumber=" + serverNumber);
					/* empty on purpose, retry */
				} catch (TspUnknownServerNameException e) {
					/*
					 * it is not the right server, bu at least there's one
					 * server
					 */
					System.out.println("No server found for serverName=" + url.getServerName() + " and serverNumber=" + serverNumber);
					oneServerExists = true;	
{'fraction_non_alphanumeric': 0.16162147933666754, 'fraction_numerical': 0.009739405106607002, 'mean_word_length': 2.477803203661327, 'pattern_counts': {'":': 0, '<': 19, '<?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': '4254365', 'n_tokens_mistral': 2242, 'n_tokens_neox': 1979, 'n_words': 693}