You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hdt.apache.org by ad...@apache.org on 2013/01/08 23:26:26 UTC

[7/11] Import of source from Apache Hadoop MapReduce contrib, this is the plugin as it existed in the Hadoop 0.23.4 release.

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/71/711f227d180fe5a123049d2577cd7e4599258187.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/71/711f227d180fe5a123049d2577cd7e4599258187.svn-base b/eclipse-plugin/.svn/pristine/71/711f227d180fe5a123049d2577cd7e4599258187.svn-base
new file mode 100644
index 0000000..8fdd19b
--- /dev/null
+++ b/eclipse-plugin/.svn/pristine/71/711f227d180fe5a123049d2577cd7e4599258187.svn-base
@@ -0,0 +1,972 @@
+/**
+ * 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.hadoop.eclipse.servers;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.Map.Entry;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.eclipse.server.ConfProp;
+import org.apache.hadoop.eclipse.server.HadoopServer;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Wizard for editing the settings of a Hadoop location
+ * 
+ * The wizard contains 3 tabs: General, Tunneling and Advanced. It edits
+ * parameters of the location member which either a new location or a copy of
+ * an existing registered location.
+ */
+
+public class HadoopLocationWizard extends WizardPage {
+
+  Image circle;
+
+  /**
+   * The location effectively edited by the wizard. This location is a copy
+   * or a new one.
+   */
+  private HadoopServer location;
+
+  /**
+   * The original location being edited by the wizard (null if we create a
+   * new instance).
+   */
+  private HadoopServer original;
+
+  /**
+   * New Hadoop location wizard
+   */
+  public HadoopLocationWizard() {
+    super("Hadoop Server", "New Hadoop Location", null);
+
+    this.original = null;
+    this.location = new HadoopServer();
+    this.location.setLocationName("");
+  }
+
+  /**
+   * Constructor to edit the parameters of an existing Hadoop server
+   * 
+   * @param server
+   */
+  public HadoopLocationWizard(HadoopServer server) {
+    super("Create a new Hadoop location", "Edit Hadoop Location", null);
+
+    this.original = server;
+    this.location = new HadoopServer(server);
+  }
+
+  /**
+   * Performs any actions appropriate in response to the user having pressed
+   * the Finish button, or refuse if finishing now is not permitted.
+   * 
+   * @return the created or updated Hadoop location
+   */
+
+  public HadoopServer performFinish() {
+    try {
+      if (this.original == null) {
+        // New location
+        Display.getDefault().syncExec(new Runnable() {
+          public void run() {
+            ServerRegistry.getInstance().addServer(
+                HadoopLocationWizard.this.location);
+          }
+        });
+        return this.location;
+
+      } else {
+        // Update location
+        final String originalName = this.original.getLocationName();
+        this.original.load(this.location);
+
+        Display.getDefault().syncExec(new Runnable() {
+          public void run() {
+            ServerRegistry.getInstance().updateServer(originalName,
+                HadoopLocationWizard.this.location);
+          }
+        });
+        return this.original;
+
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+      setMessage("Invalid server location values", IMessageProvider.ERROR);
+      return null;
+    }
+  }
+
+  /**
+   * Validates the current Hadoop location settings (look for Hadoop
+   * installation directory).
+   * 
+   */
+  private void testLocation() {
+    setMessage("Not implemented yet", IMessageProvider.WARNING);
+  }
+
+  /**
+   * Location is not complete (and finish button not available) until a host
+   * name is specified.
+   * 
+   * @inheritDoc
+   */
+  @Override
+  public boolean isPageComplete() {
+
+    {
+      String locName = location.getConfProp(ConfProp.PI_LOCATION_NAME);
+      if ((locName == null) || (locName.length() == 0)
+          || locName.contains("/")) {
+
+        setMessage("Bad location name: "
+            + "the location name should not contain "
+            + "any character prohibited in a file name.", WARNING);
+
+        return false;
+      }
+    }
+
+    {
+      String master = location.getConfProp(ConfProp.PI_JOB_TRACKER_HOST);
+      if ((master == null) || (master.length() == 0)) {
+
+        setMessage("Bad master host name: "
+            + "the master host name refers to the machine "
+            + "that runs the Job tracker.", WARNING);
+
+        return false;
+      }
+    }
+
+    {
+      String jobTracker = location.getConfProp(ConfProp.JOB_TRACKER_URI);
+      String[] strs = jobTracker.split(":");
+      boolean ok = (strs.length == 2);
+      if (ok) {
+        try {
+          int port = Integer.parseInt(strs[1]);
+          ok = (port >= 0) && (port < 65536);
+        } catch (NumberFormatException nfe) {
+          ok = false;
+        }
+      }
+      if (!ok) {
+        setMessage("The job tracker information ("
+            + ConfProp.JOB_TRACKER_URI.name + ") is invalid. "
+            + "This usually looks like \"host:port\"", WARNING);
+        return false;
+      }
+    }
+
+    {
+      String fsDefaultURI = location.getConfProp(ConfProp.FS_DEFAULT_URI);
+      try {
+        URI uri = new URI(fsDefaultURI);
+      } catch (URISyntaxException e) {
+
+        setMessage("The default file system URI is invalid. "
+            + "This usually looks like \"hdfs://host:port/\" "
+            + "or \"file:///dir/\"", WARNING);
+      }
+    }
+
+    setMessage("Define the location of a Hadoop infrastructure "
+        + "for running MapReduce applications.");
+    return true;
+  }
+
+  /**
+   * Create the wizard
+   */
+  /* @inheritDoc */
+  public void createControl(Composite parent) {
+    setTitle("Define Hadoop location");
+    setDescription("Define the location of a Hadoop infrastructure "
+        + "for running MapReduce applications.");
+
+    Composite panel = new Composite(parent, SWT.FILL);
+    GridLayout glayout = new GridLayout(2, false);
+    panel.setLayout(glayout);
+
+    TabMediator mediator = new TabMediator(panel);
+    {
+      GridData gdata = new GridData(GridData.FILL_BOTH);
+      gdata.horizontalSpan = 2;
+      mediator.folder.setLayoutData(gdata);
+    }
+    this.setControl(panel /* mediator.folder */);
+    {
+      final Button btn = new Button(panel, SWT.NONE);
+      btn.setText("&Load from file");
+      btn.setEnabled(false);
+      btn.setToolTipText("Not yet implemented");
+      btn.addListener(SWT.Selection, new Listener() {
+        public void handleEvent(Event e) {
+          // TODO
+        }
+      });
+    }
+    {
+      final Button validate = new Button(panel, SWT.NONE);
+      validate.setText("&Validate location");
+      validate.setEnabled(false);
+      validate.setToolTipText("Not yet implemented");
+      validate.addListener(SWT.Selection, new Listener() {
+        public void handleEvent(Event e) {
+          testLocation();
+        }
+      });
+    }
+  }
+
+  private interface TabListener {
+    void notifyChange(ConfProp prop, String propValue);
+  }
+
+  /*
+   * Mediator pattern to keep tabs synchronized with each other and with the
+   * location state.
+   */
+
+  private class TabMediator {
+    TabFolder folder;
+
+    private Set<TabListener> tabs = new HashSet<TabListener>();
+
+    TabMediator(Composite parent) {
+      folder = new TabFolder(parent, SWT.NONE);
+      tabs.add(new TabMain(this));
+      tabs.add(new TabAdvanced(this));
+    }
+
+    /**
+     * Access to current configuration settings
+     * 
+     * @param propName the property name
+     * @return the current property value
+     */
+    String get(String propName) {
+      return location.getConfProp(propName);
+    }
+
+    String get(ConfProp prop) {
+      return location.getConfProp(prop);
+    }
+
+    /**
+     * Implements change notifications from any tab: update the location
+     * state and other tabs
+     * 
+     * @param source origin of the notification (one of the tree tabs)
+     * @param propName modified property
+     * @param propValue new value
+     */
+    void notifyChange(TabListener source, final ConfProp prop,
+        final String propValue) {
+      // Ignore notification when no change
+      String oldValue = location.getConfProp(prop);
+      if ((oldValue != null) && oldValue.equals(propValue))
+        return;
+
+      location.setConfProp(prop, propValue);
+      Display.getDefault().syncExec(new Runnable() {
+        public void run() {
+          getContainer().updateButtons();
+        }
+      });
+
+      this.fireChange(source, prop, propValue);
+
+      /*
+       * Now we deal with dependencies between settings
+       */
+      final String jobTrackerHost =
+          location.getConfProp(ConfProp.PI_JOB_TRACKER_HOST);
+      final String jobTrackerPort =
+          location.getConfProp(ConfProp.PI_JOB_TRACKER_PORT);
+      final String nameNodeHost =
+          location.getConfProp(ConfProp.PI_NAME_NODE_HOST);
+      final String nameNodePort =
+          location.getConfProp(ConfProp.PI_NAME_NODE_PORT);
+      final boolean colocate =
+          location.getConfProp(ConfProp.PI_COLOCATE_MASTERS)
+              .equalsIgnoreCase("yes");
+      final String jobTrackerURI =
+          location.getConfProp(ConfProp.JOB_TRACKER_URI);
+      final String fsDefaultURI =
+          location.getConfProp(ConfProp.FS_DEFAULT_URI);
+      final String socksServerURI =
+          location.getConfProp(ConfProp.SOCKS_SERVER);
+      final boolean socksProxyEnable =
+          location.getConfProp(ConfProp.PI_SOCKS_PROXY_ENABLE)
+              .equalsIgnoreCase("yes");
+      final String socksProxyHost =
+          location.getConfProp(ConfProp.PI_SOCKS_PROXY_HOST);
+      final String socksProxyPort =
+          location.getConfProp(ConfProp.PI_SOCKS_PROXY_PORT);
+
+      Display.getDefault().syncExec(new Runnable() {
+        public void run() {
+          switch (prop) {
+            case PI_JOB_TRACKER_HOST: {
+              if (colocate)
+                notifyChange(null, ConfProp.PI_NAME_NODE_HOST,
+                    jobTrackerHost);
+              String newJobTrackerURI =
+                  String.format("%s:%s", jobTrackerHost, jobTrackerPort);
+              notifyChange(null, ConfProp.JOB_TRACKER_URI, newJobTrackerURI);
+              break;
+            }
+            case PI_JOB_TRACKER_PORT: {
+              String newJobTrackerURI =
+                  String.format("%s:%s", jobTrackerHost, jobTrackerPort);
+              notifyChange(null, ConfProp.JOB_TRACKER_URI, newJobTrackerURI);
+              break;
+            }
+            case PI_NAME_NODE_HOST: {
+              String newHDFSURI =
+                  String.format("hdfs://%s:%s/", nameNodeHost, nameNodePort);
+              notifyChange(null, ConfProp.FS_DEFAULT_URI, newHDFSURI);
+
+              // Break colocation if someone force the DFS Master
+              if (!colocate && !nameNodeHost.equals(jobTrackerHost))
+                notifyChange(null, ConfProp.PI_COLOCATE_MASTERS, "no");
+              break;
+            }
+            case PI_NAME_NODE_PORT: {
+              String newHDFSURI =
+                  String.format("hdfs://%s:%s/", nameNodeHost, nameNodePort);
+              notifyChange(null, ConfProp.FS_DEFAULT_URI, newHDFSURI);
+              break;
+            }
+            case PI_SOCKS_PROXY_HOST: {
+              String newSocksProxyURI =
+                  String.format("%s:%s", socksProxyHost, socksProxyPort);
+              notifyChange(null, ConfProp.SOCKS_SERVER, newSocksProxyURI);
+              break;
+            }
+            case PI_SOCKS_PROXY_PORT: {
+              String newSocksProxyURI =
+                  String.format("%s:%s", socksProxyHost, socksProxyPort);
+              notifyChange(null, ConfProp.SOCKS_SERVER, newSocksProxyURI);
+              break;
+            }
+            case JOB_TRACKER_URI: {
+              String[] strs = jobTrackerURI.split(":", 2);
+              String host = strs[0];
+              String port = (strs.length == 2) ? strs[1] : "";
+              notifyChange(null, ConfProp.PI_JOB_TRACKER_HOST, host);
+              notifyChange(null, ConfProp.PI_JOB_TRACKER_PORT, port);
+              break;
+            }
+            case FS_DEFAULT_URI: {
+              try {
+                URI uri = new URI(fsDefaultURI);
+                if (uri.getScheme().equals("hdfs")) {
+                  String host = uri.getHost();
+                  String port = Integer.toString(uri.getPort());
+                  notifyChange(null, ConfProp.PI_NAME_NODE_HOST, host);
+                  notifyChange(null, ConfProp.PI_NAME_NODE_PORT, port);
+                }
+              } catch (URISyntaxException use) {
+                // Ignore the update!
+              }
+              break;
+            }
+            case SOCKS_SERVER: {
+              String[] strs = socksServerURI.split(":", 2);
+              String host = strs[0];
+              String port = (strs.length == 2) ? strs[1] : "";
+              notifyChange(null, ConfProp.PI_SOCKS_PROXY_HOST, host);
+              notifyChange(null, ConfProp.PI_SOCKS_PROXY_PORT, port);
+              break;
+            }
+            case PI_COLOCATE_MASTERS: {
+              if (colocate)
+                notifyChange(null, ConfProp.PI_NAME_NODE_HOST,
+                    jobTrackerHost);
+              break;
+            }
+            case PI_SOCKS_PROXY_ENABLE: {
+              if (socksProxyEnable) {
+                notifyChange(null, ConfProp.SOCKET_FACTORY_DEFAULT,
+                    "org.apache.hadoop.net.SocksSocketFactory");
+              } else {
+                notifyChange(null, ConfProp.SOCKET_FACTORY_DEFAULT,
+                "org.apache.hadoop.net.StandardSocketFactory");
+              }
+              break;
+            }
+          }
+        }
+      });
+
+    }
+
+    /**
+     * Change notifications on properties (by name). A property might not be
+     * reflected as a ConfProp enum. If it is, the notification is forwarded
+     * to the ConfProp notifyChange method. If not, it is processed here.
+     * 
+     * @param source
+     * @param propName
+     * @param propValue
+     */
+    void notifyChange(TabListener source, String propName, String propValue) {
+
+      ConfProp prop = ConfProp.getByName(propName);
+      if (prop != null)
+        notifyChange(source, prop, propValue);
+
+      location.setConfProp(propName, propValue);
+    }
+
+    /**
+     * Broadcast a property change to all registered tabs. If a tab is
+     * identified as the source of the change, this tab will not be notified.
+     * 
+     * @param source TODO
+     * @param prop
+     * @param value
+     */
+    private void fireChange(TabListener source, ConfProp prop, String value) {
+      for (TabListener tab : tabs) {
+        if (tab != source)
+          tab.notifyChange(prop, value);
+      }
+    }
+
+  }
+
+  /**
+   * Create a SWT Text component for the given {@link ConfProp} text
+   * configuration property.
+   * 
+   * @param listener
+   * @param parent
+   * @param prop
+   * @return
+   */
+  private Text createConfText(ModifyListener listener, Composite parent,
+      ConfProp prop) {
+
+    Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
+    GridData data = new GridData(GridData.FILL_HORIZONTAL);
+    text.setLayoutData(data);
+    text.setData("hProp", prop);
+    text.setText(location.getConfProp(prop));
+    text.addModifyListener(listener);
+
+    return text;
+  }
+
+  /**
+   * Create a SWT Checked Button component for the given {@link ConfProp}
+   * boolean configuration property.
+   * 
+   * @param listener
+   * @param parent
+   * @param prop
+   * @return
+   */
+  private Button createConfCheckButton(SelectionListener listener,
+      Composite parent, ConfProp prop, String text) {
+
+    Button button = new Button(parent, SWT.CHECK);
+    button.setText(text);
+    button.setData("hProp", prop);
+    button.setSelection(location.getConfProp(prop).equalsIgnoreCase("yes"));
+    button.addSelectionListener(listener);
+
+    return button;
+  }
+
+  /**
+   * Create editor entry for the given configuration property. The editor is
+   * a couple (Label, Text).
+   * 
+   * @param listener the listener to trigger on property change
+   * @param parent the SWT parent container
+   * @param prop the property to create an editor for
+   * @param labelText a label (null will defaults to the property name)
+   * 
+   * @return a SWT Text field
+   */
+  private Text createConfLabelText(ModifyListener listener,
+      Composite parent, ConfProp prop, String labelText) {
+
+    Label label = new Label(parent, SWT.NONE);
+    if (labelText == null)
+      labelText = prop.name;
+    label.setText(labelText);
+
+    return createConfText(listener, parent, prop);
+  }
+
+  /**
+   * Create an editor entry for the given configuration name
+   * 
+   * @param listener the listener to trigger on property change
+   * @param parent the SWT parent container
+   * @param propName the name of the property to create an editor for
+   * @param labelText a label (null will defaults to the property name)
+   * 
+   * @return a SWT Text field
+   */
+  private Text createConfNameEditor(ModifyListener listener,
+      Composite parent, String propName, String labelText) {
+
+    {
+      ConfProp prop = ConfProp.getByName(propName);
+      if (prop != null)
+        return createConfLabelText(listener, parent, prop, labelText);
+    }
+
+    Label label = new Label(parent, SWT.NONE);
+    if (labelText == null)
+      labelText = propName;
+    label.setText(labelText);
+
+    Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
+    GridData data = new GridData(GridData.FILL_HORIZONTAL);
+    text.setLayoutData(data);
+    text.setData("hPropName", propName);
+    text.setText(location.getConfProp(propName));
+    text.addModifyListener(listener);
+
+    return text;
+  }
+
+  /**
+   * Main parameters of the Hadoop location:
+   * <li> host and port of the Map/Reduce master (Job tracker)
+   * <li> host and port of the DFS master (Name node)
+   * <li> SOCKS proxy
+   */
+  private class TabMain implements TabListener, ModifyListener,
+      SelectionListener {
+
+    TabMediator mediator;
+
+    Text locationName;
+
+    Text textJTHost;
+
+    Text textNNHost;
+
+    Button colocateMasters;
+
+    Text textJTPort;
+
+    Text textNNPort;
+
+    Text userName;
+
+    Button useSocksProxy;
+
+    Text socksProxyHost;
+
+    Text socksProxyPort;
+
+    TabMain(TabMediator mediator) {
+      this.mediator = mediator;
+      TabItem tab = new TabItem(mediator.folder, SWT.NONE);
+      tab.setText("General");
+      tab.setToolTipText("General location parameters");
+      tab.setImage(circle);
+      tab.setControl(createControl(mediator.folder));
+    }
+
+    private Control createControl(Composite parent) {
+
+      Composite panel = new Composite(parent, SWT.FILL);
+      panel.setLayout(new GridLayout(2, false));
+
+      GridData data;
+
+      /*
+       * Location name
+       */
+      {
+        Composite subpanel = new Composite(panel, SWT.FILL);
+        subpanel.setLayout(new GridLayout(2, false));
+        data = new GridData();
+        data.horizontalSpan = 2;
+        data.horizontalAlignment = SWT.FILL;
+        subpanel.setLayoutData(data);
+
+        locationName =
+            createConfLabelText(this, subpanel, ConfProp.PI_LOCATION_NAME,
+                "&Location name:");
+      }
+
+      /*
+       * Map/Reduce group
+       */
+      {
+        Group groupMR = new Group(panel, SWT.SHADOW_NONE);
+        groupMR.setText("Map/Reduce Master");
+        groupMR.setToolTipText("Address of the Map/Reduce master node "
+            + "(the Job Tracker).");
+        GridLayout layout = new GridLayout(2, false);
+        groupMR.setLayout(layout);
+        data = new GridData();
+        data.verticalAlignment = SWT.FILL;
+        data.horizontalAlignment = SWT.CENTER;
+        data.widthHint = 250;
+        groupMR.setLayoutData(data);
+
+        // Job Tracker host
+        Label label = new Label(groupMR, SWT.NONE);
+        label.setText("Host:");
+        data =
+            new GridData(GridData.BEGINNING, GridData.CENTER, false, true);
+        label.setLayoutData(data);
+
+        textJTHost =
+            createConfText(this, groupMR, ConfProp.PI_JOB_TRACKER_HOST);
+        data = new GridData(GridData.FILL, GridData.CENTER, true, true);
+        textJTHost.setLayoutData(data);
+
+        // Job Tracker port
+        label = new Label(groupMR, SWT.NONE);
+        label.setText("Port:");
+        data =
+            new GridData(GridData.BEGINNING, GridData.CENTER, false, true);
+        label.setLayoutData(data);
+
+        textJTPort =
+            createConfText(this, groupMR, ConfProp.PI_JOB_TRACKER_PORT);
+        data = new GridData(GridData.FILL, GridData.CENTER, true, true);
+        textJTPort.setLayoutData(data);
+      }
+
+      /*
+       * DFS group
+       */
+      {
+        Group groupDFS = new Group(panel, SWT.SHADOW_NONE);
+        groupDFS.setText("DFS Master");
+        groupDFS.setToolTipText("Address of the Distributed FileSystem "
+            + "master node (the Name Node).");
+        GridLayout layout = new GridLayout(2, false);
+        groupDFS.setLayout(layout);
+        data = new GridData();
+        data.horizontalAlignment = SWT.CENTER;
+        data.widthHint = 250;
+        groupDFS.setLayoutData(data);
+
+        colocateMasters =
+            createConfCheckButton(this, groupDFS,
+                ConfProp.PI_COLOCATE_MASTERS, "Use M/R Master host");
+        data = new GridData();
+        data.horizontalSpan = 2;
+        colocateMasters.setLayoutData(data);
+
+        // Job Tracker host
+        Label label = new Label(groupDFS, SWT.NONE);
+        data = new GridData();
+        label.setText("Host:");
+        label.setLayoutData(data);
+
+        textNNHost =
+            createConfText(this, groupDFS, ConfProp.PI_NAME_NODE_HOST);
+
+        // Job Tracker port
+        label = new Label(groupDFS, SWT.NONE);
+        data = new GridData();
+        label.setText("Port:");
+        label.setLayoutData(data);
+
+        textNNPort =
+            createConfText(this, groupDFS, ConfProp.PI_NAME_NODE_PORT);
+      }
+
+      {
+        Composite subpanel = new Composite(panel, SWT.FILL);
+        subpanel.setLayout(new GridLayout(2, false));
+        data = new GridData();
+        data.horizontalSpan = 2;
+        data.horizontalAlignment = SWT.FILL;
+        subpanel.setLayoutData(data);
+
+        userName =
+            createConfLabelText(this, subpanel, ConfProp.PI_USER_NAME,
+                "&User name:");
+      }
+
+      // SOCKS proxy group
+      {
+        Group groupSOCKS = new Group(panel, SWT.SHADOW_NONE);
+        groupSOCKS.setText("SOCKS proxy");
+        groupSOCKS.setToolTipText("Address of the SOCKS proxy to use "
+            + "to connect to the infrastructure.");
+        GridLayout layout = new GridLayout(2, false);
+        groupSOCKS.setLayout(layout);
+        data = new GridData();
+        data.horizontalAlignment = SWT.CENTER;
+        data.horizontalSpan = 2;
+        data.widthHint = 250;
+        groupSOCKS.setLayoutData(data);
+
+        useSocksProxy =
+            createConfCheckButton(this, groupSOCKS,
+                ConfProp.PI_SOCKS_PROXY_ENABLE, "Enable SOCKS proxy");
+        data = new GridData();
+        data.horizontalSpan = 2;
+        useSocksProxy.setLayoutData(data);
+
+        // SOCKS proxy host
+        Label label = new Label(groupSOCKS, SWT.NONE);
+        data = new GridData();
+        label.setText("Host:");
+        label.setLayoutData(data);
+
+        socksProxyHost =
+            createConfText(this, groupSOCKS, ConfProp.PI_SOCKS_PROXY_HOST);
+
+        // SOCKS proxy port
+        label = new Label(groupSOCKS, SWT.NONE);
+        data = new GridData();
+        label.setText("Port:");
+        label.setLayoutData(data);
+
+        socksProxyPort =
+            createConfText(this, groupSOCKS, ConfProp.PI_SOCKS_PROXY_PORT);
+      }
+
+      // Update the state of all widgets according to the current values!
+      reloadConfProp(ConfProp.PI_COLOCATE_MASTERS);
+      reloadConfProp(ConfProp.PI_SOCKS_PROXY_ENABLE);
+      reloadConfProp(ConfProp.PI_JOB_TRACKER_HOST);
+
+      return panel;
+    }
+
+    /**
+     * Reload the given configuration property value
+     * 
+     * @param prop
+     */
+    private void reloadConfProp(ConfProp prop) {
+      this.notifyChange(prop, location.getConfProp(prop));
+    }
+
+    public void notifyChange(ConfProp prop, String propValue) {
+      switch (prop) {
+        case PI_JOB_TRACKER_HOST: {
+          textJTHost.setText(propValue);
+          break;
+        }
+        case PI_JOB_TRACKER_PORT: {
+          textJTPort.setText(propValue);
+          break;
+        }
+        case PI_LOCATION_NAME: {
+          locationName.setText(propValue);
+          break;
+        }
+        case PI_USER_NAME: {
+          userName.setText(propValue);
+          break;
+        }
+        case PI_COLOCATE_MASTERS: {
+          if (colocateMasters != null) {
+            boolean colocate = propValue.equalsIgnoreCase("yes");
+            colocateMasters.setSelection(colocate);
+            if (textNNHost != null) {
+              textNNHost.setEnabled(!colocate);
+            }
+          }
+          break;
+        }
+        case PI_NAME_NODE_HOST: {
+          textNNHost.setText(propValue);
+          break;
+        }
+        case PI_NAME_NODE_PORT: {
+          textNNPort.setText(propValue);
+          break;
+        }
+        case PI_SOCKS_PROXY_ENABLE: {
+          if (useSocksProxy != null) {
+            boolean useProxy = propValue.equalsIgnoreCase("yes");
+            useSocksProxy.setSelection(useProxy);
+            if (socksProxyHost != null)
+              socksProxyHost.setEnabled(useProxy);
+            if (socksProxyPort != null)
+              socksProxyPort.setEnabled(useProxy);
+          }
+          break;
+        }
+        case PI_SOCKS_PROXY_HOST: {
+          socksProxyHost.setText(propValue);
+          break;
+        }
+        case PI_SOCKS_PROXY_PORT: {
+          socksProxyPort.setText(propValue);
+          break;
+        }
+      }
+    }
+
+    /* @inheritDoc */
+    public void modifyText(ModifyEvent e) {
+      final Text text = (Text) e.widget;
+      final ConfProp prop = (ConfProp) text.getData("hProp");
+      Display.getDefault().syncExec(new Runnable() {
+        public void run() {
+          mediator.notifyChange(TabMain.this, prop, text.getText());
+        }
+      });
+    }
+
+    /* @inheritDoc */
+    public void widgetDefaultSelected(SelectionEvent e) {
+      this.widgetSelected(e);
+    }
+
+    /* @inheritDoc */
+    public void widgetSelected(SelectionEvent e) {
+      final Button button = (Button) e.widget;
+      final ConfProp prop = (ConfProp) button.getData("hProp");
+
+      Display.getDefault().syncExec(new Runnable() {
+        public void run() {
+          // We want to receive the update also!
+          mediator.notifyChange(null, prop, button.getSelection() ? "yes"
+              : "no");
+        }
+      });
+    }
+
+  }
+
+  private class TabAdvanced implements TabListener, ModifyListener {
+    TabMediator mediator;
+
+    private Composite panel;
+
+    private Map<String, Text> textMap = new TreeMap<String, Text>();
+
+    TabAdvanced(TabMediator mediator) {
+      this.mediator = mediator;
+      TabItem tab = new TabItem(mediator.folder, SWT.NONE);
+      tab.setText("Advanced parameters");
+      tab.setToolTipText("Access to advanced Hadoop parameters");
+      tab.setImage(circle);
+      tab.setControl(createControl(mediator.folder));
+
+    }
+
+    private Control createControl(Composite parent) {
+      ScrolledComposite sc =
+          new ScrolledComposite(parent, SWT.BORDER | SWT.H_SCROLL
+              | SWT.V_SCROLL);
+
+      panel = new Composite(sc, SWT.NONE);
+      sc.setContent(panel);
+
+      sc.setExpandHorizontal(true);
+      sc.setExpandVertical(true);
+
+      sc.setMinSize(640, 480);
+
+      GridLayout layout = new GridLayout();
+      layout.numColumns = 2;
+      layout.makeColumnsEqualWidth = false;
+      panel.setLayout(layout);
+      panel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
+          true, 1, 1));
+
+      // Sort by property name
+      Configuration config = location.getConfiguration();
+      SortedMap<String, String> map = new TreeMap<String, String>();
+      Iterator<Entry<String, String>> it = config.iterator();
+      while (it.hasNext()) {
+        Entry<String, String> entry = it.next();
+        map.put(entry.getKey(), entry.getValue());
+      }
+
+      for (Entry<String, String> entry : map.entrySet()) {
+        Text text = createConfNameEditor(this, panel, entry.getKey(), null);
+        textMap.put(entry.getKey(), text);
+      }
+
+      sc.setMinSize(panel.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+      return sc;
+    }
+
+    public void notifyChange(ConfProp prop, final String propValue) {
+      Text text = textMap.get(prop.name);
+      text.setText(propValue);
+    }
+
+    public void modifyText(ModifyEvent e) {
+      final Text text = (Text) e.widget;
+      Object hProp = text.getData("hProp");
+      final ConfProp prop = (hProp != null) ? (ConfProp) hProp : null;
+      Object hPropName = text.getData("hPropName");
+      final String propName =
+          (hPropName != null) ? (String) hPropName : null;
+
+      Display.getDefault().syncExec(new Runnable() {
+        public void run() {
+          if (prop != null)
+            mediator.notifyChange(TabAdvanced.this, prop, text.getText());
+          else
+            mediator
+                .notifyChange(TabAdvanced.this, propName, text.getText());
+        }
+      });
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/77/77ef1187f3557d88b99a1c24549d174cec11aaf3.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/77/77ef1187f3557d88b99a1c24549d174cec11aaf3.svn-base b/eclipse-plugin/.svn/pristine/77/77ef1187f3557d88b99a1c24549d174cec11aaf3.svn-base
new file mode 100644
index 0000000..30a37cd
--- /dev/null
+++ b/eclipse-plugin/.svn/pristine/77/77ef1187f3557d88b99a1c24549d174cec11aaf3.svn-base
@@ -0,0 +1,203 @@
+/**
+ * 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.hadoop.eclipse.servers;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.eclipse.Activator;
+import org.apache.hadoop.eclipse.server.HadoopServer;
+import org.eclipse.jface.dialogs.MessageDialog;
+
+/**
+ * Register of Hadoop locations.
+ * 
+ * Each location corresponds to a Hadoop {@link Configuration} stored as an
+ * XML file in the workspace plug-in configuration directory:
+ * <p>
+ * <tt>
+ * &lt;workspace-dir&gt;/.metadata/.plugins/org.apache.hadoop.eclipse/locations/*.xml
+ * </tt>
+ * 
+ */
+public class ServerRegistry {
+
+  private static final ServerRegistry INSTANCE = new ServerRegistry();
+
+  public static final int SERVER_ADDED = 0;
+
+  public static final int SERVER_REMOVED = 1;
+
+  public static final int SERVER_STATE_CHANGED = 2;
+
+  private final File baseDir =
+      Activator.getDefault().getStateLocation().toFile();
+
+  private final File saveDir = new File(baseDir, "locations");
+
+  private ServerRegistry() {
+    if (saveDir.exists() && !saveDir.isDirectory())
+      saveDir.delete();
+    if (!saveDir.exists())
+      saveDir.mkdirs();
+
+    load();
+  }
+
+  private Map<String, HadoopServer> servers;
+
+  private Set<IHadoopServerListener> listeners =
+      new HashSet<IHadoopServerListener>();
+
+  public static ServerRegistry getInstance() {
+    return INSTANCE;
+  }
+
+  public synchronized Collection<HadoopServer> getServers() {
+    return Collections.unmodifiableCollection(servers.values());
+  }
+
+  /**
+   * Load all available locations from the workspace configuration directory.
+   */
+  private synchronized void load() {
+    Map<String, HadoopServer> map = new TreeMap<String, HadoopServer>();
+    for (File file : saveDir.listFiles()) {
+      try {
+        HadoopServer server = new HadoopServer(file);
+        map.put(server.getLocationName(), server);
+
+      } catch (Exception exn) {
+        System.err.println(exn);
+      }
+    }
+    this.servers = map;
+  }
+
+  private synchronized void store() {
+    try {
+      File dir = File.createTempFile("locations", "new", baseDir);
+      dir.delete();
+      dir.mkdirs();
+
+      for (HadoopServer server : servers.values()) {
+        server.storeSettingsToFile(new File(dir, server.getLocationName()
+            + ".xml"));
+      }
+
+      FilenameFilter XMLFilter = new FilenameFilter() {
+        public boolean accept(File dir, String name) {
+          String lower = name.toLowerCase();
+          return lower.endsWith(".xml");
+        }
+      };
+
+      File backup = new File(baseDir, "locations.backup");
+      if (backup.exists()) {
+        for (File file : backup.listFiles(XMLFilter))
+          if (!file.delete())
+            throw new IOException("Unable to delete backup location file: "
+                + file);
+        if (!backup.delete())
+          throw new IOException(
+              "Unable to delete backup location directory: " + backup);
+      }
+
+      saveDir.renameTo(backup);
+      dir.renameTo(saveDir);
+
+    } catch (IOException ioe) {
+      ioe.printStackTrace();
+      MessageDialog.openError(null,
+          "Saving configuration of Hadoop locations failed", ioe.toString());
+    }
+  }
+
+  public void dispose() {
+    for (HadoopServer server : getServers()) {
+      server.dispose();
+    }
+  }
+
+  public synchronized HadoopServer getServer(String location) {
+    return servers.get(location);
+  }
+
+  /*
+   * HadoopServer map listeners
+   */
+
+  public void addListener(IHadoopServerListener l) {
+    synchronized (listeners) {
+      listeners.add(l);
+    }
+  }
+
+  public void removeListener(IHadoopServerListener l) {
+    synchronized (listeners) {
+      listeners.remove(l);
+    }
+  }
+
+  private void fireListeners(HadoopServer location, int kind) {
+    synchronized (listeners) {
+      for (IHadoopServerListener listener : listeners) {
+        listener.serverChanged(location, kind);
+      }
+    }
+  }
+
+  public synchronized void removeServer(HadoopServer server) {
+    this.servers.remove(server.getLocationName());
+    store();
+    fireListeners(server, SERVER_REMOVED);
+  }
+
+  public synchronized void addServer(HadoopServer server) {
+    this.servers.put(server.getLocationName(), server);
+    store();
+    fireListeners(server, SERVER_ADDED);
+  }
+
+  /**
+   * Update one Hadoop location
+   * 
+   * @param originalName the original location name (might have changed)
+   * @param server the location
+   */
+  public synchronized void updateServer(String originalName,
+      HadoopServer server) {
+
+    // Update the map if the location name has changed
+    if (!server.getLocationName().equals(originalName)) {
+      servers.remove(originalName);
+      servers.put(server.getLocationName(), server);
+    }
+    store();
+    fireListeners(server, SERVER_STATE_CHANGED);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/7b/7b05b0524be44ceb90d7eeab43a68fde8e9e670f.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/7b/7b05b0524be44ceb90d7eeab43a68fde8e9e670f.svn-base b/eclipse-plugin/.svn/pristine/7b/7b05b0524be44ceb90d7eeab43a68fde8e9e670f.svn-base
new file mode 100644
index 0000000..55a2e60
--- /dev/null
+++ b/eclipse-plugin/.svn/pristine/7b/7b05b0524be44ceb90d7eeab43a68fde8e9e670f.svn-base
@@ -0,0 +1,184 @@
+/**
+ * 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.hadoop.eclipse;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
+import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * Wizard for creating a new Reducer class (a class that runs the Reduce
+ * portion of a MapReduce job). The class is pre-filled with a template.
+ * 
+ */
+
+public class NewReducerWizard extends NewElementWizard implements
+    INewWizard, IRunnableWithProgress {
+  private Page page;
+
+  public NewReducerWizard() {
+    setWindowTitle("New Reducer");
+  }
+
+  public void run(IProgressMonitor monitor) {
+    try {
+      page.createType(monitor);
+    } catch (CoreException e) {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    } catch (InterruptedException e) {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+  }
+
+  @Override
+  public void init(IWorkbench workbench, IStructuredSelection selection) {
+    super.init(workbench, selection);
+
+    page = new Page();
+    addPage(page);
+    page.setSelection(selection);
+  }
+
+  public static class Page extends NewTypeWizardPage {
+    public Page() {
+      super(true, "Reducer");
+
+      setTitle("Reducer");
+      setDescription("Create a new Reducer implementation.");
+      setImageDescriptor(ImageLibrary.get("wizard.reducer.new"));
+    }
+
+    public void setSelection(IStructuredSelection selection) {
+      initContainerPage(getInitialJavaElement(selection));
+      initTypePage(getInitialJavaElement(selection));
+    }
+
+    @Override
+    public void createType(IProgressMonitor monitor) throws CoreException,
+        InterruptedException {
+      super.createType(monitor);
+    }
+
+    @Override
+    protected void createTypeMembers(IType newType, ImportsManager imports,
+        IProgressMonitor monitor) throws CoreException {
+      super.createTypeMembers(newType, imports, monitor);
+      imports.addImport("java.io.IOException");
+      imports.addImport("org.apache.hadoop.io.WritableComparable");
+      imports.addImport("org.apache.hadoop.mapred.OutputCollector");
+      imports.addImport("org.apache.hadoop.mapred.Reporter");
+      imports.addImport("java.util.Iterator");
+      newType
+          .createMethod(
+              "public void reduce(WritableComparable _key, Iterator values, OutputCollector output, Reporter reporter) throws IOException \n{\n"
+                  + "\t// replace KeyType with the real type of your key\n"
+                  + "\tKeyType key = (KeyType) _key;\n\n"
+                  + "\twhile (values.hasNext()) {\n"
+                  + "\t\t// replace ValueType with the real type of your value\n"
+                  + "\t\tValueType value = (ValueType) values.next();\n\n"
+                  + "\t\t// process value\n" + "\t}\n" + "}\n", null, false,
+              monitor);
+    }
+
+    public void createControl(Composite parent) {
+      // super.createControl(parent);
+
+      initializeDialogUnits(parent);
+      Composite composite = new Composite(parent, SWT.NONE);
+      GridLayout layout = new GridLayout();
+      layout.numColumns = 4;
+      composite.setLayout(layout);
+
+      createContainerControls(composite, 4);
+      createPackageControls(composite, 4);
+      createSeparator(composite, 4);
+      createTypeNameControls(composite, 4);
+      createSuperClassControls(composite, 4);
+      createSuperInterfacesControls(composite, 4);
+      // createSeparator(composite, 4);
+
+      setControl(composite);
+
+      setSuperClass("org.apache.hadoop.mapred.MapReduceBase", true);
+      setSuperInterfaces(Arrays
+          .asList(new String[] { "org.apache.hadoop.mapred.Reducer" }), true);
+
+      setFocus();
+      validate();
+    }
+
+    @Override
+    protected void handleFieldChanged(String fieldName) {
+      super.handleFieldChanged(fieldName);
+
+      validate();
+    }
+
+    private void validate() {
+      updateStatus(new IStatus[] { fContainerStatus, fPackageStatus,
+          fTypeNameStatus, fSuperClassStatus, fSuperInterfacesStatus });
+    }
+  }
+
+  @Override
+  public boolean performFinish() {
+    if (super.performFinish()) {
+      if (getCreatedElement() != null) {
+        selectAndReveal(page.getModifiedResource());
+        openResource((IFile) page.getModifiedResource());
+      }
+
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  @Override
+  protected void finishPage(IProgressMonitor monitor)
+      throws InterruptedException, CoreException {
+    this.run(monitor);
+  }
+
+  @Override
+  public IJavaElement getCreatedElement() {
+    return (page.getCreatedType() == null) ? null : page.getCreatedType()
+        .getPrimaryElement();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/7d/7def8343b8feb9aef49444c1e759d309b679b633.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/7d/7def8343b8feb9aef49444c1e759d309b679b633.svn-base b/eclipse-plugin/.svn/pristine/7d/7def8343b8feb9aef49444c1e759d309b679b633.svn-base
new file mode 100644
index 0000000..fca7d46
--- /dev/null
+++ b/eclipse-plugin/.svn/pristine/7d/7def8343b8feb9aef49444c1e759d309b679b633.svn-base
@@ -0,0 +1,244 @@
+/**
+ * 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.hadoop.eclipse.dfs;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.hadoop.eclipse.ImageLibrary;
+import org.apache.hadoop.eclipse.server.HadoopServer;
+import org.apache.hadoop.eclipse.servers.ServerRegistry;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Handles viewing of DFS locations
+ * <p>
+ * 
+ * The content handled by this provider is a tree:
+ * 
+ * <tt>
+ * <br>DFSLocationsRoot
+ * <br>\_HadoopServer
+ * <br>|  \_DfsFolder
+ * <br>|  |  \_DfsFile
+ * <br>|  \_DfsFolder
+ * <br>| ...
+ * <br>\_HadoopServer...
+ * </tt>
+ * 
+ * The code should not block here: blocking operations need to be done
+ * asynchronously so as not to freeze the UI!
+ */
+public class DFSContentProvider implements ITreeContentProvider,
+    ILabelProvider {
+
+  /**
+   * The viewer that displays this Tree content
+   */
+  private Viewer viewer;
+
+  private StructuredViewer sviewer;
+
+  private Map<HadoopServer, DFSContent> rootFolders =
+      new HashMap<HadoopServer, DFSContent>();
+
+  /**
+   * Constructor: load resources (icons).
+   */
+  public DFSContentProvider() {
+  }
+
+  private final DFSLocationsRoot locationsRoot = new DFSLocationsRoot(this);
+
+  /*
+   * ITreeContentProvider implementation
+   */
+
+  /* @inheritDoc */
+  public Object[] getChildren(Object parent) {
+
+    if (!(parent instanceof DFSContent))
+      return null;
+    DFSContent content = (DFSContent) parent;
+    return content.getChildren();
+  }
+
+  public Object[] test(Object parentElement) {
+    if (parentElement instanceof DFSLocationsRoot) {
+      return ServerRegistry.getInstance().getServers().toArray();
+
+    } else if (parentElement instanceof HadoopServer) {
+      final HadoopServer location = (HadoopServer) parentElement;
+      Object root = rootFolders.get(location);
+      if (root != null)
+        return new Object[] { root };
+
+      return new Object[] { "Connecting to DFS..." };
+
+    } else if (parentElement instanceof DFSFolder) {
+      DFSFolder folder = (DFSFolder) parentElement;
+      return folder.getChildren();
+    }
+
+    return new Object[] { "<Unknown DFSContent>" };
+  }
+
+  /* @inheritDoc */
+  public Object getParent(Object element) {
+
+    if (element instanceof DFSPath) {
+      return ((DFSPath) element).getParent();
+
+    } else if (element instanceof HadoopServer) {
+      return locationsRoot;
+    }
+
+    return null;
+  }
+
+  /* @inheritDoc */
+  public boolean hasChildren(Object element) {
+    if (element instanceof DFSContent) {
+      DFSContent content = (DFSContent) element;
+      return content.hasChildren();
+    }
+    return false;
+  }
+
+  /*
+   * IStructureContentProvider implementation
+   */
+
+  /* @inheritDoc */
+  public Object[] getElements(final Object inputElement) {
+    return new Object[] { locationsRoot };
+    // return ServerRegistry.getInstance().getServers().toArray();
+  }
+
+  /*
+   * ILabelProvider implementation
+   */
+
+  /* @inheritDoc */
+  public Image getImage(Object element) {
+    if (element instanceof DFSLocationsRoot)
+      return ImageLibrary.getImage("dfs.browser.root.entry");
+
+    else if (element instanceof DFSLocation)
+      return ImageLibrary.getImage("dfs.browser.location.entry");
+
+    else if (element instanceof DFSFolder)
+      return ImageLibrary.getImage("dfs.browser.folder.entry");
+
+    else if (element instanceof DFSFile)
+      return ImageLibrary.getImage("dfs.browser.file.entry");
+
+    return null;
+  }
+
+  /* @inheritDoc */
+  public String getText(Object element) {
+    if (element instanceof DFSFile)
+      return ((DFSFile) element).toDetailedString();
+
+    return element.toString();
+  }
+
+  /*
+   * IBaseLabelProvider implementation
+   */
+
+  /* @inheritDoc */
+  public void addListener(ILabelProviderListener listener) {
+  }
+
+  /* @inheritDoc */
+  public void removeListener(ILabelProviderListener listener) {
+  }
+
+  /* @inheritDoc */
+  public boolean isLabelProperty(Object element, String property) {
+    return false;
+  }
+
+  /*
+   * IContentProvider implementation
+   */
+
+  /* @inheritDoc */
+  public void dispose() {
+  }
+
+  /* @inheritDoc */
+  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+    this.viewer = viewer;
+    if ((viewer != null) && (viewer instanceof StructuredViewer))
+      this.sviewer = (StructuredViewer) viewer;
+    else
+      this.sviewer = null;
+  }
+
+  /*
+   * Miscellaneous
+   */
+
+  /**
+   * Ask the viewer for this content to refresh
+   */
+  void refresh() {
+    // no display, nothing to update
+    if (this.viewer == null)
+      return;
+
+    Display.getDefault().asyncExec(new Runnable() {
+      public void run() {
+        DFSContentProvider.this.viewer.refresh();
+      }
+    });
+  }
+
+  /**
+   * Ask the viewer to refresh a single element
+   * 
+   * @param content what to refresh
+   */
+  void refresh(final DFSContent content) {
+    if (this.sviewer != null) {
+      Display.getDefault().asyncExec(new Runnable() {
+        public void run() {
+          DFSContentProvider.this.sviewer.refresh(content);
+        }
+      });
+
+    } else {
+      refresh();
+    }
+  }
+
+  Viewer getViewer() {
+    return this.viewer;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/80/80d4b9ffc19060f0ce0d1afd50e43fc756fe81a1.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/80/80d4b9ffc19060f0ce0d1afd50e43fc756fe81a1.svn-base b/eclipse-plugin/.svn/pristine/80/80d4b9ffc19060f0ce0d1afd50e43fc756fe81a1.svn-base
new file mode 100644
index 0000000..c8b34c3
--- /dev/null
+++ b/eclipse-plugin/.svn/pristine/80/80d4b9ffc19060f0ce0d1afd50e43fc756fe81a1.svn-base
@@ -0,0 +1,478 @@
+/**
+ * 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.hadoop.eclipse.actions;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.hadoop.eclipse.ImageLibrary;
+import org.apache.hadoop.eclipse.dfs.DFSActions;
+import org.apache.hadoop.eclipse.dfs.DFSFile;
+import org.apache.hadoop.eclipse.dfs.DFSFolder;
+import org.apache.hadoop.eclipse.dfs.DFSLocation;
+import org.apache.hadoop.eclipse.dfs.DFSLocationsRoot;
+import org.apache.hadoop.eclipse.dfs.DFSPath;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.IStorageEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Actual implementation of DFS actions
+ */
+public class DFSActionImpl implements IObjectActionDelegate {
+
+  private ISelection selection;
+
+  private IWorkbenchPart targetPart;
+
+  /* @inheritDoc */
+  public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+    this.targetPart = targetPart;
+  }
+
+  /* @inheritDoc */
+  public void run(IAction action) {
+
+    // Ignore non structured selections
+    if (!(this.selection instanceof IStructuredSelection))
+      return;
+
+    // operate on the DFS asynchronously to prevent blocking the main UI
+    final IStructuredSelection ss = (IStructuredSelection) selection;
+    final String actionId = action.getActionDefinitionId();
+    Display.getDefault().asyncExec(new Runnable() {
+      public void run() {
+        try {
+          switch (DFSActions.getById(actionId)) {
+            case DELETE: {
+              delete(ss);
+              break;
+            }
+            case OPEN: {
+              open(ss);
+              break;
+            }
+            case MKDIR: {
+              mkdir(ss);
+              break;
+            }
+            case UPLOAD_FILES: {
+              uploadFilesToDFS(ss);
+              break;
+            }
+            case UPLOAD_DIR: {
+              uploadDirectoryToDFS(ss);
+              break;
+            }
+            case REFRESH: {
+              refresh(ss);
+              break;
+            }
+            case DOWNLOAD: {
+              downloadFromDFS(ss);
+              break;
+            }
+            case RECONNECT: {
+              reconnect(ss);
+              break;
+            }
+            case DISCONNECT: {
+              disconnect(ss);
+              break;
+            }
+            default: {
+              System.err.printf("Unhandled DFS Action: " + actionId);
+              break;
+            }
+          }
+
+        } catch (Exception e) {
+          e.printStackTrace();
+          MessageDialog.openError(Display.getDefault().getActiveShell(),
+              "DFS Action error",
+              "An error occurred while performing DFS operation: "
+                  + e.getMessage());
+        }
+      }
+    });
+  }
+
+  /**
+   * Create a new sub-folder into an existing directory
+   * 
+   * @param selection
+   */
+  private void mkdir(IStructuredSelection selection) {
+    List<DFSFolder> folders = filterSelection(DFSFolder.class, selection);
+    if (folders.size() >= 1) {
+      DFSFolder folder = folders.get(0);
+      InputDialog dialog =
+          new InputDialog(Display.getCurrent().getActiveShell(),
+              "Create subfolder", "Enter the name of the subfolder", "",
+              null);
+      if (dialog.open() == InputDialog.OK)
+        folder.mkdir(dialog.getValue());
+    }
+  }
+
+  /**
+   * Implement the import action (upload files from the current machine to
+   * HDFS)
+   * 
+   * @param object
+   * @throws SftpException
+   * @throws JSchException
+   * @throws InvocationTargetException
+   * @throws InterruptedException
+   */
+  private void uploadFilesToDFS(IStructuredSelection selection)
+      throws InvocationTargetException, InterruptedException {
+
+    // Ask the user which files to upload
+    FileDialog dialog =
+        new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN
+            | SWT.MULTI);
+    dialog.setText("Select the local files to upload");
+    dialog.open();
+
+    List<File> files = new ArrayList<File>();
+    for (String fname : dialog.getFileNames())
+      files.add(new File(dialog.getFilterPath() + File.separator + fname));
+
+    // TODO enable upload command only when selection is exactly one folder
+    List<DFSFolder> folders = filterSelection(DFSFolder.class, selection);
+    if (folders.size() >= 1)
+      uploadToDFS(folders.get(0), files);
+  }
+
+  /**
+   * Implement the import action (upload directory from the current machine
+   * to HDFS)
+   * 
+   * @param object
+   * @throws SftpException
+   * @throws JSchException
+   * @throws InvocationTargetException
+   * @throws InterruptedException
+   */
+  private void uploadDirectoryToDFS(IStructuredSelection selection)
+      throws InvocationTargetException, InterruptedException {
+
+    // Ask the user which local directory to upload
+    DirectoryDialog dialog =
+        new DirectoryDialog(Display.getCurrent().getActiveShell(), SWT.OPEN
+            | SWT.MULTI);
+    dialog.setText("Select the local file or directory to upload");
+
+    String dirName = dialog.open();
+    final File dir = new File(dirName);
+    List<File> files = new ArrayList<File>();
+    files.add(dir);
+
+    // TODO enable upload command only when selection is exactly one folder
+    final List<DFSFolder> folders =
+        filterSelection(DFSFolder.class, selection);
+    if (folders.size() >= 1)
+      uploadToDFS(folders.get(0), files);
+
+  }
+
+  private void uploadToDFS(final DFSFolder folder, final List<File> files)
+      throws InvocationTargetException, InterruptedException {
+
+    PlatformUI.getWorkbench().getProgressService().busyCursorWhile(
+        new IRunnableWithProgress() {
+          public void run(IProgressMonitor monitor)
+              throws InvocationTargetException {
+
+            int work = 0;
+            for (File file : files)
+              work += computeUploadWork(file);
+
+            monitor.beginTask("Uploading files to distributed file system",
+                work);
+
+            for (File file : files) {
+              try {
+                folder.upload(monitor, file);
+
+              } catch (IOException ioe) {
+                ioe.printStackTrace();
+                MessageDialog.openError(null,
+                    "Upload files to distributed file system",
+                    "Upload failed.\n" + ioe);
+              }
+            }
+
+            monitor.done();
+
+            // Update the UI
+            folder.doRefresh();
+          }
+        });
+  }
+
+  private void reconnect(IStructuredSelection selection) {
+    for (DFSLocation location : filterSelection(DFSLocation.class, selection))
+      location.reconnect();
+  }
+
+  private void disconnect(IStructuredSelection selection) {
+    if (selection.size() != 1)
+      return;
+
+    Object first = selection.getFirstElement();
+    if (!(first instanceof DFSLocationsRoot))
+      return;
+
+    DFSLocationsRoot root = (DFSLocationsRoot) first;
+    root.disconnect();
+    root.refresh();
+  }
+
+  /**
+   * Implements the Download action from HDFS to the current machine
+   * 
+   * @param object
+   * @throws SftpException
+   * @throws JSchException
+   * @throws InterruptedException
+   * @throws InvocationTargetException
+   */
+  private void downloadFromDFS(IStructuredSelection selection)
+      throws InvocationTargetException, InterruptedException {
+
+    // Ask the user where to put the downloaded files
+    DirectoryDialog dialog =
+        new DirectoryDialog(Display.getCurrent().getActiveShell());
+    dialog.setText("Copy to local directory");
+    dialog.setMessage("Copy the selected files and directories from the "
+        + "distributed filesystem to a local directory");
+    String directory = dialog.open();
+
+    if (directory == null)
+      return;
+
+    final File dir = new File(directory);
+    if (!dir.exists())
+      dir.mkdirs();
+
+    if (!dir.isDirectory()) {
+      MessageDialog.openError(null, "Download to local file system",
+          "Invalid directory location: \"" + dir + "\"");
+      return;
+    }
+
+    final List<DFSPath> paths = filterSelection(DFSPath.class, selection);
+
+    PlatformUI.getWorkbench().getProgressService().busyCursorWhile(
+        new IRunnableWithProgress() {
+          public void run(IProgressMonitor monitor)
+              throws InvocationTargetException {
+
+            int work = 0;
+            for (DFSPath path : paths)
+              work += path.computeDownloadWork();
+
+            monitor
+                .beginTask("Downloading files to local file system", work);
+
+            for (DFSPath path : paths) {
+              if (monitor.isCanceled())
+                return;
+              try {
+                path.downloadToLocalDirectory(monitor, dir);
+              } catch (Exception e) {
+                // nothing we want to do here
+                e.printStackTrace();
+              }
+            }
+
+            monitor.done();
+          }
+        });
+  }
+
+  /**
+   * Open the selected DfsPath in the editor window
+   * 
+   * @param selection
+   * @throws JSchException
+   * @throws IOException
+   * @throws PartInitException
+   * @throws InvocationTargetException
+   * @throws InterruptedException
+   */
+  private void open(IStructuredSelection selection) throws IOException,
+      PartInitException, InvocationTargetException, InterruptedException {
+
+    for (DFSFile file : filterSelection(DFSFile.class, selection)) {
+
+      IStorageEditorInput editorInput = new DFSFileEditorInput(file);
+      targetPart.getSite().getWorkbenchWindow().getActivePage().openEditor(
+          editorInput, "org.eclipse.ui.DefaultTextEditor");
+    }
+  }
+
+  /**
+   * @param selection
+   * @throws JSchException
+   */
+  private void refresh(IStructuredSelection selection) {
+    for (DFSPath path : filterSelection(DFSPath.class, selection))
+      path.refresh();
+
+  }
+
+  private void delete(IStructuredSelection selection) {
+    List<DFSPath> list = filterSelection(DFSPath.class, selection);
+    if (list.isEmpty())
+      return;
+
+    StringBuffer msg = new StringBuffer();
+    msg.append("Are you sure you want to delete "
+        + "the following files from the distributed file system?\n");
+    for (DFSPath path : list)
+      msg.append(path.getPath()).append("\n");
+
+    if (MessageDialog.openConfirm(null, "Confirm Delete from DFS", msg
+        .toString())) {
+
+      Set<DFSPath> toRefresh = new HashSet<DFSPath>();
+      for (DFSPath path : list) {
+        path.delete();
+        toRefresh.add(path.getParent());
+      }
+
+      for (DFSPath path : toRefresh) {
+        path.refresh();
+      }
+    }
+  }
+
+  /* @inheritDoc */
+  public void selectionChanged(IAction action, ISelection selection) {
+    this.selection = selection;
+  }
+
+  /**
+   * Extract the list of <T> from the structured selection
+   * 
+   * @param clazz the class T
+   * @param selection the structured selection
+   * @return the list of <T> it contains
+   */
+  private static <T> List<T> filterSelection(Class<T> clazz,
+      IStructuredSelection selection) {
+    List<T> list = new ArrayList<T>();
+    for (Object obj : selection.toList()) {
+      if (clazz.isAssignableFrom(obj.getClass())) {
+        list.add((T) obj);
+      }
+    }
+    return list;
+  }
+
+  private static int computeUploadWork(File file) {
+    if (file.isDirectory()) {
+      int contentWork = 1;
+      for (File child : file.listFiles())
+        contentWork += computeUploadWork(child);
+      return contentWork;
+
+    } else if (file.isFile()) {
+      return 1 + (int) (file.length() / 1024);
+
+    } else {
+      return 0;
+    }
+  }
+
+}
+
+/**
+ * Adapter to allow the viewing of a DfsFile in the Editor window
+ */
+class DFSFileEditorInput extends PlatformObject implements
+    IStorageEditorInput {
+
+  private DFSFile file;
+
+  /**
+   * Constructor
+   * 
+   * @param file
+   */
+  DFSFileEditorInput(DFSFile file) {
+    this.file = file;
+  }
+
+  /* @inheritDoc */
+  public String getToolTipText() {
+    return file.toDetailedString();
+  }
+
+  /* @inheritDoc */
+  public IPersistableElement getPersistable() {
+    return null;
+  }
+
+  /* @inheritDoc */
+  public String getName() {
+    return file.toString();
+  }
+
+  /* @inheritDoc */
+  public ImageDescriptor getImageDescriptor() {
+    return ImageLibrary.get("dfs.file.editor");
+  }
+
+  /* @inheritDoc */
+  public boolean exists() {
+    return true;
+  }
+
+  /* @inheritDoc */
+  public IStorage getStorage() throws CoreException {
+    return file.getIStorage();
+  }
+};

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/85/85314a28d030928a1618df24212b0071201ebabd.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/85/85314a28d030928a1618df24212b0071201ebabd.svn-base b/eclipse-plugin/.svn/pristine/85/85314a28d030928a1618df24212b0071201ebabd.svn-base
new file mode 100644
index 0000000..2df29e9
--- /dev/null
+++ b/eclipse-plugin/.svn/pristine/85/85314a28d030928a1618df24212b0071201ebabd.svn-base
@@ -0,0 +1,383 @@
+/**
+ * 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.hadoop.eclipse.servers;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.eclipse.Activator;
+import org.apache.hadoop.eclipse.ErrorMessageDialog;
+import org.apache.hadoop.eclipse.server.HadoopServer;
+import org.apache.hadoop.eclipse.server.JarModule;
+import org.apache.hadoop.io.IOUtils;
+import org.apache.hadoop.mapred.JobConf;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Wizard for publishing a job to a Hadoop server.
+ */
+
+public class RunOnHadoopWizard extends Wizard {
+
+  private MainWizardPage mainPage;
+
+  private HadoopLocationWizard createNewPage;
+
+  /**
+   * The file resource (containing a main()) to run on the Hadoop location
+   */
+  private IFile resource;
+
+  /**
+   * The launch configuration to update
+   */
+  private ILaunchConfigurationWorkingCopy iConf;
+
+  private IProgressMonitor progressMonitor;
+
+  public RunOnHadoopWizard(IFile resource,
+      ILaunchConfigurationWorkingCopy iConf) {
+    this.resource = resource;
+    this.iConf = iConf;
+    setForcePreviousAndNextButtons(true);
+    setNeedsProgressMonitor(true);
+    setWindowTitle("Run on Hadoop");
+  }
+
+  /**
+   * This wizard contains 2 pages:
+   * <li> the first one lets the user choose an already existing location
+   * <li> the second one allows the user to create a new location, in case it
+   * does not already exist
+   */
+  /* @inheritDoc */
+  @Override
+  public void addPages() {
+    addPage(this.mainPage = new MainWizardPage());
+    addPage(this.createNewPage = new HadoopLocationWizard());
+  }
+
+  /**
+   * Performs any actions appropriate in response to the user having pressed
+   * the Finish button, or refuse if finishing now is not permitted.
+   */
+  /* @inheritDoc */
+  @Override
+  public boolean performFinish() {
+
+    /*
+     * Create a new location or get an existing one
+     */
+    HadoopServer location = null;
+    if (mainPage.createNew.getSelection()) {
+      location = createNewPage.performFinish();
+
+    } else if (mainPage.table.getSelection().length == 1) {
+      location = (HadoopServer) mainPage.table.getSelection()[0].getData();
+    }
+
+    if (location == null)
+      return false;
+
+    /*
+     * Get the base directory of the plug-in for storing configurations and
+     * JARs
+     */
+    File baseDir = Activator.getDefault().getStateLocation().toFile();
+
+    // Package the Job into a JAR
+    File jarFile = JarModule.createJarPackage(resource);
+    if (jarFile == null) {
+      ErrorMessageDialog.display("Run on Hadoop",
+          "Unable to create or locate the JAR file for the Job");
+      return false;
+    }
+
+    /*
+     * Generate a temporary Hadoop configuration directory and add it to the
+     * classpath of the launch configuration
+     */
+
+    File confDir;
+    try {
+      confDir = File.createTempFile("hadoop-conf-", "", baseDir);
+      confDir.delete();
+      confDir.mkdirs();
+      if (!confDir.isDirectory()) {
+        ErrorMessageDialog.display("Run on Hadoop",
+            "Cannot create temporary directory: " + confDir);
+        return false;
+      }
+    } catch (IOException ioe) {
+      ioe.printStackTrace();
+      return false;
+    }
+
+    // Prepare the Hadoop configuration
+    JobConf conf = new JobConf(location.getConfiguration());
+    conf.setJar(jarFile.getAbsolutePath());
+
+    // Write it to the disk file
+    try {
+      // File confFile = File.createTempFile("core-site-", ".xml",
+      // confDir);
+      File confFile = new File(confDir, "core-site.xml");
+      FileOutputStream fos = new FileOutputStream(confFile);
+      try {
+        conf.writeXml(fos);
+        fos.close();
+        fos = null;
+      } finally {
+        IOUtils.closeStream(fos);
+      }
+
+    } catch (IOException ioe) {
+      ioe.printStackTrace();
+      return false;
+    }
+
+    // Setup the Launch class path
+    List<String> classPath;
+    try {
+      classPath =
+          iConf.getAttribute(
+              IJavaLaunchConfigurationConstants.ATTR_CLASSPATH,
+              new ArrayList());
+      IPath confIPath = new Path(confDir.getAbsolutePath());
+      IRuntimeClasspathEntry cpEntry =
+          JavaRuntime.newArchiveRuntimeClasspathEntry(confIPath);
+      classPath.add(0, cpEntry.getMemento());
+      iConf.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH,
+          classPath);
+      iConf.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, mainPage.argumentsText.getText());
+
+    } catch (CoreException e) {
+      e.printStackTrace();
+      return false;
+    }
+
+    // location.runResource(resource, progressMonitor);
+    return true;
+  }
+
+  private void refreshButtons() {
+    getContainer().updateButtons();
+  }
+
+  /**
+   * Allows finish when an existing server is selected or when a new server
+   * location is defined
+   */
+  /* @inheritDoc */
+  @Override
+  public boolean canFinish() {
+    if (mainPage != null)
+      return mainPage.canFinish();
+    return false;
+  }
+
+  /**
+   * This is the main page of the wizard. It allows the user either to choose
+   * an already existing location or to indicate he wants to create a new
+   * location.
+   */
+  public class MainWizardPage extends WizardPage {
+
+    private Button createNew;
+
+    private Table table;
+    private Text argumentsText;
+
+    private Button chooseExisting;
+
+    public MainWizardPage() {
+      super("Select or define server to run on");
+      setTitle("Select Hadoop location");
+      setDescription("Select a Hadoop location to run on.");
+    }
+
+    /* @inheritDoc */
+    @Override
+    public boolean canFlipToNextPage() {
+      return createNew.getSelection();
+    }
+
+    /* @inheritDoc */
+    public void createControl(Composite parent) {
+      Composite panel = new Composite(parent, SWT.NONE);
+      panel.setLayout(new GridLayout(1, false));     
+      
+      // Label
+      Label label = new Label(panel, SWT.NONE);
+      label.setText("Select a Hadoop Server to run on.");
+      GridData gData = new GridData(GridData.FILL_BOTH);
+      gData.grabExcessVerticalSpace = false;
+      label.setLayoutData(gData);
+
+      // Create location button
+      createNew = new Button(panel, SWT.RADIO);
+      createNew.setText("Define a new Hadoop server location");
+      createNew.setLayoutData(gData);
+      createNew.addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+
+        public void widgetSelected(SelectionEvent e) {
+          setPageComplete(true);
+          RunOnHadoopWizard.this.refreshButtons();
+        }
+      });
+      createNew.setSelection(true);
+
+      // Select existing location button
+      chooseExisting = new Button(panel, SWT.RADIO);
+      chooseExisting
+          .setText("Choose an existing server from the list below");
+      chooseExisting.setLayoutData(gData);
+      chooseExisting.addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+
+        public void widgetSelected(SelectionEvent e) {
+          if (chooseExisting.getSelection()
+              && (table.getSelectionCount() == 0)) {
+            if (table.getItems().length > 0) {
+              table.setSelection(0);
+            }
+          }
+          RunOnHadoopWizard.this.refreshButtons();
+        }
+      });
+
+      // Table of existing locations
+      Composite serverListPanel = new Composite(panel, SWT.FILL);
+      gData = new GridData(GridData.FILL_BOTH);
+      gData.horizontalSpan = 1;
+      serverListPanel.setLayoutData(gData);
+
+      FillLayout layout = new FillLayout();
+      layout.marginHeight = layout.marginWidth = 12;
+      serverListPanel.setLayout(layout);
+
+      table =
+          new Table(serverListPanel, SWT.BORDER | SWT.H_SCROLL
+              | SWT.V_SCROLL | SWT.FULL_SELECTION);
+      table.setHeaderVisible(true);
+      table.setLinesVisible(true);
+
+      TableColumn nameColumn = new TableColumn(table, SWT.LEFT);
+      nameColumn.setText("Location");
+      nameColumn.setWidth(450);
+
+      TableColumn hostColumn = new TableColumn(table, SWT.LEFT);
+      hostColumn.setText("Master host name");
+      hostColumn.setWidth(250);
+
+      // If the user select one entry, switch to "chooseExisting"
+      table.addSelectionListener(new SelectionListener() {
+        public void widgetDefaultSelected(SelectionEvent e) {
+        }
+
+        public void widgetSelected(SelectionEvent e) {
+          chooseExisting.setSelection(true);
+          createNew.setSelection(false);
+          setPageComplete(table.getSelectionCount() == 1);
+          RunOnHadoopWizard.this.refreshButtons();
+        }
+      });
+
+      // Label
+      Label argumentsLabel = new Label(panel, SWT.NONE);
+      argumentsLabel.setText("Arguments:");
+      GridData gDataArgumentsLabel = new GridData(GridData.FILL_BOTH);
+      gDataArgumentsLabel.grabExcessVerticalSpace = false;
+      argumentsLabel.setLayoutData(gDataArgumentsLabel); 
+      
+      // Textbox
+      argumentsText = new Text(panel, SWT.NONE);
+      try {
+        argumentsText.setText(iConf.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""));
+      } catch (CoreException e1) {
+        e1.printStackTrace();
+      }
+      GridData gDataArgumentsText = new GridData(GridData.FILL_BOTH);
+      gDataArgumentsText.grabExcessVerticalSpace = false;
+      argumentsText.setLayoutData(gDataArgumentsText);      
+      
+      
+      TableViewer viewer = new TableViewer(table);
+      HadoopServerSelectionListContentProvider provider =
+          new HadoopServerSelectionListContentProvider();
+      viewer.setContentProvider(provider);
+      viewer.setLabelProvider(provider);
+      viewer.setInput(new Object());
+      // don't care, get from singleton server registry
+
+      this.setControl(panel);
+    }
+
+    /**
+     * Returns whether this page state allows the Wizard to finish or not
+     * 
+     * @return can the wizard finish or not?
+     */
+    public boolean canFinish() {
+      if (!isControlCreated())
+        return false;
+
+      if (this.createNew.getSelection())
+        return getNextPage().isPageComplete();
+
+      return this.chooseExisting.getSelection();
+    }
+  }
+
+  /**
+   * @param progressMonitor
+   */
+  public void setProgressMonitor(IProgressMonitor progressMonitor) {
+    this.progressMonitor = progressMonitor;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/88/882e7039b17d98cff6f5278d927ac19f42b645c0.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/88/882e7039b17d98cff6f5278d927ac19f42b645c0.svn-base b/eclipse-plugin/.svn/pristine/88/882e7039b17d98cff6f5278d927ac19f42b645c0.svn-base
new file mode 100644
index 0000000..ba270f4
Binary files /dev/null and b/eclipse-plugin/.svn/pristine/88/882e7039b17d98cff6f5278d927ac19f42b645c0.svn-base differ

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/88/88ddc0785600bcca701bd54732cda11f2f99e70a.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/88/88ddc0785600bcca701bd54732cda11f2f99e70a.svn-base b/eclipse-plugin/.svn/pristine/88/88ddc0785600bcca701bd54732cda11f2f99e70a.svn-base
new file mode 100644
index 0000000..17f4ace
--- /dev/null
+++ b/eclipse-plugin/.svn/pristine/88/88ddc0785600bcca701bd54732cda11f2f99e70a.svn-base
@@ -0,0 +1,76 @@
+/**
+ * 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.hadoop.eclipse.servers;
+
+import org.apache.hadoop.eclipse.server.HadoopServer;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Provider that enables selection of a predefined Hadoop server.
+ */
+
+public class HadoopServerSelectionListContentProvider implements
+    IContentProvider, ITableLabelProvider, IStructuredContentProvider {
+  public void dispose() {
+
+  }
+
+  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+  }
+
+  public Image getColumnImage(Object element, int columnIndex) {
+    return null;
+  }
+
+  public String getColumnText(Object element, int columnIndex) {
+    if (element instanceof HadoopServer) {
+      HadoopServer location = (HadoopServer) element;
+      if (columnIndex == 0) {
+        return location.getLocationName();
+
+      } else if (columnIndex == 1) {
+        return location.getMasterHostName();
+      }
+    }
+
+    return element.toString();
+  }
+
+  public void addListener(ILabelProviderListener listener) {
+
+  }
+
+  public boolean isLabelProperty(Object element, String property) {
+    return false;
+  }
+
+  public void removeListener(ILabelProviderListener listener) {
+
+  }
+
+  public Object[] getElements(Object inputElement) {
+    return ServerRegistry.getInstance().getServers().toArray();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/8b/8bb56ee1409640bfc438904ff64c8d176e13e685.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/8b/8bb56ee1409640bfc438904ff64c8d176e13e685.svn-base b/eclipse-plugin/.svn/pristine/8b/8bb56ee1409640bfc438904ff64c8d176e13e685.svn-base
new file mode 100644
index 0000000..cdfbe93
--- /dev/null
+++ b/eclipse-plugin/.svn/pristine/8b/8bb56ee1409640bfc438904ff64c8d176e13e685.svn-base
@@ -0,0 +1,73 @@
+/**
+ * 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.hadoop.eclipse.actions;
+
+import org.apache.hadoop.eclipse.ImageLibrary;
+import org.apache.hadoop.eclipse.server.HadoopServer;
+import org.apache.hadoop.eclipse.servers.HadoopLocationWizard;
+import org.apache.hadoop.eclipse.view.servers.ServerView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+
+/**
+ * Editing server properties action
+ */
+public class EditLocationAction extends Action {
+
+  private ServerView serverView;
+
+  public EditLocationAction(ServerView serverView) {
+    this.serverView = serverView;
+
+    setText("Edit Hadoop location...");
+    setImageDescriptor(ImageLibrary.get("server.view.action.location.edit"));
+  }
+
+  @Override
+  public void run() {
+
+    final HadoopServer server = serverView.getSelectedServer();
+    if (server == null)
+      return;
+
+    WizardDialog dialog = new WizardDialog(null, new Wizard() {
+      private HadoopLocationWizard page = new HadoopLocationWizard(server);
+
+      @Override
+      public void addPages() {
+        super.addPages();
+        setWindowTitle("Edit Hadoop location...");
+        addPage(page);
+      }
+
+      @Override
+      public boolean performFinish() {
+        page.performFinish();
+        return true;
+      }
+    });
+
+    dialog.create();
+    dialog.setBlockOnOpen(true);
+    dialog.open();
+
+    super.run();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/8c/8c563fc9e8b16ae3eefcd24d43c76755dc8c2034.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/8c/8c563fc9e8b16ae3eefcd24d43c76755dc8c2034.svn-base b/eclipse-plugin/.svn/pristine/8c/8c563fc9e8b16ae3eefcd24d43c76755dc8c2034.svn-base
new file mode 100644
index 0000000..5a1c095
Binary files /dev/null and b/eclipse-plugin/.svn/pristine/8c/8c563fc9e8b16ae3eefcd24d43c76755dc8c2034.svn-base differ

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/8e/8e45775e4f0b9ca2fd916059de64203f77719567.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/8e/8e45775e4f0b9ca2fd916059de64203f77719567.svn-base b/eclipse-plugin/.svn/pristine/8e/8e45775e4f0b9ca2fd916059de64203f77719567.svn-base
new file mode 100644
index 0000000..fe1d64e
Binary files /dev/null and b/eclipse-plugin/.svn/pristine/8e/8e45775e4f0b9ca2fd916059de64203f77719567.svn-base differ

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/8e/8ec5904a0976aabbb0c475c849cc1f6697fb7187.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/8e/8ec5904a0976aabbb0c475c849cc1f6697fb7187.svn-base b/eclipse-plugin/.svn/pristine/8e/8ec5904a0976aabbb0c475c849cc1f6697fb7187.svn-base
new file mode 100644
index 0000000..2de5c5d
Binary files /dev/null and b/eclipse-plugin/.svn/pristine/8e/8ec5904a0976aabbb0c475c849cc1f6697fb7187.svn-base differ

http://git-wip-us.apache.org/repos/asf/incubator-hdt/blob/a1719e04/eclipse-plugin/.svn/pristine/8f/8f88af8f84086bdd1f858a0561796393a7342253.svn-base
----------------------------------------------------------------------
diff --git a/eclipse-plugin/.svn/pristine/8f/8f88af8f84086bdd1f858a0561796393a7342253.svn-base b/eclipse-plugin/.svn/pristine/8f/8f88af8f84086bdd1f858a0561796393a7342253.svn-base
new file mode 100644
index 0000000..61b800d
Binary files /dev/null and b/eclipse-plugin/.svn/pristine/8f/8f88af8f84086bdd1f858a0561796393a7342253.svn-base differ