<commit_before>/*******************************************************************************
 * Copyright © 2018 EMBL - European Bioinformatics Institute
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific
 * language governing permissions and limitations under the
 * License.
 ******************************************************************************/

package org.mousephenotype.cda.loads.create.extract.cdabase.support;

import org.mousephenotype.cda.db.pojo.*;
import org.mousephenotype.impress2.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;

import java.util.*;

@Component
public class ImpressLoadUtils {

    // Save exceptions in a set for client retrieval.
    private Set<String> exceptions = new HashSet<>();
    public Set<String> getExceptions() {
        return exceptions;
    }


    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Value("${impress.service.url}")
    protected String impressServiceUrl;

    /**
     * Will perform a request to the supplied URL and unmarshall the response into an object.  In the case where
     * the endpoint does not respond correctly, this method will retry the request up to 5 times, backing off the
     * time between retries to allow the service to recover.  Retry delays are in seconds 1.5, 3.0, 6.0, 12.0, 24.0
     *
     * @param url the endpoint to access to get the data
     * @return Object corresponding to the value retrieved from the URL
     */
    @Retryable(
            maxAttempts = 5,
            backoff = @Backoff(delay = 1500, multiplier = 2),
            value = RuntimeException.class)
    private Object getResponseObjectFromImpress(String url) {
        RestTemplate rt = new RestTemplate();
        Object o = rt.getForEntity(url, Object.class);
        return ((ResponseEntity) o).getBody();
    }

<commit_msg>Increase time allowed for retrying<commit_after>/*******************************************************************************
 * Copyright © 2018 EMBL - European Bioinformatics Institute
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific
 * language governing permissions and limitations under the
 * License.
 ******************************************************************************/

package org.mousephenotype.cda.loads.create.extract.cdabase.support;

import org.mousephenotype.cda.db.pojo.*;
import org.mousephenotype.impress2.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;

import java.util.*;

@Component
public class ImpressLoadUtils {

    // Save exceptions in a set for client retrieval.
    private Set<String> exceptions = new HashSet<>();
    public Set<String> getExceptions() {
        return exceptions;
    }


    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Value("${impress.service.url}")
    protected String impressServiceUrl;

    /**
     * Will perform a request to the supplied URL and unmarshall the response into an object.  In the case where
     * the endpoint does not respond correctly, this method will retry the request up to 5 times, backing off the
     * time between retries to allow the service to recover.  Retry delays are in seconds 1.5, 3.0, 6.0, 12.0, 24.0
     *
     * @param url the endpoint to access to get the data
     * @return Object corresponding to the value retrieved from the URL
     */
    @Retryable(
            maxAttempts = 10,
            backoff = @Backoff(delay = 1500, multiplier = 2),
            value = RuntimeException.class)
    private Object getResponseObjectFromImpress(String url) {
        RestTemplate rt = new RestTemplate();
        Object o = rt.getForEntity(url, Object.class);
        return ((ResponseEntity) o).getBody();
    }


{'fraction_non_alphanumeric': 0.1390728476821192, 'fraction_numerical': 0.011221486387049302, 'mean_word_length': 3.9472247497725204, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1896604', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1351, 'n_words': 500}