Search in sources :

Example 11 with ClusterState

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

the class GridClusterStateProcessor method onLocalJoin.

/**
 * {@inheritDoc}
 */
@Override
@Nullable
public IgniteInternalFuture<Boolean> onLocalJoin(DiscoCache discoCache) {
    final DiscoveryDataClusterState state = globalState;
    if (state.state().active())
        checkLocalNodeInBaseline(state.baselineTopology());
    if (state.transition()) {
        joinFut = new TransitionOnJoinWaitFuture(state, discoCache);
        return joinFut;
    } else {
        ClusterState targetState = ctx.config().getClusterStateOnStart();
        if (targetState == null)
            targetState = ctx.config().isAutoActivationEnabled() ? ACTIVE : INACTIVE;
        boolean serverNode = !ctx.clientNode() && !ctx.isDaemon();
        boolean activation = !state.state().active() && targetState.active();
        if (serverNode && activation && !inMemoryMode) {
            if (isBaselineSatisfied(state.baselineTopology(), discoCache.serverNodes()))
                changeGlobalState(targetState, true, state.baselineTopology().currentBaseline(), false);
        }
    }
    return null;
}
Also used : ClusterState(org.apache.ignite.cluster.ClusterState) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with ClusterState

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

the class GridJettyRestHandler method createRequest.

/**
 * Creates REST request.
 *
 * @param cmd Command.
 * @param params Parameters.
 * @param req Servlet request.
 * @return REST request.
 * @throws IgniteCheckedException If creation failed.
 */
@Nullable
private GridRestRequest createRequest(GridRestCommand cmd, Map<String, String> params, HttpServletRequest req) throws IgniteCheckedException {
    GridRestRequest restReq;
    switch(cmd) {
        case GET_OR_CREATE_CACHE:
            {
                GridRestCacheRequest restReq0 = new GridRestCacheRequest();
                restReq0.cacheName(params.get(CACHE_NAME_PARAM));
                String templateName = params.get(TEMPLATE_NAME_PARAM);
                if (!F.isEmpty(templateName))
                    restReq0.templateName(templateName);
                String backups = params.get(BACKUPS_PARAM);
                CacheConfigurationOverride cfg = new CacheConfigurationOverride();
                // Set cache backups.
                if (!F.isEmpty(backups)) {
                    try {
                        cfg.backups(Integer.parseInt(backups));
                    } catch (NumberFormatException e) {
                        throw new IgniteCheckedException("Failed to parse number of cache backups: " + backups, e);
                    }
                }
                // Set cache group name.
                String cacheGrp = params.get(CACHE_GROUP_PARAM);
                if (!F.isEmpty(cacheGrp))
                    cfg.cacheGroup(cacheGrp);
                // Set cache data region name.
                String dataRegion = params.get(DATA_REGION_PARAM);
                if (!F.isEmpty(dataRegion))
                    cfg.dataRegion(dataRegion);
                // Set cache write mode.
                String wrtSyncMode = params.get(WRITE_SYNCHRONIZATION_MODE_PARAM);
                if (!F.isEmpty(wrtSyncMode)) {
                    try {
                        cfg.writeSynchronizationMode(CacheWriteSynchronizationMode.valueOf(wrtSyncMode));
                    } catch (IllegalArgumentException e) {
                        throw new IgniteCheckedException("Failed to parse cache write synchronization mode: " + wrtSyncMode, e);
                    }
                }
                if (!cfg.isEmpty())
                    restReq0.configuration(cfg);
                restReq = restReq0;
                break;
            }
        case DESTROY_CACHE:
            {
                GridRestCacheRequest restReq0 = new GridRestCacheRequest();
                restReq0.cacheName(params.get(CACHE_NAME_PARAM));
                restReq = restReq0;
                break;
            }
        case ATOMIC_DECREMENT:
        case ATOMIC_INCREMENT:
            {
                DataStructuresRequest restReq0 = new DataStructuresRequest();
                restReq0.key(params.get("key"));
                restReq0.initial(longValue("init", params, null));
                restReq0.delta(longValue("delta", params, null));
                restReq = restReq0;
                break;
            }
        case CACHE_CONTAINS_KEY:
        case CACHE_CONTAINS_KEYS:
        case CACHE_GET:
        case CACHE_GET_ALL:
        case CACHE_GET_AND_PUT:
        case CACHE_GET_AND_REPLACE:
        case CACHE_PUT_IF_ABSENT:
        case CACHE_GET_AND_PUT_IF_ABSENT:
        case CACHE_PUT:
        case CACHE_PUT_ALL:
        case CACHE_REMOVE:
        case CACHE_REMOVE_VALUE:
        case CACHE_REPLACE_VALUE:
        case CACHE_GET_AND_REMOVE:
        case CACHE_REMOVE_ALL:
        case CACHE_CLEAR:
        case CACHE_ADD:
        case CACHE_CAS:
        case CACHE_METRICS:
        case CACHE_SIZE:
        case CACHE_UPDATE_TLL:
        case CACHE_METADATA:
        case CACHE_REPLACE:
        case CACHE_APPEND:
        case CACHE_PREPEND:
            {
                GridRestCacheRequest restReq0 = new GridRestCacheRequest();
                String cacheName = params.get(CACHE_NAME_PARAM);
                restReq0.cacheName(F.isEmpty(cacheName) ? null : cacheName);
                String keyType = params.get("keyType");
                String valType = params.get("valueType");
                Converter converter = new Converter(cacheName);
                restReq0.key(converter.convert(keyType, params.get("key")));
                restReq0.value(converter.convert(valType, params.get("val")));
                restReq0.value2(converter.convert(valType, params.get("val2")));
                Object val1 = converter.convert(valType, params.get("val1"));
                if (val1 != null)
                    restReq0.value(val1);
                // Cache operations via REST will use binary objects.
                restReq0.cacheFlags(intValue("cacheFlags", params, KEEP_BINARIES_MASK));
                restReq0.ttl(longValue("exp", params, null));
                if (cmd == CACHE_GET_ALL || cmd == CACHE_PUT_ALL || cmd == CACHE_REMOVE_ALL || cmd == CACHE_CONTAINS_KEYS) {
                    List<Object> keys = converter.values(keyType, "k", params);
                    List<Object> vals = converter.values(valType, "v", params);
                    if (keys.size() < vals.size())
                        throw new IgniteCheckedException("Number of keys must be greater or equals to number of values.");
                    Map<Object, Object> map = U.newHashMap(keys.size());
                    Iterator<Object> keyIt = keys.iterator();
                    Iterator<Object> valIt = vals.iterator();
                    while (keyIt.hasNext()) map.put(keyIt.next(), valIt.hasNext() ? valIt.next() : null);
                    restReq0.values(map);
                }
                restReq = restReq0;
                break;
            }
        case TOPOLOGY:
        case NODE:
            {
                GridRestTopologyRequest restReq0 = new GridRestTopologyRequest();
                restReq0.includeMetrics(Boolean.parseBoolean(params.get("mtr")));
                restReq0.includeAttributes(Boolean.parseBoolean(params.get("attr")));
                String caches = params.get("caches");
                restReq0.includeCaches(caches == null || Boolean.parseBoolean(caches));
                restReq0.nodeIp(params.get("ip"));
                restReq0.nodeId(uuidValue("id", params));
                restReq = restReq0;
                break;
            }
        case EXE:
        case RESULT:
        case NOOP:
            {
                GridRestTaskRequest restReq0 = new GridRestTaskRequest();
                restReq0.taskId(params.get("id"));
                restReq0.taskName(params.get("name"));
                restReq0.params(new Converter().values(null, "p", params));
                restReq0.async(Boolean.parseBoolean(params.get("async")));
                restReq0.timeout(longValue("timeout", params, 0L));
                restReq = restReq0;
                break;
            }
        case LOG:
            {
                GridRestLogRequest restReq0 = new GridRestLogRequest();
                restReq0.path(params.get("path"));
                restReq0.from(intValue("from", params, -1));
                restReq0.to(intValue("to", params, -1));
                restReq = restReq0;
                break;
            }
        case DATA_REGION_METRICS:
        case DATA_STORAGE_METRICS:
        case NAME:
        case VERSION:
        case PROBE:
            {
                restReq = new GridRestRequest();
                break;
            }
        case CLUSTER_ACTIVE:
        case CLUSTER_INACTIVE:
        case CLUSTER_ACTIVATE:
        case CLUSTER_DEACTIVATE:
        case CLUSTER_CURRENT_STATE:
            {
                GridRestChangeStateRequest restReq0 = new GridRestChangeStateRequest();
                if (cmd == CLUSTER_CURRENT_STATE)
                    restReq0.reqCurrentState();
                else if (cmd == CLUSTER_ACTIVE || cmd == CLUSTER_ACTIVATE)
                    restReq0.active(true);
                else
                    restReq0.active(false);
                restReq0.forceDeactivation(booleanValue(GridRestClusterStateRequest.ARG_FORCE, params, false));
                restReq = restReq0;
                break;
            }
        case CLUSTER_STATE:
        case CLUSTER_SET_STATE:
            {
                GridRestClusterStateRequest restReq0 = new GridRestClusterStateRequest();
                if (cmd == CLUSTER_STATE)
                    restReq0.reqCurrentMode();
                else {
                    ClusterState newState = enumValue("state", params, ClusterState.class);
                    restReq0.state(newState);
                    restReq0.forceDeactivation(booleanValue(GridRestClusterStateRequest.ARG_FORCE, params, false));
                }
                restReq = restReq0;
                break;
            }
        case CLUSTER_NAME:
            {
                restReq = new GridRestClusterNameRequest();
                break;
            }
        case BASELINE_CURRENT_STATE:
        case BASELINE_SET:
        case BASELINE_ADD:
        case BASELINE_REMOVE:
            {
                GridRestBaselineRequest restReq0 = new GridRestBaselineRequest();
                restReq0.topologyVersion(longValue("topVer", params, null));
                restReq0.consistentIds(new Converter().values(null, "consistentId", params));
                restReq = restReq0;
                break;
            }
        case AUTHENTICATE:
            {
                restReq = new GridRestRequest();
                break;
            }
        case ADD_USER:
        case REMOVE_USER:
        case UPDATE_USER:
            {
                RestUserActionRequest restReq0 = new RestUserActionRequest();
                restReq0.user(params.get("user"));
                restReq0.password(params.get("password"));
                restReq = restReq0;
                break;
            }
        case EXECUTE_SQL_QUERY:
        case EXECUTE_SQL_FIELDS_QUERY:
            {
                RestQueryRequest restReq0 = new RestQueryRequest();
                String cacheName = params.get(CACHE_NAME_PARAM);
                restReq0.sqlQuery(params.get("qry"));
                restReq0.arguments(new Converter(cacheName).values(null, "arg", params).toArray());
                restReq0.typeName(params.get("type"));
                String pageSize = params.get("pageSize");
                if (pageSize != null)
                    restReq0.pageSize(Integer.parseInt(pageSize));
                String keepBinary = params.get("keepBinary");
                if (keepBinary != null)
                    restReq0.keepBinary(Boolean.parseBoolean(keepBinary));
                String distributedJoins = params.get("distributedJoins");
                if (distributedJoins != null)
                    restReq0.distributedJoins(Boolean.parseBoolean(distributedJoins));
                restReq0.cacheName(cacheName);
                if (cmd == EXECUTE_SQL_QUERY)
                    restReq0.queryType(RestQueryRequest.QueryType.SQL);
                else
                    restReq0.queryType(RestQueryRequest.QueryType.SQL_FIELDS);
                restReq = restReq0;
                break;
            }
        case EXECUTE_SCAN_QUERY:
            {
                RestQueryRequest restReq0 = new RestQueryRequest();
                restReq0.sqlQuery(params.get("qry"));
                String pageSize = params.get("pageSize");
                if (pageSize != null)
                    restReq0.pageSize(Integer.parseInt(pageSize));
                restReq0.cacheName(params.get(CACHE_NAME_PARAM));
                restReq0.className(params.get("className"));
                restReq0.queryType(RestQueryRequest.QueryType.SCAN);
                restReq = restReq0;
                break;
            }
        case FETCH_SQL_QUERY:
            {
                RestQueryRequest restReq0 = new RestQueryRequest();
                String qryId = params.get("qryId");
                if (qryId != null)
                    restReq0.queryId(Long.parseLong(qryId));
                String pageSize = params.get("pageSize");
                if (pageSize != null)
                    restReq0.pageSize(Integer.parseInt(pageSize));
                restReq0.cacheName(params.get(CACHE_NAME_PARAM));
                restReq = restReq0;
                break;
            }
        case CLOSE_SQL_QUERY:
            {
                RestQueryRequest restReq0 = new RestQueryRequest();
                String qryId = params.get("qryId");
                if (qryId != null)
                    restReq0.queryId(Long.parseLong(qryId));
                restReq0.cacheName(params.get(CACHE_NAME_PARAM));
                restReq = restReq0;
                break;
            }
        case NODE_STATE_BEFORE_START:
            {
                restReq = new GridRestNodeStateBeforeStartRequest();
                break;
            }
        case WARM_UP:
            {
                GridRestWarmUpRequest restReq0 = new GridRestWarmUpRequest();
                restReq0.stopWarmUp(Boolean.parseBoolean(String.valueOf(params.get("stopWarmUp"))));
                restReq = restReq0;
                break;
            }
        default:
            throw new IgniteCheckedException("Invalid command: " + cmd);
    }
    restReq.address(new InetSocketAddress(req.getRemoteAddr(), req.getRemotePort()));
    restReq.command(cmd);
    Object certs = req.getAttribute("javax.servlet.request.X509Certificate");
    if (certs instanceof X509Certificate[])
        restReq.certificates((X509Certificate[]) certs);
    // TODO: In IGNITE 3.0 we should check credentials only for AUTHENTICATE command.
    if (!credentials(params, IGNITE_LOGIN, IGNITE_PASSWORD, restReq))
        credentials(params, USER_PARAM, PWD_PARAM, restReq);
    String clientId = params.get("clientId");
    try {
        if (clientId != null)
            restReq.clientId(UUID.fromString(clientId));
    } catch (Exception ignored) {
    // Ignore invalid client id. Rest handler will process this logic.
    }
    String destId = params.get("destId");
    try {
        if (destId != null)
            restReq.destinationId(UUID.fromString(destId));
    } catch (IllegalArgumentException ignored) {
    // Don't fail - try to execute locally.
    }
    String sesTokStr = params.get("sessionToken");
    try {
        if (sesTokStr != null) {
            // Token is a UUID encoded as 16 bytes as HEX.
            byte[] bytes = U.hexString2ByteArray(sesTokStr);
            if (bytes.length == 16)
                restReq.sessionToken(bytes);
        }
    } catch (IllegalArgumentException ignored) {
    // Ignore invalid session token.
    }
    return restReq;
}
Also used : GridRestClusterStateRequest(org.apache.ignite.internal.processors.rest.request.GridRestClusterStateRequest) GridRestTopologyRequest(org.apache.ignite.internal.processors.rest.request.GridRestTopologyRequest) InetSocketAddress(java.net.InetSocketAddress) GridRestLogRequest(org.apache.ignite.internal.processors.rest.request.GridRestLogRequest) GridRestCacheRequest(org.apache.ignite.internal.processors.rest.request.GridRestCacheRequest) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridRestTaskRequest(org.apache.ignite.internal.processors.rest.request.GridRestTaskRequest) RestQueryRequest(org.apache.ignite.internal.processors.rest.request.RestQueryRequest) Iterator(java.util.Iterator) DataStructuresRequest(org.apache.ignite.internal.processors.rest.request.DataStructuresRequest) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) GridRestRequest(org.apache.ignite.internal.processors.rest.request.GridRestRequest) ClusterState(org.apache.ignite.cluster.ClusterState) GridRestClusterNameRequest(org.apache.ignite.internal.processors.rest.request.GridRestClusterNameRequest) CacheConfigurationOverride(org.apache.ignite.internal.processors.cache.CacheConfigurationOverride) GridRestBaselineRequest(org.apache.ignite.internal.processors.rest.request.GridRestBaselineRequest) GridRestNodeStateBeforeStartRequest(org.apache.ignite.internal.processors.rest.request.GridRestNodeStateBeforeStartRequest) GridRestWarmUpRequest(org.apache.ignite.internal.processors.rest.request.GridRestWarmUpRequest) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) RestUserActionRequest(org.apache.ignite.internal.processors.rest.request.RestUserActionRequest) GridRestChangeStateRequest(org.apache.ignite.internal.processors.rest.request.GridRestChangeStateRequest) BinaryObject(org.apache.ignite.binary.BinaryObject) Map(java.util.Map) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with ClusterState

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

the class IgniteMXBeanImpl method clusterState.

/**
 * {@inheritDoc}
 */
@Override
public void clusterState(String state, boolean forceDeactivation) {
    ClusterState newState = ClusterState.valueOf(state);
    ctx.gateway().readLock();
    try {
        ctx.state().changeGlobalState(newState, forceDeactivation, ctx.cluster().get().forServers().nodes(), false).get();
    } catch (IgniteCheckedException e) {
        throw U.convertException(e);
    } finally {
        ctx.gateway().readUnlock();
    }
}
Also used : ClusterState(org.apache.ignite.cluster.ClusterState) IgniteCheckedException(org.apache.ignite.IgniteCheckedException)

Example 14 with ClusterState

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

the class GridDiscoveryManager method topologySnapshotMessage.

/**
 * @param clo Wrapper of logger.
 * @param topVer Topology version.
 * @param discoCache Discovery cache.
 * @param evtType Event type.
 * @param evtNode Event node.
 * @param srvNodesNum Server nodes number.
 * @param clientNodesNum Client nodes number.
 * @param totalCpus Total cpu number.
 * @param heap Heap size.
 * @param offheap Offheap size.
 * @param needNodesDetails Flag for additional alive nodes logging.
 */
private void topologySnapshotMessage(IgniteClosure<String, Void> clo, long topVer, DiscoCache discoCache, int evtType, ClusterNode evtNode, int srvNodesNum, int clientNodesNum, int totalCpus, double heap, double offheap, boolean needNodesDetails) {
    DiscoveryDataClusterState state = discoCache.state();
    SB summary = new SB(PREFIX);
    summary.a(" [");
    summary.a(discoOrdered ? "ver=" + topVer + ", " : "");
    summary.a("locNode=").a(U.id8(discoCache.localNode().id()));
    summary.a(", servers=").a(srvNodesNum);
    summary.a(", clients=").a(clientNodesNum);
    summary.a(", state=").a(state.active() ? "ACTIVE" : "INACTIVE");
    summary.a(", CPUs=").a(totalCpus);
    summary.a(", offheap=").a(offheap).a("GB");
    summary.a(", heap=").a(heap).a("GB");
    if ((evtType == EVT_NODE_JOINED || evtType == EVT_NODE_LEFT || evtType == EVT_NODE_FAILED) && needNodesDetails) {
        summary.a(", aliveNodes=[");
        for (ClusterNode clusterNode : discoCache.allNodes()) {
            if (discoCache.alive(clusterNode.id()))
                summary.a(nodeDescription(clusterNode)).a(", ");
        }
        summary.setLength(summary.length() - 2);
        summary.a(']');
    }
    summary.a(']');
    clo.apply(summary.toString());
    ClusterNode currCrd = discoCache.oldestServerNode();
    if ((evtType == EventType.EVT_NODE_FAILED || evtType == EventType.EVT_NODE_LEFT) && currCrd != null && currCrd.order() > evtNode.order() && !evtNode.isClient() && !evtNode.isDaemon())
        clo.apply("Coordinator changed [prev=" + evtNode + ", cur=" + currCrd + "]");
    BaselineTopology blt = state.baselineTopology();
    if (blt != null && discoCache.baselineNodes() != null) {
        int bltSize = discoCache.baselineNodes().size();
        int bltOnline = discoCache.aliveBaselineNodes().size();
        int bltOffline = bltSize - bltOnline;
        clo.apply("  ^-- Baseline [id=" + blt.id() + ", size=" + bltSize + ", online=" + bltOnline + ", offline=" + bltOffline + ']');
        ClusterState targetState = ctx.config().getClusterStateOnStart();
        if (targetState == null)
            targetState = ctx.config().isAutoActivationEnabled() ? ACTIVE : INACTIVE;
        if (!state.state().active() && targetState.active()) {
            String offlineConsistentIds = "";
            if (bltOffline > 0 && bltOffline <= 5) {
                Collection<BaselineNode> offlineNodes = new HashSet<>(discoCache.baselineNodes());
                offlineNodes.removeAll(discoCache.aliveBaselineNodes());
                offlineConsistentIds = ' ' + F.nodeConsistentIds(offlineNodes).toString();
            }
            if (bltOffline == 0) {
                if (evtType == EVT_NODE_JOINED && discoCache.baselineNode(evtNode))
                    clo.apply("  ^-- All baseline nodes are online, will start auto-activation");
            } else
                clo.apply("  ^-- " + bltOffline + " nodes left for auto-activation" + offlineConsistentIds);
        }
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) ClusterState(org.apache.ignite.cluster.ClusterState) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) BaselineTopology(org.apache.ignite.internal.processors.cluster.BaselineTopology) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) SB(org.apache.ignite.internal.util.typedef.internal.SB) BaselineNode(org.apache.ignite.cluster.BaselineNode) HashSet(java.util.HashSet)

Example 15 with ClusterState

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

the class GridCachePartitionExchangeManager method onClusterStateChangeFinish.

/**
 */
private void onClusterStateChangeFinish(IgniteInternalFuture<AffinityTopologyVersion> fut, ExchangeActions exchActions, boolean baselineChanging) {
    A.notNull(exchActions, "exchActions");
    GridEventStorageManager evtMngr = cctx.kernalContext().event();
    if (exchActions.activate() && evtMngr.isRecordable(EVT_CLUSTER_ACTIVATED) || exchActions.deactivate() && evtMngr.isRecordable(EVT_CLUSTER_DEACTIVATED) || exchActions.changedClusterState() && evtMngr.isRecordable(EVT_CLUSTER_STATE_CHANGED)) {
        List<Event> evts = new ArrayList<>(2);
        ClusterNode locNode = cctx.kernalContext().discovery().localNode();
        Collection<BaselineNode> bltNodes = cctx.kernalContext().cluster().get().currentBaselineTopology();
        boolean collectionUsed = false;
        if (exchActions.activate() && evtMngr.isRecordable(EVT_CLUSTER_ACTIVATED)) {
            assert !exchActions.deactivate() : exchActions;
            collectionUsed = true;
            evts.add(new ClusterActivationEvent(locNode, "Cluster activated.", EVT_CLUSTER_ACTIVATED, bltNodes));
        }
        if (exchActions.deactivate() && evtMngr.isRecordable(EVT_CLUSTER_DEACTIVATED)) {
            assert !exchActions.activate() : exchActions;
            collectionUsed = true;
            evts.add(new ClusterActivationEvent(locNode, "Cluster deactivated.", EVT_CLUSTER_DEACTIVATED, bltNodes));
        }
        if (exchActions.changedClusterState() && evtMngr.isRecordable(EVT_CLUSTER_STATE_CHANGED)) {
            StateChangeRequest req = exchActions.stateChangeRequest();
            if (collectionUsed && bltNodes != null)
                bltNodes = new ArrayList<>(bltNodes);
            evts.add(new ClusterStateChangeEvent(req.prevState(), req.state(), bltNodes, locNode, "Cluster state changed."));
        }
        A.notEmpty(evts, "events " + exchActions);
        cctx.kernalContext().pools().getSystemExecutorService().submit(() -> evts.forEach(e -> cctx.kernalContext().event().record(e)));
    }
    GridKernalContext ctx = cctx.kernalContext();
    DiscoveryDataClusterState state = ctx.state().clusterState();
    if (baselineChanging) {
        ctx.pools().getStripedExecutorService().execute(new Runnable() {

            @Override
            public void run() {
                if (ctx.event().isRecordable(EventType.EVT_BASELINE_CHANGED)) {
                    ctx.event().record(new BaselineChangedEvent(ctx.discovery().localNode(), "Baseline changed.", EventType.EVT_BASELINE_CHANGED, ctx.cluster().get().currentBaselineTopology()));
                }
            }
        });
    }
}
Also used : GridEventStorageManager(org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager) ClusterNode(org.apache.ignite.cluster.ClusterNode) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) RebalanceFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander.RebalanceFuture) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) GridPartitionStateMap(org.apache.ignite.internal.util.GridPartitionStateMap) GridDhtPartitionsSingleRequest(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleRequest) CachePartitionFullCountersMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionFullCountersMap) Map(java.util.Map) AffinityFunction(org.apache.ignite.cache.affinity.AffinityFunction) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) ClusterActivationEvent(org.apache.ignite.events.ClusterActivationEvent) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) GridStringBuilder(org.apache.ignite.internal.util.GridStringBuilder) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) FinishPreloadingTask(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.FinishPreloadingTask) ClusterGroupEmptyException(org.apache.ignite.cluster.ClusterGroupEmptyException) GridToStringExclude(org.apache.ignite.internal.util.tostring.GridToStringExclude) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Event(org.apache.ignite.events.Event) Set(java.util.Set) ChangeGlobalStateFinishMessage(org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage) TRANSACTION_OWNER_THREAD_DUMP_PROVIDING(org.apache.ignite.internal.IgniteFeatures.TRANSACTION_OWNER_THREAD_DUMP_PROVIDING) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) IGNITE_DIAGNOSTIC_WARN_LIMIT(org.apache.ignite.IgniteSystemProperties.IGNITE_DIAGNOSTIC_WARN_LIMIT) CountDownLatch(java.util.concurrent.CountDownLatch) SnapshotDiscoveryMessage(org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotDiscoveryMessage) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteDhtPartitionsToReloadMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionsToReloadMap) SYSTEM_WORKER_TERMINATION(org.apache.ignite.failure.FailureType.SYSTEM_WORKER_TERMINATION) DiscoveryLocalJoinData(org.apache.ignite.internal.managers.discovery.DiscoveryLocalJoinData) GridDhtPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology) GridListSet(org.apache.ignite.internal.util.GridListSet) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) IgniteCompute(org.apache.ignite.IgniteCompute) IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT(org.apache.ignite.IgniteSystemProperties.IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT) SecurityContext(org.apache.ignite.internal.processors.security.SecurityContext) IgniteThread(org.apache.ignite.thread.IgniteThread) SecurityUtils.remoteSecurityContext(org.apache.ignite.internal.processors.security.SecurityUtils.remoteSecurityContext) ClusterState(org.apache.ignite.cluster.ClusterState) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) U(org.apache.ignite.internal.util.typedef.internal.U) EVT_DISCOVERY_CUSTOM_EVT(org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) IgniteLogger(org.apache.ignite.IgniteLogger) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteBiInClosure(org.apache.ignite.lang.IgniteBiInClosure) ClusterNode(org.apache.ignite.cluster.ClusterNode) CI1(org.apache.ignite.internal.util.typedef.CI1) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) S(org.apache.ignite.internal.util.typedef.internal.S) IgniteDiagnosticAware(org.apache.ignite.internal.IgniteDiagnosticAware) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) GridDhtPartitionFullMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap) IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager) EXCHANGE_FUTURE(org.apache.ignite.internal.processors.tracing.SpanType.EXCHANGE_FUTURE) IGNITE_IO_DUMP_ON_TIMEOUT(org.apache.ignite.IgniteSystemProperties.IGNITE_IO_DUMP_ON_TIMEOUT) A(org.apache.ignite.internal.util.typedef.internal.A) CachePartitionPartialCountersMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionPartialCountersMap) Ignite(org.apache.ignite.Ignite) BaselineNode(org.apache.ignite.cluster.BaselineNode) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) RebalanceReassignExchangeTask(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.RebalanceReassignExchangeTask) T2(org.apache.ignite.internal.util.typedef.T2) NONE(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion.NONE) AtomicLong(java.util.concurrent.atomic.AtomicLong) GridDhtPartitionMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap) ClusterStateChangeEvent(org.apache.ignite.events.ClusterStateChangeEvent) CLUSTER_METRICS(org.apache.ignite.internal.processors.metric.GridMetricManager.CLUSTER_METRICS) GridDhtPartitionsExchangeFuture.nextDumpTimeout(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.nextDumpTimeout) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridDhtPartitionsFullMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) GridDhtPartitionExchangeId(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) DiscoveryCustomEvent(org.apache.ignite.internal.events.DiscoveryCustomEvent) CRITICAL_ERROR(org.apache.ignite.failure.FailureType.CRITICAL_ERROR) SYSTEM_POOL(org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL) GridDhtPartitionSupplyMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage) ExchangeLatchManager(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.latch.ExchangeLatchManager) CacheRebalanceMode(org.apache.ignite.cache.CacheRebalanceMode) GridWorker(org.apache.ignite.internal.util.worker.GridWorker) StopCachesOnClientReconnectExchangeTask(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.StopCachesOnClientReconnectExchangeTask) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) PME_OPS_BLOCKED_DURATION(org.apache.ignite.internal.processors.metric.GridMetricManager.PME_OPS_BLOCKED_DURATION) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BooleanMetricImpl(org.apache.ignite.internal.processors.metric.impl.BooleanMetricImpl) X(org.apache.ignite.internal.util.typedef.X) IgniteDhtPartitionHistorySuppliersMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionHistorySuppliersMap) PME_METRICS(org.apache.ignite.internal.processors.metric.GridMetricManager.PME_METRICS) IgniteFuture(org.apache.ignite.lang.IgniteFuture) SecurityUtils.withRemoteSecurityContext(org.apache.ignite.internal.processors.security.SecurityUtils.withRemoteSecurityContext) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) EventType(org.apache.ignite.events.EventType) OperationSecurityContext(org.apache.ignite.internal.processors.security.OperationSecurityContext) IgniteFeatures.allNodesSupports(org.apache.ignite.internal.IgniteFeatures.allNodesSupports) Collection(java.util.Collection) SpanTags(org.apache.ignite.internal.processors.tracing.SpanTags) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) EVT_CLUSTER_ACTIVATED(org.apache.ignite.events.EventType.EVT_CLUSTER_ACTIVATED) NavigableSet(java.util.NavigableSet) IgniteDiagnosticPrepareContext(org.apache.ignite.internal.IgniteDiagnosticPrepareContext) IgniteNeedReconnectException(org.apache.ignite.internal.IgniteNeedReconnectException) UUID(java.util.UUID) Instant(java.time.Instant) CI2(org.apache.ignite.internal.util.typedef.CI2) Collectors(java.util.stream.Collectors) IGNITE_PRELOAD_RESEND_TIMEOUT(org.apache.ignite.IgniteSystemProperties.IGNITE_PRELOAD_RESEND_TIMEOUT) IgniteSystemProperties.getLong(org.apache.ignite.IgniteSystemProperties.getLong) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) DiscoveryEventListener(org.apache.ignite.internal.managers.eventstorage.DiscoveryEventListener) GridDhtPartitionDemandMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage) TOPIC_CACHE(org.apache.ignite.internal.GridTopic.TOPIC_CACHE) BaselineChangedEvent(org.apache.ignite.events.BaselineChangedEvent) CU(org.apache.ignite.internal.util.typedef.internal.CU) GridDhtPartitionDemandLegacyMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandLegacyMessage) Optional(java.util.Optional) IgniteFutureTimeoutCheckedException(org.apache.ignite.internal.IgniteFutureTimeoutCheckedException) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) NotNull(org.jetbrains.annotations.NotNull) ForceRebalanceExchangeTask(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.ForceRebalanceExchangeTask) PME_DURATION_HISTOGRAM(org.apache.ignite.internal.processors.metric.GridMetricManager.PME_DURATION_HISTOGRAM) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) Span(org.apache.ignite.internal.processors.tracing.Span) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) HashMap(java.util.HashMap) DFLT_PRELOAD_RESEND_TIMEOUT(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader.DFLT_PRELOAD_RESEND_TIMEOUT) DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) AtomicReference(java.util.concurrent.atomic.AtomicReference) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) SchemaNodeLeaveExchangeWorkerTask(org.apache.ignite.internal.processors.query.schema.SchemaNodeLeaveExchangeWorkerTask) GridClientPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridClientPartitionTopology) FailureContext(org.apache.ignite.failure.FailureContext) IgniteUtils(org.apache.ignite.internal.util.IgniteUtils) PME_OPS_BLOCKED_DURATION_HISTOGRAM(org.apache.ignite.internal.processors.metric.GridMetricManager.PME_OPS_BLOCKED_DURATION_HISTOGRAM) F(org.apache.ignite.internal.util.typedef.F) EVT_NODE_JOINED(org.apache.ignite.events.EventType.EVT_NODE_JOINED) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) ReentrantLock(java.util.concurrent.locks.ReentrantLock) EVT_CLUSTER_DEACTIVATED(org.apache.ignite.events.EventType.EVT_CLUSTER_DEACTIVATED) GridTimeoutObject(org.apache.ignite.internal.processors.timeout.GridTimeoutObject) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) GridDhtPartitionsSingleMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage) EVT_CLUSTER_STATE_CHANGED(org.apache.ignite.events.EventType.EVT_CLUSTER_STATE_CHANGED) GridAffinityAssignmentCache(org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache) PARTIAL_COUNTERS_MAP_SINCE(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionPartialCountersMap.PARTIAL_COUNTERS_MAP_SINCE) GridToStringInclude(org.apache.ignite.internal.util.tostring.GridToStringInclude) TimeUnit(java.util.concurrent.TimeUnit) PartitionsExchangeAware(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.PartitionsExchangeAware) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) HistogramMetricImpl(org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl) ChangeGlobalStateMessage(org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) TransactionState(org.apache.ignite.transactions.TransactionState) PME_DURATION(org.apache.ignite.internal.processors.metric.GridMetricManager.PME_DURATION) REBALANCED(org.apache.ignite.internal.processors.metric.GridMetricManager.REBALANCED) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) GridEventStorageManager(org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager) Comparator(java.util.Comparator) Collections(java.util.Collections) GridKernalContext(org.apache.ignite.internal.GridKernalContext) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) ClusterStateChangeEvent(org.apache.ignite.events.ClusterStateChangeEvent) BaselineNode(org.apache.ignite.cluster.BaselineNode) ClusterActivationEvent(org.apache.ignite.events.ClusterActivationEvent) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) ClusterActivationEvent(org.apache.ignite.events.ClusterActivationEvent) Event(org.apache.ignite.events.Event) ClusterStateChangeEvent(org.apache.ignite.events.ClusterStateChangeEvent) DiscoveryCustomEvent(org.apache.ignite.internal.events.DiscoveryCustomEvent) BaselineChangedEvent(org.apache.ignite.events.BaselineChangedEvent) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) BaselineChangedEvent(org.apache.ignite.events.BaselineChangedEvent)

Aggregations

ClusterState (org.apache.ignite.cluster.ClusterState)20 Map (java.util.Map)8 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 IgniteEx (org.apache.ignite.internal.IgniteEx)8 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)7 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)7 Test (org.junit.Test)7 Ignite (org.apache.ignite.Ignite)6 DiscoveryDataClusterState (org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState)6 Collection (java.util.Collection)5 Collections (java.util.Collections)5 HashMap (java.util.HashMap)5 Set (java.util.Set)5 UUID (java.util.UUID)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 F (org.apache.ignite.internal.util.typedef.F)5 List (java.util.List)4 ClusterNode (org.apache.ignite.cluster.ClusterNode)4 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)4 CU (org.apache.ignite.internal.util.typedef.internal.CU)4