Java源码示例:org.apache.ignite.configuration.DeploymentMode

示例1
/**
 * @param name Name of resource.
 * @param deploymentInfo Grid cached deployment info.
 * @return Class if can to load resource with the <code>name</code> or {@code null} otherwise.
 */
@Nullable private Class<?> tryToloadClassFromCacheDep(String name, CachedDeploymentInfo<K, V> deploymentInfo) {
    UUID sndId = deploymentInfo.senderId();
    IgniteUuid ldrId = deploymentInfo.loaderId();
    String userVer = deploymentInfo.userVersion();
    DeploymentMode mode = deploymentInfo.mode();
    Map<UUID, IgniteUuid> participants = deploymentInfo.participants();

    GridDeployment d = cctx.gridDeploy().getGlobalDeployment(
        mode,
        name,
        name,
        userVer,
        sndId,
        ldrId,
        participants,
        F.<ClusterNode>alwaysTrue());

    Class cls = d != null ? d.deployedClass(name) : null;

    return cls;
}
 
示例2
/**
 * Validates service configuration.
 *
 * @param c Service configuration.
 * @throws IgniteException If validation failed.
 */
private void validate(ServiceConfiguration c) throws IgniteException {
    IgniteConfiguration cfg = ctx.config();

    DeploymentMode depMode = cfg.getDeploymentMode();

    if (cfg.isPeerClassLoadingEnabled() && (depMode == PRIVATE || depMode == ISOLATED))
        throw new IgniteException("Cannot deploy services in PRIVATE or ISOLATED deployment mode: " + depMode);

    ensure(c.getName() != null, "getName() != null", null);
    ensure(c.getTotalCount() >= 0, "getTotalCount() >= 0", c.getTotalCount());
    ensure(c.getMaxPerNodeCount() >= 0, "getMaxPerNodeCount() >= 0", c.getMaxPerNodeCount());
    ensure(c.getService() != null, "getService() != null", c.getService());
    ensure(c.getTotalCount() > 0 || c.getMaxPerNodeCount() > 0,
        "c.getTotalCount() > 0 || c.getMaxPerNodeCount() > 0", null);
}
 
示例3
/**
 * @param depMode Deployment mode to use.
 * @throws Exception If failed.
 */
private void checkNonDefaultClass(DeploymentMode depMode) throws Exception {
    try {
        this.depMode = depMode;

        info("Start Gridify test with Test AOP Task in Deployment Mode : " + depMode);

        startGrid();

        deployTask();

        int res = getTarget().gridifyNonDefaultClass("1");

        if (res != 10)
            fail("Method gridifyNonDefault returns wrong value [result=" + res + ", expect=1]");

        info("Executed @Gridify method gridifyNonDefaultClass(0) [result=" + res + ']');
    }
    finally {
        stopGrid();
    }
}
 
示例4
/**
 * Process one test.
 *
 * @param depMode deployment mode.
 * @throws Exception if error occur.
 */
private void processTest(DeploymentMode depMode) throws Exception {
    this.depMode = depMode;

    try {
        Ignite ignite1 = startGrid(1);
        startGrid(2);

        long res = ignite1.compute().execute(FactorialTask.class, 3L);

        assert res == factorial(3);

        res = ignite1.compute().execute(FactorialTask.class, 3L);

        assert res == factorial(3);
    }
    finally {
        stopGrid(2);
        stopGrid(1);
    }
}
 
示例5
/**
 * @param depMode deployment mode.
 * @throws Exception If failed.
 */
private void processTestGridifyResource(DeploymentMode depMode) throws Exception {
    try {
        this.depMode = depMode;

        startGrid(1);

        Integer res = executeGridifyResource(1);

        // P2P deployment
        assert res != null : "res != null";
        assert res == 1 : "Unexpected result [res=" + res + ", expected=0]";

        info("Tests passed.");
    }
    finally {
        stopGrid(1);
    }
}
 
示例6
/**
 * @param depMode Deployment mode to use.
 * @throws Exception If failed.
 */
private void checkNonDefaultNameResource(DeploymentMode depMode) throws Exception {
    this.depMode = depMode;

    info("Start Gridify test with Test AOP Task in Deployment Mode : " + depMode);

    try {
        startGrid();

        deployTask();

        int res = getTarget().gridifyNonDefaultNameResource("4");

        if (res != 40)
            fail("Method gridifyNonDefaultNameResource returns wrong value [result=" + res + ", expect=4]");

        info("Executed @Gridify method gridifyNonDefaultNameResource(4) [result=" + res + ']');
    }
    finally {
        stopGrid();
    }
}
 
示例7
/**
 * @param depMode Deployment mode.
 * @param clsLdr Class loader.
 * @param clsLdrId Class loader ID.
 * @param userVer User version.
 * @param sampleClsName Sample class name.
 * @param loc {@code True} if local deployment.
 */
GridDeployment(DeploymentMode depMode, ClassLoader clsLdr, IgniteUuid clsLdrId, String userVer,
    String sampleClsName, boolean loc) {
    assert depMode != null;
    assert clsLdr != null;
    assert clsLdrId != null;
    assert userVer != null;
    assert sampleClsName != null;

    this.clsLdr = clsLdr;
    this.clsLdrId = clsLdrId;
    this.userVer = userVer;
    this.depMode = depMode;
    this.sampleClsName = sampleClsName;
    this.loc = loc;
}
 
示例8
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    // Override P2P configuration to exclude Task and Job classes
    cfg.setPeerClassLoadingLocalClassPathExclude(GridDeploymentTestJob.class.getName(),
        GridDeploymentTestTask.class.getName());

    // Following tests makes sense in ISOLATED modes (they redeploy tasks
    // and don't change task version. The different tasks with the same version from the same node
    // executed in parallel - this does not work in share mode.)
    cfg.setDeploymentMode(DeploymentMode.ISOLATED);

    cfg.setPeerClassLoadingLocalClassPathExclude(
        "org.apache.ignite.internal.GridMultipleVersionsDeploymentSelfTest*");

    cfg.setIncludeEventTypes(EventType.EVTS_ALL);

    return cfg;
}
 
示例9
/**
 * Test {@link DeploymentMode#ISOLATED} mode.
 *
 * @throws Exception if error occur.
 */
@Test
public void testIsolatedMode() throws Exception {
    depMode = DeploymentMode.ISOLATED;

    deploymentTest();
}
 
示例10
/**
 * Test {@link org.apache.ignite.configuration.DeploymentMode#CONTINUOUS} mode.
 *
 * @throws Exception if error occur.
 */
@Test
public void testContinuousMode() throws Exception {
    depMode = DeploymentMode.CONTINUOUS;

    processTest(false, false);
}
 
示例11
/**
 * @throws Exception If fail.
 */
@Test
public void testStartedInPrivateMode() throws Exception {
    deploymentMode = DeploymentMode.PRIVATE;
    marshaller = new BinaryMarshaller();

    doCheckStarted(deploymentMode);
}
 
示例12
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    clsLdrId = U.readIgniteUuid(in);
    depMode = DeploymentMode.fromOrdinal(in.readByte());
    userVer = U.readString(in);
    locDepOwner = in.readBoolean();
    participants = U.readMap(in);
}
 
示例13
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    src = U.readByteArray(in);

    depMode = DeploymentMode.fromOrdinal(in.readInt());

    clsLdrId = U.readIgniteUuid(in);
    srcClsName = U.readString(in);
    userVer = U.readString(in);
    ldrParties = U.readMap(in);
}
 
示例14
/**
 * Test GridDeploymentMode.CONTINUOUS mode.
 *
 * @throws Exception If failed.
 */
@Test
public void testContinuousMode() throws Exception {
    depMode = DeploymentMode.CONTINUOUS;

    processTest();
}
 
示例15
/**
 * Test {@link org.apache.ignite.configuration.DeploymentMode#CONTINUOUS} mode.
 *
 * @throws Exception if error occur.
 */
@Test
public void testContinuousMode() throws Exception {
    depMode = DeploymentMode.CONTINUOUS;

    affinityTest();
}
 
示例16
/**
 * @throws Exception In case of error.
 */
@Test
public void testInvokeAllDeployment2() throws Exception {
    depMode = DeploymentMode.SHARED;

    doTestInvokeAll();
}
 
示例17
/**
 * @param depMode Deployment mode to use.
 * @throws Exception If failed.
 */
private void checkDefaultResource(DeploymentMode depMode) throws Exception {
    this.depMode = depMode;

    info("Start Gridify test with Default AOP Task in Deploy Mode : " + depMode);

    startGrid();

    int res;

    try {
        res = -1;

        Object targetObj = target();

        if (targetObj instanceof TestAopTarget)
            res = ((TestAopTarget)targetObj).gridifyDefaultResource("1");
        else
            res = ((TestAopTargetInterface)targetObj).gridifyDefaultResource("1");

        if (res != 1)
            fail("Method gridifyDefaultResource returned wrong value [result=" + res + ", expect=1]");
    }
    finally {
        stopGrid();
    }

    info("Executed @Gridify method gridifyDefaultResource(0) [result=" + res + ']');
}
 
示例18
/**
 * @throws Exception In case of error.
 */
@Test
public void testGetDeployment2WithKeepBinary() throws Exception {
    depMode = DeploymentMode.SHARED;

    doTestGet(true);
}
 
示例19
/** {@inheritDoc} */
@Override public void start() throws IgniteCheckedException {
    if (ctx.isDaemon())
        return;

    IgniteConfiguration cfg = ctx.config();

    DeploymentMode depMode = cfg.getDeploymentMode();

    if (cfg.isPeerClassLoadingEnabled() && (depMode == PRIVATE || depMode == ISOLATED) &&
        !F.isEmpty(cfg.getServiceConfiguration()))
        throw new IgniteCheckedException("Cannot deploy services in PRIVATE or ISOLATED deployment mode: " + depMode);
}
 
示例20
/**
 * Test GridDeploymentMode.ISOLATED mode.
 *
 * @throws Exception if error occur.
 */
@Test
public void testIsolatedMode() throws Exception {
    depMode = DeploymentMode.ISOLATED;

    processTest(false, false);
}
 
示例21
/**
 * @param depMode deployment mode.
 * @throws Throwable If task execution failed.
 */
protected void processTest(DeploymentMode depMode) throws Throwable {
    this.depMode = depMode;

    try {
        final Ignite ignite1 = startGrid(1);
        final Ignite ignite2 = startGrid(2);
        final Ignite ignite3 = startGrid(3);

        for (int i = 0; i < ITERATIONS; i++) {
            ignite1.compute().localDeployTask(loadTaskClass(), loadTaskClass().getClassLoader());
            ignite2.compute().localDeployTask(loadTaskClass(), loadTaskClass().getClassLoader());

            ComputeTaskFuture<Integer> fut1 = executeAsync(ignite1.compute(), TASK_NAME, Arrays.asList(
                ignite1.cluster().localNode().id(),
                ignite2.cluster().localNode().id(),
                ignite3.cluster().localNode().id()));

            ComputeTaskFuture<Integer> fut2 = executeAsync(ignite2.compute(), TASK_NAME, Arrays.asList(
                ignite1.cluster().localNode().id(),
                ignite2.cluster().localNode().id(),
                ignite3.cluster().localNode().id()));

            Integer res1 = fut1.get(5000);
            Integer res2 = fut2.get(5000);

            if (res1 == null || res2 == null)
                throw new IgniteCheckedException("Received wrong result.");
        }
    }
    finally {
        stopGrid(1);
        stopGrid(2);
        stopGrid(3);
    }
}
 
示例22
/**
 * Test {@link DeploymentMode#CONTINUOUS} mode.
 *
 * @throws Exception if error occur.
 */
@Test
public void testContinuousMode() throws Exception {
    depMode = DeploymentMode.CONTINUOUS;

    processTest();
}
 
示例23
/**
 * Test GridDeploymentMode.ISOLATED mode.
 *
 * @throws Exception if error occur.
 */
@Test
public void testRedeployIsolatedMode() throws Exception {
    depMode = DeploymentMode.ISOLATED;

    processTest(true, false);
}
 
示例24
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setDeploymentMode(DeploymentMode.SHARED);

    return cfg;
}
 
示例25
@Override
protected IgniteConfiguration createInstance() {
    if (!configured) {
        address = serverConfigurationService.getString("ignite.address");
        home = serverConfigurationService.getString("ignite.home");
        remoteAddresses = serverConfigurationService.getStrings("ignite.addresses");
        port = serverConfigurationService.getInt("ignite.port", 0);
        range = serverConfigurationService.getInt("ignite.range", 10);
        mode = serverConfigurationService.getString("ignite.mode", "worker");
        name = serverConfigurationService.getServerName();
        node = serverConfigurationService.getServerId();

        // disable banner
        System.setProperty("IGNITE_NO_ASCII", "true");
        System.setProperty("IGNITE_QUIET", "true");
        System.setProperty("IGNITE_PERFORMANCE_SUGGESTIONS_DISABLED", "true");

        configureName();
        configureHome();
        configurePort();

        igniteConfiguration.setIgniteHome(home);
        igniteConfiguration.setConsistentId(node);
        igniteConfiguration.setIgniteInstanceName(name);

        if (StringUtils.equalsIgnoreCase("client", mode)) {
            igniteConfiguration.setClientMode(true);
        } else {
            igniteConfiguration.setClientMode(false);
        }

        igniteConfiguration.setDeploymentMode(DeploymentMode.CONTINUOUS);

        igniteConfiguration.setGridLogger(new Slf4jLogger());

        igniteConfiguration.setCacheConfiguration(cacheConfiguration);

        // local node network configuration
        TcpCommunicationSpi tcpCommunication = new TcpCommunicationSpi();
        TcpDiscoverySpi tcpDiscovery = new TcpDiscoverySpi();
        TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder();

        List<String> discoveryAddresses = new ArrayList<>();
        if (StringUtils.isNotBlank(address)) {
            tcpCommunication.setLocalAddress(address);
            tcpDiscovery.setLocalAddress(address);
            discoveryAddresses.add(address + ":" + (port + range) + ".." + (port + range + range - 1));
        } else {
            discoveryAddresses.add("127.0.0.1:" + (port + range) + ".." + (port + range + range - 1));
        }

        tcpCommunication.setLocalPort(port);
        tcpCommunication.setLocalPortRange(range - 1);

        tcpDiscovery.setLocalPort(port + range);
        tcpDiscovery.setLocalPortRange(range - 1);

        // remote node network configuration, 1.2.3.5:49000..49009
        if (remoteAddresses != null && remoteAddresses.length > 0) {
            discoveryAddresses.addAll(Arrays.asList(remoteAddresses));
        }

        finder.setAddresses(discoveryAddresses);
        tcpDiscovery.setIpFinder(finder);

        igniteConfiguration.setDiscoverySpi(tcpDiscovery);
        igniteConfiguration.setCommunicationSpi(tcpCommunication);

        log.info("Ignite configured with home=[{}], node=[{}], name=[{}], client mode=[{}], tcp ports=[{}..{}], discovery ports=[{}..{}]",
                igniteConfiguration.getIgniteHome(),
                igniteConfiguration.getConsistentId(),
                igniteConfiguration.getIgniteInstanceName(),
                igniteConfiguration.isClientMode(),
                tcpCommunication.getLocalPort(),
                tcpCommunication.getLocalPort() + tcpCommunication.getLocalPortRange(),
                tcpDiscovery.getLocalPort(),
                tcpDiscovery.getLocalPort() + tcpDiscovery.getLocalPortRange());

        configured = Boolean.TRUE;
    }
    return igniteConfiguration;
}
 
示例26
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    return super.getConfiguration(igniteInstanceName)
        .setPeerClassLoadingEnabled(true)
        .setDeploymentMode(DeploymentMode.SHARED);
}
 
示例27
/**
 * @throws Exception If test failed.
 */
@Test
public void testDefaultPrivate() throws Exception {
    checkDefault(DeploymentMode.PRIVATE);
}
 
示例28
/**
 * @throws Exception If test failed.
 */
@Test
public void testDefaultContinuous() throws Exception {
    checkDefault(DeploymentMode.CONTINUOUS);
}
 
示例29
/**
 * @return Deployment mode.
 */
public DeploymentMode deploymentMode() {
    return depMode;
}
 
示例30
/**
 * @throws Exception If test failed.
 */
@Test
public void testDefaultWithUserClassLoaderIsolated() throws Exception {
    checkDefaultWithUserClassLoader(DeploymentMode.ISOLATED);
}