Search in sources :

Example 1 with INACTIVE

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

the class SystemViewCommandTest method testPagesList.

/**
 */
@Test
public void testPagesList() throws Exception {
    String cacheName = "cacheFL";
    IgniteCache<Integer, byte[]> cache = ignite0.getOrCreateCache(new CacheConfiguration<Integer, byte[]>().setName(cacheName).setAffinity(new RendezvousAffinityFunction().setPartitions(1)));
    GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) ignite0.context().cache().context().database();
    int pageSize = dbMgr.pageSize();
    try {
        dbMgr.enableCheckpoints(false).get();
        int key = 0;
        // Fill up different free-list buckets.
        for (int j = 0; j < pageSize / 2; j++) cache.put(key++, new byte[j + 1]);
        // Put some pages to one bucket to overflow pages cache.
        for (int j = 0; j < 1000; j++) cache.put(key++, new byte[pageSize / 2]);
        List<List<String>> cacheGrpView = systemView(ignite0, CACHE_GRP_PAGE_LIST_VIEW);
        List<List<String>> dataRegionView = systemView(ignite0, DATA_REGION_PAGE_LIST_VIEW);
        String cacheId = Integer.toString(cacheId(cacheName));
        // Test filtering by 3 columns.
        assertFalse(cacheGrpView.stream().noneMatch(row -> cacheId.equals(row.get(0)) && "0".equals(row.get(1)) && "0".equals(row.get(3))));
        // Test filtering with invalid cache group id.
        assertTrue(cacheGrpView.stream().noneMatch(row -> "-1".equals(row.get(0))));
        // Test filtering with invalid partition id.
        assertTrue(cacheGrpView.stream().noneMatch(row -> "-1".equals(row.get(1))));
        // Test filtering with invalid bucket number.
        assertTrue(cacheGrpView.stream().noneMatch(row -> "-1".equals(row.get(3))));
        assertFalse(cacheGrpView.stream().noneMatch(row -> Integer.parseInt(row.get(4)) > 0 && cacheId.equals(row.get(0))));
        assertFalse(cacheGrpView.stream().noneMatch(row -> Integer.parseInt(row.get(5)) > 0 && cacheId.equals(row.get(0))));
        assertFalse(cacheGrpView.stream().noneMatch(row -> Integer.parseInt(row.get(6)) > 0 && cacheId.equals(row.get(0))));
        assertFalse(dataRegionView.stream().noneMatch(row -> row.get(0).startsWith(DATA_REGION_NAME)));
        assertTrue(dataRegionView.stream().noneMatch(row -> row.get(0).startsWith(DATA_REGION_NAME) && Integer.parseInt(row.get(4)) > 0));
    } finally {
        dbMgr.enableCheckpoints(true).get();
    }
    ignite0.cluster().state(INACTIVE);
    ignite0.cluster().state(ACTIVE);
    IgniteCache<Integer, Integer> cacheInMemory = ignite0.getOrCreateCache(new CacheConfiguration<Integer, Integer>().setName("cacheFLInMemory").setDataRegionName(DATA_REGION_NAME));
    cacheInMemory.put(0, 0);
    // After activation/deactivation new view for data region pages lists should be created, check that new view
    // correctly reflects changes in free-lists.
    assertTrue(systemView(ignite0, DATA_REGION_PAGE_LIST_VIEW).stream().noneMatch(row -> row.get(0).startsWith(DATA_REGION_NAME) && Integer.parseInt(row.get(4)) > 0));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Arrays(java.util.Arrays) GridCacheUtils.cacheId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId) MAX_VALUE(java.lang.Integer.MAX_VALUE) TestObjectEnum(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectEnum) EXIT_CODE_INVALID_ARGUMENTS(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_INVALID_ARGUMENTS) Arrays.asList(java.util.Arrays.asList) PART_STATES_VIEW(org.apache.ignite.internal.processors.cache.GridCacheProcessor.PART_STATES_VIEW) SQL_TBLS_VIEW(org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_TBLS_VIEW) IgniteUtils.toStringSafe(org.apache.ignite.internal.util.IgniteUtils.toStringSafe) TestAffinityFunction(org.apache.ignite.internal.processors.cache.metric.SqlViewExporterSpiTest.TestAffinityFunction) INACTIVE(org.apache.ignite.cluster.ClusterState.INACTIVE) SystemView(org.apache.ignite.spi.systemview.view.SystemView) Set(java.util.Set) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) IgniteCache(org.apache.ignite.IgniteCache) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TEST_TRANSFORMER(org.apache.ignite.internal.metric.SystemViewSelfTest.TEST_TRANSFORMER) QueryCursor(org.apache.ignite.cache.query.QueryCursor) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) ScanQuery(org.apache.ignite.cache.query.ScanQuery) U(org.apache.ignite.internal.util.typedef.internal.U) EXIT_CODE_OK(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK) BINARY_METADATA_VIEW(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.BINARY_METADATA_VIEW) ArrayList(java.util.ArrayList) COLUMN_SEPARATOR(org.apache.ignite.internal.commandline.systemview.SystemViewCommand.COLUMN_SEPARATOR) DISTRIBUTED_METASTORE_VIEW(org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageImpl.DISTRIBUTED_METASTORE_VIEW) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) IgniteClient(org.apache.ignite.client.IgniteClient) AbstractSchemaSelfTest.queryProcessor(org.apache.ignite.internal.processors.cache.index.AbstractSchemaSelfTest.queryProcessor) TEST_PREDICATE(org.apache.ignite.internal.metric.SystemViewSelfTest.TEST_PREDICATE) SQL_SCHEMA_VIEW(org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_SCHEMA_VIEW) TestTransformer(org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer) STREAM_POOL_QUEUE_VIEW(org.apache.ignite.internal.processors.pool.PoolProcessor.STREAM_POOL_QUEUE_VIEW) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) TASKS_VIEW(org.apache.ignite.internal.processors.task.GridTaskProcessor.TASKS_VIEW) Properties(java.util.Properties) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) Field(java.lang.reflect.Field) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) SCAN_QRY_SYS_VIEW(org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW) TRANSACTIONAL(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL) NODE_ID(org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) SQL_VIEW_COLS_VIEW(org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_VIEW_COLS_VIEW) SNAPSHOT_SYS_VIEW(org.apache.ignite.spi.systemview.view.SnapshotView.SNAPSHOT_SYS_VIEW) SYSTEM_VIEW(org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW) CQ_SYS_VIEW(org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.CQ_SYS_VIEW) CacheMode(org.apache.ignite.cache.CacheMode) IgniteJdbcThinDriver(org.apache.ignite.IgniteJdbcThinDriver) StripedExecutor(org.apache.ignite.internal.util.StripedExecutor) DATA_REGION_PAGE_LIST_VIEW(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager.DATA_REGION_PAGE_LIST_VIEW) Connection(java.sql.Connection) SERIALIZABLE(org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE) SQL_TBL_COLS_VIEW(org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_TBL_COLS_VIEW) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) Transaction(org.apache.ignite.transactions.Transaction) CACHE_GRP_PAGE_LIST_VIEW(org.apache.ignite.internal.processors.cache.GridCacheProcessor.CACHE_GRP_PAGE_LIST_VIEW) IgniteEx(org.apache.ignite.internal.IgniteEx) METASTORE_VIEW(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.METASTORE_VIEW) REPEATABLE_READ(org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) SystemViewCommandArg(org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridDhtPartitionState(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState) SVCS_VIEW(org.apache.ignite.internal.processors.service.IgniteServiceProcessor.SVCS_VIEW) CLI_CONN_VIEW(org.apache.ignite.internal.processors.odbc.ClientListenerProcessor.CLI_CONN_VIEW) SCHEMA_SYS(org.apache.ignite.internal.processors.query.QueryUtils.SCHEMA_SYS) OPTIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC) UUID(java.util.UUID) CommandList(org.apache.ignite.internal.commandline.CommandList) Collectors(java.util.stream.Collectors) VisorSystemViewTask(org.apache.ignite.internal.visor.systemview.VisorSystemViewTask) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Objects(java.util.Objects) List(java.util.List) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) DFLT_SCHEMA(org.apache.ignite.internal.processors.query.QueryUtils.DFLT_SCHEMA) DummyService(org.apache.ignite.internal.processors.service.DummyService) GridCacheUtils.cacheGroupId(org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheGroupId) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) CACHES_VIEW(org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHES_VIEW) HashSet(java.util.HashSet) SYS_POOL_QUEUE_VIEW(org.apache.ignite.internal.processors.pool.PoolProcessor.SYS_POOL_QUEUE_VIEW) AttributeVisitor(org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker.AttributeVisitor) Pattern.quote(java.util.regex.Pattern.quote) TestRunnable(org.apache.ignite.internal.metric.SystemViewSelfTest.TestRunnable) SQL_VIEWS_VIEW(org.apache.ignite.internal.processors.query.h2.SchemaManager.SQL_VIEWS_VIEW) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) MetricUtils.toSqlName(org.apache.ignite.internal.processors.metric.impl.MetricUtils.toSqlName) SqlConfiguration(org.apache.ignite.configuration.SqlConfiguration) TestPredicate(org.apache.ignite.internal.metric.SystemViewSelfTest.TestPredicate) TXS_MON_LIST(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.TXS_MON_LIST) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) CACHE_GRPS_VIEW(org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHE_GRPS_VIEW) TestObjectAllTypes(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses.TestObjectAllTypes) GridTestUtils.assertContains(org.apache.ignite.testframework.GridTestUtils.assertContains) Consumer(java.util.function.Consumer) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) Ignition(org.apache.ignite.Ignition) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) CommandList(org.apache.ignite.internal.commandline.CommandList) List(java.util.List) Test(org.junit.Test)

Example 2 with INACTIVE

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

the class IgniteClusterImpl method validateBeforeBaselineChange.

/**
 * Executes validation checks of cluster state and BaselineTopology before changing BaselineTopology to new one.
 */
private void validateBeforeBaselineChange(Collection<? extends BaselineNode> baselineTop) {
    verifyBaselineTopologySupport(ctx.discovery().discoCache());
    if (!ctx.state().clusterState().active())
        throw new IgniteException("Changing BaselineTopology on inactive cluster is not allowed.");
    if (baselineTop != null) {
        if (baselineTop.isEmpty())
            throw new IgniteException("BaselineTopology must contain at least one node.");
        List<BaselineNode> currBlT = Optional.ofNullable(ctx.state().clusterState().baselineTopology()).map(BaselineTopology::currentBaseline).orElse(Collections.emptyList());
        Collection<ClusterNode> srvrs = ctx.cluster().get().forServers().nodes();
        for (BaselineNode node : baselineTop) {
            Object consistentId = node.consistentId();
            if (currBlT.stream().noneMatch(currBlTNode -> Objects.equals(currBlTNode.consistentId(), consistentId)) && srvrs.stream().noneMatch(currServersNode -> Objects.equals(currServersNode.consistentId(), consistentId)))
                throw new IgniteException("Check arguments. Node with consistent ID [" + consistentId + "] not found in server nodes.");
        }
        Collection<Object> onlineNodes = onlineBaselineNodesRequestedForRemoval(baselineTop);
        if (onlineNodes != null) {
            if (!onlineNodes.isEmpty())
                throw new IgniteException("Removing online nodes from BaselineTopology is not supported: " + onlineNodes);
        }
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) ATTR_MACS(org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS) ObjectOutput(java.io.ObjectOutput) InetAddress(java.net.InetAddress) SB(org.apache.ignite.internal.util.typedef.internal.SB) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteCluster(org.apache.ignite.IgniteCluster) Map(java.util.Map) BaselineTopology(org.apache.ignite.internal.processors.cluster.BaselineTopology) StartNodeCallable(org.apache.ignite.internal.util.nodestart.StartNodeCallable) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) IgniteFuture(org.apache.ignite.lang.IgniteFuture) INACTIVE(org.apache.ignite.cluster.ClusterState.INACTIVE) IgniteNodeStartUtils.parseFile(org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils.parseFile) Externalizable(java.io.Externalizable) ClusterGroupEmptyException(org.apache.ignite.cluster.ClusterGroupEmptyException) GridToStringExclude(org.apache.ignite.internal.util.tostring.GridToStringExclude) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) Set(java.util.Set) UUID(java.util.UUID) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BaselineAutoAdjustStatus(org.apache.ignite.internal.processors.cluster.baseline.autoadjust.BaselineAutoAdjustStatus) CU(org.apache.ignite.internal.util.typedef.internal.CU) Optional(java.util.Optional) ObjectInput(java.io.ObjectInput) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) ShutdownPolicy(org.apache.ignite.ShutdownPolicy) IgniteFutureImpl(org.apache.ignite.internal.util.future.IgniteFutureImpl) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) DistributedEnumProperty(org.apache.ignite.internal.processors.configuration.distributed.DistributedEnumProperty) ClusterState(org.apache.ignite.cluster.ClusterState) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) U(org.apache.ignite.internal.util.typedef.internal.U) HashMap(java.util.HashMap) IgniteLogger(org.apache.ignite.IgniteLogger) DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) GridKernalContext(org.apache.ignite.internal.GridKernalContext) ClusterNode(org.apache.ignite.cluster.ClusterNode) CI1(org.apache.ignite.internal.util.typedef.CI1) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) IgniteComponentType(org.apache.ignite.internal.IgniteComponentType) ClusterStartNodeResult(org.apache.ignite.cluster.ClusterStartNodeResult) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) F(org.apache.ignite.internal.util.typedef.F) ATTR_IPS(org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IPS) A(org.apache.ignite.internal.util.typedef.internal.A) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) BaselineNode(org.apache.ignite.cluster.BaselineNode) File(java.io.File) ObjectStreamException(java.io.ObjectStreamException) IgniteSshHelper(org.apache.ignite.internal.util.nodestart.IgniteSshHelper) IgniteRemoteStartSpecification(org.apache.ignite.internal.util.nodestart.IgniteRemoteStartSpecification) Collections(java.util.Collections) IgniteNodeStartUtils.specifications(org.apache.ignite.internal.util.nodestart.IgniteNodeStartUtils.specifications) IgniteException(org.apache.ignite.IgniteException) BaselineNode(org.apache.ignite.cluster.BaselineNode)

Example 3 with INACTIVE

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

the class GridCommandHandlerTest method testBaselineAddOnNotActiveCluster.

/**
 * Test baseline add items works via control.sh
 *
 * @throws Exception If failed.
 */
@Test
public void testBaselineAddOnNotActiveCluster() throws Exception {
    Ignite ignite = startGrid(1);
    assertFalse(ignite.cluster().active());
    String consistentIDs = getTestIgniteInstanceName(1);
    injectTestSystemOut();
    assertEquals(EXIT_CODE_UNEXPECTED_ERROR, execute("--baseline", "add", consistentIDs));
    assertContains(log, testOut.toString(), "Changing BaselineTopology on inactive cluster is not allowed.");
    consistentIDs = getTestIgniteInstanceName(1) + ", " + getTestIgniteInstanceName(2) + "," + getTestIgniteInstanceName(3);
    assertEquals(EXIT_CODE_INVALID_ARGUMENTS, execute("--baseline", "add", consistentIDs));
    String testOutStr = testOut.toString();
    // Ignite instase 1 can be logged only in arguments list.
    boolean isInstanse1Found = Arrays.stream(testOutStr.split("\n")).filter(s -> s.contains("Arguments:")).noneMatch(s -> s.contains(getTestIgniteInstanceName() + "1"));
    assertTrue(testOutStr, testOutStr.contains("Node not found for consistent ID:"));
    assertFalse(testOutStr, isInstanse1Found);
}
Also used : RandomAccessFile(java.io.RandomAccessFile) BlockedWarmUpConfiguration(org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpConfiguration) Arrays(java.util.Arrays) GridCacheMvccCandidate(org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) UnaryOperator(java.util.function.UnaryOperator) GridConcurrentHashSet(org.apache.ignite.internal.client.util.GridConcurrentHashSet) EntryProcessor(javax.cache.processor.EntryProcessor) BooleanSupplier(java.util.function.BooleanSupplier) GridFunc(org.apache.ignite.internal.util.lang.GridFunc) GridTestUtils.runAsync(org.apache.ignite.testframework.GridTestUtils.runAsync) FileIO(org.apache.ignite.internal.processors.cache.persistence.file.FileIO) REENCRYPTION_RESUME(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.REENCRYPTION_RESUME) Matcher(java.util.regex.Matcher) EXIT_CODE_INVALID_ARGUMENTS(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_INVALID_ARGUMENTS) Map(java.util.Map) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) Path(java.nio.file.Path) GridDhtTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest) VisorTxInfo(org.apache.ignite.internal.visor.tx.VisorTxInfo) IgniteCacheGroupsWithRestartsTest(org.apache.ignite.internal.processors.cache.persistence.db.IgniteCacheGroupsWithRestartsTest) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) INACTIVE(org.apache.ignite.cluster.ClusterState.INACTIVE) GridClientFactory(org.apache.ignite.internal.client.GridClientFactory) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) VisorFindAndDeleteGarbageInPersistenceTaskResult(org.apache.ignite.internal.visor.cache.VisorFindAndDeleteGarbageInPersistenceTaskResult) Set(java.util.Set) ChangeGlobalStateFinishMessage(org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage) READ_COMMITTED(org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED) MASTER_KEY_NAME_2(org.apache.ignite.internal.encryption.AbstractEncryptionTest.MASTER_KEY_NAME_2) IgniteCache(org.apache.ignite.IgniteCache) EXIT_CODE_CONNECTION_FAILED(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_CONNECTION_FAILED) Serializable(java.io.Serializable) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) READ_ONLY_SAFE(org.apache.ignite.cache.PartitionLossPolicy.READ_ONLY_SAFE) REENCRYPTION_SUSPEND(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.REENCRYPTION_SUSPEND) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) GridClientImpl(org.apache.ignite.internal.client.impl.GridClientImpl) GridClusterStateProcessor(org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor) Message(org.apache.ignite.plugin.extensions.communication.Message) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) ClusterState(org.apache.ignite.cluster.ClusterState) U(org.apache.ignite.internal.util.typedef.internal.U) CACHE_GROUP_KEY_IDS(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.CACHE_GROUP_KEY_IDS) EntryProcessorException(javax.cache.processor.EntryProcessorException) EXIT_CODE_OK(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) REENCRYPTION_RATE(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.REENCRYPTION_RATE) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) ClusterNode(org.apache.ignite.cluster.ClusterNode) BlockedWarmUpStrategy(org.apache.ignite.internal.processors.cache.warmup.BlockedWarmUpStrategy) ACTIVE_READ_ONLY(org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) REENCRYPTION_STATUS(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.REENCRYPTION_STATUS) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) DEFAULT_TARGET_FOLDER(org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor.DEFAULT_TARGET_FOLDER) Files(java.nio.file.Files) IOException(java.io.IOException) IgniteSnapshotManager(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager) VisorTxTaskResult(org.apache.ignite.internal.visor.tx.VisorTxTaskResult) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) Field(java.lang.reflect.Field) BaselineNode(org.apache.ignite.cluster.BaselineNode) File(java.io.File) TRANSACTIONAL(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL) IgniteTxEntry(org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry) GridNearLockResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) AtomicLong(java.util.concurrent.atomic.AtomicLong) TransactionRollbackException(org.apache.ignite.transactions.TransactionRollbackException) TreeMap(java.util.TreeMap) Paths(java.nio.file.Paths) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) IgniteDataStreamer(org.apache.ignite.IgniteDataStreamer) LongMetric(org.apache.ignite.spi.metric.LongMetric) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence) CheckpointState(org.apache.ignite.internal.processors.cache.persistence.CheckpointState) GridNearTxFinishRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest) SNAPSHOT_METRICS(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNAPSHOT_METRICS) IgniteNodeAttributes(org.apache.ignite.internal.IgniteNodeAttributes) Transaction(org.apache.ignite.transactions.Transaction) CONFIRM_MSG(org.apache.ignite.internal.commandline.CommandHandler.CONFIRM_MSG) GridTestUtils.assertThrows(org.apache.ignite.testframework.GridTestUtils.assertThrows) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) MutableEntry(javax.cache.processor.MutableEntry) CHANGE_CACHE_GROUP_KEY(org.apache.ignite.internal.commandline.encryption.EncryptionSubcommands.CHANGE_CACHE_GROUP_KEY) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) X(org.apache.ignite.internal.util.typedef.X) PARTITIONED(org.apache.ignite.cache.CacheMode.PARTITIONED) TestStorageUtils.corruptDataEntry(org.apache.ignite.util.TestStorageUtils.corruptDataEntry) DEACTIVATE(org.apache.ignite.internal.commandline.CommandList.DEACTIVATE) IgniteFuture(org.apache.ignite.lang.IgniteFuture) File.separatorChar(java.io.File.separatorChar) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) OPTIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC) UUID(java.util.UUID) TransactionProxyImpl(org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl) IGNITE_CLUSTER_NAME(org.apache.ignite.IgniteSystemProperties.IGNITE_CLUSTER_NAME) Collectors(java.util.stream.Collectors) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) GRID_NOT_IDLE_MSG(org.apache.ignite.internal.processors.cache.verify.IdleVerifyUtility.GRID_NOT_IDLE_MSG) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) CU(org.apache.ignite.internal.util.typedef.internal.CU) Pattern(java.util.regex.Pattern) ShutdownPolicy(org.apache.ignite.ShutdownPolicy) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) ClusterStateTestUtils(org.apache.ignite.internal.processors.cache.ClusterStateTestUtils) NotNull(org.jetbrains.annotations.NotNull) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) GridJobExecuteResponse(org.apache.ignite.internal.GridJobExecuteResponse) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) IntStream(java.util.stream.IntStream) LongAdder(java.util.concurrent.atomic.LongAdder) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IgniteSnapshotManager.resolveSnapshotWorkDirectory(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.resolveSnapshotWorkDirectory) HashMap(java.util.HashMap) Function(java.util.function.Function) WarmUpTestPluginProvider(org.apache.ignite.internal.processors.cache.warmup.WarmUpTestPluginProvider) ToFileDumpProcessor(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.dumpprocessors.ToFileDumpProcessor) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) FileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory) IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP) G(org.apache.ignite.internal.util.typedef.G) F(org.apache.ignite.internal.util.typedef.F) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) OpenOption(java.nio.file.OpenOption) AbstractSnapshotSelfTest.snp(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.snp) FindAndDeleteGarbageArg(org.apache.ignite.internal.commandline.cache.argument.FindAndDeleteGarbageArg) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) EXIT_CODE_UNEXPECTED_ERROR(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_UNEXPECTED_ERROR) GridTestUtils.assertContains(org.apache.ignite.testframework.GridTestUtils.assertContains) TimeUnit(java.util.concurrent.TimeUnit) BitSet(java.util.BitSet) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) TransactionTimeoutException(org.apache.ignite.transactions.TransactionTimeoutException) Ignite(org.apache.ignite.Ignite) IgniteCacheGroupsWithRestartsTest(org.apache.ignite.internal.processors.cache.persistence.db.IgniteCacheGroupsWithRestartsTest) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest) Test(org.junit.Test)

Example 4 with INACTIVE

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

the class ClusterStateChangeEventTest method test.

/**
 */
@Test
public void test() throws Exception {
    IgniteEx crd = grid(0);
    crd.cluster().state(ACTIVE);
    Map<Integer, Integer> data = IntStream.range(0, 1000).boxed().collect(Collectors.toMap(i -> i, i -> i));
    crd.cache(DEFAULT_CACHE_NAME).putAll(data);
    for (Ignite node : G.allGrids()) assertEquals(node.name(), ACTIVE, node.cluster().state());
    // ACTIVE -> READ_ONLY
    changeStateAndCheckEvents(ACTIVE_READ_ONLY);
    // READ_ONLY -> ACTIVE
    changeStateAndCheckEvents(ACTIVE);
    // ACTIVE -> INACTIVE
    changeStateAndCheckEvents(INACTIVE);
    // INACTIVE -> READ_ONLY
    changeStateAndCheckEvents(ACTIVE_READ_ONLY);
    // READ_ONLY -> INACTIVE
    changeStateAndCheckEvents(INACTIVE);
    // INACTIVE -> ACTIVE
    changeStateAndCheckEvents(ACTIVE);
}
Also used : IntStream(java.util.stream.IntStream) ClusterState(org.apache.ignite.cluster.ClusterState) HashMap(java.util.HashMap) IgniteEx(org.apache.ignite.internal.IgniteEx) ACTIVE_READ_ONLY(org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY) Map(java.util.Map) Collectors.toSet(java.util.stream.Collectors.toSet) G(org.apache.ignite.internal.util.typedef.G) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) F(org.apache.ignite.internal.util.typedef.F) IgniteFuture(org.apache.ignite.lang.IgniteFuture) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) INACTIVE(org.apache.ignite.cluster.ClusterState.INACTIVE) EventType(org.apache.ignite.events.EventType) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Event(org.apache.ignite.events.Event) Set(java.util.Set) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) EVT_CLUSTER_STATE_CHANGED(org.apache.ignite.events.EventType.EVT_CLUSTER_STATE_CHANGED) Collectors(java.util.stream.Collectors) BaselineNode(org.apache.ignite.cluster.BaselineNode) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ClusterStateChangeEvent(org.apache.ignite.events.ClusterStateChangeEvent) Comparator.comparingLong(java.util.Comparator.comparingLong) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Collections.max(java.util.Collections.max) IgniteEx(org.apache.ignite.internal.IgniteEx) Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 5 with INACTIVE

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

the class IgniteClusterActivateDeactivateTestWithPersistence method testDeactivateClusterWithPersistentCachesAndDifferentDataRegions.

/**
 * Tests "soft" deactivation (without using the --force flag)
 * when the cluster contains persistent caches and cluster nodes "support" different lists of data regions.
 *
 * Expected behavior: the cluster should be deactivated successfully (there is no data loss)..
 *
 * @throws Exception If failed.
 */
@Test
public void testDeactivateClusterWithPersistentCachesAndDifferentDataRegions() throws Exception {
    IgniteEx srv = startGrid(0);
    addAdditionalDataRegion = true;
    IgniteEx srv1 = startGrid(1);
    IgniteEx clientNode = startClientGrid(2);
    clientNode.cluster().state(ACTIVE);
    DataStorageConfiguration dsCfg = srv1.configuration().getDataStorageConfiguration();
    DataRegionConfiguration persistentRegion = Arrays.stream(dsCfg.getDataRegionConfigurations()).filter(region -> ADDITIONAL_PERSISTENT_DATA_REGION.equals(region.getName())).findFirst().orElse(null);
    assertTrue("It is assumed that the '" + ADDITIONAL_PERSISTENT_DATA_REGION + "' data storage region exists and persistent.", persistentRegion != null && persistentRegion.isPersistenceEnabled());
    final UUID srv1NodeId = srv1.localNode().id();
    // Create a new cache that is placed into persistent data region.
    srv.getOrCreateCache(new CacheConfiguration<>("test-client-cache").setDataRegionName(persistentRegion.getName()).setAffinity(new RendezvousAffinityFunction(false, 1)).setNodeFilter(node -> node.id().equals(srv1NodeId)));
    // Try to deactivate the cluster without the `force` flag.
    IgniteInternalFuture<?> deactivateFut = srv.context().state().changeGlobalState(INACTIVE, false, Collections.emptyList(), false);
    try {
        deactivateFut.get(10, SECONDS);
    } catch (IgniteCheckedException e) {
        log.error("Failed to deactivate the cluster.", e);
        fail("Failed to deactivate the cluster. [err=" + e.getMessage() + ']');
    }
    awaitPartitionMapExchange();
    // Let's check that all nodes in the cluster have the same state.
    for (Ignite node : G.allGrids()) {
        IgniteEx n = (IgniteEx) node;
        ClusterState state = n.context().state().clusterState().state();
        assertTrue("Node must be in inactive state. " + "[node=" + n.configuration().getIgniteInstanceName() + ", actual=" + state + ']', INACTIVE == state);
    }
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Arrays(java.util.Arrays) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) ClusterState(org.apache.ignite.cluster.ClusterState) GridTestUtils.assertThrows(org.apache.ignite.testframework.GridTestUtils.assertThrows) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) GridTestUtils.assertActive(org.apache.ignite.testframework.GridTestUtils.assertActive) LinkedHashMap(java.util.LinkedHashMap) ACTIVE_READ_ONLY(org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) CacheWriteSynchronizationMode(org.apache.ignite.cache.CacheWriteSynchronizationMode) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) Assume(org.junit.Assume) GridTestUtils.assertThrowsAnyCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause) G(org.apache.ignite.internal.util.typedef.G) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) INACTIVE(org.apache.ignite.cluster.ClusterState.INACTIVE) GridTestUtils.assertThrowsWithCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Set(java.util.Set) GridConcurrentHashSet(org.apache.ignite.internal.util.GridConcurrentHashSet) Test(org.junit.Test) UUID(java.util.UUID) Ignite(org.apache.ignite.Ignite) IgniteCache(org.apache.ignite.IgniteCache) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteClusterReadOnlyException(org.apache.ignite.internal.processors.cache.distributed.dht.IgniteClusterReadOnlyException) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) MvccFeatureChecker(org.apache.ignite.testframework.MvccFeatureChecker) CU(org.apache.ignite.internal.util.typedef.internal.CU) IgniteDataStreamer(org.apache.ignite.IgniteDataStreamer) Assert(org.junit.Assert) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) SECONDS(java.util.concurrent.TimeUnit.SECONDS) ClusterState(org.apache.ignite.cluster.ClusterState) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test)

Aggregations

Set (java.util.Set)5 ACTIVE (org.apache.ignite.cluster.ClusterState.ACTIVE)5 INACTIVE (org.apache.ignite.cluster.ClusterState.INACTIVE)5 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)5 Map (java.util.Map)4 UUID (java.util.UUID)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 Ignite (org.apache.ignite.Ignite)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 Arrays (java.util.Arrays)3 Collection (java.util.Collection)3 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Collectors (java.util.stream.Collectors)3 IgniteCache (org.apache.ignite.IgniteCache)3 ClusterState (org.apache.ignite.cluster.ClusterState)3 ACTIVE_READ_ONLY (org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY)3 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)3 IgniteEx (org.apache.ignite.internal.IgniteEx)3