Search in sources :

Example 26 with InternalGemFireException

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

the class DistributionManager method create.

/**
   * Creates a new distribution manager and discovers the other members of the distributed system.
   * Note that it does not check to see whether or not this VM already has a distribution manager.
   * 
   * @param system The distributed system to which this distribution manager will send messages.
   */
public static DistributionManager create(InternalDistributedSystem system) {
    DistributionManager distributionManager = null;
    try {
        int vmKind;
        if (Boolean.getBoolean(InternalLocator.FORCE_LOCATOR_DM_TYPE)) {
            // if this DM is starting for a locator, set it to be a locator DM
            vmKind = LOCATOR_DM_TYPE;
        } else if (isDedicatedAdminVM) {
            vmKind = ADMIN_ONLY_DM_TYPE;
        } else {
            vmKind = NORMAL_DM_TYPE;
        }
        RemoteTransportConfig transport = new RemoteTransportConfig(system.getConfig(), vmKind);
        transport.setIsReconnectingDS(system.isReconnectingDS());
        transport.setOldDSMembershipInfo(system.oldDSMembershipInfo());
        long start = System.currentTimeMillis();
        distributionManager = new DistributionManager(system, transport);
        distributionManager.assertDistributionManagerType();
        {
            InternalDistributedMember id = distributionManager.getDistributionManagerId();
            if (!"".equals(id.getName())) {
                for (InternalDistributedMember m : (List<InternalDistributedMember>) distributionManager.getViewMembers()) {
                    if (m.equals(id)) {
                        // SO once we find ourself break out of this loop.
                        break;
                    }
                    if (id.getName().equals(m.getName())) {
                        if (distributionManager.getMembershipManager().verifyMember(m, "member is using the name of " + id)) {
                            throw new IncompatibleSystemException("Member " + id + " could not join this distributed system because the existing member " + m + " used the same name. Set the \"name\" gemfire property to a unique value.");
                        }
                    }
                }
            }
            // add ourselves
            distributionManager.addNewMember(id);
            // ShutdownException could be thrown here
            distributionManager.selectElder();
        }
        // Send out a StartupMessage to the other members.
        StartupOperation op = new StartupOperation(distributionManager, transport);
        try {
            if (!distributionManager.sendStartupMessage(op, true)) {
                // we're the first one.
                if (distributionManager.getOtherDistributionManagerIds().size() == 0) {
                    logger.info(LocalizedMessage.create(LocalizedStrings.DistributionManager_DIDNT_HEAR_BACK_FROM_ANY_OTHER_SYSTEM_I_AM_THE_FIRST_ONE));
                } else if (transport.isMcastEnabled()) {
                    // perform a multicast ping test
                    if (!distributionManager.testMulticast()) {
                        logger.warn(LocalizedMessage.create(LocalizedStrings.DistributionManager_RECEIVED_NO_STARTUP_RESPONSES_BUT_OTHER_MEMBERS_EXIST_MULTICAST_IS_NOT_RESPONSIVE));
                    }
                }
            }
        } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
            // This is ALWAYS bad; don't consult a CancelCriterion.
            throw new InternalGemFireException(LocalizedStrings.DistributionManager_INTERRUPTED_WHILE_WAITING_FOR_FIRST_STARTUPRESPONSEMESSAGE.toLocalizedString(), ex);
        } catch (IncompatibleSystemException ex) {
            logger.fatal(ex.getMessage(), ex);
            throw ex;
        } finally {
            distributionManager.readyToSendMsgs();
        }
        if (logger.isInfoEnabled()) {
            long delta = System.currentTimeMillis() - start;
            Object[] logArgs = new Object[] { distributionManager.getDistributionManagerId(), transport, Integer.valueOf(distributionManager.getOtherDistributionManagerIds().size()), distributionManager.getOtherDistributionManagerIds(), (logger.isInfoEnabled(LogMarker.DM) ? " (VERBOSE, took " + delta + " ms)" : ""), ((distributionManager.getDMType() == ADMIN_ONLY_DM_TYPE) ? " (admin only)" : (distributionManager.getDMType() == LOCATOR_DM_TYPE) ? " (locator)" : "") };
            logger.info(LogMarker.DM, LocalizedMessage.create(LocalizedStrings.DistributionManager_DISTRIBUTIONMANAGER_0_STARTED_ON_1_THERE_WERE_2_OTHER_DMS_3_4_5, logArgs));
            MembershipLogger.logStartup(distributionManager.getDistributionManagerId());
        }
        return distributionManager;
    } catch (RuntimeException r) {
        if (distributionManager != null) {
            if (logger.isDebugEnabled()) {
                logger.debug("cleaning up incompletely started DistributionManager due to exception", r);
            }
            distributionManager.uncleanShutdown(true);
        }
        throw r;
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) InternalGemFireException(org.apache.geode.InternalGemFireException) RemoteTransportConfig(org.apache.geode.internal.admin.remote.RemoteTransportConfig) IncompatibleSystemException(org.apache.geode.IncompatibleSystemException)

Example 27 with InternalGemFireException

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

the class HARegionQueue method reinitializeRegion.

/**
   * reinitialize the queue, presumably pulling current information from seconaries
   */
public void reinitializeRegion() {
    InternalCache cache = this.region.getCache();
    String regionName = this.region.getName();
    this.region.destroyRegion();
    Exception problem = null;
    try {
        createHARegion(regionName, cache);
    } catch (IOException e) {
        problem = e;
    } catch (ClassNotFoundException e) {
        problem = e;
    }
    if (problem != null) {
        throw new InternalGemFireException("Problem recreating region queue '" + regionName + "'");
    }
    try {
        this.putGIIDataInRegion();
    } catch (InterruptedException e) {
        cache.getCancelCriterion().checkCancelInProgress(e);
        Thread.currentThread().interrupt();
    }
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException) InternalCache(org.apache.geode.internal.cache.InternalCache) IOException(java.io.IOException) TimeoutException(org.apache.geode.cache.TimeoutException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) CancelException(org.apache.geode.CancelException) InternalGemFireException(org.apache.geode.InternalGemFireException) CacheWriterException(org.apache.geode.cache.CacheWriterException) ConcurrentModificationException(java.util.ConcurrentModificationException) NoSuchElementException(java.util.NoSuchElementException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Example 28 with InternalGemFireException

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

the class CacheXmlGenerator method generate.

/**
   * Generates XML for <code>ExpirationAttributes</code>
   */
private void generate(String kind, ExpirationAttributes attrs, CustomExpiry custom) throws SAXException {
    if (attrs == null) {
        return;
    }
    handler.startElement("", kind, kind, EMPTY);
    int timeout = attrs.getTimeout();
    ExpirationAction action = attrs.getAction();
    AttributesImpl atts = new AttributesImpl();
    atts.addAttribute("", "", TIMEOUT, "", String.valueOf(timeout));
    String actionString;
    if (action.equals(ExpirationAction.DESTROY)) {
        actionString = DESTROY;
    } else if (action.equals(ExpirationAction.INVALIDATE)) {
        actionString = INVALIDATE;
    } else if (action.equals(ExpirationAction.LOCAL_DESTROY)) {
        actionString = LOCAL_DESTROY;
    } else if (action.equals(ExpirationAction.LOCAL_INVALIDATE)) {
        actionString = LOCAL_INVALIDATE;
    } else {
        throw new InternalGemFireException(LocalizedStrings.CacheXmlGenerator_UNKNOWN_EXPIRATIONACTION_0.toLocalizedString(action));
    }
    atts.addAttribute("", "", ACTION, "", actionString);
    handler.startElement("", EXPIRATION_ATTRIBUTES, EXPIRATION_ATTRIBUTES, atts);
    if (custom != null) {
        AttributesImpl endAtts = new AttributesImpl();
        handler.startElement("", CUSTOM_EXPIRY, CUSTOM_EXPIRY, endAtts);
        generate((Declarable) custom, false);
        handler.endElement("", CUSTOM_EXPIRY, CUSTOM_EXPIRY);
    }
    handler.endElement("", EXPIRATION_ATTRIBUTES, EXPIRATION_ATTRIBUTES);
    handler.endElement("", kind, kind);
}
Also used : DiskWriteAttributesImpl(org.apache.geode.internal.cache.DiskWriteAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) AttributesImpl(org.xml.sax.helpers.AttributesImpl) ExpirationAction(org.apache.geode.cache.ExpirationAction) InternalGemFireException(org.apache.geode.InternalGemFireException)

Example 29 with InternalGemFireException

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

the class CacheXmlParser method startGatewaySender.

private void startGatewaySender(Attributes atts) {
    GatewaySenderFactory gatewaySenderFactory = this.cache.createGatewaySenderFactory();
    String parallel = atts.getValue(PARALLEL);
    if (parallel == null) {
        gatewaySenderFactory.setParallel(GatewaySender.DEFAULT_IS_PARALLEL);
    } else {
        gatewaySenderFactory.setParallel(Boolean.parseBoolean(parallel));
    }
    // manual-start
    String manualStart = atts.getValue(MANUAL_START);
    if (manualStart == null) {
        gatewaySenderFactory.setManualStart(GatewaySender.DEFAULT_MANUAL_START);
    } else {
        gatewaySenderFactory.setManualStart(Boolean.parseBoolean(manualStart));
    }
    // socket-buffer-size
    String socketBufferSize = atts.getValue(SOCKET_BUFFER_SIZE);
    if (socketBufferSize == null) {
        gatewaySenderFactory.setSocketBufferSize(GatewaySender.DEFAULT_SOCKET_BUFFER_SIZE);
    } else {
        gatewaySenderFactory.setSocketBufferSize(Integer.parseInt(socketBufferSize));
    }
    // socket-read-timeout
    String socketReadTimeout = atts.getValue(SOCKET_READ_TIMEOUT);
    if (socketReadTimeout == null) {
        gatewaySenderFactory.setSocketReadTimeout(GatewaySender.DEFAULT_SOCKET_READ_TIMEOUT);
    } else {
        gatewaySenderFactory.setSocketReadTimeout(Integer.parseInt(socketReadTimeout));
    }
    // batch-conflation
    String batchConflation = atts.getValue(ENABLE_BATCH_CONFLATION);
    if (batchConflation == null) {
        gatewaySenderFactory.setBatchConflationEnabled(GatewaySender.DEFAULT_BATCH_CONFLATION);
    } else {
        gatewaySenderFactory.setBatchConflationEnabled(Boolean.parseBoolean(batchConflation));
    }
    // batch-size
    String batchSize = atts.getValue(BATCH_SIZE);
    if (batchSize == null) {
        gatewaySenderFactory.setBatchSize(GatewaySender.DEFAULT_BATCH_SIZE);
    } else {
        gatewaySenderFactory.setBatchSize(Integer.parseInt(batchSize));
    }
    // batch-time-interval
    String batchTimeInterval = atts.getValue(BATCH_TIME_INTERVAL);
    if (batchTimeInterval == null) {
        gatewaySenderFactory.setBatchTimeInterval(GatewaySender.DEFAULT_BATCH_TIME_INTERVAL);
    } else {
        gatewaySenderFactory.setBatchTimeInterval(Integer.parseInt(batchTimeInterval));
    }
    // enable-persistence
    String enablePersistence = atts.getValue(ENABLE_PERSISTENCE);
    if (enablePersistence == null) {
        gatewaySenderFactory.setPersistenceEnabled(GatewaySender.DEFAULT_PERSISTENCE_ENABLED);
    } else {
        gatewaySenderFactory.setPersistenceEnabled(Boolean.parseBoolean(enablePersistence));
    }
    String diskStoreName = atts.getValue(DISK_STORE_NAME);
    if (diskStoreName == null) {
        gatewaySenderFactory.setDiskStoreName(null);
    } else {
        gatewaySenderFactory.setDiskStoreName(diskStoreName);
    }
    String diskSynchronous = atts.getValue(DISK_SYNCHRONOUS);
    if (diskSynchronous == null) {
        gatewaySenderFactory.setDiskSynchronous(GatewaySender.DEFAULT_DISK_SYNCHRONOUS);
    } else {
        gatewaySenderFactory.setDiskSynchronous(Boolean.parseBoolean(diskSynchronous));
    }
    // maximum-queue-memory
    String maxQueueMemory = atts.getValue(MAXIMUM_QUEUE_MEMORY);
    if (maxQueueMemory == null) {
        gatewaySenderFactory.setMaximumQueueMemory(GatewaySender.DEFAULT_MAXIMUM_QUEUE_MEMORY);
    } else {
        gatewaySenderFactory.setMaximumQueueMemory(Integer.parseInt(maxQueueMemory));
    }
    String alertThreshold = atts.getValue(ALERT_THRESHOLD);
    if (alertThreshold == null) {
        gatewaySenderFactory.setAlertThreshold(GatewaySender.DEFAULT_ALERT_THRESHOLD);
    } else {
        gatewaySenderFactory.setAlertThreshold(Integer.parseInt(alertThreshold));
    }
    String dispatcherThreads = atts.getValue(DISPATCHER_THREADS);
    if (dispatcherThreads == null) {
        gatewaySenderFactory.setDispatcherThreads(GatewaySender.DEFAULT_DISPATCHER_THREADS);
    } else {
        gatewaySenderFactory.setDispatcherThreads(Integer.parseInt(dispatcherThreads));
    }
    String id = atts.getValue(ID);
    String orderPolicy = atts.getValue(ORDER_POLICY);
    if (orderPolicy != null) {
        try {
            gatewaySenderFactory.setOrderPolicy(GatewaySender.OrderPolicy.valueOf(orderPolicy.toUpperCase()));
        } catch (IllegalArgumentException e) {
            throw new InternalGemFireException(LocalizedStrings.SerialGatewaySender_UNKNOWN_GATEWAY_ORDER_POLICY_0_1.toLocalizedString(new Object[] { id, orderPolicy }));
        }
    }
    String remoteDS = atts.getValue(REMOTE_DISTRIBUTED_SYSTEM_ID);
    stack.push(id);
    stack.push(remoteDS);
    stack.push(gatewaySenderFactory);
// GatewaySender sender = gatewaySenderFactory.create(id, Integer.parseInt(remoteDS));
// stack.push(sender);
}
Also used : InternalGemFireException(org.apache.geode.InternalGemFireException) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory)

Example 30 with InternalGemFireException

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

the class CacheXmlGenerator method generate.

/**
   * Generates XML for <code>SubscriptionAttributes</code>
   */
private void generate(SubscriptionAttributes attrs) throws SAXException {
    if (attrs == null) {
        return;
    }
    String interestString = null;
    InterestPolicy ip = attrs.getInterestPolicy();
    AttributesImpl atts = new AttributesImpl();
    if (ip.isAll()) {
        interestString = ALL;
    } else if (ip.isCacheContent()) {
        interestString = CACHE_CONTENT;
    } else {
        throw new InternalGemFireException(LocalizedStrings.CacheXmlGenerator_UNKNOWN_INTERESTPOLICY_0.toLocalizedString(ip));
    }
    atts.addAttribute("", "", INTEREST_POLICY, "", interestString);
    handler.startElement("", SUBSCRIPTION_ATTRIBUTES, SUBSCRIPTION_ATTRIBUTES, atts);
    handler.endElement("", SUBSCRIPTION_ATTRIBUTES, SUBSCRIPTION_ATTRIBUTES);
}
Also used : DiskWriteAttributesImpl(org.apache.geode.internal.cache.DiskWriteAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) AttributesImpl(org.xml.sax.helpers.AttributesImpl) InternalGemFireException(org.apache.geode.InternalGemFireException) InterestPolicy(org.apache.geode.cache.InterestPolicy)

Aggregations

InternalGemFireException (org.apache.geode.InternalGemFireException)46 IOException (java.io.IOException)12 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)8 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)8 ExecutionException (java.util.concurrent.ExecutionException)7 UnknownHostException (java.net.UnknownHostException)6 Future (java.util.concurrent.Future)6 Method (java.lang.reflect.Method)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 List (java.util.List)4 CancelException (org.apache.geode.CancelException)4 CacheException (org.apache.geode.cache.CacheException)4 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)4 ServerOperationException (org.apache.geode.cache.client.ServerOperationException)4 NoSuchElementException (java.util.NoSuchElementException)3 Set (java.util.Set)3 ExecutorService (java.util.concurrent.ExecutorService)3