Report statistics as an XML document to given output stream.
335607
public void reportSummary(@WillClose OutputStream out) throws IOException {
        XMLOutput xmlOutput = new OutputStreamXMLOutput(out);
        try {
            writeXML(xmlOutput);
        } finally {
            xmlOutput.finish();
        }
    }
287200
private void writeToWithMetrics(final OutputStream outstream) throws IOException {
        if (outstream == null) {
            throw new IllegalArgumentException("Output stream may not be null");
        }
        final InputStream content = getContent();
        final long length = getContentLength();
        InputStream instream = content;
        try {
            byte[] buffer = new byte[BUFFER_SIZE];
            int l;
            if (length < 0) {
                // consume until EOF
                while ((l = instream.read(buffer)) != -1) {
                    long startNano = helper.startTiming();
                    outstream.write(buffer, 0, l);
                    helper.increment(l, startNano);
                }
            } else {
                // consume no more than length
                long remaining = length;
                while (remaining > 0) {
                    l = instream.read(buffer, 0, (int)Math.min(BUFFER_SIZE, remaining));
                    if (l == -1) {
                        break;
                    }
                    long startNano = helper.startTiming();
                    outstream.write(buffer, 0, l);
                    helper.increment(l, startNano);
                    remaining -= l;
                }
            }
        } finally {
            helper.reportMetrics();
            instream.close();
        }
    }
38347
def dumpStatsTo(filename):
  """"""
  with open(filename, 'w') as f:
    latest = getStats()
    latest['last-updated'] = time.time()
    json.dump(getStats(), f, cls=StatContainerEncoder)
770514
def object2xml(self, data):
        
        """
        if not self.__options['encoding']:
            self.set_options(encoding=self.__encoding)

        if self.__options['header_declare']:
            self.__tree.append(self.build_xml_header())

        root = self.__options['root']
        if not root:
            assert (isinstance(data, utils.DictTypes) and len(data) == 1), \
                'if root not specified, the data that dict object and length must be one required.'
            root, data = data.items()[0]

        self.build_tree(data, root)
        xml = unicode(''.join(self.__tree).strip())

        if self.__options['encoding'] != self.__encoding:
            xml = xml.encode(self.__options['encoding'], errors=self.__options['errors'])
        return xml
1306183
private void generateXMLReport( final ITransaction transaction, final WebdavResponse resp, final LockedObject lo )
        throws IOException
    {

        final HashMap<String, String> namespaces = new HashMap<String, String>();
        namespaces.put( "DAV:", "D" );

        resp.setStatus( SC_OK );
        resp.setContentType( "text/xml; charset=UTF-8" );

        final XMLWriter generatedXML = new XMLWriter( resp.getWriter(), namespaces );
        generatedXML.writeXMLHeader();
        generatedXML.writeElement( "DAV::prop", XMLWriter.OPENING );
        generatedXML.writeElement( "DAV::lockdiscovery", XMLWriter.OPENING );
        generatedXML.writeElement( "DAV::activelock", XMLWriter.OPENING );

        generatedXML.writeElement( "DAV::locktype", XMLWriter.OPENING );
        generatedXML.writeProperty( "DAV::" + _type );
        generatedXML.writeElement( "DAV::locktype", XMLWriter.CLOSING );

        generatedXML.writeElement( "DAV::lockscope", XMLWriter.OPENING );
        if ( _exclusive )
        {
            generatedXML.writeProperty( "DAV::exclusive" );
        }
        else
        {
            generatedXML.writeProperty( "DAV::shared" );
        }
        generatedXML.writeElement( "DAV::lockscope", XMLWriter.CLOSING );

        final int depth = lo.getLockDepth();

        generatedXML.writeElement( "DAV::depth", XMLWriter.OPENING );
        if ( depth == INFINITY )
        {
            generatedXML.writeText( "Infinity" );
        }
        else
        {
            generatedXML.writeText( String.valueOf( depth ) );
        }
        generatedXML.writeElement( "DAV::depth", XMLWriter.CLOSING );

        generatedXML.writeElement( "DAV::owner", XMLWriter.OPENING );
        generatedXML.writeElement( "DAV::href", XMLWriter.OPENING );
        generatedXML.writeText( _lockOwner );
        generatedXML.writeElement( "DAV::href", XMLWriter.CLOSING );
        generatedXML.writeElement( "DAV::owner", XMLWriter.CLOSING );

        final long timeout = lo.getTimeoutMillis();
        generatedXML.writeElement( "DAV::timeout", XMLWriter.OPENING );
        generatedXML.writeText( "Second-" + timeout / 1000 );
        generatedXML.writeElement( "DAV::timeout", XMLWriter.CLOSING );

        final String lockToken = lo.getID();
        generatedXML.writeElement( "DAV::locktoken", XMLWriter.OPENING );
        generatedXML.writeElement( "DAV::href", XMLWriter.OPENING );
        generatedXML.writeText( "opaquelocktoken:" + lockToken );
        generatedXML.writeElement( "DAV::href", XMLWriter.CLOSING );
        generatedXML.writeElement( "DAV::locktoken", XMLWriter.CLOSING );

        generatedXML.writeElement( "DAV::activelock", XMLWriter.CLOSING );
        generatedXML.writeElement( "DAV::lockdiscovery", XMLWriter.CLOSING );
        generatedXML.writeElement( "DAV::prop", XMLWriter.CLOSING );

        resp.addHeader( "Lock-Token", "<opaquelocktoken:" + lockToken + ">" );

        generatedXML.sendData();

    }
429095
public void generateSummaryTable(JspWriter out,
                                   JobTracker tracker) throws IOException {
    ClusterStatus status = tracker.getClusterStatus();
    int maxMapTasks = status.getMaxMapTasks();
    int maxReduceTasks = status.getMaxReduceTasks();
    int numTaskTrackers = status.getTaskTrackers();
    String tasksPerNodeStr;
    if (numTaskTrackers > 0) {
      double tasksPerNodePct = (double) (maxMapTasks + maxReduceTasks) / (double) numTaskTrackers;
      tasksPerNodeStr = percentFormat.format(tasksPerNodePct);
    } else {
      tasksPerNodeStr = "-";
    }
    out.print("<maps>" + status.getMapTasks() + "</maps>\n" +
            "<reduces>" + status.getReduceTasks() + "</reduces>\n" +
            "<total_submissions>" + tracker.getTotalSubmissions() + "</total_submissions>\n" +
            "<nodes>" + status.getTaskTrackers() + "</nodes>\n" +
            "<map_task_capacity>" + status.getMaxMapTasks() + "</map_task_capacity>\n" +
            "<reduce_task_capacity>" + status.getMaxReduceTasks() + "</reduce_task_capacity>\n" +
            "<avg_tasks_per_node>" + tasksPerNodeStr + "</avg_tasks_per_node>\n");
  }
110463
def pp_xml(body):
    """"""
    pretty = xml.dom.minidom.parseString(body)
    return pretty.toprettyxml(indent="  ")
695228
protected XMLStreamWriter createStreamWriter(OutputStream output) throws XMLStreamException {
        if (outputFactory == null) {
            outputFactory = XMLOutputFactory.newInstance();
        }
        return outputFactory.createXMLStreamWriter(output);
    }
1353120
def write_xml(self, as_string=False):
        """"""
        if not as_string:
            et.ElementTree(self.xmlreport).write('{}/{}.xml'.format(self.outpath, self.outputprefix), pretty_print=True, xml_declaration=True)
        else:
            output = et.tostring(self.xmlreport, pretty_print=True)
            if config.RAWSTRING:
                output = repr(output)
            print(output)
280531
def get_xml_stats(fname):
    
    f = mod_file.TextFile(fname)
    res = {}
    res['shortname'] = f.name
    res['folder'] = f.path
    res['filesize'] = str(f.size) + ' bytes'
    res['num_lines'] = str(f.lines) + ' lines'
    res['date_modified'] = f.GetDateAsString(f.date_modified)
    
    return res
830965
def write_xml_document(self, document):
        
        self._out.write(ET.tostring(document))
        self._out.flush()
485810
private void exportToStatsD(List<Stat> stats) {
        // group stats by kafka group
        for (Stat stat : stats) {
            @SuppressWarnings("unchecked")
            Map<String, String> tags = (Map<String, String>) stat.get(Stat.STAT_KEYS.TAGS.getName());
            long value = Long.parseLong((String) stat.get(Stat.STAT_KEYS.VALUE.getName()));
            if (mConfig.getStatsdDogstatdsTagsEnabled()) {
                String metricName = (String) stat.get(Stat.STAT_KEYS.METRIC.getName());
                String[] tagArray = new String[tags.size()];
                int i = 0;
                for (Map.Entry<String, String> e : tags.entrySet()) {
                    tagArray[i++] = e.getKey() + ':' + e.getValue();
                }
                mStatsDClient.recordGaugeValue(metricName, value, tagArray);
            } else {
                StringBuilder builder = new StringBuilder();
                if (mConfig.getStatsDPrefixWithConsumerGroup()) {
                    builder.append(tags.get(Stat.STAT_KEYS.GROUP.getName()))
                            .append(PERIOD);
                }
                String metricName = builder
                        .append((String) stat.get(Stat.STAT_KEYS.METRIC.getName()))
                        .append(PERIOD)
                        .append(tags.get(Stat.STAT_KEYS.TOPIC.getName()))
                        .append(PERIOD)
                        .append(tags.get(Stat.STAT_KEYS.PARTITION.getName()))
                        .toString();
                mStatsDClient.recordGaugeValue(metricName, value);
            }
        }
    }
1105666
public static void generateJRXML(DynamicReport dr, LayoutManager layoutManager, Map _parameters, String xmlEncoding, OutputStream outputStream) throws JRException {
        JasperReport jr = generateJasperReport(dr, layoutManager, _parameters);
        if (xmlEncoding == null)
            xmlEncoding = DEFAULT_XML_ENCODING;
        JRXmlWriter.writeReport(jr, outputStream, xmlEncoding);
    }
1202508
public static void writeXml(Serializable serializable, OutputStream output) throws IOException {
		TransportFormat.XML.writeSerializableTo(serializable, output);
	}
960956
private void saveSummaryXml(SampleNode root) {

        root.sortTree();
        Document doc = DocumentHelper.createDocument();
        Element rootElem = doc.addElement("root");
        root.appendToXml(rootElem);
        OutputFormat outformat = OutputFormat.createPrettyPrint();
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        outformat.setEncoding("UTF-8");
        try {
            XMLWriter writer = new XMLWriter(buffer, outformat);
            writer.write(doc);
            writer.flush();
            try (FileOutputStream fos = new FileOutputStream(m_summaryFilename)) {
                fos.write(buffer.toByteArray());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
891039
def dump_report_content(self, request, result):
        

        output = StringIO()
        writer = csv.writer(output, **self.csv_kwargs)
        writer.writerows([result.headers] + result.values)
        return output.getvalue()
475525
private void writeXmlDocument(String path, Document doc) throws IOException {
    zip.putNextEntry(new ZipEntry(path));
    try {
      DOMSource source = new DOMSource(doc);
      StreamResult result = new StreamResult(zip);
      transformer.transform(source, result);
    }
    catch (TransformerException ex) {
      throw new IOException("Failed to generate XML: " + ex.getMessage(), ex);
    }
    finally {
      zip.closeEntry();
    }
  }