overide method for RTU over TCP implamentaion
 @see Slave#query
776393
def read_pdu
      loop do
        header = @io.read(7)
        if header
          trn = header[0,2].unpack('n')[0]
          len = header[4,2].unpack('n')[0]
          msg = @io.read(len-1)

          log "Rx (#{(header + msg).size} bytes): " + logging_bytes(header + msg)

          if trn == @transaction
            return msg
          else
            log "Transaction number mismatch. A packet is ignored."
          end
        end
      end
    end
1032021
def read_rtu_response(io)
	    # Read the slave_id and function code
      msg = nil
      while msg.nil?
	      msg = io.read(2)
      end

      function_code = msg.getbyte(1)
      case function_code
        when 1,2,3,4 then
          # read the third byte to find out how much more
          # we need to read + CRC
          msg += io.read(1)
          msg += io.read(msg.getbyte(2)+2)
        when 5,6,15,16 then
          # We just read in an additional 6 bytes
          msg += io.read(6)
        when 22 then
          msg += io.read(8)
        when 0x80..0xff then
          msg += io.read(3)
        else
          raise ModBus::Errors::IllegalFunction, "Illegal function: #{function_code}"
      end
    end
18209
private int overlayBytes(byte[] data, int inOffset, int inLength, int inIndex) {
        int length = inLength;
        int offset = inOffset;
        int index = inIndex;
        WsByteBuffer buffer = this.parseBuffers[index];
        if (-1 == length) {
            length = data.length;
        }
        while (index <= this.parseIndex) {
            int remaining = buffer.remaining();
            if (remaining >= length) {
                // it all fits now
                buffer.put(data, offset, length);
                return index;
            }
            // put what we can, loop through the next buffer
            buffer.put(data, offset, remaining);
            offset += remaining;
            length -= remaining;
            buffer = this.parseBuffers[++index];
            buffer.position(0);
        }
        return index;
    }
402374
@Override
    public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) throws NotConnectedException, InterruptedException {
        if (lc instanceof ICECandidate) {
            if (((ICECandidate) lc).getType().equals(Type.relay)) {
                RTPBridge rtpBridge = RTPBridge.relaySession(lc.getConnection(), lc.getSessionId(), lc.getPassword(), rc, lc);
            }
        }
    }
1002979
static void remote_exec( AutoBuffer ab ) {
    long lo = ab.get8(0), hi = ab._size >= 16 ? ab.get8(8) : 0;
    final int task = ab.getTask();
    final int flag = ab.getFlag();
    assert flag==CLIENT_UDP_SEND || flag==CLIENT_TCP_SEND; // Client-side send
    // Atomically record an instance of this task, one-time-only replacing a
    // null with an RPCCall, a placeholder while we work on a proper response -
    // and it serves to let us discard dup UDP requests.
    RPCCall old = ab._h2o.has_task(task);
    // This is a UDP packet requesting an answer back for a request sent via
    // TCP but the UDP packet has arrived ahead of the TCP.  Just drop the UDP
    // and wait for the TCP to appear.
    if( old == null && flag == CLIENT_TCP_SEND ) {
      Log.warn("got tcp with existing task #, FROM " + ab._h2o.toString() + " AB: " /* +  UDP.printx16(lo,hi)*/);
      assert !ab.hasTCP():"ERROR: got tcp with existing task #, FROM " + ab._h2o.toString() + " AB: "  /* + UDP.printx16(lo,hi)*/;      // All the resends should be UDP only
      // DROP PACKET
    } else if( old == null ) {  // New task?
      RPCCall rpc;
      try {
        // Read the DTask Right Now.  If we are the TCPReceiver thread, then we
        // are reading in that thread... and thus TCP reads are single-threaded.
        rpc = new RPCCall(ab.get(water.DTask.class),ab._h2o,task);
      } catch( AutoBuffer.AutoBufferException e ) {
        // Here we assume it's a TCP fail on read - and ignore the remote_exec
        // request.  The caller will send it again.  NOTE: this case is
        // indistinguishable from a broken short-writer/long-reader bug, except
        // that we'll re-send endlessly and fail endlessly.
        Log.info("Network congestion OR short-writer/long-reader: TCP "+e._ioe.getMessage()+",  AB="+ab+", ignoring partial send");
        ab.drainClose();
        return;
      }
      RPCCall rpc2 = ab._h2o.record_task(rpc);
      if( rpc2==null ) {        // Atomically insert (to avoid double-work)
        if( rpc._dt instanceof MRTask && rpc._dt.logVerbose() )
          Log.debug("Start remote task#"+task+" "+rpc._dt.getClass()+" from "+ab._h2o);
        H2O.submitTask(rpc);    // And execute!
      } else {                  // Else lost the task-insertion race
        if(ab.hasTCP())  ab.drainClose();
        // DROP PACKET
      }

    } else if( !old._computedAndReplied) {
      // This packet has not been fully computed.  Hence it's still a work-in-
      // progress locally.  We have no answer to reply but we do not want to
      // re-offer the packet for repeated work.  Send back a NACK, letting the
      // client know we're Working On It
      assert !ab.hasTCP():"got tcp with existing task #, FROM " + ab._h2o.toString() + " AB: "   + UDP.printx16(lo,hi) + ", position = " + ab._bb.position();
      ab.clearForWriting(udp.nack._prior).putTask(UDP.udp.nack.ordinal(), task);
      // DROP PACKET
    } else {
      // This is an old re-send of the same thing we've answered to before.
      // Send back the same old answer ACK.  If we sent via TCP before, then
      // we know the answer got there so just send a control-ACK back.  If we
      // sent via UDP, resend the whole answer.
      if(ab.hasTCP()) {
        Log.warn("got tcp with existing task #, FROM " + ab._h2o.toString() + " AB: " +  UDP.printx16(lo,hi)); // All the resends should be UDP only
        ab.drainClose();
      }
      if(old._dt != null) { // already ackacked
        ++old._ackResendCnt;
        if (old._ackResendCnt % 10 == 0)
          Log.err("Possibly broken network, can not send ack through, got " + old._ackResendCnt + " for task # " + old._tsknum + ", dt == null?" + (old._dt == null));
        old.resend_ack();
      }
    }
    ab.close();
  }
495019
public void connect(IConnection conn) {
        if (conn instanceof RTMPConnection) {
            if (!isConnected()) {
                source = conn;
                SharedObjectMessage msg = new SharedObjectMessage(name, 0, isPersistent());
                msg.addEvent(new SharedObjectEvent(Type.SERVER_CONNECT, null, null));
                Channel c = ((RTMPConnection) conn).getChannel(3);
                c.write(msg);
            } else {
                throw new UnsupportedOperationException("Already connected");
            }
        } else {
            throw new UnsupportedOperationException("Only RTMP connections are supported");
        }
    }
1310945
public byte[] sendQuerySm(OutputStream os, int sequenceNumber,
            String messageId, TypeOfNumber sourceAddrTon,
            NumberingPlanIndicator sourceAddrNpi, String sourceAddr)
            throws PDUStringException, IOException {
        synchronized (os) {
            return pduSender.sendQuerySm(os, sequenceNumber, messageId,
                    sourceAddrTon, sourceAddrNpi, sourceAddr);
        }
    }
659073
private void sendQuery(Query query, V3ParameterList parameters, int maxRows, int fetchSize,
      int flags, ResultHandler resultHandler,
      BatchResultHandler batchHandler) throws IOException, SQLException {
    // Now the query itself.
    Query[] subqueries = query.getSubqueries();
    SimpleParameterList[] subparams = parameters.getSubparams();

    // We know this is deprecated, but still respect it in case anyone's using it.
    // PgJDBC its self no longer does.
    @SuppressWarnings("deprecation")
    boolean disallowBatching = (flags & QueryExecutor.QUERY_DISALLOW_BATCHING) != 0;

    if (subqueries == null) {
      flushIfDeadlockRisk(query, disallowBatching, resultHandler, batchHandler, flags);

      // If we saw errors, don't send anything more.
      if (resultHandler.getException() == null) {
        sendOneQuery((SimpleQuery) query, (SimpleParameterList) parameters, maxRows, fetchSize,
            flags);
      }
    } else {
      for (int i = 0; i < subqueries.length; ++i) {
        final Query subquery = subqueries[i];
        flushIfDeadlockRisk(subquery, disallowBatching, resultHandler, batchHandler, flags);

        // If we saw errors, don't send anything more.
        if (resultHandler.getException() != null) {
          break;
        }

        // In the situation where parameters is already
        // NO_PARAMETERS it cannot know the correct
        // number of array elements to return in the
        // above call to getSubparams(), so it must
        // return null which we check for here.
        //
        SimpleParameterList subparam = SimpleQuery.NO_PARAMETERS;
        if (subparams != null) {
          subparam = subparams[i];
        }
        sendOneQuery((SimpleQuery) subquery, subparam, maxRows, fetchSize, flags);
      }
    }
  }
897631
public void enableOverride(int overrideId, int pathId, String clientUUID) throws Exception {
        // get profileId from pathId
        int profileId = PathOverrideService.getInstance().getPath(pathId).getProfileId();
        int newPriority = 0;

        // we want to limit -1, -2 to only be added once since they are the Custom responses/requests
        if (overrideId == Constants.PLUGIN_REQUEST_OVERRIDE_CUSTOM) {
            if (this.getEnabledEndpoint(pathId, overrideId, null, clientUUID) != null) {
                return;
            }
        }

        // need to first determine the highest enabled order value for this path
        HashMap<String, Object> priorities = sqlService.getFirstResult(
            "SELECT * FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE +
                " WHERE " + Constants.REQUEST_RESPONSE_PATH_ID + "=" + pathId +
                " AND " + Constants.GENERIC_CLIENT_UUID + "='" + clientUUID +
                "' ORDER BY + " + Constants.ENABLED_OVERRIDES_PRIORITY + " DESC"
        );
        if (priorities != null) {
            newPriority = Integer.valueOf(priorities.get(Constants.ENABLED_OVERRIDES_PRIORITY.toUpperCase()).toString()) + 1;
        }

        PreparedStatement statement = null;
        try (Connection sqlConnection = sqlService.getConnection()) {

            PreparedStatement query = null;
            ResultSet results = null;
            SQLService sqlService = SQLService.getInstance();
            com.groupon.odo.proxylib.models.Method method = null;
            query = sqlConnection.prepareStatement(
                "SELECT * FROM " + Constants.DB_TABLE_OVERRIDE +
                    " WHERE " + Constants.GENERIC_ID + " = ?"
            );
            query.setString(1, String.valueOf(overrideId));
            results = query.executeQuery();
            JSONSerializer serializer = new JSONSerializer();
            if (results.next()) {
                String className = results.getString(Constants.OVERRIDE_CLASS_NAME);
                String methodName = results.getString(Constants.OVERRIDE_METHOD_NAME);
                method = PluginManager.getInstance().getMethod(className, methodName);
            }

            statement = sqlConnection.prepareStatement(
                "INSERT INTO " + Constants.DB_TABLE_ENABLED_OVERRIDE +
                    "(" + Constants.GENERIC_PROFILE_ID + "," + Constants.GENERIC_CLIENT_UUID + "," +
                    Constants.REQUEST_RESPONSE_PATH_ID + "," + Constants.ENABLED_OVERRIDES_OVERRIDE_ID + "," +
                    Constants.ENABLED_OVERRIDES_PRIORITY + "," + Constants.ENABLED_OVERRIDES_ARGUMENTS +  "," +
                    Constants.ENABLED_OVERRIDES_RESPONSE_CODE + ")" +
                    " VALUES (?, ?, ?, ?, ?, ?, ?);"
            );
            statement.setInt(1, profileId);
            statement.setString(2, clientUUID);
            statement.setInt(3, pathId);
            statement.setInt(4, overrideId);
            statement.setInt(5, newPriority);
            if (method == null) {
                statement.setString(6, "");
            } else {
                ArrayList<String> argDefaults = new ArrayList<String>();
                for (int i = 0; i < method.getMethodArguments().length; i++) {
                    if (i < method.getMethodDefaultArguments().length && method.getMethodDefaultArguments()[i] != null) {
                        argDefaults.add(String.valueOf(method.getMethodDefaultArguments()[i]));
                    } else {
                        argDefaults.add("");
                    }
                }
                statement.setString(6, serializer.serialize(argDefaults));
            }
            statement.setString(7,"200");
            statement.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }
    }
1049200
private void initThriftServer() throws TTransportException, FatalChronosException,
      ChronosException {

    int maxThread = Integer.parseInt(properties.getProperty(MAX_THREAD,
      String.valueOf(Integer.MAX_VALUE)));
    String serverHost = properties.getProperty(FailoverServer.SERVER_HOST);
    int serverPort = Integer.parseInt(properties.getProperty(FailoverServer.SERVER_PORT));
    TServerSocket serverTransport = new TServerSocket(new InetSocketAddress(serverHost, serverPort));
    Factory proFactory = new TBinaryProtocol.Factory();

    chronosImplement = new ChronosImplement(properties, chronosServerWatcher);

    TProcessor processor = new ChronosService.Processor(chronosImplement);
    Args rpcArgs = new Args(serverTransport);
    rpcArgs.processor(processor);
    rpcArgs.protocolFactory(proFactory);
    rpcArgs.maxWorkerThreads(maxThread);
    thriftServer = new TThreadPoolServer(rpcArgs);
  }
964587
@Override
    public RTMPConnection getConnectionBySessionId(String sessionId) {
        log.debug("Getting connection by session id: {}", sessionId);
        if (connMap.containsKey(sessionId)) {
            return connMap.get(sessionId);
        } else {
            log.warn("Connection not found for {}", sessionId);
            if (log.isTraceEnabled()) {
                log.trace("Connections ({}) {}", connMap.size(), connMap.values());
            }
        }
        return null;
    }
1118238
public static void debugTraceWsByteBufferInfo(Object _this, TraceComponent _tc, WsByteBuffer buffer, String string)
   {
      if (buffer != null)
      {
         StringBuffer sb = new StringBuffer(buffer.getClass().toString());
         sb.append("@");
         sb.append(Integer.toHexString(System.identityHashCode(buffer)));
         sb.append(" pos=");
         sb.append(buffer.position());
         sb.append(" limit=");
         sb.append(buffer.limit());
         sb.append(" - ");
         sb.append(string);
         SibTr.debug(_this, _tc, sb.toString());
      }
      else
      {
         SibTr.debug(_this, _tc, "WsByteBuffer: null - "+string);
      }
   }
340552
function onSDPDescription(id,rtcId,data)
    {
        if(scope._servConn.useRTC)
        {
            if(scope.hasWebRTCSupport())
            {
                var peer   = getOrCreatePeer(id);
                peer.rtcId = rtcId;
                peer.onServerMessage(JSON.parse(data));
            }
            else
            {
                scope._servConn.sendRTCState(false,id);
            }
        }
    }
116051
def _domain_event_rtc_change_cb(conn, domain, utcoffset, opaque):
    '''
    
    '''
    _salt_send_domain_event(opaque, conn, domain, opaque['event'], {
        'utcoffset': utcoffset
    })
504236
def _send_query(self):
        
        timeout = 60
        ofproto = self._datapath.ofproto
        parser = self._datapath.ofproto_parser
        if ofproto_v1_0.OFP_VERSION == ofproto.OFP_VERSION:
            send_port = ofproto.OFPP_NONE
        else:
            send_port = ofproto.OFPP_ANY

        # create a general query.
        res_igmp = igmp.igmp(
            msgtype=igmp.IGMP_TYPE_QUERY,
            maxresp=igmp.QUERY_RESPONSE_INTERVAL * 10,
            csum=0,
            address='0.0.0.0')
        res_ipv4 = ipv4.ipv4(
            total_length=len(ipv4.ipv4()) + len(res_igmp),
            proto=inet.IPPROTO_IGMP, ttl=1,
            src='0.0.0.0',
            dst=igmp.MULTICAST_IP_ALL_HOST)
        res_ether = ethernet.ethernet(
            dst=igmp.MULTICAST_MAC_ALL_HOST,
            src=self._datapath.ports[ofproto.OFPP_LOCAL].hw_addr,
            ethertype=ether.ETH_TYPE_IP)
        res_pkt = packet.Packet()
        res_pkt.add_protocol(res_ether)
        res_pkt.add_protocol(res_ipv4)
        res_pkt.add_protocol(res_igmp)
        res_pkt.serialize()

        flood = [parser.OFPActionOutput(ofproto.OFPP_FLOOD)]

        while True:
            # reset reply status.
            for status in self._mcast.values():
                for port in status.keys():
                    status[port] = False

            # send a general query to the host that sent this message.
            self._do_packet_out(
                self._datapath, res_pkt.data, send_port, flood)
            hub.sleep(igmp.QUERY_RESPONSE_INTERVAL)

            # QUERY timeout expired.
            del_groups = []
            for group, status in self._mcast.items():
                del_ports = []
                actions = []
                for port in status.keys():
                    if not status[port]:
                        del_ports.append(port)
                    else:
                        actions.append(parser.OFPActionOutput(port))
                if len(actions) and len(del_ports):
                    self._set_flow_entry(
                        self._datapath, actions, self.server_port, group)
                if not len(actions):
                    self._del_flow_entry(
                        self._datapath, self.server_port, group)
                    del_groups.append(group)
                if len(del_ports):
                    for port in del_ports:
                        self._del_flow_entry(self._datapath, port, group)
                for port in del_ports:
                    del status[port]
            for group in del_groups:
                del self._mcast[group]

            rest_time = timeout - igmp.QUERY_RESPONSE_INTERVAL
            hub.sleep(rest_time)
1143016
def program_rtr(self, args, rout_id, namespace=None):
        
        if namespace is None:
            namespace = self.find_rtr_namespace(rout_id)
        if namespace is None:
            LOG.error("Unable to find namespace for router %s", rout_id)
            return False
        final_args = ['ip', 'netns', 'exec', namespace] + args
        try:
            utils.execute(final_args, root_helper=self.root_helper)
        except Exception as e:
            LOG.error("Unable to execute %(cmd)s. "
                      "Exception: %(exception)s",
                      {'cmd': final_args, 'exception': e})
            return False
        return True
1175897
private static InetSocketAddress overrideProxy(String proxyHostPort) {
    if (proxyHostPort == null) {
      return null;
    }

    String[] parts = proxyHostPort.split(":", 2);
    int port = 80;
    if (parts.length > 1) {
      port = Integer.parseInt(parts[1]);
    }
    log.warning(
        "Detected GRPC_PROXY_EXP and will honor it, but this feature will "
            + "be removed in a future release. Use the JVM flags "
            + "\"-Dhttps.proxyHost=HOST -Dhttps.proxyPort=PORT\" to set the https proxy for "
            + "this JVM.");
    return new InetSocketAddress(parts[0], port);
  }