Github user rmetzger commented on a diff in the pull request:
https://github.com/apache/incubator-flink/pull/94#discussion_r17476806
--- Diff:
flink-java/src/main/java/org/apache/flink/api/java/io/RemoteCollectorOutputFormat.java
---
@@ -0,0 +1,110 @@
+package org.apache.flink.api.java.io;
+
+/**
+ * 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.
+ */
+
+import java.io.IOException;
+import java.rmi.AccessException;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+import org.apache.flink.api.common.io.OutputFormat;
+import org.apache.flink.configuration.Configuration;
+
+/**
+ * An output format that sends results through JAVA RMI to an
+ * {@link IRemoteCollector} implementation. The client has to provide an
+ * implementation of {@link IRemoteCollector} and has to write it's plan's
+ * output into an instance of {@link RemoteCollectorOutputFormat}. Further
in
+ * the client's VM parameters -Djava.rmi.server.hostname should be set to
the
+ * own IP address.
+ */
+public class RemoteCollectorOutputFormat<T> implements OutputFormat<T> {
+
+ private static final long serialVersionUID = 1922744224032398102L;
+
+ /**
+ * The reference of the {@link IRemoteCollector} object
+ */
+ private IRemoteCollector<T> remoteCollector;
+
+ /**
+ * Config parameter for the remote's port number
+ */
+ public static final String PORT = "port";
+ /**
+ * Config parameter for the remote's address
+ */
+ public static final String REMOTE = "remote";
+ /**
+ * An id used necessary for Java RMI
+ */
+ public static final String ID = "RemoteCollector";
+
+ @SuppressWarnings("unchecked")
+ @Override
+ /**
+ * This method receives the Configuration object, where the fields
"remote" and "port" must be set.
+ */
+ public void configure(Configuration parameters) {
+
+ Registry registry = null;
+ // get the remote's RMI Registry
+ try {
+ registry =
LocateRegistry.getRegistry(parameters.getString(REMOTE, "localhost"),
+ parameters.getInteger(PORT, 8888));
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ // try to get an intance of an IRemoteCollector implementation
+ try {
+ this.remoteCollector = (IRemoteCollector<T>)
registry.lookup(ID);
+ } catch (AccessException e) {
+ e.printStackTrace();
--- End diff --
Maybe its easier here to just catch Throwable here?
In addition, its very important to handle exceptions properly. In this case
I would suggest to rethrow them as runtime exceptions.
If you just write the stacktrace to stdout, users might not be able to find
out it (the message is missing).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---