<commit_before>package water.api;

import java.io.*;
import java.net.ServerSocket;
import java.util.HashMap;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;

import water.*;
import water.api.Upload.PostFile;
import water.util.Log;
import water.util.Log.Tag.Sys;

import com.google.common.io.ByteStreams;
import com.google.common.io.Closeables;

/** This is a simple web server. */
public class RequestServer extends NanoHTTPD {

  // cache of all loaded resources
  private static final ConcurrentHashMap<String,byte[]> _cache = new ConcurrentHashMap();
  protected static final HashMap<String,Request> _requests = new HashMap();

  private static final Request _http404;
  private static final Request _http500;

  // initialization ------------------------------------------------------------
  static {
    _http404 = registerRequest(new HTTP404());
    _http500 = registerRequest(new HTTP500());


    Request.addToNavbar(registerRequest(new Inspect()),     "Inspect",      "Data");
    Request.addToNavbar(registerRequest(new StoreView()),   "View All",     "Data");
    Request.addToNavbar(registerRequest(new Parse()),       "Parse",        "Data");
    Request.addToNavbar(registerRequest(new RReader()),     "Parse R Data", "Data");
    Request.addToNavbar(registerRequest(new ImportFiles()), "Import Files", "Data");
    Request.addToNavbar(registerRequest(new ImportUrl()),   "Import URL",   "Data");
    Request.addToNavbar(registerRequest(new ImportS3()),    "Import S3",    "Data");
    Request.addToNavbar(registerRequest(new ExportS3()),    "Export S3",    "Data");
    Request.addToNavbar(registerRequest(new ImportHdfs()),  "Import HDFS",  "Data");
    Request.addToNavbar(registerRequest(new Upload()),      "Upload",       "Data");
    Request.addToNavbar(registerRequest(new Get()),         "Download",     "Data");

    Request.addToNavbar(registerRequest(new RF()),          "Random Forest", "Model");
    Request.addToNavbar(registerRequest(new GLM()),         "GLM",           "Model");
    Request.addToNavbar(registerRequest(new GLMGrid()),     "GLMGrid",       "Model");
    Request.addToNavbar(registerRequest(new KMeans()),      "KMeans",        "Model");
    Request.addToNavbar(registerRequest(new Console()),     "Console",       "Model");

    Request.addToNavbar(registerRequest(new RFScore()),     "Random Forest", "Score");
    Request.addToNavbar(registerRequest(new GLMScore()),    "GLM",           "Score");
    Request.addToNavbar(registerRequest(new KMeansScore()), "KMeans",        "Score");
    Request.addToNavbar(registerRequest(new Score()),       "Apply Model",   "Score");

    //Request.addToNavbar(registerRequest(new Plot()),        "Basic",         "Plot");

    Request.addToNavbar(registerRequest(new Jobs()),        "Jobs",          "Admin");
    Request.addToNavbar(registerRequest(new Cloud()),       "Cluster Status","Admin");
    Request.addToNavbar(registerRequest(new IOStatus()),    "Cluster I/O",   "Admin");
    Request.addToNavbar(registerRequest(new Timeline()),    "Timeline",      "Admin");
    Request.addToNavbar(registerRequest(new JStack()),      "Stack Dump",    "Admin");
    Request.addToNavbar(registerRequest(new Debug()),       "Debug Dump",    "Admin");
    Request.addToNavbar(registerRequest(new LogView()),     "Inspect Log",   "Admin");
    Request.addToNavbar(registerRequest(new Shutdown()),    "Shutdown",      "Admin");

    Request.addToNavbar(registerRequest(new Tutorials()),           "View All",      "Tutorials");
    Request.addToNavbar(registerRequest(new TutorialRFIris()),      "Random Forest", "Tutorials");
    Request.addToNavbar(registerRequest(new TutorialGLMProstate()), "GLM",           "Tutorials");
    Request.addToNavbar(registerRequest(new TutorialKMeans()),      "KMeans",        "Tutorials");

    // internal handlers
    registerRequest(new Cancel());
    registerRequest(new Exec());
    registerRequest(new ExportS3Progress());
    registerRequest(new GLMGridProgress());
    registerRequest(new GLMProgressPage());
    registerRequest(new GetVector());
    registerRequest(new LogView.LogDownload());
    registerRequest(new RReaderProgress());
    registerRequest(new PostFile());
    registerRequest(new Progress());
    registerRequest(new PutValue());
    registerRequest(new PutVector());
    registerRequest(new Remove());
    registerRequest(new RemoveAck());
    registerRequest(new RFView());
    registerRequest(new RFTreeView());
    registerRequest(new TypeaheadKeysRequest("Existing H2O Key", "", null));
    registerRequest(new TypeaheadHexKeyRequest());
    registerRequest(new TypeaheadFileRequest());
    registerRequest(new TypeaheadS3BucketRequest());
    registerRequest(new TypeaheadHdfsPathRequest());

    // testing hooks
    registerRequest(new TestPoll());
    registerRequest(new TestRedirect());
    Request.initializeNavBar();
  }

  /** Registers the request with the request server.<commit_msg>Fixed missing typeahed requests for models.<commit_after>package water.api;

import java.io.*;
import java.net.ServerSocket;
import java.util.HashMap;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;

import water.*;
import water.api.Upload.PostFile;
import water.util.Log;
import water.util.Log.Tag.Sys;

import com.google.common.io.ByteStreams;
import com.google.common.io.Closeables;

/** This is a simple web server. */
public class RequestServer extends NanoHTTPD {

  // cache of all loaded resources
  private static final ConcurrentHashMap<String,byte[]> _cache = new ConcurrentHashMap();
  protected static final HashMap<String,Request> _requests = new HashMap();

  private static final Request _http404;
  private static final Request _http500;

  // initialization ------------------------------------------------------------
  static {
    _http404 = registerRequest(new HTTP404());
    _http500 = registerRequest(new HTTP500());


    Request.addToNavbar(registerRequest(new Inspect()),     "Inspect",      "Data");
    Request.addToNavbar(registerRequest(new StoreView()),   "View All",     "Data");
    Request.addToNavbar(registerRequest(new Parse()),       "Parse",        "Data");
    Request.addToNavbar(registerRequest(new RReader()),     "Parse R Data", "Data");
    Request.addToNavbar(registerRequest(new ImportFiles()), "Import Files", "Data");
    Request.addToNavbar(registerRequest(new ImportUrl()),   "Import URL",   "Data");
    Request.addToNavbar(registerRequest(new ImportS3()),    "Import S3",    "Data");
    Request.addToNavbar(registerRequest(new ExportS3()),    "Export S3",    "Data");
    Request.addToNavbar(registerRequest(new ImportHdfs()),  "Import HDFS",  "Data");
    Request.addToNavbar(registerRequest(new Upload()),      "Upload",       "Data");
    Request.addToNavbar(registerRequest(new Get()),         "Download",     "Data");

    Request.addToNavbar(registerRequest(new RF()),          "Random Forest", "Model");
    Request.addToNavbar(registerRequest(new GLM()),         "GLM",           "Model");
    Request.addToNavbar(registerRequest(new GLMGrid()),     "GLMGrid",       "Model");
    Request.addToNavbar(registerRequest(new KMeans()),      "KMeans",        "Model");
    Request.addToNavbar(registerRequest(new Console()),     "Console",       "Model");

    Request.addToNavbar(registerRequest(new RFScore()),     "Random Forest", "Score");
    Request.addToNavbar(registerRequest(new GLMScore()),    "GLM",           "Score");
    Request.addToNavbar(registerRequest(new KMeansScore()), "KMeans",        "Score");
    Request.addToNavbar(registerRequest(new Score()),       "Apply Model",   "Score");

    //Request.addToNavbar(registerRequest(new Plot()),        "Basic",         "Plot");

    Request.addToNavbar(registerRequest(new Jobs()),        "Jobs",          "Admin");
    Request.addToNavbar(registerRequest(new Cloud()),       "Cluster Status","Admin");
    Request.addToNavbar(registerRequest(new IOStatus()),    "Cluster I/O",   "Admin");
    Request.addToNavbar(registerRequest(new Timeline()),    "Timeline",      "Admin");
    Request.addToNavbar(registerRequest(new JStack()),      "Stack Dump",    "Admin");
    Request.addToNavbar(registerRequest(new Debug()),       "Debug Dump",    "Admin");
    Request.addToNavbar(registerRequest(new LogView()),     "Inspect Log",   "Admin");
    Request.addToNavbar(registerRequest(new Shutdown()),    "Shutdown",      "Admin");

    Request.addToNavbar(registerRequest(new Tutorials()),           "View All",      "Tutorials");
    Request.addToNavbar(registerRequest(new TutorialRFIris()),      "Random Forest", "Tutorials");
    Request.addToNavbar(registerRequest(new TutorialGLMProstate()), "GLM",           "Tutorials");
    Request.addToNavbar(registerRequest(new TutorialKMeans()),      "KMeans",        "Tutorials");

    // internal handlers
    registerRequest(new Cancel());
    registerRequest(new Exec());
    registerRequest(new ExportS3Progress());
    registerRequest(new GLMGridProgress());
    registerRequest(new GLMProgressPage());
    registerRequest(new GetVector());
    registerRequest(new LogView.LogDownload());
    registerRequest(new RReaderProgress());
    registerRequest(new PostFile());
    registerRequest(new Progress());
    registerRequest(new PutValue());
    registerRequest(new PutVector());
    registerRequest(new Remove());
    registerRequest(new RemoveAck());
    registerRequest(new RFView());
    registerRequest(new RFTreeView());
    registerRequest(new TypeaheadKeysRequest("Existing H2O Key", "", null));
    registerRequest(new TypeaheadHexKeyRequest());
    registerRequest(new TypeaheadFileRequest());
    registerRequest(new TypeaheadS3BucketRequest());
    registerRequest(new TypeaheadHdfsPathRequest());
    registerRequest(new TypeaheadRFModelKeyRequest());
    registerRequest(new TypeaheadGLMModelKeyRequest());

    // testing hooks
    registerRequest(new TestPoll());
    registerRequest(new TestRedirect());
    Request.initializeNavBar();
  }

  /** Registers the request with the request server.
{'fraction_non_alphanumeric': 0.14968753099890883, 'fraction_numerical': 0.004959825414145422, 'mean_word_length': 3.9738529847064625, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6949183', 'n_tokens_mistral': 2850, 'n_tokens_neox': 2769, 'n_words': 572}