org.jgroups.util.Util.streamableToByteBuffer()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(207)

本文整理了Java中org.jgroups.util.Util.streamableToByteBuffer()方法的一些代码示例,展示了Util.streamableToByteBuffer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.streamableToByteBuffer()方法的具体详情如下:
包路径:org.jgroups.util.Util
类名称:Util
方法名:streamableToByteBuffer

Util.streamableToByteBuffer介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

  1. public void mouseDragged(MouseEvent e) {
  2. int x=e.getX(), y=e.getY();
  3. DrawCommand comm=new DrawCommand(DrawCommand.DRAW, x, y, draw_color.getRGB());
  4. try {
  5. byte[] buf=Util.streamableToByteBuffer(comm);
  6. sendToAll(buf);
  7. }
  8. catch(Exception ex) {
  9. System.err.println(ex);
  10. }
  11. }

代码示例来源:origin: wildfly/wildfly

  1. public void sendClearPanelMsg() {
  2. DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
  3. try {
  4. byte[] buf=Util.streamableToByteBuffer(comm);
  5. sendToAll(buf);
  6. }
  7. catch(Exception ex) {
  8. System.err.println(ex);
  9. }
  10. }

代码示例来源:origin: wildfly/wildfly

  1. public void mouseDragged(MouseEvent e) {
  2. int x=e.getX(), y=e.getY();
  3. DrawCommand comm=new DrawCommand(DrawCommand.DRAW, x, y, draw_color.getRGB());
  4. if(no_channel) {
  5. drawPoint(comm);
  6. return;
  7. }
  8. try {
  9. byte[] buf=Util.streamableToByteBuffer(comm);
  10. if(use_unicasts)
  11. sendToAll(buf);
  12. else
  13. channel.send(new Message(null, buf));
  14. }
  15. catch(Exception ex) {
  16. System.err.println(ex);
  17. }
  18. }

代码示例来源:origin: wildfly/wildfly

  1. protected void sendOwnState(final Map<Point,Color> copy) {
  2. if(copy == null)
  3. return;
  4. for(Point point: copy.keySet()) {
  5. // we don't need the color: it is our draw_color anyway
  6. DrawCommand comm=new DrawCommand(DrawCommand.DRAW, point.x, point.y, draw_color.getRGB());
  7. try {
  8. byte[] buf=Util.streamableToByteBuffer(comm);
  9. if(use_unicasts)
  10. sendToAll(buf);
  11. else
  12. channel.send(new Message(null, buf));
  13. }
  14. catch(Exception ex) {
  15. System.err.println(ex);
  16. }
  17. }
  18. }

代码示例来源:origin: wildfly/wildfly

  1. protected void sendViewOnLocalCluster(ViewData data, boolean use_seperate_thread, final List<Address> new_mbrs) {
  2. try {
  3. final byte[] buffer=Util.streamableToByteBuffer(data);
  4. final List<Address> destinations=new ArrayList<>();
  5. destinations.add(null); // send to all
  6. if(new_mbrs != null)
  7. destinations.addAll(new_mbrs);
  8. if(use_seperate_thread) {
  9. timer.execute(() -> sendViewOnLocalCluster(destinations, buffer));
  10. }
  11. else
  12. sendViewOnLocalCluster(destinations, buffer);
  13. }
  14. catch(Exception e) {
  15. log.error(Util.getMessage("FailedSendingViewToLocalCluster"), e);
  16. }
  17. }

代码示例来源:origin: wildfly/wildfly

  1. public void sendClearPanelMsg() {
  2. DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
  3. try {
  4. byte[] buf=Util.streamableToByteBuffer(comm);
  5. if(use_unicasts)
  6. sendToAll(buf);
  7. else
  8. channel.send(new Message(null, buf));
  9. }
  10. catch(Exception ex) {
  11. System.err.println(ex);
  12. }
  13. }

代码示例来源:origin: wildfly/wildfly

  1. /** Wraps the message annd sends it to the current coordinator */
  2. protected void forwardToCoord(Message msg) {
  3. Message tmp=msg.copy(true, Global.BLOCKS_START_ID); // // we only copy headers from building blocks
  4. if(tmp.getSrc() == null)
  5. tmp.setSrc(local_addr);
  6. try {
  7. byte[] buf=Util.streamableToByteBuffer(tmp);
  8. if(coord != null) {
  9. // optimization: if I'm the coord, simply relay to the remote cluster via the bridge
  10. if(coord.equals(local_addr)) {
  11. forward(buf, 0, buf.length);
  12. return;
  13. }
  14. tmp=new Message(coord, buf, 0, buf.length) // reusing tmp is OK here ...
  15. .putHeader(id, new RelayHeader(RelayHeader.Type.FORWARD));
  16. down_prot.down(tmp);
  17. }
  18. }
  19. catch(Exception e) {
  20. log.error(Util.getMessage("FailedForwardingUnicastMessageToCoord"), e);
  21. }
  22. }

代码示例来源:origin: wildfly/wildfly

  1. /**
  2. * Creates a byte[] representation of the PingData, but DISCARDING the view it contains.
  3. * @param data the PingData instance to serialize.
  4. * @return
  5. */
  6. protected byte[] serializeWithoutView(PingData data) {
  7. final PingData clone = new PingData(data.getAddress(), data.isServer(), data.getLogicalName(), data.getPhysicalAddr()).coord(data.isCoord());
  8. try {
  9. return Util.streamableToByteBuffer(clone);
  10. }
  11. catch(Exception e) {
  12. log.error(Util.getMessage("ErrorSerializingPingData"), e);
  13. return null;
  14. }
  15. }

代码示例来源:origin: wildfly/wildfly

  1. public Object up(Message msg) {
  2. Address dest=msg.getDest();
  3. RelayHeader hdr=msg.getHeader(getId());
  4. if(hdr != null)
  5. return handleUpEvent(msg, hdr);
  6. if(is_coord && relay && dest == null && !msg.isFlagSet(Message.Flag.NO_RELAY)) {
  7. Message tmp=msg.copy(true, Global.BLOCKS_START_ID); // we only copy headers from building blocks
  8. try {
  9. byte[] buf=Util.streamableToByteBuffer(tmp);
  10. forward(buf, 0, buf.length);
  11. }
  12. catch(Exception e) {
  13. log.warn("failed relaying message", e);
  14. }
  15. }
  16. return up_prot.up(msg);
  17. }

代码示例来源:origin: wildfly/wildfly

  1. protected void sendViewToRemote(ViewData view_data, boolean use_seperate_thread) {
  2. try {
  3. if(bridge != null && bridge.isConnected()) {
  4. byte[] buf=Util.streamableToByteBuffer(view_data);
  5. final Message msg=new Message(null, buf).putHeader(id, RelayHeader.create(RelayHeader.Type.VIEW));
  6. if(use_seperate_thread) {
  7. timer.execute(() -> {
  8. try {
  9. bridge.send(msg);
  10. }
  11. catch(Exception e) {
  12. log.error(Util.getMessage("FailedSendingViewToRemote"), e);
  13. }
  14. });
  15. }
  16. else
  17. bridge.send(msg);
  18. }
  19. }
  20. catch(Exception e) {
  21. log.error(Util.getMessage("FailedSendingViewToRemote"), e);
  22. }
  23. }

代码示例来源:origin: wildfly/wildfly

  1. public void up(MessageBatch batch) {
  2. for(Message msg: batch) {
  3. RelayHeader hdr=msg.getHeader(getId());
  4. if(hdr != null) {
  5. batch.remove(msg);
  6. try {
  7. handleUpEvent(msg, hdr);
  8. continue; // fix for https://issues.jboss.org/browse/JGRP-2073
  9. }
  10. catch(Throwable t) {
  11. log.error(Util.getMessage("FailedProcessingMessage"), t);
  12. }
  13. }
  14. // Leave the messages in the batch: they're going to be forwarded, but we also need to deliver them locally
  15. if(is_coord && relay && msg.dest() == null && !msg.isFlagSet(Message.Flag.NO_RELAY)) {
  16. Message tmp=msg.copy(true, Global.BLOCKS_START_ID); // we only copy headers from building blocks
  17. try {
  18. byte[] buf=Util.streamableToByteBuffer(tmp);
  19. forward(buf, 0, buf.length);
  20. }
  21. catch(Exception e) {
  22. log.warn("failed relaying message", e);
  23. }
  24. }
  25. }
  26. if(!batch.isEmpty())
  27. up_prot.up(batch);
  28. }

代码示例来源:origin: org.jboss.eap/wildfly-client-all

  1. public void mouseDragged(MouseEvent e) {
  2. int x=e.getX(), y=e.getY();
  3. DrawCommand comm=new DrawCommand(DrawCommand.DRAW, x, y, draw_color.getRGB());
  4. try {
  5. byte[] buf=Util.streamableToByteBuffer(comm);
  6. sendToAll(buf);
  7. }
  8. catch(Exception ex) {
  9. System.err.println(ex);
  10. }
  11. }

代码示例来源:origin: org.jboss.eap/wildfly-client-all

  1. public void sendClearPanelMsg() {
  2. DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
  3. try {
  4. byte[] buf=Util.streamableToByteBuffer(comm);
  5. sendToAll(buf);
  6. }
  7. catch(Exception ex) {
  8. System.err.println(ex);
  9. }
  10. }

代码示例来源:origin: org.jgroups/com.springsource.org.jgroups

  1. public void mouseDragged(MouseEvent e) {
  2. int x=e.getX(), y=e.getY();
  3. DrawCommand comm=new DrawCommand(DrawCommand.DRAW, x, y,
  4. draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue());
  5. if(no_channel) {
  6. drawPoint(comm);
  7. return;
  8. }
  9. try {
  10. byte[] buf=Util.streamableToByteBuffer(comm);
  11. data_channel.send(new Message(null, null, buf));
  12. Thread.yield(); // gives the repainter some breath
  13. }
  14. catch(Exception ex) {
  15. System.err.println(ex);
  16. }
  17. }

代码示例来源:origin: org.jgroups/com.springsource.org.jgroups

  1. public void sendClearPanelMsg() {
  2. int tmp[]=new int[1]; tmp[0]=0;
  3. DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
  4. try {
  5. byte[] buf=Util.streamableToByteBuffer(comm);
  6. channel.send(new Message(null, null, buf));
  7. }
  8. catch(Exception ex) {
  9. System.err.println(ex);
  10. }
  11. }

代码示例来源:origin: org.jgroups/com.springsource.org.jgroups

  1. public void sendClearPanelMsg() {
  2. int tmp[]=new int[1];
  3. tmp[0]=0;
  4. DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
  5. try {
  6. byte[] buf=Util.streamableToByteBuffer(comm);
  7. data_channel.send(new Message(null, null, buf));
  8. }
  9. catch(Exception ex) {
  10. System.err.println(ex);
  11. }
  12. }

代码示例来源:origin: org.jboss.eap/wildfly-client-all

  1. public void sendClearPanelMsg() {
  2. DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
  3. try {
  4. byte[] buf=Util.streamableToByteBuffer(comm);
  5. if(use_unicasts)
  6. sendToAll(buf);
  7. else
  8. channel.send(new Message(null, buf));
  9. }
  10. catch(Exception ex) {
  11. System.err.println(ex);
  12. }
  13. }

代码示例来源:origin: org.integratedmodelling/klab-common

  1. public void sendClearPanelMsg() {
  2. DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
  3. try {
  4. byte[] buf=Util.streamableToByteBuffer(comm);
  5. if(use_unicasts)
  6. sendToAll(buf);
  7. else
  8. channel.send(new Message(null, null, buf));
  9. }
  10. catch(Exception ex) {
  11. System.err.println(ex);
  12. }
  13. }

代码示例来源:origin: org.jboss.eap/wildfly-client-all

  1. /**
  2. * Creates a byte[] representation of the PingData, but DISCARDING the view it contains.
  3. * @param data the PingData instance to serialize.
  4. * @return
  5. */
  6. protected byte[] serializeWithoutView(PingData data) {
  7. final PingData clone = new PingData(data.getAddress(), data.isServer(), data.getLogicalName(), data.getPhysicalAddr()).coord(data.isCoord());
  8. try {
  9. return Util.streamableToByteBuffer(clone);
  10. }
  11. catch(Exception e) {
  12. log.error(Util.getMessage("ErrorSerializingPingData"), e);
  13. return null;
  14. }
  15. }

代码示例来源:origin: org.jboss.eap/wildfly-client-all

  1. public Object up(Message msg) {
  2. Address dest=msg.getDest();
  3. RelayHeader hdr=msg.getHeader(getId());
  4. if(hdr != null)
  5. return handleUpEvent(msg, hdr);
  6. if(is_coord && relay && dest == null && !msg.isFlagSet(Message.Flag.NO_RELAY)) {
  7. Message tmp=msg.copy(true, Global.BLOCKS_START_ID); // we only copy headers from building blocks
  8. try {
  9. byte[] buf=Util.streamableToByteBuffer(tmp);
  10. forward(buf, 0, buf.length);
  11. }
  12. catch(Exception e) {
  13. log.warn("failed relaying message", e);
  14. }
  15. }
  16. return up_prot.up(msg);
  17. }

相关文章

Util类方法