Search in sources :

Example 1 with JsonObject

use of dontweave.gson.JsonObject in project h2o-2 by h2oai.

the class GroupedAverage method serve.

@Override
public Response serve() {
    JsonObject json = new JsonObject();
    Frame fr = source.deepSlice(null, null);
    UKV.put(destination_key, fr);
    return Response.done(json);
}
Also used : Frame(water.fvec.Frame) JsonObject(dontweave.gson.JsonObject)

Example 2 with JsonObject

use of dontweave.gson.JsonObject in project h2o-2 by h2oai.

the class WebAPI method exportModel.

/**
   * Exports a model to a JSON file.
   */
static void exportModel() throws Exception {
    HttpClient client = new HttpClient();
    GetMethod get = new GetMethod(URL + "/2/ExportModel.json?model=MyInitialNeuralNet");
    int status = client.executeMethod(get);
    if (status != 200)
        throw new Exception(get.getStatusText());
    JsonObject response = (JsonObject) new JsonParser().parse(new InputStreamReader(get.getResponseBodyAsStream()));
    JsonElement model = response.get("model");
    JsonWriter writer = new JsonWriter(new FileWriter(JSON_FILE));
    writer.setLenient(true);
    writer.setIndent("  ");
    Streams.write(model, writer);
    writer.close();
    get.releaseConnection();
}
Also used : InputStreamReader(java.io.InputStreamReader) JsonElement(dontweave.gson.JsonElement) HttpClient(org.apache.commons.httpclient.HttpClient) FileWriter(java.io.FileWriter) GetMethod(org.apache.commons.httpclient.methods.GetMethod) JsonObject(dontweave.gson.JsonObject) JsonWriter(dontweave.gson.stream.JsonWriter) JsonParser(dontweave.gson.JsonParser)

Example 3 with JsonObject

use of dontweave.gson.JsonObject in project h2o-2 by h2oai.

the class SetTimezone method serve.

// Reply value is the current setting
@Override
protected Response serve() {
    invoke();
    String s = ParseTime.getTimezone().getID();
    JsonObject response = new JsonObject();
    response.addProperty("tz", s);
    return Response.done(response);
}
Also used : JsonObject(dontweave.gson.JsonObject)

Example 4 with JsonObject

use of dontweave.gson.JsonObject in project h2o-2 by h2oai.

the class Shutdown method serve.

@Override
public Response serve() {
    java.util.Timer t = new java.util.Timer("Shutdown Timer");
    t.schedule(new TimerTask() {

        @Override
        public void run() {
            UDPRebooted.T.shutdown.send(H2O.SELF);
            H2O.exit(0);
        }
    }, 100);
    JsonObject json = new JsonObject();
    json.addProperty(STATUS, "shutting down");
    return Response.done(json);
}
Also used : TimerTask(java.util.TimerTask) JsonObject(dontweave.gson.JsonObject)

Example 5 with JsonObject

use of dontweave.gson.JsonObject in project h2o-2 by h2oai.

the class TypeaheadRequest method serve.

@Override
protected final Response serve() {
    JsonArray array = serve(_filter.value(), _limit.value());
    JsonObject response = new JsonObject();
    response.add(ITEMS, array);
    return Response.done(response);
}
Also used : JsonArray(dontweave.gson.JsonArray) JsonObject(dontweave.gson.JsonObject)

Aggregations

JsonObject (dontweave.gson.JsonObject)41 JsonElement (dontweave.gson.JsonElement)5 JsonParser (dontweave.gson.JsonParser)4 JsonArray (dontweave.gson.JsonArray)3 Frame (water.fvec.Frame)3 Job (water.Job)2 Value (water.Value)2 JsonPrimitive (dontweave.gson.JsonPrimitive)1 JsonWriter (dontweave.gson.stream.JsonWriter)1 FileWriter (java.io.FileWriter)1 InputStreamReader (java.io.InputStreamReader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Date (java.util.Date)1 TimerTask (java.util.TimerTask)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 GetMethod (org.apache.commons.httpclient.methods.GetMethod)1 Path (org.apache.hadoop.fs.Path)1 Key (water.Key)1 Timer (water.Timer)1 FrameSummary (water.api.Frames.FrameSummary)1