SLIDER-994 add "nodemap" command to get the (JSON) nodemap of the YARN cluster
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/cc94e056 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/cc94e056 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/cc94e056 Branch: refs/heads/develop Commit: cc94e056c3b0e8436932417503e08f33d0a4f0bb Parents: 0c1977b Author: Steve Loughran <ste...@apache.org> Authored: Fri Nov 20 19:06:05 2015 +0000 Committer: Steve Loughran <ste...@apache.org> Committed: Fri Nov 20 19:06:05 2015 +0000 ---------------------------------------------------------------------- .../apache/slider/api/SliderApplicationApi.java | 7 +- .../org/apache/slider/api/proto/Messages.java | 293 ++++--------------- .../org/apache/slider/client/SliderClient.java | 16 +- .../client/ipc/SliderApplicationIpcClient.java | 3 +- .../client/ipc/SliderClusterOperations.java | 24 +- .../rest/SliderApplicationApiRestClient.java | 11 +- .../server/appmaster/rpc/SliderIPCService.java | 9 +- .../rest/application/ApplicationResource.java | 15 +- .../resources/LiveNodesRefresher.java | 11 +- .../src/main/proto/SliderClusterMessages.proto | 8 +- .../rest/AbstractAppApiTestDelegates.groovy | 10 +- .../providers/agent/TestAgentAAEcho.groovy | 4 + 12 files changed, 112 insertions(+), 299 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/cc94e056/slider-core/src/main/java/org/apache/slider/api/SliderApplicationApi.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/api/SliderApplicationApi.java b/slider-core/src/main/java/org/apache/slider/api/SliderApplicationApi.java index 750dba5..d21785f 100644 --- a/slider-core/src/main/java/org/apache/slider/api/SliderApplicationApi.java +++ b/slider-core/src/main/java/org/apache/slider/api/SliderApplicationApi.java @@ -22,6 +22,7 @@ import org.apache.slider.api.types.ApplicationLivenessInformation; import org.apache.slider.api.types.ComponentInformation; import org.apache.slider.api.types.ContainerInformation; import org.apache.slider.api.types.NodeInformation; +import org.apache.slider.api.types.NodeInformationList; import org.apache.slider.api.types.PingInformation; import org.apache.slider.core.conf.AggregateConf; import org.apache.slider.core.conf.ConfTree; @@ -126,13 +127,13 @@ public interface SliderApplicationApi { * @throws IOException on any failure */ ComponentInformation getComponent(String componentName) throws IOException; - + /** * List all nodes into a map of [name:info] - * @return a possibly empty map of nodes + * @return a possibly empty list of nodes * @throws IOException on any failure */ - Map<String, NodeInformation> getLiveNodes() throws IOException; + NodeInformationList getLiveNodes() throws IOException; /** * Get information about a node http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/cc94e056/slider-core/src/main/java/org/apache/slider/api/proto/Messages.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/api/proto/Messages.java b/slider-core/src/main/java/org/apache/slider/api/proto/Messages.java index ed056f5..6dd5849 100644 --- a/slider-core/src/main/java/org/apache/slider/api/proto/Messages.java +++ b/slider-core/src/main/java/org/apache/slider/api/proto/Messages.java @@ -32389,47 +32389,27 @@ public final class Messages { public interface GetLiveNodesResponseProtoOrBuilder extends com.google.protobuf.MessageOrBuilder { - // repeated string names = 1; - /** - * <code>repeated string names = 1;</code> - */ - java.util.List<java.lang.String> - getNamesList(); - /** - * <code>repeated string names = 1;</code> - */ - int getNamesCount(); + // repeated .org.apache.slider.api.NodeInformationProto nodes = 1; /** - * <code>repeated string names = 1;</code> - */ - java.lang.String getNames(int index); - /** - * <code>repeated string names = 1;</code> - */ - com.google.protobuf.ByteString - getNamesBytes(int index); - - // repeated .org.apache.slider.api.NodeInformationProto nodes = 2; - /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ java.util.List<org.apache.slider.api.proto.Messages.NodeInformationProto> getNodesList(); /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ org.apache.slider.api.proto.Messages.NodeInformationProto getNodes(int index); /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ int getNodesCount(); /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ java.util.List<? extends org.apache.slider.api.proto.Messages.NodeInformationProtoOrBuilder> getNodesOrBuilderList(); /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ org.apache.slider.api.proto.Messages.NodeInformationProtoOrBuilder getNodesOrBuilder( int index); @@ -32487,16 +32467,8 @@ public final class Messages { } case 10: { if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - names_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000001; - } - names_.add(input.readBytes()); - break; - } - case 18: { - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { nodes_ = new java.util.ArrayList<org.apache.slider.api.proto.Messages.NodeInformationProto>(); - mutable_bitField0_ |= 0x00000002; + mutable_bitField0_ |= 0x00000001; } nodes_.add(input.readMessage(org.apache.slider.api.proto.Messages.NodeInformationProto.PARSER, extensionRegistry)); break; @@ -32510,9 +32482,6 @@ public final class Messages { e.getMessage()).setUnfinishedMessage(this); } finally { if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - names_ = new com.google.protobuf.UnmodifiableLazyStringList(names_); - } - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { nodes_ = java.util.Collections.unmodifiableList(nodes_); } this.unknownFields = unknownFields.build(); @@ -32546,66 +32515,36 @@ public final class Messages { return PARSER; } - // repeated string names = 1; - public static final int NAMES_FIELD_NUMBER = 1; - private com.google.protobuf.LazyStringList names_; - /** - * <code>repeated string names = 1;</code> - */ - public java.util.List<java.lang.String> - getNamesList() { - return names_; - } - /** - * <code>repeated string names = 1;</code> - */ - public int getNamesCount() { - return names_.size(); - } - /** - * <code>repeated string names = 1;</code> - */ - public java.lang.String getNames(int index) { - return names_.get(index); - } - /** - * <code>repeated string names = 1;</code> - */ - public com.google.protobuf.ByteString - getNamesBytes(int index) { - return names_.getByteString(index); - } - - // repeated .org.apache.slider.api.NodeInformationProto nodes = 2; - public static final int NODES_FIELD_NUMBER = 2; + // repeated .org.apache.slider.api.NodeInformationProto nodes = 1; + public static final int NODES_FIELD_NUMBER = 1; private java.util.List<org.apache.slider.api.proto.Messages.NodeInformationProto> nodes_; /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public java.util.List<org.apache.slider.api.proto.Messages.NodeInformationProto> getNodesList() { return nodes_; } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public java.util.List<? extends org.apache.slider.api.proto.Messages.NodeInformationProtoOrBuilder> getNodesOrBuilderList() { return nodes_; } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public int getNodesCount() { return nodes_.size(); } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public org.apache.slider.api.proto.Messages.NodeInformationProto getNodes(int index) { return nodes_.get(index); } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public org.apache.slider.api.proto.Messages.NodeInformationProtoOrBuilder getNodesOrBuilder( int index) { @@ -32613,7 +32552,6 @@ public final class Messages { } private void initFields() { - names_ = com.google.protobuf.LazyStringArrayList.EMPTY; nodes_ = java.util.Collections.emptyList(); } private byte memoizedIsInitialized = -1; @@ -32634,11 +32572,8 @@ public final class Messages { public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); - for (int i = 0; i < names_.size(); i++) { - output.writeBytes(1, names_.getByteString(i)); - } for (int i = 0; i < nodes_.size(); i++) { - output.writeMessage(2, nodes_.get(i)); + output.writeMessage(1, nodes_.get(i)); } getUnknownFields().writeTo(output); } @@ -32649,18 +32584,9 @@ public final class Messages { if (size != -1) return size; size = 0; - { - int dataSize = 0; - for (int i = 0; i < names_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeBytesSizeNoTag(names_.getByteString(i)); - } - size += dataSize; - size += 1 * getNamesList().size(); - } for (int i = 0; i < nodes_.size(); i++) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, nodes_.get(i)); + .computeMessageSize(1, nodes_.get(i)); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -32685,8 +32611,6 @@ public final class Messages { org.apache.slider.api.proto.Messages.GetLiveNodesResponseProto other = (org.apache.slider.api.proto.Messages.GetLiveNodesResponseProto) obj; boolean result = true; - result = result && getNamesList() - .equals(other.getNamesList()); result = result && getNodesList() .equals(other.getNodesList()); result = result && @@ -32702,10 +32626,6 @@ public final class Messages { } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); - if (getNamesCount() > 0) { - hash = (37 * hash) + NAMES_FIELD_NUMBER; - hash = (53 * hash) + getNamesList().hashCode(); - } if (getNodesCount() > 0) { hash = (37 * hash) + NODES_FIELD_NUMBER; hash = (53 * hash) + getNodesList().hashCode(); @@ -32820,11 +32740,9 @@ public final class Messages { public Builder clear() { super.clear(); - names_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); if (nodesBuilder_ == null) { nodes_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } else { nodesBuilder_.clear(); } @@ -32855,16 +32773,10 @@ public final class Messages { public org.apache.slider.api.proto.Messages.GetLiveNodesResponseProto buildPartial() { org.apache.slider.api.proto.Messages.GetLiveNodesResponseProto result = new org.apache.slider.api.proto.Messages.GetLiveNodesResponseProto(this); int from_bitField0_ = bitField0_; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - names_ = new com.google.protobuf.UnmodifiableLazyStringList( - names_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.names_ = names_; if (nodesBuilder_ == null) { - if (((bitField0_ & 0x00000002) == 0x00000002)) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { nodes_ = java.util.Collections.unmodifiableList(nodes_); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } result.nodes_ = nodes_; } else { @@ -32885,21 +32797,11 @@ public final class Messages { public Builder mergeFrom(org.apache.slider.api.proto.Messages.GetLiveNodesResponseProto other) { if (other == org.apache.slider.api.proto.Messages.GetLiveNodesResponseProto.getDefaultInstance()) return this; - if (!other.names_.isEmpty()) { - if (names_.isEmpty()) { - names_ = other.names_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureNamesIsMutable(); - names_.addAll(other.names_); - } - onChanged(); - } if (nodesBuilder_ == null) { if (!other.nodes_.isEmpty()) { if (nodes_.isEmpty()) { nodes_ = other.nodes_; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureNodesIsMutable(); nodes_.addAll(other.nodes_); @@ -32912,7 +32814,7 @@ public final class Messages { nodesBuilder_.dispose(); nodesBuilder_ = null; nodes_ = other.nodes_; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); nodesBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getNodesFieldBuilder() : null; @@ -32954,106 +32856,13 @@ public final class Messages { } private int bitField0_; - // repeated string names = 1; - private com.google.protobuf.LazyStringList names_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureNamesIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - names_ = new com.google.protobuf.LazyStringArrayList(names_); - bitField0_ |= 0x00000001; - } - } - /** - * <code>repeated string names = 1;</code> - */ - public java.util.List<java.lang.String> - getNamesList() { - return java.util.Collections.unmodifiableList(names_); - } - /** - * <code>repeated string names = 1;</code> - */ - public int getNamesCount() { - return names_.size(); - } - /** - * <code>repeated string names = 1;</code> - */ - public java.lang.String getNames(int index) { - return names_.get(index); - } - /** - * <code>repeated string names = 1;</code> - */ - public com.google.protobuf.ByteString - getNamesBytes(int index) { - return names_.getByteString(index); - } - /** - * <code>repeated string names = 1;</code> - */ - public Builder setNames( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureNamesIsMutable(); - names_.set(index, value); - onChanged(); - return this; - } - /** - * <code>repeated string names = 1;</code> - */ - public Builder addNames( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureNamesIsMutable(); - names_.add(value); - onChanged(); - return this; - } - /** - * <code>repeated string names = 1;</code> - */ - public Builder addAllNames( - java.lang.Iterable<java.lang.String> values) { - ensureNamesIsMutable(); - super.addAll(values, names_); - onChanged(); - return this; - } - /** - * <code>repeated string names = 1;</code> - */ - public Builder clearNames() { - names_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - /** - * <code>repeated string names = 1;</code> - */ - public Builder addNamesBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - ensureNamesIsMutable(); - names_.add(value); - onChanged(); - return this; - } - - // repeated .org.apache.slider.api.NodeInformationProto nodes = 2; + // repeated .org.apache.slider.api.NodeInformationProto nodes = 1; private java.util.List<org.apache.slider.api.proto.Messages.NodeInformationProto> nodes_ = java.util.Collections.emptyList(); private void ensureNodesIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { nodes_ = new java.util.ArrayList<org.apache.slider.api.proto.Messages.NodeInformationProto>(nodes_); - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000001; } } @@ -33061,7 +32870,7 @@ public final class Messages { org.apache.slider.api.proto.Messages.NodeInformationProto, org.apache.slider.api.proto.Messages.NodeInformationProto.Builder, org.apache.slider.api.proto.Messages.NodeInformationProtoOrBuilder> nodesBuilder_; /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public java.util.List<org.apache.slider.api.proto.Messages.NodeInformationProto> getNodesList() { if (nodesBuilder_ == null) { @@ -33071,7 +32880,7 @@ public final class Messages { } } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public int getNodesCount() { if (nodesBuilder_ == null) { @@ -33081,7 +32890,7 @@ public final class Messages { } } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public org.apache.slider.api.proto.Messages.NodeInformationProto getNodes(int index) { if (nodesBuilder_ == null) { @@ -33091,7 +32900,7 @@ public final class Messages { } } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public Builder setNodes( int index, org.apache.slider.api.proto.Messages.NodeInformationProto value) { @@ -33108,7 +32917,7 @@ public final class Messages { return this; } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public Builder setNodes( int index, org.apache.slider.api.proto.Messages.NodeInformationProto.Builder builderForValue) { @@ -33122,7 +32931,7 @@ public final class Messages { return this; } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public Builder addNodes(org.apache.slider.api.proto.Messages.NodeInformationProto value) { if (nodesBuilder_ == null) { @@ -33138,7 +32947,7 @@ public final class Messages { return this; } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public Builder addNodes( int index, org.apache.slider.api.proto.Messages.NodeInformationProto value) { @@ -33155,7 +32964,7 @@ public final class Messages { return this; } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public Builder addNodes( org.apache.slider.api.proto.Messages.NodeInformationProto.Builder builderForValue) { @@ -33169,7 +32978,7 @@ public final class Messages { return this; } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public Builder addNodes( int index, org.apache.slider.api.proto.Messages.NodeInformationProto.Builder builderForValue) { @@ -33183,7 +32992,7 @@ public final class Messages { return this; } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public Builder addAllNodes( java.lang.Iterable<? extends org.apache.slider.api.proto.Messages.NodeInformationProto> values) { @@ -33197,12 +33006,12 @@ public final class Messages { return this; } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public Builder clearNodes() { if (nodesBuilder_ == null) { nodes_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); } else { nodesBuilder_.clear(); @@ -33210,7 +33019,7 @@ public final class Messages { return this; } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public Builder removeNodes(int index) { if (nodesBuilder_ == null) { @@ -33223,14 +33032,14 @@ public final class Messages { return this; } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public org.apache.slider.api.proto.Messages.NodeInformationProto.Builder getNodesBuilder( int index) { return getNodesFieldBuilder().getBuilder(index); } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public org.apache.slider.api.proto.Messages.NodeInformationProtoOrBuilder getNodesOrBuilder( int index) { @@ -33240,7 +33049,7 @@ public final class Messages { } } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public java.util.List<? extends org.apache.slider.api.proto.Messages.NodeInformationProtoOrBuilder> getNodesOrBuilderList() { @@ -33251,14 +33060,14 @@ public final class Messages { } } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public org.apache.slider.api.proto.Messages.NodeInformationProto.Builder addNodesBuilder() { return getNodesFieldBuilder().addBuilder( org.apache.slider.api.proto.Messages.NodeInformationProto.getDefaultInstance()); } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public org.apache.slider.api.proto.Messages.NodeInformationProto.Builder addNodesBuilder( int index) { @@ -33266,7 +33075,7 @@ public final class Messages { index, org.apache.slider.api.proto.Messages.NodeInformationProto.getDefaultInstance()); } /** - * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 2;</code> + * <code>repeated .org.apache.slider.api.NodeInformationProto nodes = 1;</code> */ public java.util.List<org.apache.slider.api.proto.Messages.NodeInformationProto.Builder> getNodesBuilderList() { @@ -33279,7 +33088,7 @@ public final class Messages { nodesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< org.apache.slider.api.proto.Messages.NodeInformationProto, org.apache.slider.api.proto.Messages.NodeInformationProto.Builder, org.apache.slider.api.proto.Messages.NodeInformationProtoOrBuilder>( nodes_, - ((bitField0_ & 0x00000002) == 0x00000002), + ((bitField0_ & 0x00000001) == 0x00000001), getParentForChildren(), isClean()); nodes_ = null; @@ -34166,12 +33975,12 @@ public final class Messages { "oto\022\020\n\010hostname\030\001 \001(\t\022\023\n\013requesterId\030\002 \002", "(\t\022\020\n\010password\030\003 \002(\t\022\014\n\004type\030\004 \002(\t\"1\n Ge" + "tCertificateStoreResponseProto\022\r\n\005store\030" + - "\001 \002(\014\"\032\n\030GetLiveNodesRequestProto\"f\n\031Get" + - "LiveNodesResponseProto\022\r\n\005names\030\001 \003(\t\022:\n" + - "\005nodes\030\002 \003(\0132+.org.apache.slider.api.Nod" + - "eInformationProto\"\'\n\027GetLiveNodeRequestP" + - "roto\022\014\n\004name\030\001 \002(\tB-\n\033org.apache.slider." + - "api.protoB\010Messages\210\001\001\240\001\001" + "\001 \002(\014\"\032\n\030GetLiveNodesRequestProto\"W\n\031Get" + + "LiveNodesResponseProto\022:\n\005nodes\030\001 \003(\0132+." + + "org.apache.slider.api.NodeInformationPro" + + "to\"\'\n\027GetLiveNodeRequestProto\022\014\n\004name\030\001 " + + "\002(\tB-\n\033org.apache.slider.api.protoB\010Mess" + + "ages\210\001\001\240\001\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -34471,7 +34280,7 @@ public final class Messages { internal_static_org_apache_slider_api_GetLiveNodesResponseProto_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_org_apache_slider_api_GetLiveNodesResponseProto_descriptor, - new java.lang.String[] { "Names", "Nodes", }); + new java.lang.String[] { "Nodes", }); internal_static_org_apache_slider_api_GetLiveNodeRequestProto_descriptor = getDescriptor().getMessageTypes().get(49); internal_static_org_apache_slider_api_GetLiveNodeRequestProto_fieldAccessorTable = new http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/cc94e056/slider-core/src/main/java/org/apache/slider/client/SliderClient.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java index ca9bb12..0753ecc 100644 --- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java +++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java @@ -106,6 +106,7 @@ import org.apache.slider.common.params.LaunchArgsAccessor; import org.apache.slider.common.tools.ConfigHelper; import org.apache.slider.common.tools.Duration; import org.apache.slider.common.tools.SliderFileSystem; +import org.apache.slider.common.tools.SliderUtils; import org.apache.slider.common.tools.SliderVersionInfo; import org.apache.slider.core.build.InstanceBuilder; import org.apache.slider.core.build.InstanceIO; @@ -4254,9 +4255,13 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe * @throws IOException IO problems * @throws YarnException YARN problems */ - public NodeInformationList listInstanceNodes(ActionNodesArgs args) + public NodeInformationList listInstanceNodes(String instance, ActionNodesArgs args) throws YarnException, IOException { - return yarnClient.listNodes(args.label, args.healthy); + // TODO + log.info("listInstanceNodes {}", instance); + SliderClusterOperations clusterOps = + new SliderClusterOperations(bondToCluster(instance)); + return clusterOps.getLiveNodes(); } /** @@ -4269,7 +4274,12 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe public int actionNodes(String instance, ActionNodesArgs args) throws YarnException, IOException { args.instance = instance; - NodeInformationList nodes = listYarnClusterNodes(args); + NodeInformationList nodes; + if (SliderUtils.isUnset(instance)) { + nodes = listYarnClusterNodes(args); + } else { + nodes = listInstanceNodes(instance, args); + } log.debug("Node listing for {} has {} nodes", args, nodes.size()); JsonSerDeser<NodeInformationList> serDeser = NodeInformationList.createSerializer(); if (args.outputFile != null) { http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/cc94e056/slider-core/src/main/java/org/apache/slider/client/ipc/SliderApplicationIpcClient.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/ipc/SliderApplicationIpcClient.java b/slider-core/src/main/java/org/apache/slider/client/ipc/SliderApplicationIpcClient.java index 291583d..a007326 100644 --- a/slider-core/src/main/java/org/apache/slider/client/ipc/SliderApplicationIpcClient.java +++ b/slider-core/src/main/java/org/apache/slider/client/ipc/SliderApplicationIpcClient.java @@ -24,6 +24,7 @@ import org.apache.slider.api.types.ApplicationLivenessInformation; import org.apache.slider.api.types.ComponentInformation; import org.apache.slider.api.types.ContainerInformation; import org.apache.slider.api.types.NodeInformation; +import org.apache.slider.api.types.NodeInformationList; import org.apache.slider.api.types.PingInformation; import org.apache.slider.api.SliderApplicationApi; import org.apache.slider.core.conf.AggregateConf; @@ -196,7 +197,7 @@ public class SliderApplicationIpcClient implements SliderApplicationApi { } @Override - public Map<String, NodeInformation> getLiveNodes() throws IOException { + public NodeInformationList getLiveNodes() throws IOException { try { return operations.getLiveNodes(); } catch (IOException e) { http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/cc94e056/slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java b/slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java index e1ec971..392f451 100644 --- a/slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java +++ b/slider-core/src/main/java/org/apache/slider/client/ipc/SliderClusterOperations.java @@ -19,6 +19,9 @@ package org.apache.slider.client.ipc; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; +import org.apache.hadoop.yarn.api.records.NodeReport; +import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.slider.api.ClusterDescription; import org.apache.slider.api.ClusterNode; @@ -31,8 +34,10 @@ import org.apache.slider.api.types.ApplicationLivenessInformation; import org.apache.slider.api.types.ComponentInformation; import org.apache.slider.api.types.ContainerInformation; import org.apache.slider.api.types.NodeInformation; +import org.apache.slider.api.types.NodeInformationList; import org.apache.slider.api.types.PingInformation; import org.apache.slider.common.tools.Duration; +import org.apache.slider.common.tools.SliderUtils; import org.apache.slider.core.conf.AggregateConf; import org.apache.slider.core.conf.ConfTree; import org.apache.slider.core.conf.ConfTreeOperations; @@ -237,7 +242,7 @@ public class SliderClusterOperations { /** * Get the details on a list of uuids - * @param uuids + * @param uuids instance IDs * @return a possibly empty list of node details * @throws IOException * @throws YarnException @@ -468,22 +473,16 @@ public class SliderClusterOperations { return unmarshall(proto); } - public Map<String, NodeInformation> getLiveNodes() throws IOException { + public NodeInformationList getLiveNodes() throws IOException { Messages.GetLiveNodesResponseProto response = appMaster.getLiveNodes(Messages.GetLiveNodesRequestProto.newBuilder().build()); - int namesCount = response.getNamesCount(); int records = response.getNodesCount(); - if (namesCount != records) { - throw new IOException( - "Number of names returned (" + namesCount + ")" + - " does not match the number of records returned: " + records); + NodeInformationList nil = new NodeInformationList(records); + for (int i = 0; i < records; i++) { + nil.add(unmarshall(response.getNodes(i))); } - Map<String, NodeInformation> map = new HashMap<>(namesCount); - for (int i = 0; i < namesCount; i++) { - map.put(response.getNames(i), unmarshall(response.getNodes(i))); - } - return map; + return nil; } public NodeInformation getLiveNode(String hostname) throws IOException { @@ -527,5 +526,4 @@ public class SliderClusterOperations { return unmarshall(response); } - } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/cc94e056/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiRestClient.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiRestClient.java b/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiRestClient.java index 54c60d1..4283ee8 100644 --- a/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiRestClient.java +++ b/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationApiRestClient.java @@ -21,11 +21,9 @@ package org.apache.slider.client.rest; import com.google.common.base.Preconditions; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.GenericType; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.filter.LoggingFilter; import com.sun.jersey.api.representation.Form; import org.apache.commons.lang.StringUtils; import org.apache.slider.api.types.ApplicationLivenessInformation; @@ -33,11 +31,11 @@ import org.apache.slider.api.types.ComponentInformation; import org.apache.slider.api.types.ContainerInformation; import org.apache.slider.api.SliderApplicationApi; import org.apache.slider.api.types.NodeInformation; +import org.apache.slider.api.types.NodeInformationList; import org.apache.slider.core.conf.AggregateConf; import org.apache.slider.core.conf.ConfTree; import org.apache.slider.core.conf.ConfTreeOperations; import org.apache.slider.core.exceptions.ExceptionConverter; -import org.apache.slider.core.persist.ConfTreeSerDeser; import org.apache.slider.core.restclient.HttpVerb; import org.apache.slider.api.types.PingInformation; import org.slf4j.Logger; @@ -258,14 +256,13 @@ public class SliderApplicationApiRestClient extends BaseRestClient } @Override - public Map<String, NodeInformation> getLiveNodes() throws IOException { - return getApplicationResource(LIVE_NODES, - new GenericType<Map<String, NodeInformation>>() { }); + public NodeInformationList getLiveNodes() throws IOException { + return getApplicationResource(LIVE_NODES, NodeInformationList.class); } @Override public NodeInformation getLiveNode(String hostname) throws IOException { - return getApplicationResource(LIVE_COMPONENTS + "/" + hostname, + return getApplicationResource(LIVE_NODES + "/" + hostname, NodeInformation.class); } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/cc94e056/slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderIPCService.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderIPCService.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderIPCService.java index a983f53..fda23aa 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderIPCService.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderIPCService.java @@ -31,6 +31,7 @@ import org.apache.slider.api.types.ApplicationLivenessInformation; import org.apache.slider.api.types.ComponentInformation; import org.apache.slider.api.types.ContainerInformation; import org.apache.slider.api.types.NodeInformation; +import org.apache.slider.api.types.NodeInformationList; import org.apache.slider.core.conf.AggregateConf; import org.apache.slider.core.conf.ConfTree; import org.apache.slider.core.exceptions.ServiceNotReadyException; @@ -423,14 +424,12 @@ public class SliderIPCService extends AbstractService @Override public Messages.GetLiveNodesResponseProto getLiveNodes(Messages.GetLiveNodesRequestProto request) throws IOException { - Map<String, NodeInformation> infoMap = - (Map<String, NodeInformation>) cache.lookupWithIOE(LIVE_NODES); + NodeInformationList info = (NodeInformationList) cache.lookupWithIOE(LIVE_NODES); Messages.GetLiveNodesResponseProto.Builder builder = Messages.GetLiveNodesResponseProto.newBuilder(); - for (Map.Entry<String, NodeInformation> entry : infoMap.entrySet()) { - builder.addNames(entry.getKey()); - builder.addNodes(marshall(entry.getValue())); + for (NodeInformation nodeInformation : info) { + builder.addNodes(marshall(nodeInformation)); } return builder.build(); } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/cc94e056/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java index 1b54a31..52068d6 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java @@ -26,6 +26,7 @@ import org.apache.slider.api.types.ApplicationLivenessInformation; import org.apache.slider.api.types.ComponentInformation; import org.apache.slider.api.types.ContainerInformation; import org.apache.slider.api.types.NodeInformation; +import org.apache.slider.api.types.NodeInformationList; import org.apache.slider.core.conf.AggregateConf; import org.apache.slider.core.conf.ConfTree; import org.apache.slider.core.exceptions.NoSuchNodeException; @@ -350,31 +351,31 @@ TODO: decide what structure to return here, then implement @GET @Path(LIVE_NODES) @Produces({APPLICATION_JSON}) - public Map<String, NodeInformation> getLiveNodes() { + public NodeInformationList getLiveNodes() { markGet(SLIDER_SUBPATH_APPLICATION, LIVE_COMPONENTS); try { - return (Map<String, NodeInformation>) cache.lookup(LIVE_NODES); + return (NodeInformationList) cache.lookup(LIVE_NODES); } catch (Exception e) { throw buildException(LIVE_COMPONENTS, e); } } @GET - @Path(LIVE_NODES + "/{node}") + @Path(LIVE_NODES + "/{hostname}") @Produces({APPLICATION_JSON}) - public NodeInformation getLiveNode(@PathParam("node") String node) { + public NodeInformation getLiveNode(@PathParam("hostname") String hostname) { markGet(SLIDER_SUBPATH_APPLICATION, LIVE_COMPONENTS); try { - NodeInformation ni = state.getNodeInformation(node); + NodeInformation ni = state.getNodeInformation(hostname); if (ni != null) { return ni; } else { - throw new NotFoundException("Unknown node: " + node); + throw new NotFoundException("Unknown node: " + hostname); } } catch (NotFoundException e) { throw e; } catch (Exception e) { - throw buildException(LIVE_CONTAINERS + "/" + node, e); + throw buildException(LIVE_COMPONENTS + "/" + hostname, e); } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/cc94e056/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveNodesRefresher.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveNodesRefresher.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveNodesRefresher.java index d4ab8fe..aeb7a11 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveNodesRefresher.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/resources/LiveNodesRefresher.java @@ -18,16 +18,14 @@ package org.apache.slider.server.appmaster.web.rest.application.resources; -import org.apache.slider.api.types.NodeInformation; +import org.apache.slider.api.types.NodeInformationList; import org.apache.slider.server.appmaster.state.StateAccessForProviders; -import java.util.Map; - /** * Update the live nodes map */ public class LiveNodesRefresher - implements ResourceRefresher<Map<String, NodeInformation>> { + implements ResourceRefresher<NodeInformationList> { private final StateAccessForProviders state; @@ -36,7 +34,8 @@ public class LiveNodesRefresher } @Override - public Map<String, NodeInformation> refresh() { - return state.getNodeInformationSnapshot(); + public NodeInformationList refresh() { + + return new NodeInformationList(state.getNodeInformationSnapshot().values()); } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/cc94e056/slider-core/src/main/proto/SliderClusterMessages.proto ---------------------------------------------------------------------- diff --git a/slider-core/src/main/proto/SliderClusterMessages.proto b/slider-core/src/main/proto/SliderClusterMessages.proto index 2836454..9a4265c 100644 --- a/slider-core/src/main/proto/SliderClusterMessages.proto +++ b/slider-core/src/main/proto/SliderClusterMessages.proto @@ -25,10 +25,7 @@ package org.apache.slider.api; //import "Security.proto"; /* - To debug compilation problems, bypass the maven build and invoke protoc - from the command line - - protoc --java_out=target src/main/proto/SliderClusterMessages.proto + Look at SliderClusterProtocol.proto to see how to build this */ message RoleInstanceState { @@ -390,8 +387,7 @@ message GetLiveNodesRequestProto { } message GetLiveNodesResponseProto { - repeated string names = 1; - repeated NodeInformationProto nodes = 2; + repeated NodeInformationProto nodes = 1; } message GetLiveNodeRequestProto { http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/cc94e056/slider-core/src/test/groovy/org/apache/slider/agent/rest/AbstractAppApiTestDelegates.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/rest/AbstractAppApiTestDelegates.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/rest/AbstractAppApiTestDelegates.groovy index 6d1bcfc..6727a29 100644 --- a/slider-core/src/test/groovy/org/apache/slider/agent/rest/AbstractAppApiTestDelegates.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/agent/rest/AbstractAppApiTestDelegates.groovy @@ -24,10 +24,8 @@ import org.apache.slider.api.SliderApplicationApi import org.apache.slider.api.StateValues import org.apache.slider.api.types.ComponentInformation import org.apache.slider.api.types.ContainerInformation -import org.apache.slider.api.types.NodeInformation import org.apache.slider.core.conf.ConfTreeOperations import org.apache.slider.test.Outcome -import org.junit.Test import static org.apache.slider.api.ResourceKeys.* import static org.apache.slider.api.StatusKeys.* @@ -210,10 +208,10 @@ public abstract class AbstractAppApiTestDelegates extends AbstractRestTestDelega describe "Node listing via $appAPI" def liveNodes = appAPI.liveNodes assert liveNodes.size() > 0 - def h = liveNodes.keySet()[0]; + prettyPrintAsJson(liveNodes) + def h = liveNodes[0].hostname; def localhost = appAPI.getLiveNode(h) - - + assert localhost.httpAddress == liveNodes[0].httpAddress } /** @@ -239,7 +237,7 @@ public abstract class AbstractAppApiTestDelegates extends AbstractRestTestDelega testLiveContainers(); testRESTModel() testAppLiveness() -// testListNodes(); + testListNodes(); } public void testFlexOperation() { http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/cc94e056/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAAEcho.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAAEcho.groovy b/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAAEcho.groovy index 255dcaf..7072fc6 100644 --- a/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAAEcho.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAAEcho.groovy @@ -135,6 +135,7 @@ class TestAgentAAEcho extends TestAgentEcho { //expect the role count to be the same waitForRoleCount(sliderClient, onlyOneEcho, 1000) + def echoInstances = sliderClient.listNodeUUIDsByRole(roleName) queryRestAPI(sliderClient, roles, proxyAM) // flex size // while running, ask for many more, expect them to still be outstanding @@ -147,6 +148,9 @@ class TestAgentAAEcho extends TestAgentEcho { sliderClient.flex(clustername, onlyOneEcho); waitForRoleCount(sliderClient, onlyOneEcho, 1000) + def echoInstances2 = sliderClient.listNodeUUIDsByRole(roleName) + assertArrayEquals(echoInstances, echoInstances2) + } protected void queryRestAPI(SliderClient sliderClient, Map<String, Integer> roles, String proxyAM) {