e2etests/testlocalapps/allinone/src/main/java/allinone/MainServlet.java [126:252]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class MainServlet extends HttpServlet {
  private static final Logger logger = Logger.getLogger(MainServlet.class.getName());

  private static final Charset US_ASCII_CHARSET = US_ASCII;
  private static final Level[] LOG_LEVELS =
      new Level[] {Level.FINEST, Level.FINE, Level.CONFIG, Level.INFO, Level.WARNING, Level.SEVERE};
  // "Car" datastore entity.
  private static final String CAR_KIND = "Car";
  private static final String COLOR_PROPERTY = "color";
  private static final String BRAND_PROPERTY = "brand";
  private static final String[] COLORS = new String[] { "green", "red", "blue" };
  private static final String[] BRANDS = new String[] { "toyota", "honda", "nissan" };
  // "Log" datastore entity.
  private static final String LOG_KIND = "Log";
  private static final String URL_PROPERTY = "url";
  private static final String DATE_PROPERTY = "date";

  private static final ImmutableSet<String> VALID_PARAMETERS =
      ImmutableSet.of(
          "add_tasks",
          "awt_text",
          "clear_pinned_buffers",
          "datastore_count",
          "datastore_cron",
          "datastore_entities",
          "datastore_queries",
          "deferred_task",
          "deferred_task_verify",
          "direct_byte_buffer_size",
          "fetch_project_id_from_metadata",
          "fetch_service_account_scopes_from_metadata",
          "fetch_service_account_token_from_metadata",
          "fetch_url",
          "fetch_url_using_httpurlconnection",
          "forward",
          "get_attribute",
          "get_environment",
          "get_header",
          "get_metadata",
          "get_named_dispatcher",
          "get_system_property",
          "jmx_info",
          "jmx_list_vm_options",
          "jmx_thread_dump",
          "list_attributes",
          "list_environment",
          "list_headers",
          "list_processes",
          "list_system_properties",
          "log_flush",
          "log_lines",
          "log_remaining_time",
          "math_loops",
          "math_ms",
          "memcache_loops",
          "memcache_size",
          "oom",
          "pin_byte_buffer",
          "pin_byte_buffer_size",
          "random_response_size",
          "response_size",
          "set_servlet_attributes",
          "silent",
          "sql_columns",
          "sql_db",
          "sql_len",
          "sql_replace",
          "sql_rows",
          "sql_timeout",
          // "spanner_id",
          // "spanner_db",
          "task_url",
          "user",
          "validate_fs");

  private static final List<ByteBuffer> PINNED_BUFFERS = new ArrayList<>();

  private final Random random = new Random();
  private ServletContext context;

  @Override
  public void init(ServletConfig config) {
    this.context = config.getServletContext();
  }

  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
      IOException {
    validateParameters(req);
    // In silent mode, regular response output is suppressed and a single "OK"
    // string is printed if all actions ran successfully.
    boolean silent = req.getParameter("silent") != null;
    resp.setContentType("text/plain");
    PrintWriter responseWriter = resp.getWriter();
    PrintWriter w = (silent ? new PrintWriter(new StringWriter()) : responseWriter);
    // These options are also present in the python allinone application, sometimes
    // with slightly different names, e.g. "queries" vs "datastore_queries".
    Integer mathMsParam = getIntParameter("math_ms", req);
    if (mathMsParam != null) {
      performMathMs(mathMsParam, w);
    }
    Integer mathLoopsParam = getIntParameter("math_loops", req);
    if (mathLoopsParam != null) {
      performMathLoops(mathLoopsParam, w);
    }
    Integer memcacheLoopsParam = getIntParameter("memcache_loops", req);
    if (memcacheLoopsParam != null) {
      Integer size = getIntParameter("memcache_size", req);
      performMemcacheLoops(memcacheLoopsParam, size, w);
    }
    Integer logLinesParam = getIntParameter("log_lines", req);
    if (logLinesParam != null) {
      performLogging(logLinesParam, w);
    }
    if (req.getParameter("log_flush") != null) {
      performLogFlush(w);
    }
    Integer responseSizeParam = getIntParameter("response_size", req);
    if (responseSizeParam != null) {
      performResponseSize(responseSizeParam, w);
    }
    Integer queriesParam = getIntParameter("datastore_queries", req);
    if (queriesParam != null) {
      performQueries(queriesParam, w);
    }
    Integer entitiesParam = getIntParameter("datastore_entities", req);
    if (entitiesParam != null) {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



runtime/testapps/src/main/java/com/google/apphosting/loadtesting/allinone/MainServlet.java [128:254]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class MainServlet extends HttpServlet {
  private static final Logger logger = Logger.getLogger(MainServlet.class.getName());

  private static final Charset US_ASCII_CHARSET = US_ASCII;
  private static final Level[] LOG_LEVELS =
      new Level[] {Level.FINEST, Level.FINE, Level.CONFIG, Level.INFO, Level.WARNING, Level.SEVERE};
  // "Car" datastore entity.
  private static final String CAR_KIND = "Car";
  private static final String COLOR_PROPERTY = "color";
  private static final String BRAND_PROPERTY = "brand";
  private static final String[] COLORS = new String[] { "green", "red", "blue" };
  private static final String[] BRANDS = new String[] { "toyota", "honda", "nissan" };
  // "Log" datastore entity.
  private static final String LOG_KIND = "Log";
  private static final String URL_PROPERTY = "url";
  private static final String DATE_PROPERTY = "date";

  private static final ImmutableSet<String> VALID_PARAMETERS =
      ImmutableSet.of(
          "add_tasks",
          "awt_text",
          "clear_pinned_buffers",
          "datastore_count",
          "datastore_cron",
          "datastore_entities",
          "datastore_queries",
          "deferred_task",
          "deferred_task_verify",
          "direct_byte_buffer_size",
          "fetch_project_id_from_metadata",
          "fetch_service_account_scopes_from_metadata",
          "fetch_service_account_token_from_metadata",
          "fetch_url",
          "fetch_url_using_httpurlconnection",
          "forward",
          "get_attribute",
          "get_environment",
          "get_header",
          "get_metadata",
          "get_named_dispatcher",
          "get_system_property",
          "jmx_info",
          "jmx_list_vm_options",
          "jmx_thread_dump",
          "list_attributes",
          "list_environment",
          "list_headers",
          "list_processes",
          "list_system_properties",
          "log_flush",
          "log_lines",
          "log_remaining_time",
          "math_loops",
          "math_ms",
          "memcache_loops",
          "memcache_size",
          "oom",
          "pin_byte_buffer",
          "pin_byte_buffer_size",
          "random_response_size",
          "response_size",
          "set_servlet_attributes",
          "silent",
          "sql_columns",
          "sql_db",
          "sql_len",
          "sql_replace",
          "sql_rows",
          "sql_timeout",
          // "spanner_id",
          // "spanner_db",
          "task_url",
          "user",
          "validate_fs");

  private static final List<ByteBuffer> PINNED_BUFFERS = new ArrayList<>();

  private final Random random = new Random();
  private ServletContext context;

  @Override
  public void init(ServletConfig config) {
    this.context = config.getServletContext();
  }

  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
      IOException {
    validateParameters(req);
    // In silent mode, regular response output is suppressed and a single "OK"
    // string is printed if all actions ran successfully.
    boolean silent = req.getParameter("silent") != null;
    resp.setContentType("text/plain");
    PrintWriter responseWriter = resp.getWriter();
    PrintWriter w = (silent ? new PrintWriter(new StringWriter()) : responseWriter);
    // These options are also present in the python allinone application, sometimes
    // with slightly different names, e.g. "queries" vs "datastore_queries".
    Integer mathMsParam = getIntParameter("math_ms", req);
    if (mathMsParam != null) {
      performMathMs(mathMsParam, w);
    }
    Integer mathLoopsParam = getIntParameter("math_loops", req);
    if (mathLoopsParam != null) {
      performMathLoops(mathLoopsParam, w);
    }
    Integer memcacheLoopsParam = getIntParameter("memcache_loops", req);
    if (memcacheLoopsParam != null) {
      Integer size = getIntParameter("memcache_size", req);
      performMemcacheLoops(memcacheLoopsParam, size, w);
    }
    Integer logLinesParam = getIntParameter("log_lines", req);
    if (logLinesParam != null) {
      performLogging(logLinesParam, w);
    }
    if (req.getParameter("log_flush") != null) {
      performLogFlush(w);
    }
    Integer responseSizeParam = getIntParameter("response_size", req);
    if (responseSizeParam != null) {
      performResponseSize(responseSizeParam, w);
    }
    Integer queriesParam = getIntParameter("datastore_queries", req);
    if (queriesParam != null) {
      performQueries(queriesParam, w);
    }
    Integer entitiesParam = getIntParameter("datastore_entities", req);
    if (entitiesParam != null) {
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



