@@ -1013,13 +1013,25 @@ public void accept(String sClusterFound, String sResult)
10131013 sCluster = sTok .nextToken ().trim ();
10141014 try (Connection conn2 = Connection .open (sCluster , socketAddr , cTimeoutMillis ))
10151015 {
1016- System .out .println ("Cluster " + sCluster + ":\t " + conn2 .lookup (NS_STRING_PREFIX + sName ));
1016+ String sResultLookup = conn2 .lookup (NS_STRING_PREFIX + sName );
1017+
1018+ System .out .println ("Cluster " + sCluster + ":\t " + sResultLookup );
1019+ if (sResultLookup == null )
1020+ {
1021+ reportNameWarning (sName );
1022+ }
10171023 }
10181024 }
10191025 }
10201026 else
10211027 {
1022- System .out .println (conn .lookup (NS_STRING_PREFIX + sName ));
1028+ String sResultLookup = conn .lookup (NS_STRING_PREFIX + sName );
1029+
1030+ System .out .println (sResultLookup );
1031+ if (sResultLookup == null )
1032+ {
1033+ reportNameWarning (sName );
1034+ }
10231035 }
10241036 }
10251037 ex = null ;
@@ -1045,7 +1057,15 @@ public void accept(String sClusterFound, String sResult)
10451057 */
10461058 protected static void showInstructions ()
10471059 {
1048- String sClass = NSLookup .class .getCanonicalName ();
1060+ String sClass = NSLookup .class .getCanonicalName ();
1061+ StringBuffer sbLookupNames = new StringBuffer ("Valid predefined lookup names for -" + COMMAND_NAME + " option: " );
1062+
1063+ for (String sName : VALID_PREDEFINED_LOOKUP_NAMES )
1064+ {
1065+ sbLookupNames .append (" " + sName + "," );
1066+ }
1067+ sbLookupNames .setCharAt (sbLookupNames .length () - 1 , '.' );
1068+
10491069 System .out .println ();
10501070 System .out .println ("java " + sClass + " <commands ...>" );
10511071 System .out .println ();
@@ -1058,11 +1078,66 @@ protected static void showInstructions()
10581078 System .out .println ("\t -" + COMMAND_PORT + " the cluster port; default " + DEFAULT_CLUSTERPORT );
10591079 System .out .println ("\t -" + COMMAND_TIMEOUT + " the timeout (in seconds) of the lookup request; default " + (DEFAULT_TIMEOUT /1000 ));
10601080 System .out .println ();
1081+ System .out .println (sbLookupNames .toString ());
1082+ System .out .println ();
10611083 System .out .println ("Example:" );
10621084 System .out .println ("\t java " + sClass + " -" + COMMAND_HOST + " host.mycompany.com -" + COMMAND_NAME + " " + JMX_CONNECTOR_URL );
10631085 System .out .println ();
10641086 }
10651087
1088+ /**
1089+ * Descriptive error feedback for a failed lookup of provided -name parameter.
1090+ *
1091+ * @param sName value passed to -name argument
1092+ *
1093+ * @return null if no feedback or descriptive feedback
1094+ */
1095+ protected static String validateName (String sName )
1096+ {
1097+ for (String s : VALID_PREDEFINED_LOOKUP_NAMES )
1098+ {
1099+ if (s .equals (sName ))
1100+ {
1101+ return null ;
1102+ }
1103+ }
1104+
1105+ StringBuffer sb = new StringBuffer ();
1106+
1107+ sb .append ("Warning: provided -name parameter of \" " + sName + "\" " );
1108+ sb .append (" does not match predefined Name Service lookups of " );
1109+ for (int i =0 ; i < VALID_PREDEFINED_LOOKUP_NAMES .length ; i ++)
1110+ {
1111+ sb .append ("\" " + VALID_PREDEFINED_LOOKUP_NAMES [i ] + "\" " );
1112+ if (i + 1 < VALID_PREDEFINED_LOOKUP_NAMES .length )
1113+ {
1114+ sb .append ("," );
1115+ }
1116+ else
1117+ {
1118+ sb .append ("." );
1119+ }
1120+ }
1121+ sb .append (System .lineSeparator ());
1122+ sb .append ("warning: If looking up an extend proxy service, verify the scoped proxy service name is correct." );
1123+ return sb .toString ();
1124+ }
1125+
1126+ /**
1127+ * Reports {@code -name} parameter warning when appropriate to standard error.
1128+ *
1129+ * @param sName Name Service looked up
1130+ */
1131+ protected static void reportNameWarning (String sName )
1132+ {
1133+ String sWarning = validateName (sName );
1134+
1135+ if (sWarning != null )
1136+ {
1137+ System .err .println (sWarning );
1138+ }
1139+ }
1140+
10661141 // ----- static data members -------------------------------------------
10671142
10681143 public static final String COMMAND_HELP = "?" ;
@@ -1117,6 +1192,13 @@ protected static void showInstructions()
11171192 */
11181193 public static final String HTTP_HEALTH_URL = "health/HTTPHealthURL" ;
11191194
1195+ /**
1196+ * Cluster info lookup name.
1197+ *
1198+ * @since 25.03
1199+ */
1200+ public static final String CLUSTER_INFO = "Cluster/info" ;
1201+
11201202 /**
11211203 * The gRPC Proxy lookup name.
11221204 *
@@ -1126,6 +1208,14 @@ protected static void showInstructions()
11261208 // This value here must match the fully scoped name used for the gRPC proxy in the
11271209 // grpc-proxy-cache-config.xml file and in the GrpcDependencies.DEFAULT_PROXY_NAME field
11281210
1211+ /**
1212+ * Valid predefined lookup names.
1213+ *
1214+ * @since 25.03
1215+ */
1216+ public static final String [] VALID_PREDEFINED_LOOKUP_NAMES =
1217+ {JMX_CONNECTOR_URL , HTTP_MANAGEMENT_URL , HTTP_METRICS_URL , HTTP_HEALTH_URL , GRPC_PROXY_URL , CLUSTER_INFO };
1218+
11291219 /**
11301220 * Default timeout in milliseconds
11311221 */
0 commit comments