本文整理了Java中org.jgroups.util.Util.streamableFromByteBuffer()
方法的一些代码示例,展示了Util.streamableFromByteBuffer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.streamableFromByteBuffer()
方法的具体详情如下:
包路径:org.jgroups.util.Util
类名称:Util
方法名:streamableFromByteBuffer
暂无
代码示例来源:origin: wildfly/wildfly
public static <T extends Streamable> T streamableFromByteBuffer(Supplier<T> factory, byte[] buffer) throws Exception {
return streamableFromByteBuffer(factory, buffer, 0, buffer.length);
}
代码示例来源:origin: wildfly/wildfly
public static <T extends Streamable> T streamableFromByteBuffer(Class<? extends Streamable> cl,byte[] buffer) throws Exception {
return streamableFromByteBuffer(cl,buffer,0,buffer.length);
}
代码示例来源:origin: wildfly/wildfly
protected static PingData deserialize(final byte[] data) throws Exception {
return Util.streamableFromByteBuffer(PingData::new, data);
}
代码示例来源:origin: wildfly/wildfly
DrawCommand comm=Util.streamableFromByteBuffer(DrawCommand::new, buf, offset, length);
switch(comm.mode) {
case DrawCommand.DRAW:
代码示例来源:origin: wildfly/wildfly
public void receive(Message msg) {
byte[] buf=msg.getRawBuffer();
if(buf == null) {
System.err.printf("%s: received null buffer from %s, headers: %s\n", channel.getAddress(), msg.src(), msg.printHeaders());
return;
}
try {
DrawCommand comm=Util.streamableFromByteBuffer(DrawCommand::new, buf, msg.getOffset(), msg.getLength());
switch(comm.mode) {
case DrawCommand.DRAW:
if(panel != null)
panel.drawPoint(comm);
break;
case DrawCommand.CLEAR:
clearPanel();
break;
default:
System.err.println("***** received invalid draw command " + comm.mode);
break;
}
}
catch(Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: wildfly/wildfly
case VIEW:
try {
ViewData data=Util.streamableFromByteBuffer(ViewData::new, msg.getRawBuffer(),
msg.getOffset(), msg.getLength());
代码示例来源:origin: wildfly/wildfly
protected Object installView(byte[] buf, int offset, int length) {
try {
ViewData data=Util.streamableFromByteBuffer(ViewData::new, buf, offset, length);
if(data.uuids != null)
NameCache.add(data.uuids);
remote_view=data.remote_view;
if(global_view == null || (data.global_view != null &&!global_view.equals(data.global_view))) {
global_view=data.global_view;
synchronized(this) {
if(data.global_view.getViewId().getId() > global_view_id)
global_view_id=data.global_view.getViewId().getId();
}
if(present_global_views)
return up_prot.up(new Event(Event.VIEW_CHANGE, global_view));
}
}
catch(Exception e) {
log.error(Util.getMessage("FailedInstallingView"), e);
}
return null;
}
代码示例来源:origin: wildfly/wildfly
protected void sendOnLocalCluster(byte[] buf, int offset, int length) {
try {
Message msg=Util.streamableFromByteBuffer(Message::new, buf, offset, length);
Address sender=msg.getSrc();
Address dest=msg.getDest();
if(!isLocal(dest)) {
if(log.isWarnEnabled())
log.warn("[" + local_addr + "] dest=" + dest + " is not local (site=" + this.site + "); discarding it");
return;
}
// set myself to be the sender
msg.setSrc(local_addr);
// later, in RELAY, we'll take the original sender from the header and make it the sender
msg.putHeader(id, RelayHeader.createDisseminateHeader(sender));
if(log.isTraceEnabled())
log.trace("received msg from " + sender + ", passing down the stack with dest=" +
msg.getDest() + " and src=" + msg.getSrc());
down_prot.down(msg);
}
catch(Exception e) {
log.error(Util.getMessage("FailedSendingOnLocalCluster"), e);
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public static <T extends Streamable> T streamableFromByteBuffer(Supplier<T> factory, byte[] buffer) throws Exception {
return streamableFromByteBuffer(factory, buffer, 0, buffer.length);
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public static <T extends Streamable> T streamableFromByteBuffer(Class<? extends Streamable> cl,byte[] buffer) throws Exception {
return streamableFromByteBuffer(cl,buffer,0,buffer.length);
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
protected static PingData deserialize(final byte[] data) throws Exception {
return Util.streamableFromByteBuffer(PingData::new, data);
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
DrawCommand comm=Util.streamableFromByteBuffer(DrawCommand::new, buf, offset, length);
switch(comm.mode) {
case DrawCommand.DRAW:
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
public void receive(Message msg) {
byte[] buf=msg.getRawBuffer();
DrawCommand comm=null;
try {
comm=(DrawCommand)Util.streamableFromByteBuffer(DrawCommand.class, buf, msg.getOffset(), msg.getLength());
switch(comm.mode) {
case DrawCommand.DRAW:
if(panel != null)
panel.drawPoint(comm);
break;
case DrawCommand.CLEAR:
clearPanel();
break;
default:
System.err.println("***** Draw2Channels.run(): received invalid draw command " + comm.mode);
break;
}
}
catch(Exception ex) {
ex.printStackTrace();
}
}
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
public void receive(Message msg) {
byte[] buf=msg.getRawBuffer();
if(buf == null) {
System.err.println("received null buffer from " + msg.getSrc() + ", headers: " + msg.printHeaders());
return;
}
try {
DrawCommand comm=(DrawCommand)Util.streamableFromByteBuffer(DrawCommand.class, buf, msg.getOffset(), msg.getLength());
switch(comm.mode) {
case DrawCommand.DRAW:
if(panel != null)
panel.drawPoint(comm);
break;
case DrawCommand.CLEAR:
clearPanel();
break;
default:
System.err.println("***** received invalid draw command " + comm.mode);
break;
}
}
catch(Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: org.integratedmodelling/klab-common
public void receive(Message msg) {
byte[] buf=msg.getRawBuffer();
if(buf == null) {
System.err.println("[" + channel.getAddress() + "] received null buffer from " + msg.getSrc() +
", headers: " + msg.printHeaders());
return;
}
try {
DrawCommand comm=(DrawCommand)Util.streamableFromByteBuffer(DrawCommand.class, buf, msg.getOffset(), msg.getLength());
switch(comm.mode) {
case DrawCommand.DRAW:
if(panel != null)
panel.drawPoint(comm);
break;
case DrawCommand.CLEAR:
clearPanel();
break;
default:
System.err.println("***** received invalid draw command " + comm.mode);
break;
}
}
catch(Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public void receive(Message msg) {
byte[] buf=msg.getRawBuffer();
if(buf == null) {
System.err.printf("%s: received null buffer from %s, headers: %s\n", channel.getAddress(), msg.src(), msg.printHeaders());
return;
}
try {
DrawCommand comm=Util.streamableFromByteBuffer(DrawCommand::new, buf, msg.getOffset(), msg.getLength());
switch(comm.mode) {
case DrawCommand.DRAW:
if(panel != null)
panel.drawPoint(comm);
break;
case DrawCommand.CLEAR:
clearPanel();
break;
default:
System.err.println("***** received invalid draw command " + comm.mode);
break;
}
}
catch(Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
private static Message _decrypt(Cipher cipher, Message msg, boolean decrypt_entire_msg) throws Exception {
if(!decrypt_entire_msg) {
msg.setBuffer(cipher.doFinal(msg.getRawBuffer(), msg.getOffset(), msg.getLength()));
return msg;
}
byte[] decrypted_msg=cipher.doFinal(msg.getRawBuffer(), msg.getOffset(), msg.getLength());
Message ret=(Message)Util.streamableFromByteBuffer(Message.class, decrypted_msg);
if(ret.getDest() == null)
ret.setDest(msg.getDest());
if(ret.getSrc() == null)
ret.setSrc(msg.getSrc());
return ret;
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
protected Object installView(byte[] buf, int offset, int length) {
try {
ViewData data=Util.streamableFromByteBuffer(ViewData::new, buf, offset, length);
if(data.uuids != null)
NameCache.add(data.uuids);
remote_view=data.remote_view;
if(global_view == null || (data.global_view != null &&!global_view.equals(data.global_view))) {
global_view=data.global_view;
synchronized(this) {
if(data.global_view.getViewId().getId() > global_view_id)
global_view_id=data.global_view.getViewId().getId();
}
if(present_global_views)
return up_prot.up(new Event(Event.VIEW_CHANGE, global_view));
}
}
catch(Exception e) {
log.error(Util.getMessage("FailedInstallingView"), e);
}
return null;
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
case VIEW:
try {
ViewData data=Util.streamableFromByteBuffer(ViewData::new, msg.getRawBuffer(),
msg.getOffset(), msg.getLength());
代码示例来源:origin: org.jboss.eap/wildfly-client-all
protected void sendOnLocalCluster(byte[] buf, int offset, int length) {
try {
Message msg=Util.streamableFromByteBuffer(Message::new, buf, offset, length);
Address sender=msg.getSrc();
Address dest=msg.getDest();
if(!isLocal(dest)) {
if(log.isWarnEnabled())
log.warn("[" + local_addr + "] dest=" + dest + " is not local (site=" + this.site + "); discarding it");
return;
}
// set myself to be the sender
msg.setSrc(local_addr);
// later, in RELAY, we'll take the original sender from the header and make it the sender
msg.putHeader(id, RelayHeader.createDisseminateHeader(sender));
if(log.isTraceEnabled())
log.trace("received msg from " + sender + ", passing down the stack with dest=" +
msg.getDest() + " and src=" + msg.getSrc());
down_prot.down(msg);
}
catch(Exception e) {
log.error(Util.getMessage("FailedSendingOnLocalCluster"), e);
}
}
内容来源于网络,如有侵权,请联系作者删除!