本文整理了Java中org.jgroups.util.Util.streamableToByteBuffer()
方法的一些代码示例,展示了Util.streamableToByteBuffer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.streamableToByteBuffer()
方法的具体详情如下:
包路径:org.jgroups.util.Util
类名称:Util
方法名:streamableToByteBuffer
暂无
代码示例来源:origin: wildfly/wildfly
public void mouseDragged(MouseEvent e) {
int x=e.getX(), y=e.getY();
DrawCommand comm=new DrawCommand(DrawCommand.DRAW, x, y, draw_color.getRGB());
try {
byte[] buf=Util.streamableToByteBuffer(comm);
sendToAll(buf);
}
catch(Exception ex) {
System.err.println(ex);
}
}
代码示例来源:origin: wildfly/wildfly
public void sendClearPanelMsg() {
DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
try {
byte[] buf=Util.streamableToByteBuffer(comm);
sendToAll(buf);
}
catch(Exception ex) {
System.err.println(ex);
}
}
代码示例来源:origin: wildfly/wildfly
public void mouseDragged(MouseEvent e) {
int x=e.getX(), y=e.getY();
DrawCommand comm=new DrawCommand(DrawCommand.DRAW, x, y, draw_color.getRGB());
if(no_channel) {
drawPoint(comm);
return;
}
try {
byte[] buf=Util.streamableToByteBuffer(comm);
if(use_unicasts)
sendToAll(buf);
else
channel.send(new Message(null, buf));
}
catch(Exception ex) {
System.err.println(ex);
}
}
代码示例来源:origin: wildfly/wildfly
protected void sendOwnState(final Map<Point,Color> copy) {
if(copy == null)
return;
for(Point point: copy.keySet()) {
// we don't need the color: it is our draw_color anyway
DrawCommand comm=new DrawCommand(DrawCommand.DRAW, point.x, point.y, draw_color.getRGB());
try {
byte[] buf=Util.streamableToByteBuffer(comm);
if(use_unicasts)
sendToAll(buf);
else
channel.send(new Message(null, buf));
}
catch(Exception ex) {
System.err.println(ex);
}
}
}
代码示例来源:origin: wildfly/wildfly
protected void sendViewOnLocalCluster(ViewData data, boolean use_seperate_thread, final List<Address> new_mbrs) {
try {
final byte[] buffer=Util.streamableToByteBuffer(data);
final List<Address> destinations=new ArrayList<>();
destinations.add(null); // send to all
if(new_mbrs != null)
destinations.addAll(new_mbrs);
if(use_seperate_thread) {
timer.execute(() -> sendViewOnLocalCluster(destinations, buffer));
}
else
sendViewOnLocalCluster(destinations, buffer);
}
catch(Exception e) {
log.error(Util.getMessage("FailedSendingViewToLocalCluster"), e);
}
}
代码示例来源:origin: wildfly/wildfly
public void sendClearPanelMsg() {
DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
try {
byte[] buf=Util.streamableToByteBuffer(comm);
if(use_unicasts)
sendToAll(buf);
else
channel.send(new Message(null, buf));
}
catch(Exception ex) {
System.err.println(ex);
}
}
代码示例来源:origin: wildfly/wildfly
/** Wraps the message annd sends it to the current coordinator */
protected void forwardToCoord(Message msg) {
Message tmp=msg.copy(true, Global.BLOCKS_START_ID); // // we only copy headers from building blocks
if(tmp.getSrc() == null)
tmp.setSrc(local_addr);
try {
byte[] buf=Util.streamableToByteBuffer(tmp);
if(coord != null) {
// optimization: if I'm the coord, simply relay to the remote cluster via the bridge
if(coord.equals(local_addr)) {
forward(buf, 0, buf.length);
return;
}
tmp=new Message(coord, buf, 0, buf.length) // reusing tmp is OK here ...
.putHeader(id, new RelayHeader(RelayHeader.Type.FORWARD));
down_prot.down(tmp);
}
}
catch(Exception e) {
log.error(Util.getMessage("FailedForwardingUnicastMessageToCoord"), e);
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Creates a byte[] representation of the PingData, but DISCARDING the view it contains.
* @param data the PingData instance to serialize.
* @return
*/
protected byte[] serializeWithoutView(PingData data) {
final PingData clone = new PingData(data.getAddress(), data.isServer(), data.getLogicalName(), data.getPhysicalAddr()).coord(data.isCoord());
try {
return Util.streamableToByteBuffer(clone);
}
catch(Exception e) {
log.error(Util.getMessage("ErrorSerializingPingData"), e);
return null;
}
}
代码示例来源:origin: wildfly/wildfly
public Object up(Message msg) {
Address dest=msg.getDest();
RelayHeader hdr=msg.getHeader(getId());
if(hdr != null)
return handleUpEvent(msg, hdr);
if(is_coord && relay && dest == null && !msg.isFlagSet(Message.Flag.NO_RELAY)) {
Message tmp=msg.copy(true, Global.BLOCKS_START_ID); // we only copy headers from building blocks
try {
byte[] buf=Util.streamableToByteBuffer(tmp);
forward(buf, 0, buf.length);
}
catch(Exception e) {
log.warn("failed relaying message", e);
}
}
return up_prot.up(msg);
}
代码示例来源:origin: wildfly/wildfly
protected void sendViewToRemote(ViewData view_data, boolean use_seperate_thread) {
try {
if(bridge != null && bridge.isConnected()) {
byte[] buf=Util.streamableToByteBuffer(view_data);
final Message msg=new Message(null, buf).putHeader(id, RelayHeader.create(RelayHeader.Type.VIEW));
if(use_seperate_thread) {
timer.execute(() -> {
try {
bridge.send(msg);
}
catch(Exception e) {
log.error(Util.getMessage("FailedSendingViewToRemote"), e);
}
});
}
else
bridge.send(msg);
}
}
catch(Exception e) {
log.error(Util.getMessage("FailedSendingViewToRemote"), e);
}
}
代码示例来源:origin: wildfly/wildfly
public void up(MessageBatch batch) {
for(Message msg: batch) {
RelayHeader hdr=msg.getHeader(getId());
if(hdr != null) {
batch.remove(msg);
try {
handleUpEvent(msg, hdr);
continue; // fix for https://issues.jboss.org/browse/JGRP-2073
}
catch(Throwable t) {
log.error(Util.getMessage("FailedProcessingMessage"), t);
}
}
// Leave the messages in the batch: they're going to be forwarded, but we also need to deliver them locally
if(is_coord && relay && msg.dest() == null && !msg.isFlagSet(Message.Flag.NO_RELAY)) {
Message tmp=msg.copy(true, Global.BLOCKS_START_ID); // we only copy headers from building blocks
try {
byte[] buf=Util.streamableToByteBuffer(tmp);
forward(buf, 0, buf.length);
}
catch(Exception e) {
log.warn("failed relaying message", e);
}
}
}
if(!batch.isEmpty())
up_prot.up(batch);
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public void mouseDragged(MouseEvent e) {
int x=e.getX(), y=e.getY();
DrawCommand comm=new DrawCommand(DrawCommand.DRAW, x, y, draw_color.getRGB());
try {
byte[] buf=Util.streamableToByteBuffer(comm);
sendToAll(buf);
}
catch(Exception ex) {
System.err.println(ex);
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public void sendClearPanelMsg() {
DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
try {
byte[] buf=Util.streamableToByteBuffer(comm);
sendToAll(buf);
}
catch(Exception ex) {
System.err.println(ex);
}
}
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
public void mouseDragged(MouseEvent e) {
int x=e.getX(), y=e.getY();
DrawCommand comm=new DrawCommand(DrawCommand.DRAW, x, y,
draw_color.getRed(), draw_color.getGreen(), draw_color.getBlue());
if(no_channel) {
drawPoint(comm);
return;
}
try {
byte[] buf=Util.streamableToByteBuffer(comm);
data_channel.send(new Message(null, null, buf));
Thread.yield(); // gives the repainter some breath
}
catch(Exception ex) {
System.err.println(ex);
}
}
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
public void sendClearPanelMsg() {
int tmp[]=new int[1]; tmp[0]=0;
DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
try {
byte[] buf=Util.streamableToByteBuffer(comm);
channel.send(new Message(null, null, buf));
}
catch(Exception ex) {
System.err.println(ex);
}
}
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
public void sendClearPanelMsg() {
int tmp[]=new int[1];
tmp[0]=0;
DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
try {
byte[] buf=Util.streamableToByteBuffer(comm);
data_channel.send(new Message(null, null, buf));
}
catch(Exception ex) {
System.err.println(ex);
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public void sendClearPanelMsg() {
DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
try {
byte[] buf=Util.streamableToByteBuffer(comm);
if(use_unicasts)
sendToAll(buf);
else
channel.send(new Message(null, buf));
}
catch(Exception ex) {
System.err.println(ex);
}
}
代码示例来源:origin: org.integratedmodelling/klab-common
public void sendClearPanelMsg() {
DrawCommand comm=new DrawCommand(DrawCommand.CLEAR);
try {
byte[] buf=Util.streamableToByteBuffer(comm);
if(use_unicasts)
sendToAll(buf);
else
channel.send(new Message(null, null, buf));
}
catch(Exception ex) {
System.err.println(ex);
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Creates a byte[] representation of the PingData, but DISCARDING the view it contains.
* @param data the PingData instance to serialize.
* @return
*/
protected byte[] serializeWithoutView(PingData data) {
final PingData clone = new PingData(data.getAddress(), data.isServer(), data.getLogicalName(), data.getPhysicalAddr()).coord(data.isCoord());
try {
return Util.streamableToByteBuffer(clone);
}
catch(Exception e) {
log.error(Util.getMessage("ErrorSerializingPingData"), e);
return null;
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public Object up(Message msg) {
Address dest=msg.getDest();
RelayHeader hdr=msg.getHeader(getId());
if(hdr != null)
return handleUpEvent(msg, hdr);
if(is_coord && relay && dest == null && !msg.isFlagSet(Message.Flag.NO_RELAY)) {
Message tmp=msg.copy(true, Global.BLOCKS_START_ID); // we only copy headers from building blocks
try {
byte[] buf=Util.streamableToByteBuffer(tmp);
forward(buf, 0, buf.length);
}
catch(Exception e) {
log.warn("failed relaying message", e);
}
}
return up_prot.up(msg);
}
内容来源于网络,如有侵权,请联系作者删除!