Search in sources :

Example 11 with ClusterStartNodeResult

use of org.apache.ignite.cluster.ClusterStartNodeResult in project ignite by apache.

the class IgniteProjectionStartStopRestartSelfTest method testStartThreeNodesAndRestart.

/**
     * @throws Exception If failed.
     */
public void testStartThreeNodesAndRestart() throws Exception {
    joinedLatch = new CountDownLatch(3);
    Collection<ClusterStartNodeResult> res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), SSH_UNAME, pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), null, false, 0, 16);
    assert res.size() == 3;
    F.forEach(res, new CI1<ClusterStartNodeResult>() {

        @Override
        public void apply(ClusterStartNodeResult t) {
            assert t.getHostName().equals(HOST);
            if (!t.isSuccess())
                throw new IgniteException(t.getError());
        }
    });
    assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert joinedCnt.get() == 3;
    assert leftCnt.get() == 0;
    assert ignite.cluster().nodes().size() == 3;
    joinedLatch = new CountDownLatch(3);
    leftLatch = new CountDownLatch(3);
    res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), SSH_UNAME, pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), null, true, 0, 16);
    assert res.size() == 3;
    F.forEach(res, new CI1<ClusterStartNodeResult>() {

        @Override
        public void apply(ClusterStartNodeResult t) {
            assert t.getHostName().equals(HOST);
            if (!t.isSuccess())
                throw new IgniteException(t.getError());
        }
    });
    assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert leftLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert joinedCnt.get() == 6;
    assert leftCnt.get() == 3;
    assert ignite.cluster().nodes().size() == 3;
}
Also used : IgniteException(org.apache.ignite.IgniteException) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterStartNodeResult(org.apache.ignite.cluster.ClusterStartNodeResult)

Example 12 with ClusterStartNodeResult

use of org.apache.ignite.cluster.ClusterStartNodeResult in project ignite by apache.

the class IgniteProjectionStartStopRestartSelfTest method testRestartNodesFiltered.

/**
     * @throws Exception If failed.
     */
public void testRestartNodesFiltered() throws Exception {
    joinedLatch = new CountDownLatch(2);
    Collection<ClusterStartNodeResult> res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), SSH_UNAME, pwd, key, 2, U.getIgniteHome(), CFG_ATTR, null), null, false, 0, 16);
    assert res.size() == 2;
    F.forEach(res, new CI1<ClusterStartNodeResult>() {

        @Override
        public void apply(ClusterStartNodeResult t) {
            assert t.getHostName().equals(HOST);
            if (!t.isSuccess())
                throw new IgniteException(t.getError());
        }
    });
    assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    joinedLatch = new CountDownLatch(1);
    res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), SSH_UNAME, pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), null, false, 0, 16);
    assert res.size() == 1;
    F.forEach(res, new CI1<ClusterStartNodeResult>() {

        @Override
        public void apply(ClusterStartNodeResult t) {
            assert t.getHostName().equals(HOST);
            if (!t.isSuccess())
                throw new IgniteException(t.getError());
        }
    });
    assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert ignite.cluster().nodes().size() == 3;
    joinedLatch = new CountDownLatch(2);
    leftLatch = new CountDownLatch(2);
    X.println("Restarting nodes with " + CUSTOM_CFG_ATTR_KEY);
    Collection<UUID> ids = F.transform(ignite.cluster().forAttribute(CUSTOM_CFG_ATTR_KEY, CUSTOM_CFG_ATTR_VAL).nodes(), new IgniteClosure<ClusterNode, UUID>() {

        @Override
        public UUID apply(ClusterNode node) {
            return node.id();
        }
    });
    ignite.cluster().restartNodes(ids);
    assert leftLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert ignite.cluster().nodes().size() == 3;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteException(org.apache.ignite.IgniteException) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterStartNodeResult(org.apache.ignite.cluster.ClusterStartNodeResult) UUID(java.util.UUID)

Example 13 with ClusterStartNodeResult

use of org.apache.ignite.cluster.ClusterStartNodeResult in project ignite by apache.

the class IgniteProjectionStartStopRestartSelfTest method testStopNodesFiltered.

/**
     * @throws Exception If failed.
     */
public void testStopNodesFiltered() throws Exception {
    joinedLatch = new CountDownLatch(2);
    Collection<ClusterStartNodeResult> res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), SSH_UNAME, pwd, key, 2, U.getIgniteHome(), CFG_ATTR, null), null, false, 0, 16);
    assert res.size() == 2;
    F.forEach(res, new CI1<ClusterStartNodeResult>() {

        @Override
        public void apply(ClusterStartNodeResult t) {
            assert t.getHostName().equals(HOST);
            if (!t.isSuccess())
                throw new IgniteException(t.getError());
        }
    });
    assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    joinedLatch = new CountDownLatch(1);
    res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), SSH_UNAME, pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), null, false, 0, 16);
    assert res.size() == 1;
    F.forEach(res, new CI1<ClusterStartNodeResult>() {

        @Override
        public void apply(ClusterStartNodeResult t) {
            assert t.getHostName().equals(HOST);
            if (!t.isSuccess())
                throw new IgniteException(t.getError());
        }
    });
    assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert ignite.cluster().nodes().size() == 3;
    leftLatch = new CountDownLatch(2);
    Collection<UUID> ids = F.transform(ignite.cluster().forAttribute(CUSTOM_CFG_ATTR_KEY, CUSTOM_CFG_ATTR_VAL).nodes(), new IgniteClosure<ClusterNode, UUID>() {

        @Override
        public UUID apply(ClusterNode node) {
            return node.id();
        }
    });
    ignite.cluster().forAttribute(CUSTOM_CFG_ATTR_KEY, CUSTOM_CFG_ATTR_VAL).nodes();
    ignite.cluster().stopNodes(ids);
    assert leftLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert ignite.cluster().nodes().size() == 1;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteException(org.apache.ignite.IgniteException) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterStartNodeResult(org.apache.ignite.cluster.ClusterStartNodeResult) UUID(java.util.UUID)

Example 14 with ClusterStartNodeResult

use of org.apache.ignite.cluster.ClusterStartNodeResult in project ignite by apache.

the class IgniteProjectionStartStopRestartSelfTest method testRestartNodes.

/**
     * @throws Exception If failed.
     */
public void testRestartNodes() throws Exception {
    joinedLatch = new CountDownLatch(3);
    Collection<ClusterStartNodeResult> res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), SSH_UNAME, pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), null, false, 0, 16);
    assert res.size() == 3;
    F.forEach(res, new CI1<ClusterStartNodeResult>() {

        @Override
        public void apply(ClusterStartNodeResult t) {
            assert t.getHostName().equals(HOST);
            if (!t.isSuccess())
                throw new IgniteException(t.getError());
        }
    });
    assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert ignite.cluster().nodes().size() == 3;
    joinedLatch = new CountDownLatch(3);
    leftLatch = new CountDownLatch(3);
    ignite.cluster().restartNodes();
    assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert leftLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert ignite.cluster().nodes().size() == 3;
}
Also used : IgniteException(org.apache.ignite.IgniteException) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterStartNodeResult(org.apache.ignite.cluster.ClusterStartNodeResult)

Example 15 with ClusterStartNodeResult

use of org.apache.ignite.cluster.ClusterStartNodeResult in project ignite by apache.

the class IgniteProjectionStartStopRestartSelfTest method testStartFiveNodesInTwoCalls.

/**
     * @throws Exception If failed.
     */
public void testStartFiveNodesInTwoCalls() throws Exception {
    joinedLatch = new CountDownLatch(3);
    Collection<ClusterStartNodeResult> res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), SSH_UNAME, pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), null, false, 0, 16);
    assert res.size() == 3;
    F.forEach(res, new CI1<ClusterStartNodeResult>() {

        @Override
        public void apply(ClusterStartNodeResult t) {
            assert t.getHostName().equals(HOST);
            if (!t.isSuccess())
                throw new IgniteException(t.getError());
        }
    });
    assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert joinedCnt.get() == 3;
    assert leftCnt.get() == 0;
    assert ignite.cluster().nodes().size() == 3;
    joinedLatch = new CountDownLatch(2);
    res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), SSH_UNAME, pwd, key, 5, U.getIgniteHome(), CFG_NO_ATTR, null), null, false, 0, 16);
    assert res.size() == 2;
    F.forEach(res, new CI1<ClusterStartNodeResult>() {

        @Override
        public void apply(ClusterStartNodeResult t) {
            assert t.getHostName().equals(HOST);
            if (!t.isSuccess())
                throw new IgniteException(t.getError());
        }
    });
    assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
    assert joinedCnt.get() == 5;
    assert leftCnt.get() == 0;
    assert ignite.cluster().nodes().size() == 5;
}
Also used : IgniteException(org.apache.ignite.IgniteException) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterStartNodeResult(org.apache.ignite.cluster.ClusterStartNodeResult)

Aggregations

ClusterStartNodeResult (org.apache.ignite.cluster.ClusterStartNodeResult)20 CountDownLatch (java.util.concurrent.CountDownLatch)18 IgniteException (org.apache.ignite.IgniteException)18 ClusterNode (org.apache.ignite.cluster.ClusterNode)7 UUID (java.util.UUID)3 StartNodeCallable (org.apache.ignite.internal.util.nodestart.StartNodeCallable)2 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 ClusterGroupEmptyException (org.apache.ignite.cluster.ClusterGroupEmptyException)1 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)1 GridCompoundFuture (org.apache.ignite.internal.util.future.GridCompoundFuture)1 IgniteRemoteStartSpecification (org.apache.ignite.internal.util.nodestart.IgniteRemoteStartSpecification)1 IgniteSshHelper (org.apache.ignite.internal.util.nodestart.IgniteSshHelper)1