Search in sources :

Example 1 with GemFireIOException

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

the class DistributionAdvisor method waitForCurrentOperations.

/**
   * wait for the current operations being sent on views prior to the joining of the given member to
   * be placed on communication channels before returning
   * 
   * @since GemFire 5.1
   */
public void waitForCurrentOperations(long timeout) {
    // CacheProfile profile = (CacheProfile)getProfile(member);
    // long targetVersion = profile.initialMembershipVersion - 1;
    // this may wait longer than it should if the membership version changes, dumping
    // more operations into the previousVersionOpCount
    long startTime = System.currentTimeMillis();
    long warnTime = startTime + timeout;
    long quitTime = warnTime + timeout - 1000L;
    boolean warned = false;
    final boolean isDebugEnabled_STATE_FLUSH_OP = logger.isTraceEnabled(LogMarker.STATE_FLUSH_OP);
    while (true) {
        long opCount;
        synchronized (this.opCountLock) {
            opCount = this.previousVersionOpCount;
        }
        if (opCount <= 0) {
            break;
        }
        // See bug 34361 comment 79
        if (isDebugEnabled_STATE_FLUSH_OP) {
            logger.trace(LogMarker.STATE_FLUSH_OP, "Waiting for current operations to finish({})", opCount);
        }
        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {
            throw new GemFireIOException("State flush interrupted");
        }
        long now = System.currentTimeMillis();
        if ((!warned) && System.currentTimeMillis() >= warnTime) {
            warned = true;
            logger.warn(LocalizedMessage.create(LocalizedStrings.DistributionAdvisor_0_SEC_HAVE_ELAPSED_WHILE_WAITING_FOR_CURRENT_OPERATIONS_TO_DISTRIBUTE, Long.toString((warnTime - startTime) / 1000L)));
        } else if (warned && (now >= quitTime)) {
            // OSProcess.printStacks(0);
            throw new GemFireIOException("Current operations did not distribute within " + (now - startTime) + " milliseconds");
        }
    }
    if (this.membershipClosed) {
        if (isDebugEnabled_STATE_FLUSH_OP) {
            logger.trace(LogMarker.STATE_FLUSH_OP, "State Flush stopped waiting for operations to distribute because advisor has been closed");
        }
    }
}
Also used : GemFireIOException(org.apache.geode.GemFireIOException)

Example 2 with GemFireIOException

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

the class InternalDistributedSystem method createAndStartCacheServers.

/**
   * after an auto-reconnect we may need to recreate a cache server and start it
   */
public void createAndStartCacheServers(List<CacheServerCreation> cacheServerCreation, InternalCache cache) {
    List<CacheServer> servers = cache.getCacheServers();
    // to recreate it.
    if (servers.isEmpty() && cacheServerCreation != null) {
        for (CacheServerCreation bridge : cacheServerCreation) {
            CacheServerImpl impl = (CacheServerImpl) cache.addCacheServer();
            impl.configureFrom(bridge);
        }
    }
    servers = cache.getCacheServers();
    for (CacheServer server : servers) {
        try {
            if (!server.isRunning()) {
                server.start();
            }
        } catch (IOException ex) {
            throw new GemFireIOException(LocalizedStrings.CacheCreation_WHILE_STARTING_CACHE_SERVER_0.toLocalizedString(server), ex);
        }
    }
}
Also used : CacheServerCreation(org.apache.geode.internal.cache.xmlcache.CacheServerCreation) CacheServer(org.apache.geode.cache.server.CacheServer) GemFireIOException(org.apache.geode.GemFireIOException) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) GemFireIOException(org.apache.geode.GemFireIOException) IOException(java.io.IOException)

Example 3 with GemFireIOException

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

the class AgentConfigImpl method appendOptionalPropertyFileProperties.

/**
   * Appends any additional property-file specified properties to the supplied Properties. If the
   * supplied property overrides the property in the property-file, then property-file value is
   * ignored. System Properties always override the supplied properties
   * 
   * @return appendedProps Properties appened to from the property-file if any
   */
private static Properties appendOptionalPropertyFileProperties(final Properties props) {
    final URL url = getPropertyFileURL(retrievePropertyFile());
    final Properties appendedProps = new Properties();
    appendedProps.putAll(props);
    // first, get any property values set in the optional property file
    if (url != null) {
        InputStream in = null;
        try {
            in = url.openStream();
            final Properties agentPropertyFileProperties = new Properties();
            agentPropertyFileProperties.load(in);
            // don't let any properties from the file override those on the command-line
            for (final Object key : agentPropertyFileProperties.keySet()) {
                if (props.getProperty(key.toString()) == null) {
                    appendedProps.setProperty(key.toString(), agentPropertyFileProperties.getProperty(key.toString()));
                }
            }
        } catch (IOException e) {
            throw new GemFireIOException(LocalizedStrings.AgentConfigImpl_FAILED_READING_0.toLocalizedString(url.toString()), e);
        } finally {
            IOUtils.close(in);
        }
    }
    // TODO this is not exactly overriding!
    for (final Object propSuffix : props.keySet()) {
        final String key = SYSTEM_PROPERTY_PREFIX + propSuffix;
        final String value = System.getProperty(key);
        if (value != null) {
            appendedProps.put(key, value);
        }
    }
    return appendedProps;
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) GemFireIOException(org.apache.geode.GemFireIOException) GemFireIOException(org.apache.geode.GemFireIOException) IOException(java.io.IOException) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) URL(java.net.URL)

Example 4 with GemFireIOException

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

the class InternalDistributedSystem method startInitLocator.

/**
   * @since GemFire 5.7
   */
private void startInitLocator() throws InterruptedException {
    String locatorString = this.originalConfig.getStartLocator();
    if (locatorString.length() == 0) {
        return;
    }
    // there is a quorum of the old members available
    if (attemptingToReconnect && !this.isConnected) {
        if (this.quorumChecker != null) {
            logger.info("performing a quorum check to see if location services can be started early");
            if (!quorumChecker.checkForQuorum(3 * this.config.getMemberTimeout())) {
                logger.info("quorum check failed - not allowing location services to start early");
                return;
            }
            logger.info("Quorum check passed - allowing location services to start early");
        }
    }
    DistributionLocatorId locId = new DistributionLocatorId(locatorString);
    try {
        this.startedLocator = // LOG: this is
        InternalLocator.createLocator(// LOG: this is
        locId.getPort(), // LOG: this is
        null, // LOG: this is
        null, // LOG: this is
        this.logWriter, // LOG: this is after IDS has created LogWriterLoggers and
        this.securityLogWriter, // Appenders
        locId.getHost(), locId.getHostnameForClients(), this.originalConfig.toProperties(), false);
        // if locator is started this way, cluster config is not enabled, set the flag correctly
        this.startedLocator.getConfig().setEnableClusterConfiguration(false);
        boolean startedPeerLocation = false;
        try {
            this.startedLocator.startPeerLocation(true);
            startedPeerLocation = true;
        } finally {
            if (!startedPeerLocation) {
                this.startedLocator.stop();
            }
        }
    } catch (IOException e) {
        throw new GemFireIOException(LocalizedStrings.InternalDistributedSystem_PROBLEM_STARTING_A_LOCATOR_SERVICE.toLocalizedString(), e);
    }
}
Also used : DistributionLocatorId(org.apache.geode.internal.admin.remote.DistributionLocatorId) GemFireIOException(org.apache.geode.GemFireIOException) GemFireIOException(org.apache.geode.GemFireIOException) IOException(java.io.IOException)

Example 5 with GemFireIOException

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

the class IntegratedSecurityService method postProcess.

public Object postProcess(Object principal, String regionPath, Object key, Object value, boolean valueIsSerialized) {
    if (!needPostProcess())
        return value;
    if (principal == null) {
        Subject subject = getSubject();
        if (subject == null)
            return value;
        principal = (Serializable) subject.getPrincipal();
    }
    String regionName = StringUtils.stripStart(regionPath, "/");
    Object newValue = null;
    // it to the callback.
    if (valueIsSerialized && value instanceof byte[]) {
        try {
            Object oldObj = EntryEventImpl.deserialize((byte[]) value);
            Object newObj = postProcessor.processRegionValue(principal, regionName, key, oldObj);
            newValue = BlobHelper.serializeToBlob(newObj);
        } catch (IOException | SerializationException e) {
            throw new GemFireIOException("Exception de/serializing entry value", e);
        }
    } else {
        newValue = postProcessor.processRegionValue(principal, regionName, key, value);
    }
    return newValue;
}
Also used : SerializationException(org.apache.commons.lang.SerializationException) GemFireIOException(org.apache.geode.GemFireIOException) GemFireIOException(org.apache.geode.GemFireIOException) IOException(java.io.IOException) Subject(org.apache.shiro.subject.Subject)

Aggregations

GemFireIOException (org.apache.geode.GemFireIOException)31 IOException (java.io.IOException)20 File (java.io.File)5 Test (org.junit.Test)4 InputStream (java.io.InputStream)3 Properties (java.util.Properties)3 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)3 BufferedReader (java.io.BufferedReader)2 DataOutput (java.io.DataOutput)2 FileNotFoundException (java.io.FileNotFoundException)2 FileOutputStream (java.io.FileOutputStream)2 InputStreamReader (java.io.InputStreamReader)2 PrintStream (java.io.PrintStream)2 StringReader (java.io.StringReader)2 ArrayList (java.util.ArrayList)2 SerializationException (org.apache.commons.lang.SerializationException)2 CancelException (org.apache.geode.CancelException)2 ForcedDisconnectException (org.apache.geode.ForcedDisconnectException)2 GemFireConfigException (org.apache.geode.GemFireConfigException)2 InternalGemFireException (org.apache.geode.InternalGemFireException)2