private void createFile() throws HyracksDataException {
    try {
      Date date = new Date();
      String dateSuffix = date.toString().replace(' ', '_');
      String fileName =
          connectionId.getFeedId()
              + "_"
              + connectionId.getDatasetName()
              + "_"
              + runtimeId.getFeedRuntimeType()
              + "_"
              + runtimeId.getPartition()
              + "_"
              + dateSuffix;

      file = new File(fileName);
      if (!file.exists()) {
        boolean success = file.createNewFile();
        if (!success) {
          throw new HyracksDataException(
              "Unable to create spill file " + fileName + " for feed " + runtimeId);
        } else {
          if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info("Created spill file " + file.getAbsolutePath());
          }
        }
      }
      bos = new BufferedOutputStream(new FileOutputStream(file));
    } catch (Throwable th) {
      throw new HyracksDataException(th);
    }
  }
 @Override
 public JSONObject toJSON() throws JSONException {
   JSONObject obj = new JSONObject();
   obj.put(FeedConstants.MessageConstants.MESSAGE_TYPE, messageType.name());
   obj.put(FeedConstants.MessageConstants.DATAVERSE, connectionId.getFeedId().getDataverse());
   obj.put(FeedConstants.MessageConstants.FEED, connectionId.getFeedId().getFeedName());
   obj.put(FeedConstants.MessageConstants.DATASET, connectionId.getDatasetName());
   return obj;
 }