<commit_before>/* @java.file.header */

/*  _________        _____ __________________        _____
 *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
 *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
 *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
 *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
 */

package org.gridgain.grid.ggfs;

import org.apache.hadoop.conf.*;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.permission.*;
import org.gridgain.grid.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.ggfs.hadoop.v1.GridGgfsHadoopFileSystem;
import org.gridgain.grid.kernal.ggfs.hadoop.*;
import org.gridgain.grid.kernal.ggfs.hadoop.impl.*;
import org.gridgain.grid.lang.*;
import org.gridgain.grid.spi.communication.*;
import org.gridgain.grid.spi.communication.tcp.*;
import org.gridgain.grid.spi.discovery.tcp.*;
import org.gridgain.grid.spi.discovery.tcp.ipfinder.*;
import org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.*;
import org.gridgain.grid.util.*;
import org.gridgain.grid.util.typedef.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.gridgain.testframework.*;
import org.gridgain.testframework.junits.common.*;
import org.jdk8.backport.*;
import org.jetbrains.annotations.*;

import java.io.*;
import java.lang.reflect.*;
import java.net.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;

import static org.gridgain.grid.cache.GridCacheAtomicityMode.*;
import static org.gridgain.grid.cache.GridCacheMode.*;
import static org.gridgain.grid.events.GridEventType.*;
import static org.gridgain.grid.ggfs.GridGgfsMode.*;
import static org.gridgain.grid.ggfs.hadoop.GridGgfsHadoopParameters.*;

/**
 * Test hadoop file system implementation.
 */
@SuppressWarnings("all")
public abstract class GridGgfsHadoopFileSystemAbstractSelfTest extends GridCommonAbstractTest {
    /** Primary file system authority. */
    private static final String PRIMARY_AUTHORITY = "ggfs:grid1@";

    /** Primary file systme URI. */
    private static final String PRIMARY_URI = "ggfs://" + PRIMARY_AUTHORITY + "/";

    /** Secondary file system authority. */
    private static final String SECONDARY_AUTHORITY = "ggfs_secondary@127.0.0.1:11500";

    /** Secondary file systme URI. */
    private static final String SECONDARY_URI = "ggfs://" + SECONDARY_AUTHORITY + "/";

    /** Secondary file system configuration path. */
    private static final String SECONDARY_CFG_PATH = "/work/core-site-test.xml";

    /** Secondary endpoint configuration. */
    private static final String SECONDARY_ENDPOINT_CFG = "{type:'tcp', port:11500}";

    /** Group size. */
    public static final int GRP_SIZE = 128;

    /** Path to the default hadoop configuration. */
    public static final String HADOOP_FS_CFG = "examples/config/hadoop/core-site.xml";

    /** Thread count for multithreaded tests. */
    private static final int THREAD_CNT = 8;

    /** IP finder. */
    private static final GridTcpDiscoveryIpFinder IP_FINDER = new GridTcpDiscoveryVmIpFinder(true);

    /** Barrier for multithreaded tests. */
    private static CyclicBarrier barrier;

    /** File system. */
    private static FileSystem fs;

    /** Default GGFS mode. */
    protected final GridGgfsMode mode;

    /** Skip embedded mode flag. */
    private final boolean skipEmbed;

    /** Skip local shmem flag. */
    private final boolean skipLocShmem;

    /** Endpoint. */
    private final String endpoint;

    /** Primary file system URI. */
    protected URI primaryFsUri;

    /** Primary file system configuration. */
    protected Configuration primaryFsCfg;

    /** File statuses comparator. */
    private static final Comparator<FileStatus> STATUS_COMPARATOR = new Comparator<FileStatus>() {
        @SuppressWarnings("deprecation")
        @Override public int compare(FileStatus o1, FileStatus o2) {
            if (o1 == null || o2 == null)
                return o1 == o2 ? 0 : o1 == null ? -1 : 1;

            return o1.isDir() == o2.isDir() ? o1.getPath().compareTo(o2.getPath()) : o1.isDir() ? -1 : 1;
        }
    };

    /**
     * Constructor.
     *
     * @param mode Default GGFS mode.
     * @param skipEmbed Whether to skip embedded mode.
     * @param skipLocShmem Whether to skip local shmem mode.
     * @param skipLocTcp Whether to skip local TCP mode.
     */
    protected GridGgfsHadoopFileSystemAbstractSelfTest(GridGgfsMode mode, boolean skipEmbed, boolean skipLocShmem) {
        this.mode = mode;
        this.skipEmbed = skipEmbed;
        this.skipLocShmem = skipLocShmem;

        endpoint = skipLocShmem ? "127.0.0.1:10500" : "shmem:10500";
    }

    /** {@inheritDoc} */
    @Override protected void beforeTestsStarted() throws Exception {
        Configuration secondaryConf = configuration(SECONDARY_AUTHORITY, false, false);

        secondaryConf.setInt("fs.ggfs.block.size", 1024);

        String path = U.getGridGainHome() + SECONDARY_CFG_PATH;

        File file = new File(path);

        try (FileOutputStream fos = new FileOutputStream(file)) {
            secondaryConf.writeXml(fos);
        }

        startNodes();
    }

    /** {@inheritDoc} */
    @Override protected long getTestTimeout() {
        return 10 * 60 * 1000;
    }

    /**
     * Starts the nodes for this test.
     *
     * @throws Exception If failed.
     */
    private void startNodes() throws Exception {<commit_msg># gg-8204: Restoring tests (2).<commit_after>/* @java.file.header */

/*  _________        _____ __________________        _____
 *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
 *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
 *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
 *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
 */

package org.gridgain.grid.ggfs;

import org.apache.hadoop.conf.*;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.permission.*;
import org.gridgain.grid.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.ggfs.hadoop.v1.GridGgfsHadoopFileSystem;
import org.gridgain.grid.kernal.ggfs.hadoop.*;
import org.gridgain.grid.kernal.ggfs.hadoop.impl.*;
import org.gridgain.grid.lang.*;
import org.gridgain.grid.spi.communication.*;
import org.gridgain.grid.spi.communication.tcp.*;
import org.gridgain.grid.spi.discovery.tcp.*;
import org.gridgain.grid.spi.discovery.tcp.ipfinder.*;
import org.gridgain.grid.spi.discovery.tcp.ipfinder.vm.*;
import org.gridgain.grid.util.*;
import org.gridgain.grid.util.typedef.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.gridgain.testframework.*;
import org.gridgain.testframework.junits.common.*;
import org.jdk8.backport.*;
import org.jetbrains.annotations.*;

import java.io.*;
import java.lang.reflect.*;
import java.net.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;

import static org.gridgain.grid.cache.GridCacheAtomicityMode.*;
import static org.gridgain.grid.cache.GridCacheMode.*;
import static org.gridgain.grid.events.GridEventType.*;
import static org.gridgain.grid.ggfs.GridGgfsMode.*;
import static org.gridgain.grid.ggfs.hadoop.GridGgfsHadoopParameters.*;

/**
 * Test hadoop file system implementation.
 */
@SuppressWarnings("all")
public abstract class GridGgfsHadoopFileSystemAbstractSelfTest extends GridCommonAbstractTest {
    /** Primary file system authority. */
    private static final String PRIMARY_AUTHORITY = "ggfs:grid1@";

    /** Primary file systme URI. */
    private static final String PRIMARY_URI = "ggfs://" + PRIMARY_AUTHORITY + "/";

    /** Secondary file system authority. */
    private static final String SECONDARY_AUTHORITY = "ggfs_secondary@127.0.0.1:11500";

    /** Secondary file systme URI. */
    private static final String SECONDARY_URI = "ggfs://" + SECONDARY_AUTHORITY + "/";

    /** Secondary file system configuration path. */
    private static final String SECONDARY_CFG_PATH = "/work/core-site-test.xml";

    /** Secondary endpoint configuration. */
    private static final String SECONDARY_ENDPOINT_CFG = "{type:'tcp', port:11500}";

    /** Group size. */
    public static final int GRP_SIZE = 128;

    /** Path to the default hadoop configuration. */
    public static final String HADOOP_FS_CFG = "examples/config/hadoop/core-site.xml";

    /** Thread count for multithreaded tests. */
    private static final int THREAD_CNT = 8;

    /** IP finder. */
    private static final GridTcpDiscoveryIpFinder IP_FINDER = new GridTcpDiscoveryVmIpFinder(true);

    /** Barrier for multithreaded tests. */
    private static CyclicBarrier barrier;

    /** File system. */
    private static FileSystem fs;

    /** Default GGFS mode. */
    protected final GridGgfsMode mode;

    /** Skip embedded mode flag. */
    private final boolean skipEmbed;

    /** Skip local shmem flag. */
    private final boolean skipLocShmem;

    /** Endpoint. */
    private final String endpoint;

    /** Primary file system URI. */
    protected URI primaryFsUri;

    /** Primary file system configuration. */
    protected Configuration primaryFsCfg;

    /** File statuses comparator. */
    private static final Comparator<FileStatus> STATUS_COMPARATOR = new Comparator<FileStatus>() {
        @SuppressWarnings("deprecation")
        @Override public int compare(FileStatus o1, FileStatus o2) {
            if (o1 == null || o2 == null)
                return o1 == o2 ? 0 : o1 == null ? -1 : 1;

            return o1.isDir() == o2.isDir() ? o1.getPath().compareTo(o2.getPath()) : o1.isDir() ? -1 : 1;
        }
    };

    /**
     * Constructor.
     *
     * @param mode Default GGFS mode.
     * @param skipEmbed Whether to skip embedded mode.
     * @param skipLocShmem Whether to skip local shmem mode.
     * @param skipLocTcp Whether to skip local TCP mode.
     */
    protected GridGgfsHadoopFileSystemAbstractSelfTest(GridGgfsMode mode, boolean skipEmbed, boolean skipLocShmem) {
        this.mode = mode;
        this.skipEmbed = skipEmbed;
        this.skipLocShmem = skipLocShmem;

        endpoint = skipLocShmem ? "127.0.0.1:10500" : "shmem:10500";
    }

    /** {@inheritDoc} */
    @Override protected void beforeTestsStarted() throws Exception {
        Configuration secondaryConf = configuration(SECONDARY_AUTHORITY, true, true);

        secondaryConf.setInt("fs.ggfs.block.size", 1024);

        String path = U.getGridGainHome() + SECONDARY_CFG_PATH;

        File file = new File(path);

        try (FileOutputStream fos = new FileOutputStream(file)) {
            secondaryConf.writeXml(fos);
        }

        startNodes();
    }

    /** {@inheritDoc} */
    @Override protected long getTestTimeout() {
        return 10 * 60 * 1000;
    }

    /**
     * Starts the nodes for this test.
     *
     * @throws Exception If failed.
     */
    private void startNodes() throws Exception {
{'fraction_non_alphanumeric': 0.12737470598878234, 'fraction_numerical': 0.012755563596888004, 'mean_word_length': 2.891235480464625, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 4, 'substrings_counts': 4, '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': '5715918', 'n_tokens_mistral': 3561, 'n_tokens_neox': 3366, 'n_words': 770}