<commit_before>/*
 * Copyright 2006-2007 the original author or authors.
 *
 * 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
 *
 * 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.
 */

/*
 * Copyright 2006-2007 the original author or authors.
 *
 * 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
 *
 * 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.openspaces.admin.space;

import com.gigaspaces.cluster.activeelection.SpaceMode;
import org.openspaces.admin.StatisticsMonitor;
import org.openspaces.admin.space.events.ReplicationStatusChangedEventManager;
import org.openspaces.admin.space.events.SpaceInstanceAddedEventManager;
import org.openspaces.admin.space.events.SpaceInstanceLifecycleEventListener;
import org.openspaces.admin.space.events.SpaceInstanceRemovedEventManager;
import org.openspaces.admin.space.events.SpaceInstanceStatisticsChangedEventManager;
import org.openspaces.admin.space.events.SpaceModeChangedEventManager;
import org.openspaces.admin.space.events.SpaceStatisticsChangedEventManager;
import org.openspaces.core.GigaSpace;

import java.util.concurrent.TimeUnit;

/**
 * A space is composed of sevral {@link org.openspaces.admin.space.SpaceInstance}s the form a
 * topology.
 *
 * <p>There are two main logical of topolgies, one that has backups to each space instance, and
 * one that is without backups. For example, a partitioned topolgy of 2 paritions, each with one
 * backup will return 2 for {@link #getNumberOfInstances()} and 1 for {@link #getNumberOfBackups()}.
 * A replicated topology of 4 will return 4 for {@link #getNumberOfInstances()} and 0 for
 * {@link #getNumberOfBackups()}.
 *
 * <p>A Space will be discovered once one of its {@link org.openspaces.admin.space.SpaceInstance}
 * have been discovered. It will be removed once there are no {@link org.openspaces.admin.space.SpaceInstance}s
 * running.
 *
 * <p>Provides the ability to start a statistics monitor on all current {@link org.openspaces.admin.space.SpaceInstance}s using
 * {@link #startStatisticsMonitor()}. Newly discovered space instances will automatically use
 * the statistics monitor as well.
 *
 * @author kimchy
 */
public interface Space extends Iterable<SpaceInstance>, StatisticsMonitor {

    /**
     * Returns the spaces this space is one of.
     */
    Spaces getSpaces();

    /**
     * Returns the uid of the Space.
     */
    String getUid();

    /**
     * Returns the name of the Space.
     */
    String getName();

    /**
     * Retruns the number of instances as per the Space topolofy. Will return 4 if we have a replicated
     * topolgy, and 2 if we have a 2 paritions each with one backup topology.
     */
    int getNumberOfInstances();

    /**
     * Returns the number of backups per Space Instance. Returns 1 when we deploy a 2 partitions each with
     * one backup topology.
     */
    int getNumberOfBackups();

    /**
     * Returns all the space instances that are currently discovered that are part of this Space topology.
     */
    SpaceInstance[] getInstances();

    /**
     * Returns all the partitions that form this Space topology. 
     */
    SpacePartition[] getPartitions();

    /**
     * Retruns a parition for a specific partition id.
     */
    SpacePartition getPartition(int partitionId);

    /**
     * Retruns the number of currently discovered space instances.<commit_msg>fixed spelling error<commit_after>/*
 * Copyright 2006-2007 the original author or authors.
 *
 * 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
 *
 * 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.
 */

/*
 * Copyright 2006-2007 the original author or authors.
 *
 * 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
 *
 * 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.openspaces.admin.space;

import com.gigaspaces.cluster.activeelection.SpaceMode;
import org.openspaces.admin.StatisticsMonitor;
import org.openspaces.admin.space.events.ReplicationStatusChangedEventManager;
import org.openspaces.admin.space.events.SpaceInstanceAddedEventManager;
import org.openspaces.admin.space.events.SpaceInstanceLifecycleEventListener;
import org.openspaces.admin.space.events.SpaceInstanceRemovedEventManager;
import org.openspaces.admin.space.events.SpaceInstanceStatisticsChangedEventManager;
import org.openspaces.admin.space.events.SpaceModeChangedEventManager;
import org.openspaces.admin.space.events.SpaceStatisticsChangedEventManager;
import org.openspaces.core.GigaSpace;

import java.util.concurrent.TimeUnit;

/**
 * A space is composed of sevral {@link org.openspaces.admin.space.SpaceInstance}s the form a
 * topology.
 *
 * <p>There are two main logical of topolgies, one that has backups to each space instance, and
 * one that is without backups. For example, a partitioned topolgy of 2 paritions, each with one
 * backup will return 2 for {@link #getNumberOfInstances()} and 1 for {@link #getNumberOfBackups()}.
 * A replicated topology of 4 will return 4 for {@link #getNumberOfInstances()} and 0 for
 * {@link #getNumberOfBackups()}.
 *
 * <p>A Space will be discovered once one of its {@link org.openspaces.admin.space.SpaceInstance}
 * have been discovered. It will be removed once there are no {@link org.openspaces.admin.space.SpaceInstance}s
 * running.
 *
 * <p>Provides the ability to start a statistics monitor on all current {@link org.openspaces.admin.space.SpaceInstance}s using
 * {@link #startStatisticsMonitor()}. Newly discovered space instances will automatically use
 * the statistics monitor as well.
 *
 * @author kimchy
 */
public interface Space extends Iterable<SpaceInstance>, StatisticsMonitor {

    /**
     * Returns the spaces this space is one of.
     */
    Spaces getSpaces();

    /**
     * Returns the uid of the Space.
     */
    String getUid();

    /**
     * Returns the name of the Space.
     */
    String getName();

    /**
     * Returns the number of instances as per the Space topolofy. Will return 4 if we have a replicated
     * topolgy, and 2 if we have a 2 paritions each with one backup topology.
     */
    int getNumberOfInstances();

    /**
     * Returns the number of backups per Space Instance. Returns 1 when we deploy a 2 partitions each with
     * one backup topology.
     */
    int getNumberOfBackups();

    /**
     * Returns all the space instances that are currently discovered that are part of this Space topology.
     */
    SpaceInstance[] getInstances();

    /**
     * Returns all the partitions that form this Space topology. 
     */
    SpacePartition[] getPartitions();

    /**
     * Retruns a parition for a specific partition id.
     */
    SpacePartition getPartition(int partitionId);

    /**
     * Retruns the number of currently discovered space instances.
{'fraction_non_alphanumeric': 0.08176614881439084, 'fraction_numerical': 0.008176614881439084, 'mean_word_length': 3.706981858163826, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6074728', 'n_tokens_mistral': 2297, 'n_tokens_neox': 2205, 'n_words': 919}