Writes a new client crash record.
173643
def WriteClientCrashInfo(self, client_id, crash_info):
    """"""
    if client_id not in self.metadatas:
      raise db.UnknownClientError(client_id)

    ts = rdfvalue.RDFDatetime.Now()
    self.metadatas[client_id]["last_crash_timestamp"] = ts
    history = self.crash_history.setdefault(client_id, {})
    history[ts] = crash_info.SerializeToString()
1093966
private void errorNewClientConnected(Exception exception)
    {
        Verbose.warning(Server.class, "addClient", "Error on adding client: ", exception.getMessage());
        if (clients.remove(Byte.valueOf(lastId)) != null)
        {
            clientsNumber--;
        }
    }
554721
public static void crashLocalVoltDB(String errMsg, boolean stackTrace, Throwable thrown) {
        crashLocalVoltDB(errMsg, stackTrace, thrown, true);
    }
576646
void writeRecord(EngineOutputRecord eor) throws IOException {
        // eventually compress as well.
        writer.writeRecord(eor, writeMAC, writeCipher);

        /*
         * Check the sequence number state
         *
         * Note that in order to maintain the connection I/O
         * properly, we check the sequence number after the last
         * record writing process. As we request renegotiation
         * or close the connection for wrapped sequence number
         * when there is enough sequence number space left to
         * handle a few more records, so the sequence number
         * of the last record cannot be wrapped.
         */
        if ((connectionState < cs_ERROR) && !isOutboundDone()) {
            checkSequenceNumber(writeMAC, eor.contentType());
        }
    }
264221
private void write() throws IOException
   {
      m_projectFile.validateUniqueIDsForMicrosoftProject();

      writeFileCreationRecord();
      writeProjectHeader(m_projectFile.getProjectProperties());

      if (m_projectFile.getResources().isEmpty() == false)
      {
         m_resourceModel = new ResourceModel(m_projectFile, m_locale);
         m_writer.write(m_resourceModel.toString());
         for (Resource resource : m_projectFile.getResources())
         {
            writeResource(resource);
         }
      }

      if (m_projectFile.getTasks().isEmpty() == false)
      {
         m_taskModel = new TaskModel(m_projectFile, m_locale);
         m_writer.write(m_taskModel.toString());
         writeTasks(m_projectFile.getChildTasks());
      }

      m_writer.flush();
   }
907262
private void saveCrashReportFile(@NonNull File file, @NonNull CrashReportData crashData) {
        try {
            if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Writing crash report file " + file);
            final CrashReportPersister persister = new CrashReportPersister();
            persister.store(crashData, file);
        } catch (Exception e) {
            ACRA.log.e(LOG_TAG, "An error occurred while writing the report file...", e);
        }
    }
1021604
public void write(WARCWritable record) throws IOException {
        if (record.getRecord() != null) write(record.getRecord());
    }
1022801
protected boolean writeNextRecord(T record) throws IOException {
		try {
			this.serializer.serialize(record, this.collectingView);
			this.numRecordsInBuffer++;
			return true;
		} catch (EOFException eofex) {
			return false;
		}
	}
497542
protected final void sendCrash(@Nullable String comment, @Nullable String userEmail) {
        new Thread(() -> {
            final CrashReportPersister persister = new CrashReportPersister();
            try {
                if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Add user comment to " + reportFile);
                final CrashReportData crashData = persister.load(reportFile);
                crashData.put(USER_COMMENT, comment == null ? "" : comment);
                crashData.put(USER_EMAIL, userEmail == null ? "" : userEmail);
                persister.store(crashData, reportFile);
            } catch (IOException | JSONException e) {
                ACRA.log.w(LOG_TAG, "User comment not added: ", e);
            }

            // Start the report sending task
            new SchedulerStarter(this, config).scheduleReports(reportFile, false);
        }).start();
    }
13259
def WriteClientMetadata(self,
                          client_id,
                          certificate=None,
                          fleetspeak_enabled=None,
                          first_seen=None,
                          last_ping=None,
                          last_clock=None,
                          last_ip=None,
                          last_foreman=None):
    """"""
    md = {}
    if certificate is not None:
      md["certificate"] = certificate

    if fleetspeak_enabled is not None:
      md["fleetspeak_enabled"] = fleetspeak_enabled

    if first_seen is not None:
      md["first_seen"] = first_seen

    if last_ping is not None:
      md["ping"] = last_ping

    if last_clock is not None:
      md["clock"] = last_clock

    if last_ip is not None:
      md["ip"] = last_ip

    if last_foreman is not None:
      md["last_foreman_time"] = last_foreman

    if not md:
      raise ValueError("NOOP write.")

    self.metadatas.setdefault(client_id, {}).update(md)
806717
def add_ClientData(self):
        
        if not self.data_to_send:
            data = six.moves.input().replace('\\r', '\r').replace('\\n', '\n').encode()  # noqa: E501
        else:
            data = self.data_to_send.pop()
        if data == b"quit":
            return
        if self.linebreak:
            data += b"\n"
        self.add_record()
        self.add_msg(TLSApplicationData(data=data))
        raise self.ADDED_CLIENTDATA()
374314
def record_result(addr:, client:, data:, task:)
      db[:results] << addr.to_h.merge(client_id: client.id, data: data,
                                      id: UUID.new, received_at: Time.now.utc,
                                      task_id: task.id)
    end
1128188
def create_bug(self, request):
        
        if settings.BUGFILER_API_KEY is None:
            return Response({"failure": "Bugzilla API key not set!"},
                            status=HTTP_400_BAD_REQUEST)

        params = request.data

        # Arbitrarily cap crash signatures at 2048 characters to prevent perf issues on bmo
        crash_signature = params.get("crash_signature")
        if crash_signature and len(crash_signature) > 2048:
            return Response({"failure": "Crash signature can't be more than 2048 characters."},
                            status=HTTP_400_BAD_REQUEST)

        description = u"**Filed by:** {}\n{}".format(
            request.user.email.replace('@', " [at] "),
            params.get("comment", "")
        ).encode("utf-8")
        summary = params.get("summary").encode("utf-8").strip()
        url = settings.BUGFILER_API_URL + "/rest/bug"
        headers = {
            'x-bugzilla-api-key': settings.BUGFILER_API_KEY,
            'Accept': 'application/json'
        }
        data = {
            'product': params.get("product"),
            'component': params.get("component"),
            'summary': summary,
            'keywords': params.get("keywords"),
            'blocks': params.get("blocks"),
            'depends_on': params.get("depends_on"),
            'see_also': params.get("see_also"),
            'version': params.get("version"),
            'cf_crash_signature': params.get("crash_signature"),
            'severity': params.get("severity"),
            'priority': params.get("priority"),
            'description': description,
            'comment_tags': "treeherder",
        }

        try:
            response = make_request(url, method='POST', headers=headers, json=data)
        except requests.exceptions.HTTPError as e:
            try:
                message = e.response.json()['message']
            except (ValueError, KeyError):
                message = e.response.text
            return Response({"failure": message}, status=HTTP_400_BAD_REQUEST)

        return Response({"success": response.json()["id"]})
657946
def _writeCloseFrame(self, reason=DISCONNECT.GO_AWAY):
        '''

        '''
        self.transport.writeClose(reason)
        self.transport.loseConnection()
        self.transport = None
1373362
public static void crashLocalVoltDB(String errMsg, boolean stackTrace, Throwable thrown, boolean logFatal) {

        if (exitAfterMessage) {
            System.err.println(errMsg);
            VoltDB.exit(-1);
        }
        try {
            OnDemandBinaryLogger.flush();
        } catch (Throwable e) {}

        /*
         * InvocationTargetException suppresses information about the cause, so unwrap until
         * we get to the root cause
         */
        while (thrown instanceof InvocationTargetException) {
            thrown = ((InvocationTargetException)thrown).getCause();
        }

        // for test code
        wasCrashCalled = true;
        crashMessage = errMsg;
        if (ignoreCrash) {
            throw new AssertionError("Faux crash of VoltDB successful.");
        }
        if (CoreUtils.isJunitTest()) {
            VoltLogger log = new VoltLogger("HOST");
            log.warn("Declining to drop a crash file during a junit test.");
        }
        // end test code
        // send a snmp trap crash notification
        sendCrashSNMPTrap(errMsg);
        // try/finally block does its best to ensure death, no matter what context this
        // is called in
        try {
            // slightly less important than death, this try/finally block protects code that
            // prints a message to stdout
            try {
                // turn off client interface as fast as possible
                // we don't expect this to ever fail, but if it does, skip to dying immediately
                if (!turnOffClientInterface()) {
                    return; // this will jump to the finally block and die faster
                }

                // Flush trace files
                try {
                    VoltTrace.closeAllAndShutdown(new File(instance().getVoltDBRootPath(), "trace_logs").getAbsolutePath(),
                                                  TimeUnit.SECONDS.toMillis(10));
                } catch (IOException e) {}

                // Even if the logger is null, don't stop.  We want to log the stack trace and
                // any other pertinent information to a .dmp file for crash diagnosis
                List<String> currentStacktrace = new ArrayList<>();
                currentStacktrace.add("Stack trace from crashLocalVoltDB() method:");

                // Create a special dump file to hold the stack trace
                try
                {
                    TimestampType ts = new TimestampType(new java.util.Date());
                    CatalogContext catalogContext = VoltDB.instance().getCatalogContext();
                    String root = catalogContext != null ? VoltDB.instance().getVoltDBRootPath() + File.separator : "";
                    PrintWriter writer = new PrintWriter(root + "voltdb_crash" + ts.toString().replace(' ', '-') + ".txt");
                    writer.println("Time: " + ts);
                    writer.println("Message: " + errMsg);

                    writer.println();
                    writer.println("Platform Properties:");
                    PlatformProperties pp = PlatformProperties.getPlatformProperties();
                    String[] lines = pp.toLogLines(instance().getVersionString()).split("\n");
                    for (String line : lines) {
                        writer.println(line.trim());
                    }

                    if (thrown != null) {
                        writer.println();
                        writer.println("****** Exception Thread ****** ");
                        thrown.printStackTrace(writer);
                    }

                    printStackTraces(writer, currentStacktrace);
                    writer.close();
                }
                catch (Throwable err)
                {
                    // shouldn't fail, but..
                    err.printStackTrace();
                }

                VoltLogger log = null;
                try
                {
                    log = new VoltLogger("HOST");
                }
                catch (RuntimeException rt_ex)
                { /* ignore */ }

                if (log != null)
                {
                    if (logFatal) {
                        log.fatal(errMsg);
                    }
                    if (thrown != null) {
                        if (stackTrace) {
                            log.fatal("Fatal exception", thrown);
                        } else {
                            log.fatal(thrown.toString());
                        }
                    } else {
                        if (stackTrace) {
                            for (String currentStackElem : currentStacktrace) {
                                log.fatal(currentStackElem);
                            }
                        }
                    }
                } else {
                    System.err.println(errMsg);
                    if (thrown != null) {
                        if (stackTrace) {
                            thrown.printStackTrace();
                        } else {
                            System.err.println(thrown.toString());
                        }
                    } else {
                        if (stackTrace) {
                            for (String currentStackElem : currentStacktrace) {
                                System.err.println(currentStackElem);
                            }
                        }
                    }
                }
            }
            finally {
                System.err.println("VoltDB has encountered an unrecoverable error and is exiting.");
                System.err.println("The log may contain additional information.");
            }
        }
        finally {
            ShutdownHooks.useOnlyCrashHooks();
            System.exit(-1);
        }
    }
700628
def WriteClientStats(self, client_id,
                       stats):
    """"""
    if client_id not in self.ReadAllClientIDs():
      raise db.UnknownClientError(client_id)

    self.client_stats[client_id][rdfvalue.RDFDatetime.Now()] = stats
934250
def _retryable_write(self, retryable, func, session):
        """"""
        with self._tmp_session(session) as s:
            return self._retry_with_session(retryable, func, s, None)