Search in sources :

Example 1 with DeploymentResource

use of org.apache.ignite.spi.deployment.DeploymentResource in project ignite by apache.

the class GridLocalDeploymentSpiSelfTest method testDeploy.

/**
 * @throws Exception If failed.
 */
@SuppressWarnings({ "TooBroadScope" })
@Test
public void testDeploy() throws Exception {
    String taskName = "GridDeploymentTestTask";
    Class<? extends ComputeTask<?, ?>> task = GridDeploymentTestTask.class;
    deploy(task);
    checkResourceRegisteredInSpi(task.getClassLoader(), taskName, getSpi(), true);
    Map<String, String> rcsMap = new HashMap<>(2);
    rcsMap.put(taskName, task.getName());
    rcsMap.put(task.getName(), task.getName());
    // Note we use task name instead of class name.
    DeploymentResource t1 = U.invoke(getSpi().getClass(), getSpi(), "findResource0", rcsMap, taskName, task.getClassLoader());
    assertNotNull(t1);
    assertSame(t1.getResourceClass(), task);
    assertEquals(t1.getName(), taskName);
    getSpi().unregister(taskName);
    checkUndeployed(task);
    checkResourceRegisteredInSpi(task.getClassLoader(), taskName, getSpi(), false);
    checkResourceRegisteredInSpi(task.getClassLoader(), task.getName(), getSpi(), false);
}
Also used : HashMap(java.util.HashMap) ConcurrentLinkedHashMap(org.jsr166.ConcurrentLinkedHashMap) DeploymentResource(org.apache.ignite.spi.deployment.DeploymentResource) GridSpiAbstractTest(org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest) Test(org.junit.Test) GridSpiTest(org.apache.ignite.testframework.junits.spi.GridSpiTest)

Example 2 with DeploymentResource

use of org.apache.ignite.spi.deployment.DeploymentResource in project ignite by apache.

the class GridUriDeploymentAbstractSelfTest method checkTask.

/**
 * @param taskName Name of available task.
 * @throws Exception if failed.
 */
protected void checkTask(String taskName) throws Exception {
    assert taskName != null;
    DeploymentResource task = getSpi().findResource(taskName);
    assert task != null;
    info("Deployed task [task=" + task + ']');
}
Also used : DeploymentResource(org.apache.ignite.spi.deployment.DeploymentResource)

Example 3 with DeploymentResource

use of org.apache.ignite.spi.deployment.DeploymentResource in project ignite by apache.

the class GridUriDeploymentMd5CheckSelfTest method testMd5DirectoryCheck.

/**
 * Test skipping fresh deployment of .gar directories with equal content.
 *
 * @throws Exception if failed.
 */
@Test
public void testMd5DirectoryCheck() throws Exception {
    undeployCntr.set(0);
    String taskName = "GridUriDeploymentTestWithNameTask6";
    DeploymentResource task = getSpi().findResource(taskName);
    assert task == null;
    atomicCopy(getGarDir(), getDeployDir(), "uri1.gar");
    waitForTask(taskName, true, 10000);
    assert undeployCntr.get() == 0;
    atomicCopy(getGarDir(), getDeployDir(), "uri2.gar");
    waitForTask(taskName, true, 10000);
    assert undeployCntr.get() == 0;
}
Also used : DeploymentResource(org.apache.ignite.spi.deployment.DeploymentResource) GridSpiTest(org.apache.ignite.testframework.junits.spi.GridSpiTest) Test(org.junit.Test)

Example 4 with DeploymentResource

use of org.apache.ignite.spi.deployment.DeploymentResource in project ignite by apache.

the class GridUriDeploymentMd5CheckSelfTest method testMd5FileCheck.

/**
 * Test skipping fresh deployment of duplicated .gar files.
 *
 * @throws Exception if failed.
 */
@Test
public void testMd5FileCheck() throws Exception {
    undeployCntr.set(0);
    String taskName = "GridUriDeploymentTestWithNameTask7";
    DeploymentResource task = getSpi().findResource(taskName);
    assert task == null;
    atomicCopy(getGarFile(), getDeployDir(), "uri1.gar");
    waitForTask(taskName, true, 10000);
    assert undeployCntr.get() == 0;
    atomicCopy(getGarFile(), getDeployDir(), "uri2.gar");
    waitForTask(taskName, true, 10000);
    assert undeployCntr.get() == 0;
}
Also used : DeploymentResource(org.apache.ignite.spi.deployment.DeploymentResource) GridSpiTest(org.apache.ignite.testframework.junits.spi.GridSpiTest) Test(org.junit.Test)

Example 5 with DeploymentResource

use of org.apache.ignite.spi.deployment.DeploymentResource in project ignite by apache.

the class GridUriDeploymentClassloaderRegisterSelfTest method testDeploy.

/**
 * @throws Exception If failed.
 */
@Test
public void testDeploy() throws Exception {
    Class<? extends ComputeTask<?, ?>> task = GridFileDeploymentTestTask.class;
    deploy(task);
    DeploymentResource t1 = getSpi().findResource(task.getName());
    assert t1 != null;
    DeploymentResource t2 = getSpi().findResource(task.getName());
    assert t1.equals(t2);
    assert t1.getResourceClass() == t2.getResourceClass();
    getSpi().unregister(task.getName());
    checkUndeployed(task);
    assert getSpi().findResource(task.getName()) == null;
}
Also used : DeploymentResource(org.apache.ignite.spi.deployment.DeploymentResource) GridSpiAbstractTest(org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest) Test(org.junit.Test) GridSpiTest(org.apache.ignite.testframework.junits.spi.GridSpiTest)

Aggregations

DeploymentResource (org.apache.ignite.spi.deployment.DeploymentResource)10 GridSpiTest (org.apache.ignite.testframework.junits.spi.GridSpiTest)7 Test (org.junit.Test)7 GridSpiAbstractTest (org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest)5 HashMap (java.util.HashMap)1 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)1 Nullable (org.jetbrains.annotations.Nullable)1 ConcurrentLinkedHashMap (org.jsr166.ConcurrentLinkedHashMap)1