class MRConstants
{
private static final String PROTOCOL = "http";
- public static final String context = "/";
- public static final String kBasePath = "events/";
- public static final int kStdMRServicePort = 8080;
+ public static final String CONTEXT = "/";
+ public static final String BASE_PATH = "events/";
+ public static final int STD_MR_SERVICE_PORT = 8080;
public static String escape ( String s )
{
final String cleanTopic = escape ( rawTopic );
final StringBuffer url = new StringBuffer().
- append ( MRConstants.context ).
- append ( MRConstants.kBasePath ).
+ append ( MRConstants.CONTEXT).
+ append ( MRConstants.BASE_PATH).
append ( cleanTopic );
return url.toString ();
}
public static String makeUrl ( final String host, final String rawTopic )
{
final String cleanTopic = escape ( rawTopic );
-
final StringBuffer url = new StringBuffer();
- if (!host.startsWith("http") || !host.startsWith("https") ) {
+ if (!host.startsWith("http") && !host.startsWith("https") ) {
url.append( PROTOCOL + "://" );
}
url.append(host);
- url.append ( MRConstants.context );
- url.append ( MRConstants.kBasePath );
+ url.append ( MRConstants.CONTEXT);
+ url.append ( MRConstants.BASE_PATH);
url.append ( cleanTopic );
return url.toString ();
}
url.append( PROTOCOL + "://" );
}
url.append(host);
- url.append ( MRConstants.context );
- url.append ( MRConstants.kBasePath );
+ url.append ( MRConstants.CONTEXT);
+ url.append ( MRConstants.BASE_PATH);
url.append ( cleanTopic );
if(parttion!=null && !parttion.equalsIgnoreCase(""))
url.append("?partitionKey=").append(parttion);
{
final String cleanConsumerGroup = escape ( rawConsumerGroup );
final String cleanConsumerId = escape ( rawConsumerId );
- return MRConstants.context + MRConstants.kBasePath + topic + "/" + cleanConsumerGroup + "/" + cleanConsumerId;
+ return MRConstants.CONTEXT + MRConstants.BASE_PATH + topic + "/" + cleanConsumerGroup + "/" + cleanConsumerId;
}
/**
*/
public static List<HttpHost> createHostsList(Collection<String> hosts)
{
- final ArrayList<HttpHost> convertedHosts = new ArrayList<HttpHost> ();
+ final ArrayList<HttpHost> convertedHosts = new ArrayList<> ();
for ( String host : hosts )
{
if ( host.length () == 0 ) continue;
* Return an HttpHost from an input string. Input string has
* host[:port] as format. If the port section is not provided, the default port is used.
*
- * @param hosts
+ * @param host
* @return a list of hosts
*/
public static HttpHost hostForString ( String host )
if ( host.length() < 1 ) throw new IllegalArgumentException ( "An empty host entry is invalid." );
String hostPart = host;
- int port = kStdMRServicePort;
+ int port = STD_MR_SERVICE_PORT;
final int colon = host.indexOf ( ':' );
if ( colon == 0 ) throw new IllegalArgumentException ( "Host entry '" + host + "' is invalid." );
}
url.append(host);
- url.append(context);
- url.append(kBasePath);
+ url.append(CONTEXT);
+ url.append(BASE_PATH);
url.append(fTopic + "/" + cleanConsumerGroup + "/" + cleanConsumerId);
return url.toString();