Send data to graphite host

        :param payload: Data to send to graphite
10413
def report_stats(self, payload, is_retry=False):
        
        if self.debug:
            if self.pickle_proto:
                print "reporting pickled stats"
            else:
                print "reporting stats -> {\n%s}" % payload
        try:
            graphite = socket.socket()
            with eventlet.Timeout(self.graphite_timeout, True):
                graphite.connect(self.graphite_addr)
                graphite.sendall(payload)
                graphite.close()
        except eventlet.timeout.Timeout:
            self.logger.critical("Timeout sending to graphite")
            if self.debug:
                print "Timeout talking to graphite"
            if not is_retry:
                self.logger.critical('Attempting 1 retry!')
                self.report_stats(payload, is_retry=True)
            else:
                self.logger.critical('Already retried once, giving up')
        except Exception as err:
            self.logger.critical("error connecting to graphite: %s" % err)
            if self.debug:
                print "error connecting to graphite: %s" % err
        finally:
            try:
                graphite.close()
            except Exception:
                pass
1196441
def sendTo(self, dest, chunkSize):
        
        vol = self.toVol
        paths = self.sink.getPaths(vol)

        if self.sink == dest:
            logger.info("Keep: %s", self)
            self.sink.keep(self)
        else:
            # Log, but don't skip yet, so we can log more detailed skipped actions later
            skipDryRun(logger, dest.dryrun, 'INFO')("Xfer: %s", self)

            receiveContext = dest.receive(self, paths)

            sendContext = self.sink.send(self)

            # try:
            #     receiveContext.metadata['btrfsVersion'] = self.btrfsVersion
            # except AttributeError:
            #     pass

            transfer(sendContext, receiveContext, chunkSize)

        if vol.hasInfo():
            infoContext = dest.receiveVolumeInfo(paths)

            if infoContext is None:
                # vol.writeInfo(sys.stdout)
                pass
            else:
                with infoContext as stream:
                    vol.writeInfo(stream)
724690
public void send(String msg) {
    try {
      Socket socket = new Socket(graphiteHost, graphitePort);

      try {
        Writer writer = new OutputStreamWriter(socket.getOutputStream());
        try {
          writer.write(msg);
          writer.flush();
        } finally {
          try {
            writer.close();
          } catch (IOException ioe) {
            //ignore, we want to see the outer exception if any
            LOGGER.info("could not close writer");
          }
        }
        if (connectionState != ConnectionState.SUCCESS) {
          LOGGER.info("Connection to graphite Host {}",
            ((connectionState == ConnectionState.UNKNOWN) ? "established" : "recovered"));
          connectionState = ConnectionState.SUCCESS;
        }

      } catch (IOException e) {
        String action = "write";
        handleException(e, action);
      } finally {
        socket.close();
      }
    } catch (IOException e) {
      String action = "connect";
      handleException(e, action);
    }
  }
1181711
def _send(saltdata, metric_base, opts):
    '''
    
    '''

    host = opts.get('host')
    port = opts.get('port')
    skip = opts.get('skip')
    metric_base_pattern = opts.get('carbon.metric_base_pattern')
    mode = opts.get('mode').lower() if 'mode' in opts else 'text'

    log.debug('Carbon minion configured with host: %s:%s', host, port)
    log.debug('Using carbon protocol: %s', mode)

    if not (host and port):
        log.error('Host or port not defined')
        return

    # TODO: possible to use time return from salt job to be slightly more precise?
    # convert the jid to unix timestamp?
    # {'fun': 'test.version', 'jid': '20130113193949451054', 'return': '0.11.0', 'id': 'salt'}
    timestamp = int(time.time())

    handler = _send_picklemetrics if mode == 'pickle' else _send_textmetrics
    metrics = []
    log.trace('Carbon returning walking data: %s', saltdata)
    _walk(metric_base, saltdata, metrics, timestamp, skip)
    data = handler(metrics)
    log.trace('Carbon inserting data: %s', data)

    with _carbon(host, port) as sock:
        total_sent_bytes = 0
        while total_sent_bytes < len(data):
            sent_bytes = sock.send(data[total_sent_bytes:])
            if sent_bytes == 0:
                log.error('Bytes sent 0, Connection reset?')
                return

            log.debug('Sent %s bytes to carbon', sent_bytes)
            total_sent_bytes += sent_bytes
704753
def rpcexec(self, payload):
        
        log.debug(json.dumps(payload))
        self.ws.send(json.dumps(payload, ensure_ascii=False).encode("utf8"))
47983
private boolean sendPayload(URL payloadResourceUrl, RoxPayload payload, boolean optimized) {

		HttpURLConnection conn = null;
		final String payloadLogString = optimized ? "optimized payload" : "payload";

		try {
			conn = uploadPayload(payloadResourceUrl, payload);
 
			if (conn.getResponseCode() == 202) {
				LOGGER.info("The {} was successfully sent to ROX Center.", payloadLogString);
				return true;
			} else {
				LOGGER.error("Unable to send the {} to Rox. Return code: {}, content: {}", payloadLogString, conn.getResponseCode(), readInputStream(conn.getInputStream()));
			}
		} catch (IOException ioe) {
			if (!configuration.isPayloadPrint()) {
				OutputStreamWriter baos = null;
				try {
					baos = new OutputStreamWriter(new ByteArrayOutputStream(), Charset.forName(Constants.ENCODING).newEncoder());

					serializer.serializePayload(baos, payload, true);

					LOGGER.error("The {} in error: {}", payloadLogString, baos.toString());
				} catch (IOException baosIoe) {
				} finally {
					try {
						if (baos != null) {
							baos.close();
						}
					} catch (IOException baosIoe) {
					}
				}

				if (conn != null) {
					try {
						if (conn.getErrorStream() != null) {
							LOGGER.error("Unable to send the {} to ROX. Error: {}", payloadLogString, readInputStream(conn.getErrorStream()));
						} else {
							LOGGER.error("Unable to send the " + payloadLogString + " to ROX. This is probably due to an unreachable network issue.", ioe);
						}
					} catch (IOException errorIoe) {
						LOGGER.error("Unable to send the {} to ROX for unknown reason.", payloadLogString);
					}
				} else {
					LOGGER.error("Unable to send the |{} to ROX. Error: {}", payloadLogString, ioe.getMessage());
				}
			}
		}

		return false;
	}
927998
public void sendQuickReplyPayload(String payload) {
		MessageEnvelope envelope = new MessageEnvelope();
		QuickReply quickReply = new QuickReply("Sample", payload);

		ReceivedMessage message = new ReceivedMessage();
		message.setQuickReply(quickReply);
		envelope.setMessage(message);
		envelope.setSender(new User(facebookMockId));

		System.out.println("Sending quick reply: [" + message + "] as user : ["
				+ facebookMockId + "].");
		forward(envelope);
		System.out.println("Sent!");
	}
1278194
async def send_rpc(self, conn_id, address, rpc_id, payload, timeout):
        

        resp = await self._execute(self._adapter.send_rpc_sync, conn_id, address, rpc_id, payload, timeout)
        _raise_error(conn_id, 'send_rpc', resp)

        status = resp.get('status')
        payload = resp.get('payload')

        # This will raise an exception if needed based on status
        return unpack_rpc_response(status, payload, rpc_id, address)
354638
async def send(self, data, destination):
        
        if isinstance(destination, str):
            host, port = destination.split(':')
            destination = host, int(port)

        await self.requests.put({
            'data': data,
            'destination': destination
        })
659878
def send_dict(*args, **kwargs):
    
    if not _module_instance:
        raise GraphiteSendException(
            "Must call graphitesend.init() before sending")
    _module_instance.send_dict(*args, **kwargs)
    return _module_instance
1218053
def send_tick(self, payload=""):
        
        data = self.message(MessageType.SEND_TICK, payload)
        return json.loads(data, object_hook=TickReply)
789690
def send(self, payload, opcode=ABNF.OPCODE_TEXT):
        

        frame = ABNF.create_frame(payload, opcode)
        return self.send_frame(frame)
726817
def sendto(self, data, addr):
        
        asyncio.ensure_future(self.__inner_protocol.send_data(data, addr))
1189731
def _send_notification(self, handle, payload):
        

        self.bable.notify(
            connection_handle=self._connection_handle,
            attribute_handle=handle,
            value=payload
        )
758958
private void sendMessage(BeanMessageID type, Buffer payload) {
        Buffer buffer = new Buffer();
        buffer.writeByte((type.getRawValue() >> 8) & 0xff);
        buffer.writeByte(type.getRawValue() & 0xff);
        if (payload != null) {
            try {
                buffer.writeAll(payload);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        GattSerialMessage serialMessage = GattSerialMessage.fromPayload(buffer.readByteArray());
        gattClient.getSerialProfile().sendMessage(serialMessage.getBuffer());
    }
1250435
def send_ping(self, payload=''):
        
        self.send_frame(ControlFrame(OPCODE_PING, payload),
                        lambda: self.onping(payload))
        self.ping_payload = payload
        self.ping_sent = True
218794
def sendto(self, data, addr=None):
        
        if not isinstance(data, (bytes, bytearray, memoryview)):
            raise TypeError("data: expecting a bytes-like instance, got {!r}"
                                .format(type(data).__name__))
        self._check_status()
        if not self._writable:
            raise TransportError('transport is not writable')
        try:
            self._handle.send(addr, data, self._on_send_complete)
        except pyuv.error.UVError as e:
            error = TransportError.from_errno(e.args[0])
            # Try to discern between permanent and transient errors. Permanent
            # errors close the transport. This list is very likely not complete.
            if error.errno != pyuv.errno.UV_EBADF:
                raise error
            self._error = error
            self.abort()
        self._write_buffer_size += 1
        self._maybe_pause_protocol()