You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/10/09 00:53:17 UTC

[28/50] [abbrv] git commit: SLIDER-149 purge RegisteredEndpoint code, and so all traces of the original registry

SLIDER-149 purge RegisteredEndpoint code, and so all traces of the original registry


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/65e7684d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/65e7684d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/65e7684d

Branch: refs/heads/develop
Commit: 65e7684de15c6340caff0381ceb99f2a12ca3f72
Parents: 46fb5db
Author: Steve Loughran <st...@apache.org>
Authored: Fri Sep 26 14:44:38 2014 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Fri Sep 26 14:44:38 2014 +0100

----------------------------------------------------------------------
 .../core/registry/info/RegisteredEndpoint.java  | 180 -------------------
 .../providers/agent/AgentProviderService.java   |   2 +-
 .../server/appmaster/state/RoleInstance.java    |  29 +--
 3 files changed, 16 insertions(+), 195 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/65e7684d/slider-core/src/main/java/org/apache/slider/core/registry/info/RegisteredEndpoint.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/registry/info/RegisteredEndpoint.java b/slider-core/src/main/java/org/apache/slider/core/registry/info/RegisteredEndpoint.java
deleted file mode 100644
index 2351e06..0000000
--- a/slider-core/src/main/java/org/apache/slider/core/registry/info/RegisteredEndpoint.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * 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.slider.core.registry.info;
-
-import org.apache.hadoop.yarn.registry.client.types.AddressTypes;
-import org.apache.hadoop.yarn.registry.client.types.ProtocolTypes;
-import org.apache.slider.core.exceptions.SliderException;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-import java.net.InetSocketAddress;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@Deprecated
-public class RegisteredEndpoint {
-
-  // standard types
-
-  /**
-   * URL: {@value}
-   */
-  public static final String TYPE_URL = AddressTypes.ADDRESS_URI;
-  
-  
-  /**
-   * "hostname:port" pair: {@value}
-   */
-  public static final String TYPE_INETADDRESS = AddressTypes.ADDRESS_HOSTNAME_AND_PORT;
-  
-  /**
-   * simple path string: {@value}
-   */
-  public static final String TYPE_PATH = AddressTypes.ADDRESS_PATH;
-
-  // standard protocols
-  /**
-   * Classic "Writable" Hadoop IPC: {@value}
-   */
-  public static final String PROTOCOL_HADOOP_RPC = ProtocolTypes.PROTOCOL_HADOOP_IPC;
-
-  /**
-   * Protocol buffer based Hadoop IPC: {@value}
-   */
-  public static final String PROTOCOL_HADOOP_PROTOBUF = ProtocolTypes.PROTOCOL_HADOOP_IPC_PROTOBUF;
-
-  /**
-   * The address -format is driven by the type entry
-   */
-  public String address;
-
-  /**
-   * Protocol
-   */
-  public String protocol = "";
-
-  public String type = "";
-
-  /**
-   * Human readable type
-   */
-  public String description = "";
-  
-  public RegisteredEndpoint() {
-  }
-
-  public RegisteredEndpoint(String address,
-                            String protocol,
-                            String type,
-                            String description) {
-    this.address = address;
-    this.protocol = protocol;
-    this.type = type;
-    this.description = description;
-  }
-
-  /**
-   * Build an endpoint instance from a URI, extracting
-   * the protocol from it
-   * @param uri URI to set the value to
-   * @param description description
-   */
-  public RegisteredEndpoint(URI uri,
-                            String description) {
-    
-    this.address = uri.toString();
-    this.protocol = uri.getScheme();
-    this.type = TYPE_URL;
-    this.description = description;
-  }
-  /**
-   * Build an endpoint instance from a URI, extracting
-   * the protocol from it
-   * @param uri URI to set the value to
-   * @param description description
-   */
-  public RegisteredEndpoint(InetSocketAddress address,
-    String protocol,
-      String description) {
-    
-    this.address = address.toString();
-    this.protocol = protocol;
-    this.type = TYPE_INETADDRESS;
-    this.description = description;
-  }
-
-  /**
-   * Build an endpoint instance from a URL, extracting
-   * the protocol from it
-   * @param url URL to set the value to
-   * @param description description
-   */
-  public RegisteredEndpoint(URL url,
-                            String description) throws URISyntaxException {
-    this(url.toURI(), description);
-  }
-
-  /**
-   * Get the value as a URL
-   * @return  URL of the value -if the value type is URL
-   * @throws SliderException if the value is of the wrong type, or unparsable
-   */
-  public URL asURL() throws SliderException {
-    verifyEndpointType(TYPE_URL);
-    try {
-      return new URL(address);
-    } catch (MalformedURLException e) {
-      throw new SliderException(-1, e,
-          "could not create a URL from %s : %s", address, e.toString());
-    }
-  }
-
-  @Override
-  public String toString() {
-    final StringBuilder sb =
-        new StringBuilder();
-    if (TYPE_URL.equals(type)) {
-      sb.append(address);
-    } else {
-      sb.append("protocol='").append(protocol).append('\'');
-      sb.append(" address='").append(address).append('\'');
-      sb.append(" type='").append(type).append('\'');
-    }
-    sb.append(" -- \"").append(description).append('"');
-    return sb.toString();
-  }
-
-
-  /**
-   * Verify that an endpoint is of the desired type
-   * @param desiredType desired type
-   * @throws SliderException if it is not
-   */
-  public void verifyEndpointType(String desiredType) throws SliderException {
-    if (!type.equals(desiredType)) {
-      throw new SliderException(-1, "Body of endpoint is of type %s and not %s",
-          type, desiredType);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/65e7684d/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java b/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java
index 5de08dc..abca155 100644
--- a/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java
+++ b/slider-core/src/main/java/org/apache/slider/providers/agent/AgentProviderService.java
@@ -595,7 +595,7 @@ public class AgentProviderService extends AbstractProviderService implements
       this.getAllocatedPorts(containerId).put(portname, portNo);
       if (instance != null) {
         try {
-          instance.registerPortEndpoint(Integer.valueOf(portNo), portname, "");
+          instance.registerPortEndpoint(Integer.valueOf(portNo), portname);
         } catch (NumberFormatException e) {
           log.warn("Failed to parse {}: {}", portNo, e);
         }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/65e7684d/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleInstance.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleInstance.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleInstance.java
index e373843..df5e47e 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleInstance.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/RoleInstance.java
@@ -22,12 +22,13 @@ import com.google.common.base.Preconditions;
 import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.NodeId;
+import org.apache.hadoop.yarn.registry.client.binding.RegistryTypeUtils;
+import org.apache.hadoop.yarn.registry.client.types.Endpoint;
+import org.apache.hadoop.yarn.registry.client.types.ProtocolTypes;
 import org.apache.slider.api.ClusterDescription;
 import org.apache.slider.api.proto.Messages;
 import org.apache.slider.common.tools.SliderUtils;
-import org.apache.slider.core.registry.info.RegisteredEndpoint;
 
-import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -90,8 +91,8 @@ public final class RoleInstance implements Cloneable {
   /**
    * A list of registered endpoints.
    */
-  private List<RegisteredEndpoint> endpoints =
-      new ArrayList<RegisteredEndpoint>(2);
+  private List<Endpoint> endpoints =
+      new ArrayList<Endpoint>(2);
 
   public RoleInstance(Container container) {
     Preconditions.checkNotNull(container, "Null container");
@@ -194,7 +195,7 @@ public final class RoleInstance implements Cloneable {
   public Object clone() throws CloneNotSupportedException {
     RoleInstance cloned = (RoleInstance) super.clone();
     // clone the endpoint list, but not the values
-    cloned.endpoints = new ArrayList<RegisteredEndpoint>(this.endpoints);
+    cloned.endpoints = new ArrayList<Endpoint>(this.endpoints);
     return cloned;
   }
 
@@ -202,15 +203,15 @@ public final class RoleInstance implements Cloneable {
    * Get the list of endpoints. 
    * @return the endpoint list.
    */
-  public List<RegisteredEndpoint> getEndpoints() {
+  public List<Endpoint> getEndpoints() {
     return endpoints;
   }
 
   /**
    * Add an endpoint registration
-   * @param endpoint
+   * @param endpoint endpoint (non-null)
    */
-  public void addEndpoint(RegisteredEndpoint endpoint) {
+  public void addEndpoint(Endpoint endpoint) {
     Preconditions.checkArgument(endpoint != null);
     endpoints.add(endpoint);
   }
@@ -218,13 +219,13 @@ public final class RoleInstance implements Cloneable {
   /**
    * Register a port endpoint as an inet-addr formatted endpoint, using the
    * hostname as the first part of the address
-   * @param port
-   * @param protocol
-   * @param text
+   * @param port port port
+   * @param api  API API name
    */
-  public void registerPortEndpoint(int port, String protocol, String text) {
-    InetSocketAddress addr = new InetSocketAddress(host, port);
-    RegisteredEndpoint epr = new RegisteredEndpoint(addr, protocol, text);
+  public void registerPortEndpoint(int port, String api) {
+    Endpoint epr =
+        RegistryTypeUtils.inetAddrEndpoint(api,
+            ProtocolTypes.PROTOCOL_TCP, host, port);
     addEndpoint(epr);
   }