Search in sources :

Example 1 with ResumptionAction

use of org.apache.geode.cache.ResumptionAction in project geode by apache.

the class CacheXmlParser method endMembershipAttributes.

/**
   * When a <code>membership-attributes</code> element is finished, the arguments for constructing
   * the MembershipAttributes are on the stack.
   */
private void endMembershipAttributes() {
    Set roles = new HashSet();
    Object obj = null;
    while (!(obj instanceof Object[])) {
        obj = stack.pop();
        if (obj instanceof String) {
            // found a required-role name
            roles.add(obj);
        }
    }
    Object[] attrs = (Object[]) obj;
    String laName = ((String) attrs[0]).toUpperCase().replace('-', '_');
    String raName = ((String) attrs[1]).toUpperCase().replace('-', '_');
    LossAction laction = LossAction.fromName(laName);
    ResumptionAction raction = ResumptionAction.fromName(raName);
    MembershipAttributes ra = new MembershipAttributes((String[]) roles.toArray(new String[roles.size()]), laction, raction);
    RegionAttributesCreation rattrs = (RegionAttributesCreation) stack.peek();
    rattrs.setMembershipAttributes(ra);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LossAction(org.apache.geode.cache.LossAction) ResumptionAction(org.apache.geode.cache.ResumptionAction) HashSet(java.util.HashSet) MembershipAttributes(org.apache.geode.cache.MembershipAttributes)

Example 2 with ResumptionAction

use of org.apache.geode.cache.ResumptionAction in project geode by apache.

the class CacheXml66DUnitTest method testMembershipAttributes.

/**
   * Test xml support of MembershipAttributes.
   */
@Test
public void testMembershipAttributes() throws Exception {
    final String MY_ROLES = "Foo, Bip, BAM";
    final String[][] roles = new String[][] { { "Foo" }, { "Bip", "BAM" } };
    final LossAction[] policies = (LossAction[]) LossAction.VALUES.toArray(new LossAction[LossAction.VALUES.size()]);
    final ResumptionAction[] actions = (ResumptionAction[]) ResumptionAction.VALUES.toArray(new ResumptionAction[ResumptionAction.VALUES.size()]);
    CacheCreation cache = new CacheCreation();
    // for each policy, try each action and each role...
    for (int policy = 0; policy < policies.length; policy++) {
        for (int action = 0; action < actions.length; action++) {
            for (int role = 0; role < roles.length; role++) {
                String[] theRoles = roles[role];
                LossAction thePolicy = policies[policy];
                ResumptionAction theAction = actions[action];
                // if (theRoles.length == 0 && (thePolicy != LossAction.NONE || theAction !=
                // ResumptionAction.NONE
                RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
                MembershipAttributes ra = new MembershipAttributes(theRoles, thePolicy, theAction);
                attrs.setMembershipAttributes(ra);
                String region = "rootMEMBERSHIP_ATTRIBUTES_" + policy + "_" + action + "_" + role;
                cache.createRegion(region, attrs);
            }
        }
    }
    {
        // make our system play the roles used by this test so the create regions
        // will not think the a required role is missing
        Properties config = new Properties();
        config.setProperty(ROLES, MY_ROLES);
        this.xmlProps = config;
    }
    DistributedRegion.ignoreReconnect = true;
    try {
        testXml(cache);
    } finally {
        this.xmlProps = null;
        try {
            preTearDown();
        } finally {
            DistributedRegion.ignoreReconnect = false;
        }
    }
}
Also used : LossAction(org.apache.geode.cache.LossAction) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Properties(java.util.Properties) ResumptionAction(org.apache.geode.cache.ResumptionAction) MembershipAttributes(org.apache.geode.cache.MembershipAttributes) Test(org.junit.Test)

Example 3 with ResumptionAction

use of org.apache.geode.cache.ResumptionAction in project geode by apache.

the class DistributedRegion method asyncResumeReliability.

/**
   * Handles asynchronous ResumptionActions such as region reinitialize.
   */
private void asyncResumeReliability(final InternalDistributedMember id, final Set newlyAcquiredRoles) throws RejectedExecutionException {
    final ResumptionAction ra = getMembershipAttributes().getResumptionAction();
    getDistributionManager().getWaitingThreadPool().execute(new Runnable() {

        @Override
        public void run() {
            try {
                if (ra.isReinitialize()) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Reliability resumption for action of reinitialize");
                    }
                    if (!isDestroyed() && !cache.isClosed()) {
                        RegionEventImpl event = new RegionEventImpl(DistributedRegion.this, Operation.REGION_REINITIALIZE, null, false, getMyId(), generateEventID());
                        reinitialize(null, event);
                    }
                    synchronized (missingRequiredRoles) {
                        // any number of threads may be waiting on missingRequiredRoles
                        missingRequiredRoles.notifyAll();
                        if (hasListener() && id != null) {
                            // fire afterRoleGain event
                            RoleEventImpl relEvent = new RoleEventImpl(DistributedRegion.this, Operation.REGION_CREATE, null, true, id, newlyAcquiredRoles);
                            dispatchListenerEvent(EnumListenerEvent.AFTER_ROLE_GAIN, relEvent);
                        }
                    }
                }
            } catch (Exception e) {
                logger.fatal(LocalizedMessage.create(LocalizedStrings.DistributedRegion_UNEXPECTED_EXCEPTION), e);
            }
        }
    });
}
Also used : ResumptionAction(org.apache.geode.cache.ResumptionAction) TimeoutException(org.apache.geode.cache.TimeoutException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) InvalidDeltaException(org.apache.geode.InvalidDeltaException) AsyncEventQueueConfigurationException(org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException) RegionDistributionException(org.apache.geode.cache.RegionDistributionException) LockServiceDestroyedException(org.apache.geode.distributed.LockServiceDestroyedException) IOException(java.io.IOException) RoleException(org.apache.geode.cache.RoleException) GatewaySenderConfigurationException(org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException) CancelException(org.apache.geode.CancelException) DiskAccessException(org.apache.geode.cache.DiskAccessException) CacheWriterException(org.apache.geode.cache.CacheWriterException) RegionAccessException(org.apache.geode.cache.RegionAccessException) FunctionException(org.apache.geode.cache.execute.FunctionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) CacheClosedException(org.apache.geode.cache.CacheClosedException) ConcurrentCacheModificationException(org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException) PersistentReplicatesOfflineException(org.apache.geode.cache.persistence.PersistentReplicatesOfflineException)

Aggregations

ResumptionAction (org.apache.geode.cache.ResumptionAction)3 LossAction (org.apache.geode.cache.LossAction)2 MembershipAttributes (org.apache.geode.cache.MembershipAttributes)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Properties (java.util.Properties)1 Set (java.util.Set)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 CancelException (org.apache.geode.CancelException)1 InvalidDeltaException (org.apache.geode.InvalidDeltaException)1 CacheClosedException (org.apache.geode.cache.CacheClosedException)1 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)1 CacheWriterException (org.apache.geode.cache.CacheWriterException)1 DiskAccessException (org.apache.geode.cache.DiskAccessException)1 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)1 RegionAccessException (org.apache.geode.cache.RegionAccessException)1 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)1 RegionDistributionException (org.apache.geode.cache.RegionDistributionException)1 RoleException (org.apache.geode.cache.RoleException)1 TimeoutException (org.apache.geode.cache.TimeoutException)1