Saves Spark with Alluixo integration checker results.

@param resultStatus Spark job result status
@param reportWriter save user-facing messages to a generated file
502628
private void printResultInfo(Status resultStatus, PrintWriter reportWriter) {
    switch (resultStatus) {
      case FAIL_TO_FIND_CLASS:
        reportWriter.println(FAIL_TO_FIND_CLASS_MESSAGE);
        reportWriter.println(TEST_FAILED_MESSAGE);
        break;
      case FAIL_TO_FIND_FS:
        reportWriter.println(FAIL_TO_FIND_FS_MESSAGE);
        reportWriter.println(TEST_FAILED_MESSAGE);
        break;
      case FAIL_TO_SUPPORT_HA:
        reportWriter.println(FAIL_TO_SUPPORT_HA_MESSAGE);
        reportWriter.println(TEST_FAILED_MESSAGE);
        break;
      default:
        reportWriter.println(TEST_PASSED_MESSAGE);
        break;
    }
  }
556424
@Override
    public void write(Iterable<QueryResult> results) {
        logger.debug("Export to '{}' results {}", graphiteServerHostAndPort, results);
        SocketWriter socketWriter = null;
        try {
            socketWriter = socketWriterPool.borrowObject(graphiteServerHostAndPort);
            for (QueryResult result : results) {
                String msg = metricPathPrefix + result.getName() + " " + result.getValue() + " " + result.getEpoch(TimeUnit.SECONDS) + "\n";
                logger.debug("Export '{}'", msg);
                socketWriter.write(msg);
            }
            socketWriter.flush();
            socketWriterPool.returnObject(graphiteServerHostAndPort, socketWriter);
        } catch (Exception e) {
            logger.warn("Failure to send result to graphite server '{}' with {}", graphiteServerHostAndPort, socketWriter, e);
            if (socketWriter != null) {
                try {
                    socketWriterPool.invalidateObject(graphiteServerHostAndPort, socketWriter);
                } catch (Exception e2) {
                    logger.warn("Exception invalidating socketWriter connected to graphite server '{}': {}", graphiteServerHostAndPort, socketWriter, e2);
                }
            }
        }
    }
1090385
public void dumpAll(FormattedWriter fw)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "dumpAll");

        try
        {
            xmlRequestWriteOnFile(fw);
            xmlWriteRawOn(fw, true);
            fw.flush();
        } catch (IOException e)
        {
            // No FFDC Code Needed
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                SibTr.event(this, tc, "Exception caught writing Mmessage store dump!", e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "dumpAll");
    }
210015
private void outputReportFiles(List<String> reportNames, File reportDirectory, TestResult testResult,
                                   boolean tranSummary) throws IOException {

        if (reportNames.isEmpty()) {
            return;
        }
        String title = (tranSummary) ? "Transaction Summary" : "Performance Report";
        String htmlFileName = (tranSummary) ? (TRANSACTION_REPORT_NAME + ".html") : "HTML.html";
        File htmlIndexFile = new File(reportDirectory, INDEX_HTML_NAME);
        BufferedWriter writer = new BufferedWriter(new FileWriter(htmlIndexFile));
        writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>%n");
        writer.write("<HTML><HEAD>%n");
        writer.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">%n");
        writer.write(String.format("<TITLE>%s</TITLE>%n", title));
        writer.write("</HEAD>%n");
        writer.write("<BODY>%n");
        writer.write(
                "<table style=\"font-size:15px;width:100%;max-width:100%;border-left:1px solid #DDD;border-right:1px " +
                        "solid #DDD;border-bottom:1px solid #DDD;\">%n");
        writer.write(
                "<tr style=\"background-color: #F1F1F1;\"><th style=\"padding:8px;line-height:1.42857;" +
                        "vertical-align:top;border-top:1px solid #DDD;\">Name</th></tr>%n");
        boolean rolling = true;
        for (String report : reportNames) {
            if (rolling) {
                writer.write(String.format(
                        "<tr style=\"background-color: #FFF;\"><td style=\"padding:8px;line-height:1.42857;" +
                                "vertical-align:top;border-top:1px solid #DDD;" +
                                "\"><a href=\"./%s/%s\">%s</a></td></tr>%n",
                        report, htmlFileName, report));
                rolling = false;
            } else {
                writer.write(String.format(
                        "<tr style=\"background-color: #F1F1F1;\"><td style=\"padding:8px;line-height:1.42857;" +
                                "vertical-align:top;border-top:1px solid #DDD;" +
                                "\"><a href=\"./%s/%s\">%s</a></td></tr>%n",
                        report, htmlFileName, report));
                rolling = true;
            }
        }
        writer.write("</table>%n");
        writer.write("</BODY>%n");
        writer.flush();
        writer.close();

        File indexFile = new File(reportDirectory, REPORT_INDEX_NAME);
        writer = new BufferedWriter(new FileWriter(indexFile));

        Iterator<SuiteResult> resultIterator = null;
        if ((testResult != null) && (!testResult.getSuites().isEmpty())) {
            resultIterator = testResult.getSuites().iterator();//get the first
        }
        for (String report : reportNames) {
            SuiteResult suitResult = null;
            if ((resultIterator != null) && resultIterator.hasNext()) {
                suitResult = resultIterator.next();
            }
            if (suitResult == null) {
                writer.write(report + "\t##\t##\t##%n");
            } else {
                int iDuration = (int) suitResult.getDuration();
                StringBuilder bld = new StringBuilder();
                String duration = "";
                if ((iDuration / SECS_IN_DAY) > 0) {
                    bld.append(String.format("%dday ", iDuration / SECS_IN_DAY));
                    iDuration = iDuration % SECS_IN_DAY;
                }
                if ((iDuration / SECS_IN_HOUR) > 0) {
                    bld.append(String.format("%02dhr ", iDuration / SECS_IN_HOUR));
                    iDuration = iDuration % SECS_IN_HOUR;
                } else if (!duration.isEmpty()) {
                    bld.append("00hr ");
                }
                if ((iDuration / SECS_IN_MINUTE) > 0) {
                    bld.append(String.format("%02dmin ", iDuration / SECS_IN_MINUTE));
                    iDuration = iDuration % SECS_IN_MINUTE;
                } else if (!duration.isEmpty()) {
                    bld.append("00min ");
                }
                bld.append(String.format("%02dsec", iDuration));
                duration = bld.toString();
                int iPassCount = 0;
                int iFailCount = 0;
                for (Iterator i = suitResult.getCases().iterator(); i.hasNext(); ) {
                    CaseResult caseResult = (CaseResult) i.next();
                    iPassCount += caseResult.getPassCount();
                    iFailCount += caseResult.getFailCount();
                }
                writer.write(
                        String.format("%s\t%s\t%d\t%d%n",
                                report,
                                duration,
                                iPassCount,
                                iFailCount));
            }
        }
        writer.flush();
        writer.close();
    }
1230444
public void write (Object object, DataWriter writer)
        throws SAXException
    {
        SparseMisoSceneModel model = (SparseMisoSceneModel)object;
        writer.startElement(OUTER_ELEMENT);
        writeSceneData(model, writer);
        writer.endElement(OUTER_ELEMENT);
    }
264796
public static synchronized void persistInstallStatus(List<UpdateCenterJob> installingPlugins) {
        File installingPluginsFile = getInstallingPluginsFile();
	if(installingPlugins == null || installingPlugins.isEmpty()) {
		installingPluginsFile.delete();
		return;
	}
	LOGGER.fine("Writing install state to: " + installingPluginsFile.getAbsolutePath());
	Map<String,String> statuses = new HashMap<>();
	for(UpdateCenterJob j : installingPlugins) {
		if(j instanceof InstallationJob && j.getCorrelationId() != null) { // only include install jobs with a correlation id (directly selected)
			InstallationJob ij = (InstallationJob)j;
			InstallationStatus status = ij.status;
			String statusText = status.getType();
			if(status instanceof Installing) { // flag currently installing plugins as pending
				statusText = "Pending";
			}
			statuses.put(ij.plugin.name, statusText);
		}
	}
        try {
		String installingPluginXml = new XStream().toXML(statuses);
            FileUtils.write(installingPluginsFile, installingPluginXml);
        } catch (IOException e) {
            LOGGER.log(SEVERE, "Failed to save " + installingPluginsFile.getAbsolutePath(), e);
        }
    }
1120120
protected void writeFieldResultContent(final OutputStream out) throws IOException 
    {
    	document.filterSpecialChar(out, defaultText, true, true);
    }
685236
public static void writePropStats(XMLStreamWriter xmlStreamWriter,
      Map<String, Set<HierarchicalProperty>> propStatuses) throws XMLStreamException
   {
      for (Map.Entry<String, Set<HierarchicalProperty>> stat : propStatuses.entrySet())
      {
         xmlStreamWriter.writeStartElement("DAV:", "propstat");

         xmlStreamWriter.writeStartElement("DAV:", "prop");
         for (HierarchicalProperty prop : propStatuses.get(stat.getKey()))
         {
            writeProperty(xmlStreamWriter, prop);
         }
         xmlStreamWriter.writeEndElement();

         xmlStreamWriter.writeStartElement("DAV:", "status");
         xmlStreamWriter.writeCharacters(stat.getKey());
         xmlStreamWriter.writeEndElement();

         // D:propstat
         xmlStreamWriter.writeEndElement();
      }
   }
1008932
@Override
	public void write(Iterable<QueryResult> results) {
		logger.debug("Export to '{}', proxy {} metrics {}", url, proxy, results);

		HttpURLConnection urlConnection = null;

		try {
			if (proxy == null) {
				urlConnection = (HttpURLConnection) url.openConnection();
			} else {
				urlConnection = (HttpURLConnection) url.openConnection(proxy);
			}
			urlConnection.setRequestMethod("POST");
			urlConnection.setDoInput(true);
			urlConnection.setDoOutput(true);
			urlConnection.setReadTimeout(stackdriverApiTimeoutInMillis);
			urlConnection.setRequestProperty("content-type", "application/json; charset=utf-8");
			urlConnection.setRequestProperty("x-stackdriver-apikey", apiKey);

			serialize(results, urlConnection.getOutputStream());
			int responseCode = urlConnection.getResponseCode();
			if (responseCode != 200 && responseCode != 201) {
				exceptionCounter.incrementAndGet();
				logger.warn("Failure {}:'{}' to send result to Stackdriver server '{}' with proxy {}", responseCode,
						urlConnection.getResponseMessage(), url, proxy);
			}
			if (logger.isTraceEnabled()) {
				IoUtils2.copy(urlConnection.getInputStream(), System.out);
			}
		} catch (Exception e) {
			exceptionCounter.incrementAndGet();
			logger.warn("Failure to send result to Stackdriver server '{}' with proxy {}", url, proxy, e);
		} finally {
			if (urlConnection != null) {
				try {
					InputStream in = urlConnection.getInputStream();
					IoUtils2.copy(in, IoUtils2.nullOutputStream());
					IoUtils2.closeQuietly(in);
					InputStream err = urlConnection.getErrorStream();
					if (err != null) {
						IoUtils2.copy(err, IoUtils2.nullOutputStream());
						IoUtils2.closeQuietly(err);
					}
					urlConnection.disconnect();
				} catch (IOException e) {
					logger.warn("Error flushing http connection for one result, continuing");
					logger.debug("Stack trace for the http connection, usually a network timeout", e);
				}
			}

		}
	}
1081810
public void writeContent(final OutputStream result) throws IOException
    {
        result.write(OPEN_GROUP);
        switch(infoType) {
            case Meta.AUTHOR:
                result.write(INFO_AUTHOR);
            	break;
            case Meta.SUBJECT:
                result.write(INFO_SUBJECT);
        		break;
            case Meta.KEYWORDS:
                result.write(INFO_KEYWORDS);
        		break;
            case Meta.TITLE:
                result.write(INFO_TITLE);
        		break;
            case Meta.PRODUCER:
                result.write(INFO_PRODUCER);
        		break;
            case Meta.CREATIONDATE:
                result.write(INFO_CREATION_DATE);
            	break;
            default:
                result.write(INFO_AUTHOR);
            	break;
        }
        result.write(DELIMITER);
        if(infoType == Meta.CREATIONDATE) {
            result.write(DocWriter.getISOBytes(convertDate(content)));
        } else {
            document.filterSpecialChar(result, content, false, false);
        }
        result.write(CLOSE_GROUP);
    }
650858
public void save(final OutputStream out) throws IOException {
        final ZipUTF8WriterBuilder builder = ZipUTF8WriterImpl.builder();
        final ZipUTF8Writer writer = builder.build(out);
        this.save(writer);
        writer.finish(); // ensures the zip file is well formed
        writer.flush();
    }
523263
public void write(ProgressVisitor progress, ResultSet resultSet, File file) throws SQLException, IOException {
        write(progress, resultSet, file, null);
    }
428449
public void save(XMLWriter w) throws KNXMLException
	{
		/* XML layout:
		 <datapoint stateBased=[true|false] name=string mainNumber=int dptID=string
		 priority=string>
		 knxAddress
		 ...
		 </datapoint>
		*/
		final List att = new ArrayList();
		att.add(new Attribute(ATTR_STATEBASED, Boolean.toString(stateBased)));
		att.add(new Attribute(ATTR_NAME, name));
		att.add(new Attribute(ATTR_MAINNUMBER, Integer.toString(mainNo)));
		att.add(new Attribute(ATTR_DPTID, dptID == null ? "" : dptID));
		att.add(new Attribute(ATTR_PRIORITY, priority.toString()));
		w.writeElement(TAG_DATAPOINT, att, null);
		main.save(w);
		doSave(w);
		w.endElement();
	}
420785
public static boolean supportAlluxioHA(PrintWriter reportWriter,
      AlluxioConfiguration alluxioConf) {
    if (alluxioConf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) {
      reportWriter.println("Alluixo is running in high availability mode.\n");
      if (!alluxioConf.isSet(PropertyKey.ZOOKEEPER_ADDRESS)) {
        reportWriter.println("Please set Zookeeper address to support "
            + "Alluxio high availability mode.\n");
        return false;
      } else {
        reportWriter.printf("Zookeeper address is: %s.%n",
            alluxioConf.get(PropertyKey.ZOOKEEPER_ADDRESS));
      }
    }
    return true;
  }
440025
private static void reportResults(TiffReader tiffReader, int result, String filename,
      String output_file) {
    TiffDocument to = tiffReader.getModel();
    if (output_file != null) {
      // TODO: Create xml file with report
    } else {
      // Display results human readable
      switch (result) {
        case -1:
          System.out.println("File '" + filename + "' does not exist");
          break;
        case -2:
          System.out.println("IO Exception in file '" + filename + "'");
          break;
        case 0:
          if (tiffReader.getBaselineValidation().correct) {
            // The file is correct
            System.out.println("Everything ok in file '" + filename + "'");
            System.out.println("IFDs: " + to.getIfdCount());
            System.out.println("SubIFDs: " + to.getSubIfdCount());

            to.printMetadata();
            TiffEPProfile bpep = new TiffEPProfile(to);
            bpep.validate();
            bpep.getValidation().printErrors();

            TiffITProfile bpit = new TiffITProfile(to, 0);
            bpit.validate();
            bpit.getValidation().printErrors();

            int nifd = 1;
            for (TiffObject o : to.getImageIfds()) {
              IFD ifd = (IFD) o;
              if (ifd != null) {
                System.out.println("IFD " + nifd++ + " TAGS:");
                ifd.printTags();
              }
            }
          } else {
            // The file is not correct
            System.out.println("Errors in file '" + filename + "'");
            if (to != null) {
              System.out.println("IFDs: " + to.getIfdCount());
              System.out.println("SubIFDs: " + to.getSubIfdCount());
              
              // int index = 0;
              to.printMetadata();
            }
            tiffReader.getBaselineValidation().printErrors();
          }
          tiffReader.getBaselineValidation().printWarnings();
          break;
        default:
          System.out.println("Unknown result (" + result + ") in file '" + filename + "'");
          break;
      }
    }
  }
986147
@Override
  public void write(DataOutput out) throws IOException {
    Text.writeString(out, getJobId());
    out.writeDouble(getCpuUsageGHz());
    out.writeDouble(getMemUsageGB());
  }
479548
public static void writeResults(final String name, final Object output) {
		Writer writer = null;

		try {
			writer = new BufferedWriter(
					new OutputStreamWriter(
					new FileOutputStream(name + ".json"), "utf-8"));

			writer.write(output.toString());
		} catch (IOException ignored) {
		} finally {
			try {writer.close();}
            catch (Exception ignored) {}
		}
	}