// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
//   private static final long serialVersionUID = 4941423443352427505L;
// 
//   /**
//    * @param config
//    *          The configuration that contains the invalid parameter
//    * @param parameter
//    *          The name of the configuration parameter that is invalid
//    * @param throwable
//    *          The exception that occurred when setting the parameter's value
//    * @return The newly built F2SConfigurationException related to a specific
//    *         invalid parameter
//    */
//   public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
//     return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
//   }
// 
//   /**
//    * @param parameter
//    *          The name of the configuration parameter that is invalid
//    * @param value
//    *          The configured value of the parameter
//    * @param throwable
//    *          The exception that occurred when setting the parameter's value
//    * @return The newly built F2SConfigurationException related to a specific
//    *         invalid parameter
//    */
//   public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
//     return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
//   }
// 
//   protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
//     return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
//         .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
//         .append(throwable.getLocalizedMessage()).toString();
//   }
// 
//   /**
//    * @param parameter
//    *          The name of the configuration parameter that is missing
//    * @return The newly built F2SConfigurationException related to a specific
//    *         missing parameter
//    */
//   public static F2SConfigurationException missing(String parameter) {
//     return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
//         .append("\" is required but not specified").toString());
//   }
// 
//   public F2SConfigurationException() {
//     super();
//   }
// 
//   public F2SConfigurationException(String message) {
//     super(message);
//   }
// 
//   public F2SConfigurationException(Throwable throwable) {
//     super(throwable);
//   }
// 
//   public F2SConfigurationException(String message, Throwable throwable) {
//     super(message, throwable);
//   }
// }
// 
// Path: core/src/main/java/com/comcast/viper/flume2storm/connection/parameters/ConnectionParameters.java
// public interface ConnectionParameters {
//   /**
//    * @return A unique identifier of the associated {@link EventSender} /
//    *         {@link ServiceProvider} (hostname:port for instance)
//    * 
//    */
//   String getId();
// }


import java.io.Serializable;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.comcast.viper.flume2storm.connection.parameters.ConnectionParameters;
import com.google.common.base.Preconditions;
/**
 * Copyright 2014 Comcast Cable Communications Management, LLC
 *
 * Licensed 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 com.comcast.viper.flume2storm.connection.parameters;




/**
 * Configuration for the KryoNet connection. Note that the hostname of the
 * server is configured according to the following algorithm:
 * <ol>
 * <li>If the {@link #ADDRESS} parameter is specified, this is the
 * address/hostname that is used</li>
 * <li>Otherwise, the IP address of the host is retrieved and used</li>
 * <li>If the previous step failed, the default hostname
 * {@link #ADDRESS_DEFAULT} is used</li>
 * </ol>
 */
public class KryoNetConnectionParameters implements ConnectionParameters, Serializable {
  private static final long serialVersionUID = -5178954514610562054L;
  /** Configuration attribute name for {@link #getAddress()} */
  public static final String ADDRESS = "address";
  /** Default value for {@value #ADDRESS} */
  public static final String ADDRESS_DEFAULT = "localhost";
  /** Configuration attribute name for {@link #getPort()} */
  public static final String PORT = "port";
  /** Default value for {@value #PORT} */
  public static final int PORT_DEFAULT = 7000;
  /** Configuration attribute name for {@link #getObjectBufferSize()} */
  public static final String OBJECT_BUFFER_SZ = "object.buffer.size";
  /** Default value for {@value #OBJECT_BUFFER_SZ} */
  public static final int OBJECT_BUFFER_SIZE_DEFAULT = 3024;
  /** Configuration attribute name for {@link #getWriteBufferSize()} */
  public static final String WRITE_BUFFER_SZ = "write.buffer.size";
  /** Default value for {@value #WRITE_BUFFER_SZ} */
  public static final int WRITE_BUFFER_SIZE_DEFAULT = OBJECT_BUFFER_SIZE_DEFAULT * 1000;

  protected String address;
  protected int port;
  protected int objectBufferSize;
  protected int writeBufferSize;

  /**
   * @param config
   *          The configuration to use
   * @return The newly constructed {@link KryoNetConnectionParameters} based on
   *         the {@link Configuration} specified
   * @throws F2SConfigurationException
   *           If the configuration specified is invalid
   */
// Path: core/src/main/java/com/comcast/viper/flume2storm/F2SConfigurationException.java
// @SuppressWarnings("javadoc")
// public class F2SConfigurationException extends Exception {
//   private static final long serialVersionUID = 4941423443352427505L;
// 
//   /**
//    * @param config
//    *          The configuration that contains the invalid parameter
//    * @param parameter
//    *          The name of the configuration parameter that is invalid
//    * @param throwable
//    *          The exception that occurred when setting the parameter's value
//    * @return The newly built F2SConfigurationException related to a specific
//    *         invalid parameter
//    */
//   public static F2SConfigurationException with(Configuration config, String parameter, Throwable throwable) {
//     return F2SConfigurationException.with(parameter, config.getProperty(parameter), throwable);
//   }
// 
//   /**
//    * @param parameter
//    *          The name of the configuration parameter that is invalid
//    * @param value
//    *          The configured value of the parameter
//    * @param throwable
//    *          The exception that occurred when setting the parameter's value
//    * @return The newly built F2SConfigurationException related to a specific
//    *         invalid parameter
//    */
//   public static F2SConfigurationException with(String parameter, Object value, Throwable throwable) {
//     return new F2SConfigurationException(buildErrorMessage(parameter, value, throwable), throwable);
//   }
// 
//   protected static final String buildErrorMessage(String parameter, Object value, Throwable throwable) {
//     return new StringBuilder("Configuration attribute \"").append(parameter).append("\" has invalid value (\"")
//         .append(value).append("\"). ").append(throwable.getClass().getSimpleName()).append(": ")
//         .append(throwable.getLocalizedMessage()).toString();
//   }
// 
//   /**
//    * @param parameter
//    *          The name of the configuration parameter that is missing
//    * @return The newly built F2SConfigurationException related to a specific
//    *         missing parameter
//    */
//   public static F2SConfigurationException missing(String parameter) {
//     return new F2SConfigurationException(new StringBuilder("Configuration attribute \"").append(parameter)
//         .append("\" is required but not specified").toString());
//   }
// 
//   public F2SConfigurationException() {
//     super();
//   }
// 
//   public F2SConfigurationException(String message) {
//     super(message);
//   }
// 
//   public F2SConfigurationException(Throwable throwable) {
//     super(throwable);
//   }
// 
//   public F2SConfigurationException(String message, Throwable throwable) {
//     super(message, throwable);
//   }
// }
// 
// Path: core/src/main/java/com/comcast/viper/flume2storm/connection/parameters/ConnectionParameters.java
// public interface ConnectionParameters {
//   /**
//    * @return A unique identifier of the associated {@link EventSender} /
//    *         {@link ServiceProvider} (hostname:port for instance)
//    * 
//    */
//   String getId();
// }


// Path: kryonet-flume2storm/src/main/java/com/comcast/viper/flume2storm/connection/parameters/KryoNetConnectionParameters.java
import java.io.Serializable;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.comcast.viper.flume2storm.F2SConfigurationException;
import com.comcast.viper.flume2storm.connection.parameters.ConnectionParameters;
import com.google.common.base.Preconditions;

/**
 * Copyright 2014 Comcast Cable Communications Management, LLC
 *
 * Licensed 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 com.comcast.viper.flume2storm.connection.parameters;




/**
 * Configuration for the KryoNet connection. Note that the hostname of the
 * server is configured according to the following algorithm:
 * <ol>
 * <li>If the {@link #ADDRESS} parameter is specified, this is the
 * address/hostname that is used</li>
 * <li>Otherwise, the IP address of the host is retrieved and used</li>
 * <li>If the previous step failed, the default hostname
 * {@link #ADDRESS_DEFAULT} is used</li>
 * </ol>
 */
public class KryoNetConnectionParameters implements ConnectionParameters, Serializable {
  private static final long serialVersionUID = -5178954514610562054L;
  /** Configuration attribute name for {@link #getAddress()} */
  public static final String ADDRESS = "address";
  /** Default value for {@value #ADDRESS} */
  public static final String ADDRESS_DEFAULT = "localhost";
  /** Configuration attribute name for {@link #getPort()} */
  public static final String PORT = "port";
  /** Default value for {@value #PORT} */
  public static final int PORT_DEFAULT = 7000;
  /** Configuration attribute name for {@link #getObjectBufferSize()} */
  public static final String OBJECT_BUFFER_SZ = "object.buffer.size";
  /** Default value for {@value #OBJECT_BUFFER_SZ} */
  public static final int OBJECT_BUFFER_SIZE_DEFAULT = 3024;
  /** Configuration attribute name for {@link #getWriteBufferSize()} */
  public static final String WRITE_BUFFER_SZ = "write.buffer.size";
  /** Default value for {@value #WRITE_BUFFER_SZ} */
  public static final int WRITE_BUFFER_SIZE_DEFAULT = OBJECT_BUFFER_SIZE_DEFAULT * 1000;

  protected String address;
  protected int port;
  protected int objectBufferSize;
  protected int writeBufferSize;

  /**
   * @param config
   *          The configuration to use
   * @return The newly constructed {@link KryoNetConnectionParameters} based on
   *         the {@link Configuration} specified
   * @throws F2SConfigurationException
   *           If the configuration specified is invalid
   */
  public static KryoNetConnectionParameters from(Configuration config) throws F2SConfigurationException {