Search in sources :

Example 1 with CORRUPTED_DATA_FILES_MNTC_TASK_NAME

use of org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CORRUPTED_DATA_FILES_MNTC_TASK_NAME in project ignite by apache.

the class WalEnableDisableWithNodeShutdownTest method startNodeWithMaintenance.

/**
 */
private Ignite startNodeWithMaintenance(String consistentId) throws Exception {
    Ignite node;
    try {
        node = Ignition.start(igniteCfg(false, consistentId));
    } catch (Exception ex) {
        assertTrue(X.hasCause(ex, "Cache groups with potentially corrupted partition files", IgniteException.class));
        node = Ignition.start(igniteCfg(false, consistentId));
        node.compute().run(new IgniteRunnable() {

            /**
             */
            @IgniteInstanceResource
            private Ignite ignite;

            /**
             */
            @Override
            public void run() {
                MaintenanceRegistry mntcRegistry = ((IgniteEx) ignite).context().maintenanceRegistry();
                List<MaintenanceAction<?>> actions = mntcRegistry.actionsForMaintenanceTask(CORRUPTED_DATA_FILES_MNTC_TASK_NAME);
                actions.stream().filter(a -> a.name().equals(CleanCacheStoresMaintenanceAction.ACTION_NAME)).findFirst().get().execute();
                mntcRegistry.unregisterMaintenanceTask(CORRUPTED_DATA_FILES_MNTC_TASK_NAME);
            }
        });
        node.close();
        node = Ignition.start(igniteCfg(false, consistentId));
    }
    return node;
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) IgniteException(org.apache.ignite.IgniteException) MaintenanceAction(org.apache.ignite.maintenance.MaintenanceAction) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Ignition(org.apache.ignite.Ignition) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) MaintenanceRegistry(org.apache.ignite.maintenance.MaintenanceRegistry) CleanCacheStoresMaintenanceAction(org.apache.ignite.internal.processors.cache.persistence.CleanCacheStoresMaintenanceAction) X(org.apache.ignite.internal.util.typedef.X) After(org.junit.After) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) LinkedList(java.util.LinkedList) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) CacheMode(org.apache.ignite.cache.CacheMode) CORRUPTED_DATA_FILES_MNTC_TASK_NAME(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CORRUPTED_DATA_FILES_MNTC_TASK_NAME) MaintenanceAction(org.apache.ignite.maintenance.MaintenanceAction) CleanCacheStoresMaintenanceAction(org.apache.ignite.internal.processors.cache.persistence.CleanCacheStoresMaintenanceAction) Ignite(org.apache.ignite.Ignite) MaintenanceRegistry(org.apache.ignite.maintenance.MaintenanceRegistry) IgniteException(org.apache.ignite.IgniteException) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable)

Example 2 with CORRUPTED_DATA_FILES_MNTC_TASK_NAME

use of org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CORRUPTED_DATA_FILES_MNTC_TASK_NAME in project ignite by apache.

the class WalEnableDisableWithRestartsTest method startNodeWithMaintenance.

/**
 */
private Ignite startNodeWithMaintenance(String consistentId) throws Exception {
    Ignite node;
    try {
        node = Ignition.start(igniteCfg(false, consistentId));
    } catch (Exception ex) {
        if (!X.hasCause(ex, "Cache groups with potentially corrupted partition files", IgniteException.class))
            throw ex;
        node = Ignition.start(igniteCfg(false, consistentId));
        node.compute().run(new IgniteRunnable() {

            /**
             */
            @IgniteInstanceResource
            private Ignite ignite;

            /**
             */
            @Override
            public void run() {
                MaintenanceRegistry mntcRegistry = ((IgniteEx) ignite).context().maintenanceRegistry();
                List<MaintenanceAction<?>> actions = mntcRegistry.actionsForMaintenanceTask(CORRUPTED_DATA_FILES_MNTC_TASK_NAME);
                actions.stream().filter(a -> a.name().equals(CleanCacheStoresMaintenanceAction.ACTION_NAME)).findFirst().get().execute();
                mntcRegistry.unregisterMaintenanceTask(CORRUPTED_DATA_FILES_MNTC_TASK_NAME);
            }
        });
        node.close();
        node = Ignition.start(igniteCfg(false, consistentId));
    }
    return node;
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) IgniteException(org.apache.ignite.IgniteException) MaintenanceAction(org.apache.ignite.maintenance.MaintenanceAction) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Ignition(org.apache.ignite.Ignition) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) MaintenanceRegistry(org.apache.ignite.maintenance.MaintenanceRegistry) CleanCacheStoresMaintenanceAction(org.apache.ignite.internal.processors.cache.persistence.CleanCacheStoresMaintenanceAction) X(org.apache.ignite.internal.util.typedef.X) After(org.junit.After) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) LinkedList(java.util.LinkedList) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) CacheMode(org.apache.ignite.cache.CacheMode) CORRUPTED_DATA_FILES_MNTC_TASK_NAME(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CORRUPTED_DATA_FILES_MNTC_TASK_NAME) MaintenanceAction(org.apache.ignite.maintenance.MaintenanceAction) CleanCacheStoresMaintenanceAction(org.apache.ignite.internal.processors.cache.persistence.CleanCacheStoresMaintenanceAction) Ignite(org.apache.ignite.Ignite) MaintenanceRegistry(org.apache.ignite.maintenance.MaintenanceRegistry) IgniteException(org.apache.ignite.IgniteException) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable)

Aggregations

LinkedList (java.util.LinkedList)2 List (java.util.List)2 Ignite (org.apache.ignite.Ignite)2 IgniteException (org.apache.ignite.IgniteException)2 Ignition (org.apache.ignite.Ignition)2 CacheAtomicityMode (org.apache.ignite.cache.CacheAtomicityMode)2 CacheMode (org.apache.ignite.cache.CacheMode)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)2 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 CleanCacheStoresMaintenanceAction (org.apache.ignite.internal.processors.cache.persistence.CleanCacheStoresMaintenanceAction)2 CORRUPTED_DATA_FILES_MNTC_TASK_NAME (org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CORRUPTED_DATA_FILES_MNTC_TASK_NAME)2 X (org.apache.ignite.internal.util.typedef.X)2 IgniteRunnable (org.apache.ignite.lang.IgniteRunnable)2 MaintenanceAction (org.apache.ignite.maintenance.MaintenanceAction)2 MaintenanceRegistry (org.apache.ignite.maintenance.MaintenanceRegistry)2 IgniteInstanceResource (org.apache.ignite.resources.IgniteInstanceResource)2 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)2