You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2018/01/25 17:53:36 UTC
[geode] branch release/1.4.0 updated: GEODE-4370: Ensure that
rmi-io uses the JMX/RMI port (#1339)
This is an automated email from the ASF dual-hosted git repository.
jensdeppe pushed a commit to branch release/1.4.0
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/release/1.4.0 by this push:
new d565456 GEODE-4370: Ensure that rmi-io uses the JMX/RMI port (#1339)
d565456 is described below
commit d565456f65c2997a3d6d3f43f52c2a5d553a0844
Author: Jens Deppe <jd...@pivotal.io>
AuthorDate: Thu Jan 25 08:25:24 2018 -0800
GEODE-4370: Ensure that rmi-io uses the JMX/RMI port (#1339)
(cherry picked from commit 7752308db441c16505d8986816f3c2eb2de3c195)
---
.../internal/GeodeRemoteStreamExporter.java | 52 ++++++++++++++++++++++
.../geode/management/internal/ManagementAgent.java | 21 +++++++--
.../internal/cli/commands/DeployCommand.java | 9 +++-
.../functions/DownloadJarFunction.java | 8 +++-
4 files changed, 83 insertions(+), 7 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/GeodeRemoteStreamExporter.java b/geode-core/src/main/java/org/apache/geode/management/internal/GeodeRemoteStreamExporter.java
new file mode 100644
index 0000000..eddb955
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/GeodeRemoteStreamExporter.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.management.internal;
+
+import java.rmi.RemoteException;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.UnicastRemoteObject;
+
+import com.healthmarketscience.rmiio.RemoteStreamServer;
+import com.healthmarketscience.rmiio.exporter.RemoteStreamExporter;
+
+/**
+ * This class allows for exporting RMI objects when specific RMIClientSocketFactory and
+ * RMIClientSocketFactory implementations are being used.
+ */
+public class GeodeRemoteStreamExporter extends RemoteStreamExporter {
+
+ private int port;
+ private RMIClientSocketFactory clientSocketFactory;
+ private RMIServerSocketFactory serverSocketFactory;
+
+ public GeodeRemoteStreamExporter(int port, RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf) {
+ this.port = port;
+ this.clientSocketFactory = csf;
+ this.serverSocketFactory = ssf;
+ }
+
+ @Override
+ protected Object exportImpl(RemoteStreamServer<?, ?> server) throws RemoteException {
+ return UnicastRemoteObject.exportObject(server, port, clientSocketFactory, serverSocketFactory);
+ }
+
+ @Override
+ protected void unexportImpl(RemoteStreamServer<?, ?> server) throws Exception {
+ UnicastRemoteObject.unexportObject(server, true);
+ }
+}
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java b/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java
index bbd5be3..ac99266 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java
@@ -42,6 +42,7 @@ import javax.management.remote.rmi.RMIJRMPServerImpl;
import javax.management.remote.rmi.RMIServerImpl;
import javax.rmi.ssl.SslRMIClientSocketFactory;
+import com.healthmarketscience.rmiio.exporter.RemoteStreamExporter;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.Logger;
import org.eclipse.jetty.server.Server;
@@ -96,6 +97,11 @@ public class ManagementAgent {
private final DistributionConfig config;
private final SecurityService securityService;
private boolean isHttpServiceRunning = false;
+ private RMIClientSocketFactory rmiClientSocketFactory;
+ private RMIServerSocketFactory rmiServerSocketFactory;
+ private int port;
+ private RemoteStreamExporter remoteStreamExporter = null;
+
/**
* This system property is set to true when the embedded HTTP server is started so that the
* embedded pulse webapp can use a local MBeanServer instead of a remote JMX connection.
@@ -370,7 +376,7 @@ public class ManagementAgent {
*/
private void configureAndStart() throws IOException {
// get the port for RMI Registry and RMI Connector Server
- final int port = this.config.getJmxManagerPort();
+ port = this.config.getJmxManagerPort();
final String hostname;
final InetAddress bindAddr;
if (StringUtils.isBlank(this.config.getJmxManagerBindAddress())) {
@@ -395,9 +401,8 @@ public class ManagementAgent {
logger.debug("Starting jmx manager agent on port {}{}", port,
(bindAddr != null ? (" bound to " + bindAddr) : "") + (ssl ? " using SSL" : ""));
}
- RMIClientSocketFactory rmiClientSocketFactory = ssl ? new SslRMIClientSocketFactory() : null;
- RMIServerSocketFactory rmiServerSocketFactory =
- new GemFireRMIServerSocketFactory(socketCreator, bindAddr);
+ rmiClientSocketFactory = ssl ? new SslRMIClientSocketFactory() : null;
+ rmiServerSocketFactory = new GemFireRMIServerSocketFactory(socketCreator, bindAddr);
// Following is done to prevent rmi causing stop the world gcs
System.setProperty("sun.rmi.dgc.server.gcInterval", Long.toString(Long.MAX_VALUE - 1));
@@ -546,6 +551,14 @@ public class ManagementAgent {
return jmxConnectorServer;
}
+ public synchronized RemoteStreamExporter getRemoteStreamExporter() {
+ if (remoteStreamExporter == null) {
+ remoteStreamExporter =
+ new GeodeRemoteStreamExporter(port, rmiClientSocketFactory, rmiServerSocketFactory);
+ }
+ return remoteStreamExporter;
+ }
+
private static class GemFireRMIServerSocketFactory
implements RMIServerSocketFactory, Serializable {
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommand.java
index 46f8502..e010783 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DeployCommand.java
@@ -27,6 +27,7 @@ import java.util.Set;
import com.healthmarketscience.rmiio.RemoteInputStream;
import com.healthmarketscience.rmiio.SimpleRemoteInputStream;
+import com.healthmarketscience.rmiio.exporter.RemoteStreamExporter;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
@@ -39,6 +40,8 @@ import org.apache.geode.distributed.internal.ClusterConfigurationService;
import org.apache.geode.management.cli.CliMetaData;
import org.apache.geode.management.cli.ConverterHint;
import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.ManagementAgent;
+import org.apache.geode.management.internal.SystemManagementService;
import org.apache.geode.management.internal.cli.AbstractCliAroundInterceptor;
import org.apache.geode.management.internal.cli.CliUtil;
import org.apache.geode.management.internal.cli.GfshParseResult;
@@ -85,11 +88,15 @@ public class DeployCommand implements GfshCommand {
targetMembers = CliUtil.findMembers(groups, null);
List results = new ArrayList();
+ ManagementAgent agent = ((SystemManagementService) getManagementService()).getManagementAgent();
+ RemoteStreamExporter exporter = agent.getRemoteStreamExporter();
+
for (DistributedMember member : targetMembers) {
List<RemoteInputStream> remoteStreams = new ArrayList<>();
List<String> jarNames = new ArrayList<>();
for (String jarFullPath : jarFullPaths) {
- remoteStreams.add(new SimpleRemoteInputStream(new FileInputStream(jarFullPath)).export());
+ remoteStreams
+ .add(exporter.export(new SimpleRemoteInputStream(new FileInputStream(jarFullPath))));
jarNames.add(FilenameUtils.getName(jarFullPath));
}
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/DownloadJarFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/DownloadJarFunction.java
index fd93ecb..aa9ad8a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/DownloadJarFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/DownloadJarFunction.java
@@ -21,10 +21,10 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.rmi.RemoteException;
-import com.healthmarketscience.rmiio.GZIPRemoteInputStream;
import com.healthmarketscience.rmiio.RemoteInputStream;
import com.healthmarketscience.rmiio.RemoteInputStreamServer;
import com.healthmarketscience.rmiio.SimpleRemoteInputStream;
+import com.healthmarketscience.rmiio.exporter.RemoteStreamExporter;
import org.apache.logging.log4j.Logger;
import org.apache.geode.cache.execute.Function;
@@ -35,6 +35,7 @@ import org.apache.geode.distributed.internal.ClusterConfigurationService;
import org.apache.geode.distributed.internal.InternalLocator;
import org.apache.geode.internal.InternalEntity;
import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.management.internal.SystemManagementService;
public class DownloadJarFunction implements Function<Object[]>, InternalEntity {
private static final Logger logger = LogService.getLogger();
@@ -55,11 +56,14 @@ public class DownloadJarFunction implements Function<Object[]>, InternalEntity {
try {
File jarFile = sharedConfig.getPathToJarOnThisLocator(group, jarName).toFile();
+ RemoteStreamExporter exporter = ((SystemManagementService) SystemManagementService
+ .getExistingManagementService(context.getCache())).getManagementAgent()
+ .getRemoteStreamExporter();
RemoteInputStreamServer istream = null;
try {
istream =
new SimpleRemoteInputStream(new BufferedInputStream(new FileInputStream(jarFile)));
- result = istream.export();
+ result = exporter.export(istream);
istream = null;
} catch (FileNotFoundException | RemoteException ex) {
throw new FunctionException(ex);
--
To stop receiving notification emails like this one, please contact
jensdeppe@apache.org.