<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.dimm.vsm.backup;

import de.dimm.vsm.log.Log;
import de.dimm.vsm.net.RemoteCallFactory;
import de.dimm.vsm.net.interfaces.AgentApi;
import java.io.IOException;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.SocketTimeoutException;

/**
 *
 * @author Administrator
 */
public class AgentApiEntry
{
    private AgentApi api;
    private boolean online;
    RemoteCallFactory factory;

    public AgentApiEntry( AgentApi api, RemoteCallFactory factory )
    {
        this.api = api;
        this.factory = factory;
    }
    
    public RemoteCallFactory getFactory()
    {
        return factory;
    }
    

    public AgentApi getApi()
    {
        return api;
    }

    public InetAddress getAddr()
    {
        return factory.getAdress();
    }

    public int getPort()
    {
        return factory.getPort();
    }

    public boolean isOnline()
    {
        return online;
    }
    public void resetSocket() throws IOException
    {
        factory.resetSocket();
    }
    public void close() throws IOException
    {
        factory.close();
    }

    public boolean check_online(boolean mithMsg)
    {
        try
        {
            api.get_properties();
            online = true;
            return true;
        }
        catch (Exception e)
        {
            if (!(e instanceof ConnectException))
            {
                try
                {
                    factory.resetSocket();
                    api.get_properties();
                    online = true;
                    return true;
                }
                catch (Exception e2)
                {
                    if (mithMsg)
                    {
                        if (e2 instanceof ConnectException)
                            Log.warn("Adresse kann nicht kontaktiert werden", "%s:%d", getAddr().toString(), getPort());
                        else if (e2 instanceof SocketTimeoutException)
                            Log.warn("Adresse kann nicht kontaktiert werden", "%s:%d", getAddr().toString(), getPort());
                        else
                            Log.warn("Adresse kann nicht kontaktiert werden", getAddr().toString() + ":" + getPort(), e2);
                    }
                }
            }
        }
        online = false;
        return false;
    }
}<commit_msg>Cache Properties<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.dimm.vsm.backup;

import de.dimm.vsm.log.Log;
import de.dimm.vsm.net.RemoteCallFactory;
import de.dimm.vsm.net.interfaces.AgentApi;
import java.io.IOException;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.SocketTimeoutException;
import java.util.Properties;

/**
 *
 * @author Administrator
 */
public class AgentApiEntry
{
    private AgentApi api;
    private boolean online;
    RemoteCallFactory factory;
    Properties agentProps;

    public AgentApiEntry( AgentApi api, RemoteCallFactory factory )
    {
        this.api = api;
        this.factory = factory;
    }
    
    public RemoteCallFactory getFactory()
    {
        return factory;
    }
    

    public AgentApi getApi()
    {
        return api;
    }

    public InetAddress getAddr()
    {
        return factory.getAdress();
    }

    public int getPort()
    {
        return factory.getPort();
    }

    public boolean isOnline()
    {
        return online;
    }
    public void resetSocket() throws IOException
    {
        factory.resetSocket();
    }
    public void close() throws IOException
    {
        factory.close();
    }

    public boolean check_online(boolean mithMsg)
    {
        try
        {
            agentProps = api.get_properties();
            online = true;
            return true;
        }
        catch (Exception e)
        {
            if (!(e instanceof ConnectException))
            {
                try
                {
                    factory.resetSocket();
                    api.get_properties();
                    online = true;
                    return true;
                }
                catch (Exception e2)
                {
                    if (mithMsg)
                    {
                        if (e2 instanceof ConnectException)
                            Log.warn("Adresse kann nicht kontaktiert werden", "%s:%d", getAddr().toString(), getPort());
                        else if (e2 instanceof SocketTimeoutException)
                            Log.warn("Adresse kann nicht kontaktiert werden", "%s:%d", getAddr().toString(), getPort());
                        else
                            Log.warn("Adresse kann nicht kontaktiert werden", getAddr().toString() + ":" + getPort(), e2);
                    }
                }
            }
        }
        online = false;
        return false;
    }

    public boolean hasBooleanOption( String opt )
    {
        if (agentProps == null)
        {
            if (!check_online(false))
                return false;
        }
        String v = agentProps.getProperty(opt, Boolean.FALSE.toString());
        return v.equals(Boolean.TRUE.toString());
    }
}
{'fraction_non_alphanumeric': 0.09347376340041377, 'fraction_numerical': 0.0015046078615760768, 'mean_word_length': 1.5132325141776937, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '1999345', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1348, 'n_words': 340}