Search in sources :

Example 21 with InternalGemFireError

use of org.apache.geode.InternalGemFireError in project geode by apache.

the class RebalanceOperationImpl method getResults.

public RebalanceResults getResults(long timeout, TimeUnit unit) throws CancellationException, TimeoutException, InterruptedException {
    long endTime = unit.toNanos(timeout) + System.nanoTime();
    RebalanceResultsImpl results = new RebalanceResultsImpl();
    List<Future<RebalanceResults>> frlist = getFutureList();
    for (Future<RebalanceResults> fr : frlist) {
        try {
            long waitTime = endTime - System.nanoTime();
            RebalanceResults rr = fr.get(waitTime, TimeUnit.NANOSECONDS);
            results.addDetails((RebalanceResultsImpl) rr);
        } catch (ExecutionException e) {
            if (e.getCause() instanceof GemFireException) {
                throw (GemFireException) e.getCause();
            } else if (e.getCause() instanceof InternalGemFireError) {
                throw (InternalGemFireError) e.getCause();
            } else {
                throw new InternalGemFireError(e.getCause());
            }
        }
    }
    return results;
}
Also used : GemFireException(org.apache.geode.GemFireException) Future(java.util.concurrent.Future) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) RebalanceResults(org.apache.geode.cache.control.RebalanceResults) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 22 with InternalGemFireError

use of org.apache.geode.InternalGemFireError in project geode by apache.

the class CommandInitializer method registerCommand.

/**
   * Register a new command with the system.
   * 
   * @param messageType - An ordinal for this message. This must be something defined in MessageType
   *        that has not already been allocated to a different command.
   * @param versionToNewCommand The command to register, for different versions. The key is the
   *        earliest version for which this command class is valid (starting with GFE_57). The value
   *        is the command object for clients starting with that version.
   */
public static void registerCommand(int messageType, Map<Version, Command> versionToNewCommand) {
    Command command = null;
    // add a command to the map for that version
    for (Map.Entry<Version, Map<Integer, Command>> entry : ALL_COMMANDS.entrySet()) {
        Version version = entry.getKey();
        // Get the current set of commands for this version.
        Map<Integer, Command> commandMap = entry.getValue();
        // See if we have a new command to insert into this map. Otherwise, keep using the command we
        // have
        // already read
        Command newerVersion = versionToNewCommand.get(version);
        if (newerVersion != null) {
            command = newerVersion;
        }
        if (command != null) {
            Command oldCommand = commandMap.get(messageType);
            if (oldCommand != null && oldCommand != command) {
                throw new InternalGemFireError("Command is already defined int the map for message Type " + MessageType.getString(messageType) + ". Old Value=" + commandMap.get(messageType) + ", newValue=" + command + ", version=" + version);
            }
            commandMap.put(messageType, command);
        }
    }
}
Also used : GatewayReceiverCommand(org.apache.geode.internal.cache.tier.sockets.command.GatewayReceiverCommand) GetEntryCommand(org.apache.geode.internal.cache.tier.sockets.command.GetEntryCommand) TXSynchronizationCommand(org.apache.geode.internal.cache.tier.sockets.command.TXSynchronizationCommand) RollbackCommand(org.apache.geode.internal.cache.tier.sockets.command.RollbackCommand) CommitCommand(org.apache.geode.internal.cache.tier.sockets.command.CommitCommand) GetClientPartitionAttributesCommand(org.apache.geode.internal.cache.tier.sockets.command.GetClientPartitionAttributesCommand) TXFailoverCommand(org.apache.geode.internal.cache.tier.sockets.command.TXFailoverCommand) Command(org.apache.geode.internal.cache.tier.Command) GetClientPRMetadataCommand(org.apache.geode.internal.cache.tier.sockets.command.GetClientPRMetadataCommand) Version(org.apache.geode.internal.Version) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 23 with InternalGemFireError

use of org.apache.geode.InternalGemFireError in project geode by apache.

the class AbstractGatewaySender method waitUntilFlushed.

public boolean waitUntilFlushed(long timeout, TimeUnit unit) throws InterruptedException {
    boolean result = false;
    if (isParallel()) {
        try {
            WaitUntilParallelGatewaySenderFlushedCoordinator coordinator = new WaitUntilParallelGatewaySenderFlushedCoordinator(this, timeout, unit, true);
            result = coordinator.waitUntilFlushed();
        } catch (BucketMovedException | CancelException | RegionDestroyedException e) {
            logger.warn(LocalizedStrings.AbstractGatewaySender_CAUGHT_EXCEPTION_ATTEMPTING_WAIT_UNTIL_FLUSHED_RETRYING.toLocalizedString(), e);
            throw e;
        } catch (Throwable t) {
            logger.warn(LocalizedStrings.AbstractGatewaySender_CAUGHT_EXCEPTION_ATTEMPTING_WAIT_UNTIL_FLUSHED_RETURNING.toLocalizedString(), t);
            throw new InternalGemFireError(t);
        }
        return result;
    } else {
        // Serial senders are currently not supported
        throw new UnsupportedOperationException(LocalizedStrings.AbstractGatewaySender_WAIT_UNTIL_FLUSHED_NOT_SUPPORTED_FOR_SERIAL_SENDERS.toLocalizedString());
    }
}
Also used : RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) BucketMovedException(org.apache.geode.internal.cache.execute.BucketMovedException) CancelException(org.apache.geode.CancelException) WaitUntilParallelGatewaySenderFlushedCoordinator(org.apache.geode.internal.cache.wan.parallel.WaitUntilParallelGatewaySenderFlushedCoordinator) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 24 with InternalGemFireError

use of org.apache.geode.InternalGemFireError in project geode by apache.

the class CheckTypeRegistryState method send.

public static void send(DM dm) {
    Set recipients = dm.getOtherDistributionManagerIds();
    ReplyProcessor21 replyProcessor = new ReplyProcessor21(dm, recipients);
    CheckTypeRegistryState msg = new CheckTypeRegistryState(replyProcessor.getProcessorId());
    msg.setRecipients(recipients);
    dm.putOutgoing(msg);
    try {
        replyProcessor.waitForReplies();
    } catch (ReplyException e) {
        if (e.getCause() instanceof PdxInitializationException) {
            throw new PdxInitializationException("Bad PDX configuration on member " + e.getSender() + ": " + e.getCause().getMessage(), e.getCause());
        } else {
            throw new InternalGemFireError("Unexpected exception", e);
        }
    } catch (InterruptedException e) {
        throw new InternalGemFireError("Unexpected exception", e);
    }
}
Also used : Set(java.util.Set) ReplyException(org.apache.geode.distributed.internal.ReplyException) PdxInitializationException(org.apache.geode.pdx.PdxInitializationException) ReplyProcessor21(org.apache.geode.distributed.internal.ReplyProcessor21) InternalGemFireError(org.apache.geode.InternalGemFireError)

Example 25 with InternalGemFireError

use of org.apache.geode.InternalGemFireError in project geode by apache.

the class PeerTypeRegistration method allocateTypeId.

private int allocateTypeId(PdxType newType) {
    TXStateProxy currentState = suspendTX();
    Region<Object, Object> r = getIdToType();
    int id = newType.hashCode() & PLACE_HOLDER_FOR_TYPE_ID;
    int newTypeId = id | this.dsId;
    try {
        int maxTry = maxTypeId;
        while (r.get(newTypeId) != null) {
            maxTry--;
            if (maxTry == 0) {
                throw new InternalGemFireError("Used up all of the PDX type ids for this distributed system. The maximum number of PDX types is " + maxTypeId);
            }
            // Find the next available type id.
            id++;
            if (id > this.maxTypeId) {
                id = 1;
            }
            newTypeId = id | this.dsId;
        }
        return newTypeId;
    } finally {
        resumeTX(currentState);
    }
}
Also used : TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) InternalGemFireError(org.apache.geode.InternalGemFireError)

Aggregations

InternalGemFireError (org.apache.geode.InternalGemFireError)38 IOException (java.io.IOException)8 HashMap (java.util.HashMap)5 Map (java.util.Map)5 TXStateProxy (org.apache.geode.internal.cache.TXStateProxy)5 HashSet (java.util.HashSet)4 ExecutionException (java.util.concurrent.ExecutionException)4 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)4 Set (java.util.Set)3 Future (java.util.concurrent.Future)3 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)3 ServerOperationException (org.apache.geode.cache.client.ServerOperationException)3 InternalRegionArguments (org.apache.geode.internal.cache.InternalRegionArguments)3 Part (org.apache.geode.internal.cache.tier.sockets.Part)3 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 TreeSet (java.util.TreeSet)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2