public static List<byte[]> toBytesList(List<SpanPack> packs, int maxBytes) { if (packs == null) return null; try { List<byte[]> byteResultList = new ArrayList<byte[]>(); int maxLen = Math.max(maxBytes - 18000, 18000); int size = packs.size(); DataOutputX dout = new DataOutputX(Math.min(size * 500, maxBytes)); for (SpanPack pack : packs) { dout.writePack(pack); if (dout.getWriteSize() > maxLen) { byteResultList.add(dout.toByteArray()); dout = new DataOutputX(Math.min(size * 500, maxBytes)); } } if (dout.getWriteSize() > 0) { byteResultList.add(dout.toByteArray()); } return byteResultList; } catch (IOException e) { } return null; }
public static List<byte[]> toBytesList(List<SpanPack> packs, int maxBytes) { if (packs == null) return null; try { List<byte[]> byteResultList = new ArrayList<byte[]>(); int maxLen = Math.max(maxBytes - 18000, 18000); int size = packs.size(); DataOutputX dout = new DataOutputX(Math.min(size * 500, maxBytes)); for (SpanPack pack : packs) { dout.writePack(pack); if (dout.getWriteSize() > maxLen) { byteResultList.add(dout.toByteArray()); dout = new DataOutputX(Math.min(size * 500, maxBytes)); } } if (dout.getWriteSize() > 0) { byteResultList.add(dout.toByteArray()); } return byteResultList; } catch (IOException e) { } return null; }
public static List<byte[]> toBytesList(List<SpanPack> packs, int maxBytes) { if (packs == null) return null; try { List<byte[]> byteResultList = new ArrayList<byte[]>(); int maxLen = Math.max(maxBytes - 18000, 18000); int size = packs.size(); DataOutputX dout = new DataOutputX(Math.min(size * 500, maxBytes)); for (SpanPack pack : packs) { dout.writePack(pack); if (dout.getWriteSize() > maxLen) { byteResultList.add(dout.toByteArray()); dout = new DataOutputX(Math.min(size * 500, maxBytes)); } } if (dout.getWriteSize() > 0) { byteResultList.add(dout.toByteArray()); } return byteResultList; } catch (IOException e) { } return null; }
public static List<byte[]> toBytesList(List<SpanPack> packs, int maxBytes) { if (packs == null) return null; try { List<byte[]> byteResultList = new ArrayList<byte[]>(); int maxLen = Math.max(maxBytes - 18000, 18000); int size = packs.size(); DataOutputX dout = new DataOutputX(Math.min(size * 500, maxBytes)); for (SpanPack pack : packs) { dout.writePack(pack); if (dout.getWriteSize() > maxLen) { byteResultList.add(dout.toByteArray()); dout = new DataOutputX(Math.min(size * 500, maxBytes)); } } if (dout.getWriteSize() > 0) { byteResultList.add(dout.toByteArray()); } return byteResultList; } catch (IOException e) { } return null; }
private boolean write(List<byte[]> p) { try { DataOutputX buffer = new DataOutputX(); int bufferCount = 0; for (int i = 0; i < p.size(); i++) { byte[] b = p.get(i); if (b.length > conf.net_udp_packet_max_bytes) { UdpAgent.sendMTU(server, conf.net_collector_udp_port, b, conf.net_udp_packet_max_bytes); } else if (b.length + buffer.getWriteSize() > conf.net_udp_packet_max_bytes) { sendList(bufferCount, buffer.toByteArray()); buffer = new DataOutputX(); bufferCount = 0; } else { bufferCount++; buffer.write(b); } } if (buffer.getWriteSize() > 0) { sendList(bufferCount, buffer.toByteArray()); } return true; } catch (IOException e) { Logger.println("A123", "UDP", e); return false; } }
public boolean write(List<byte[]> p) { try { if (server_host == null) return false; DataOutputX buffer = new DataOutputX(); int bufferCount = 0; for (int i = 0; i < p.size(); i++) { byte[] b = p.get(i); if (b.length > conf.net_udp_packet_max_bytes) { writeMTU(b, conf.net_udp_packet_max_bytes); } else if (b.length + buffer.getWriteSize() > conf.net_udp_packet_max_bytes) { sendList(bufferCount, buffer.toByteArray()); buffer = new DataOutputX(); bufferCount = 1; buffer.write(b); } else { bufferCount++; buffer.write(b); } } if (buffer.getWriteSize() > 0) { sendList(bufferCount, buffer.toByteArray()); } return true; } catch (IOException e) { Logger.println("A123", "UDP", e); return false; } } private void sendList(int bufferCount, byte[] buffer) throws IOException {
public boolean write(List<byte[]> p) { try { if (server_host == null) return false; DataOutputX buffer = new DataOutputX(); int bufferCount = 0; for (int i = 0; i < p.size(); i++) { byte[] b = p.get(i); if (b.length > conf.net_udp_packet_max_bytes) { writeMTU(b, conf.net_udp_packet_max_bytes); } else if (b.length + buffer.getWriteSize() > conf.net_udp_packet_max_bytes) { sendList(bufferCount, buffer.toByteArray()); buffer = new DataOutputX(); bufferCount = 1; buffer.write(b); } else { bufferCount++; buffer.write(b); } } if (buffer.getWriteSize() > 0) { sendList(bufferCount, buffer.toByteArray()); } return true; } catch (IOException e) { Logger.println("A123", "UDP", e); return false; } } private void sendList(int bufferCount, byte[] buffer) throws IOException {
public static List<byte[]> toBytesList(List<SpanPack> packs, int maxBytes) { if (packs == null) return null; try { List<byte[]> byteResultList = new ArrayList<byte[]>(); int maxLen = Math.max(maxBytes - 18000, 18000); int size = packs.size(); DataOutputX dout = new DataOutputX(Math.min(size * 500, maxBytes)); for (SpanPack pack : packs) { dout.writePack(pack); if (dout.getWriteSize() > maxLen) { byteResultList.add(dout.toByteArray()); dout = new DataOutputX(Math.min(size * 500, maxBytes)); } } if (dout.getWriteSize() > 0) { byteResultList.add(dout.toByteArray()); } return byteResultList; } catch (IOException e) { } return null; }
public static List<byte[]> toBytesList(List<SpanPack> packs, int maxBytes) { if (packs == null) return null; try { List<byte[]> byteResultList = new ArrayList<byte[]>(); int maxLen = Math.max(maxBytes - 18000, 18000); int size = packs.size(); DataOutputX dout = new DataOutputX(Math.min(size * 500, maxBytes)); for (SpanPack pack : packs) { dout.writePack(pack); if (dout.getWriteSize() > maxLen) { byteResultList.add(dout.toByteArray()); dout = new DataOutputX(Math.min(size * 500, maxBytes)); } } if (dout.getWriteSize() > 0) { byteResultList.add(dout.toByteArray()); } return byteResultList; } catch (IOException e) { } return null; }
public static List<byte[]> toBytesList(List<SpanPack> packs, int maxBytes) { if (packs == null) return null; try { List<byte[]> byteResultList = new ArrayList<byte[]>(); int maxLen = Math.max(maxBytes - 18000, 18000); int size = packs.size(); DataOutputX dout = new DataOutputX(Math.min(size * 500, maxBytes)); for (SpanPack pack : packs) { dout.writePack(pack); if (dout.getWriteSize() > maxLen) { byteResultList.add(dout.toByteArray()); dout = new DataOutputX(Math.min(size * 500, maxBytes)); } } if (dout.getWriteSize() > 0) { byteResultList.add(dout.toByteArray()); } return byteResultList; } catch (IOException e) { } return null; }
public boolean write(List<byte[]> p) { try { if (serverHost == null) return false; DataOutputX buffer = new DataOutputX(); int bufferCount = 0; for (int i = 0; i < p.size(); i++) { byte[] b = p.get(i); if (b.length > config.getUdpPacketMaxBytes()) { writeMTU(b, config.getUdpPacketMaxBytes()); } else if (b.length + buffer.getWriteSize() > config.getUdpPacketMaxBytes()) { sendList(bufferCount, buffer.toByteArray()); buffer = new DataOutputX(); bufferCount = 1; buffer.write(b); } else { bufferCount++; buffer.write(b); } } if (buffer.getWriteSize() > 0) { sendList(bufferCount, buffer.toByteArray()); } return true; } catch (IOException e) { logger.log(Level.WARNING, "A123: UDP writing error." + e.getMessage()); return false; } }
public boolean write(List<byte[]> p) { try { if (server_host == null) return false; DataOutputX buffer = new DataOutputX(); int bufferCount = 0; for (int i = 0; i < p.size(); i++) { byte[] b = p.get(i); if (b.length > conf.net_udp_packet_max_bytes) { writeMTU(b, conf.net_udp_packet_max_bytes); } else if (b.length + buffer.getWriteSize() > conf.net_udp_packet_max_bytes) { sendList(bufferCount, buffer.toByteArray()); buffer = new DataOutputX(); bufferCount = 1; buffer.write(b); } else { bufferCount++; buffer.write(b); } } if (buffer.getWriteSize() > 0) { sendList(bufferCount, buffer.toByteArray()); } return true; } catch (IOException e) { Logger.println("A123", "UDP", e); return false; } } private void sendList(int bufferCount, byte[] buffer) throws IOException {