Search in sources :

Example 6 with DiscoverySpi

use of org.apache.ignite.spi.discovery.DiscoverySpi in project ignite by apache.

the class GridMultiSplitsLoadTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("ConstantConditions")
@Override
protected IgniteConfiguration getConfiguration() throws Exception {
    IgniteConfiguration cfg = super.getConfiguration();
    CommunicationSpi commSpi = new TcpCommunicationSpi();
    cfg.setCommunicationSpi(commSpi);
    DiscoverySpi discoSpi = new TcpDiscoverySpi();
    cfg.setDiscoverySpi(discoSpi);
    return cfg;
}
Also used : CommunicationSpi(org.apache.ignite.spi.communication.CommunicationSpi) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) DiscoverySpi(org.apache.ignite.spi.discovery.DiscoverySpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 7 with DiscoverySpi

use of org.apache.ignite.spi.discovery.DiscoverySpi in project ignite by apache.

the class GridSingleSplitsRedeployLoadTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration() throws Exception {
    IgniteConfiguration cfg = super.getConfiguration();
    CommunicationSpi commSpi = new TcpCommunicationSpi();
    cfg.setCommunicationSpi(commSpi);
    DiscoverySpi discoSpi = new TcpDiscoverySpi();
    cfg.setDiscoverySpi(discoSpi);
    cfg.setDeploymentMode(DeploymentMode.CONTINUOUS);
    return cfg;
}
Also used : CommunicationSpi(org.apache.ignite.spi.communication.CommunicationSpi) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) DiscoverySpi(org.apache.ignite.spi.discovery.DiscoverySpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 8 with DiscoverySpi

use of org.apache.ignite.spi.discovery.DiscoverySpi in project ignite by apache.

the class GridSpiAbstractConfigTest method checkNegativeSpiProperty.

/**
 * Checks that unacceptable property value prevents SPI from being started.
 *
 * @param spi Spi to test property on.
 * @param propName name of property to check.
 * @param val An illegal value.
 * @param checkExMsg If {@code true} then additional info will be added to failure.
 * @throws Exception If check failed.
 */
protected void checkNegativeSpiProperty(IgniteSpi spi, String propName, Object val, boolean checkExMsg) throws Exception {
    assert spi != null;
    assert propName != null;
    getTestData().getTestResources().inject(spi);
    String mtdName = "set" + propName.substring(0, 1).toUpperCase() + propName.substring(1);
    Method mtd = null;
    for (Method m : spi.getClass().getMethods()) if (m.getName().equals(mtdName)) {
        mtd = m;
        break;
    }
    assert mtd != null : "The setter is not found for property: " + propName;
    boolean err = false;
    try {
        mtd.invoke(spi, val);
    } catch (InvocationTargetException e) {
        info("SPI property setter thrown exception: " + e);
        if (e.getCause() instanceof IllegalArgumentException)
            err = true;
        else
            throw e;
    }
    if (!err)
        try {
            if (!(spi instanceof DiscoverySpi))
                spi.getNodeAttributes();
            spi.spiStart(getTestIgniteInstanceName());
        } catch (IgniteSpiException e) {
            info("SPI start thrown exception: " + e);
            if (checkExMsg)
                assert e.getMessage().contains("SPI parameter failed condition check: ") : "SPI has returned wrong exception message [propName=" + propName + ", msg=" + e + ']';
            err = true;
        }
    assert err : "No check for property [property=" + propName + ", value=" + val + ']';
}
Also used : DiscoverySpi(org.apache.ignite.spi.discovery.DiscoverySpi) Method(java.lang.reflect.Method) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 9 with DiscoverySpi

use of org.apache.ignite.spi.discovery.DiscoverySpi in project ignite by apache.

the class TcpDiscoverySelfTest method testPing.

/**
 * @throws Exception If any error occurs.
 */
public void testPing() throws Exception {
    try {
        startGrid(1);
        startGrid(2);
        startGrid(3);
        info("Nodes were started");
        for (Map.Entry<String, TcpDiscoverySpi> e : discoMap.entrySet()) {
            DiscoverySpi spi = e.getValue();
            for (Ignite g : G.allGrids()) {
                boolean res = spi.pingNode(g.cluster().localNode().id());
                assert res : e.getKey() + " failed to ping " + g.cluster().localNode().id() + " of " + g.name();
                info(e.getKey() + " pinged " + g.cluster().localNode().id() + " of " + g.name());
            }
        }
        info("All nodes pinged successfully.");
    } finally {
        stopAllGrids();
    }
}
Also used : DiscoverySpi(org.apache.ignite.spi.discovery.DiscoverySpi) Ignite(org.apache.ignite.Ignite) Map(java.util.Map) HashMap(java.util.HashMap)

Example 10 with DiscoverySpi

use of org.apache.ignite.spi.discovery.DiscoverySpi in project ignite by apache.

the class TcpDiscoverySnapshotHistoryTest method testHistorySupported.

/**
 * @throws Exception If any error occurs.
 */
public void testHistorySupported() throws Exception {
    try {
        final Ignite g = startGrid();
        DiscoverySpi spi = g.configuration().getDiscoverySpi();
        DiscoverySpiHistorySupport ann = U.getAnnotation(spi.getClass(), DiscoverySpiHistorySupport.class);
        assertNotNull("Spi does not have annotation for history support", ann);
        assertTrue("History support is disabled for current spi", ann.value());
    } finally {
        stopGrid();
    }
}
Also used : DiscoverySpi(org.apache.ignite.spi.discovery.DiscoverySpi) DiscoverySpiHistorySupport(org.apache.ignite.spi.discovery.DiscoverySpiHistorySupport) Ignite(org.apache.ignite.Ignite)

Aggregations

DiscoverySpi (org.apache.ignite.spi.discovery.DiscoverySpi)20 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)16 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)5 Ignite (org.apache.ignite.Ignite)4 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)4 CommunicationSpi (org.apache.ignite.spi.communication.CommunicationSpi)4 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 CI1 (org.apache.ignite.internal.util.typedef.CI1)3 DiscoveryDataBag (org.apache.ignite.spi.discovery.DiscoveryDataBag)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 List (java.util.List)2 Map (java.util.Map)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)2 IgniteException (org.apache.ignite.IgniteException)2 IgniteInterruptedException (org.apache.ignite.IgniteInterruptedException)2