Search in sources :

Example 1 with ClusterGroupAdapter

use of org.apache.ignite.internal.cluster.ClusterGroupAdapter in project ignite by apache.

the class GridClusterStateProcessor method sendComputeCheckGlobalState.

/**
 *  Check cluster state.
 *
 *  @return Cluster state, {@code True} if cluster active, {@code False} if inactive.
 */
private boolean sendComputeCheckGlobalState() {
    AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
    if (log.isInfoEnabled()) {
        log.info("Sending check cluster state request from node [id=" + ctx.localNodeId() + ", topVer=" + topVer + ", client=" + ctx.clientNode() + ", daemon" + ctx.isDaemon() + "]");
    }
    IgniteCompute comp = ((ClusterGroupAdapter) ctx.cluster().get().forServers()).compute();
    return comp.call(new IgniteCallable<Boolean>() {

        @IgniteInstanceResource
        private Ignite ig;

        @Override
        public Boolean call() throws Exception {
            return ig.active();
        }
    });
}
Also used : IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) Ignite(org.apache.ignite.Ignite) IgniteCompute(org.apache.ignite.IgniteCompute) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) ClusterGroupAdapter(org.apache.ignite.internal.cluster.ClusterGroupAdapter)

Example 2 with ClusterGroupAdapter

use of org.apache.ignite.internal.cluster.ClusterGroupAdapter in project ignite by apache.

the class GridClusterStateProcessor method sendComputeChangeGlobalState.

/**
 * @param activate New cluster state.
 * @param resFut State change future.
 */
private void sendComputeChangeGlobalState(boolean activate, BaselineTopology blt, boolean forceBlt, final GridFutureAdapter<Void> resFut) {
    AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
    if (log.isInfoEnabled()) {
        log.info("Sending " + prettyStr(activate) + " request from node [id=" + ctx.localNodeId() + ", topVer=" + topVer + ", client=" + ctx.clientNode() + ", daemon=" + ctx.isDaemon() + "]");
    }
    IgniteCompute comp = ((ClusterGroupAdapter) ctx.cluster().get().forServers()).compute();
    IgniteFuture<Void> fut = comp.runAsync(new ClientChangeGlobalStateComputeRequest(activate, blt, forceBlt));
    fut.listen(new CI1<IgniteFuture>() {

        @Override
        public void apply(IgniteFuture fut) {
            try {
                fut.get();
                resFut.onDone();
            } catch (Exception e) {
                resFut.onDone(e);
            }
        }
    });
}
Also used : AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteFuture(org.apache.ignite.lang.IgniteFuture) IgniteCompute(org.apache.ignite.IgniteCompute) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) ClusterGroupAdapter(org.apache.ignite.internal.cluster.ClusterGroupAdapter)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgniteCompute (org.apache.ignite.IgniteCompute)2 IgniteException (org.apache.ignite.IgniteException)2 ClusterGroupAdapter (org.apache.ignite.internal.cluster.ClusterGroupAdapter)2 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)2 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)2 Ignite (org.apache.ignite.Ignite)1 IgniteFuture (org.apache.ignite.lang.IgniteFuture)1 IgniteInstanceResource (org.apache.ignite.resources.IgniteInstanceResource)1