code: public static JsonGenerator createJsonGenerator(CoronaConf conf)
      throws IOException {
      OutputStream outputStream = new FileOutputStream(conf.getCMStateFile());
      if (conf.getCMCompressStateFlag()) {
        outputStream = new GZIPOutputStream(outputStream);
      }
      ObjectMapper mapper = new ObjectMapper();
      JsonGenerator jsonGenerator =
        new JsonFactory().createJsonGenerator(outputStream, JsonEncoding.UTF8);
      jsonGenerator.setCodec(mapper);
      if (!conf.getCMCompressStateFlag()) {
        jsonGenerator.setPrettyPrinter(new DefaultPrettyPrinter());
      }
      return jsonGenerator;
    }
docs: This is a helper method which creates a JsonGenerator instance, for writing
  the state of the ClusterManager to the state file. The JsonGenerator
  instance writes to a compressed file if we have the compression flag
  turned on.
  
  @param conf The CoronaConf instance to be used
  @return The JsonGenerator instance to be used
  @throws IOException