本文整理了Java中org.jgroups.Message.setObject()
方法的一些代码示例,展示了Message.setObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setObject()
方法的具体详情如下:
包路径:org.jgroups.Message
类名称:Message
方法名:setObject
[英]Takes an object and uses Java serialization to generate the byte[] buffer which is set in the message.
[中]获取一个对象,并使用Java序列化生成消息中设置的字节[]缓冲区。
代码示例来源:origin: wildfly/wildfly
/**
* Constructs a message given a destination and source address and the payload object
* @param dest The Address of the receiver. If it is null, then the message is sent to the group. Otherwise, it is
* sent to a single member.
* @param obj The object that will be marshalled into the byte buffer. Has to be serializable (e.g. implementing
* Serializable, Externalizable or Streamable, or be a basic type (e.g. Integer, Short etc)).
*/
public Message(Address dest, Object obj) {
this(dest);
setObject(obj);
}
代码示例来源:origin: wildfly/wildfly
private void sendMessages() throws Exception {
System.out.println("Start sending messages...");
String address = jChannel.getAddressAsString();
List<Address> mbrs = jChannel.getView().getMembers();
start = System.nanoTime();
for (int i = 0; i < numberOfMessages; ++i) {
AnycastAddress dst = getDestinations(mbrs);
Message message = new Message().dest(dst);
DataMessage dataMessage = new DataMessage();
dataMessage.type = DataMessage.DATA;
dataMessage.data = address + ":" + i;
message.setObject(dataMessage);
jChannel.send(message);
sentBytes += (dataMessage.data.getBytes().length + 1);
sentMessages++;
}
stop = System.nanoTime();
System.out.println("Finish sending messages...");
}
代码示例来源:origin: apache/geode
private Message createJGMessage(byte[] msgBytes, Address src, Address dest, short version) {
Message msg = new Message();
msg.setDest(dest);
msg.setSrc(src);
msg.setObject(msgBytes);
msg.setFlag(Message.Flag.NO_RELIABILITY);
msg.setFlag(Message.Flag.NO_FC);
msg.setFlag(Message.Flag.DONT_BUNDLE);
msg.setFlag(Message.Flag.OOB);
return msg;
}
代码示例来源:origin: org.exoplatform.kernel/exo.kernel.component.common
/**
* {@inheritDoc}
*/
protected void setObject(Message m, Object o)
{
m.setObject(o);
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Constructs a message given a destination and source address and the payload object
* @param dest The Address of the receiver. If it is null, then the message is sent to the group. Otherwise, it is
* sent to a single member.
* @param obj The object that will be marshalled into the byte buffer. Has to be serializable (e.g. implementing
* Serializable, Externalizable or Streamable, or be a basic type (e.g. Integer, Short etc)).
*/
public Message(Address dest, Object obj) {
this(dest);
setObject(obj);
}
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
/** Public constructor
* @param dest Address of receiver. If it is <em>null</em> then the message sent to the group.
* Otherwise, it contains a single destination and is sent to that member.<p>
* @param src Address of sender
* @param obj The object will be serialized into the byte buffer. <em>Object
* has to be serializable </em>! The resulting buffer must not be modified
* (e.g. buf[0]=0 is not allowed), since we don't copy the contents on clopy() or clone().<p/>
* Note that this is a convenience method and JGroups will use default Java serialization to
* serialize <code>obj</code> into a byte buffer.
*/
public Message(Address dest, Address src, Serializable obj) {
this(dest);
setSrc(src);
setObject(obj);
}
代码示例来源:origin: org.codehaus.hydra-cache/harmony
@Override
public void broadcast(ResponseMessage response) throws IOException {
Message message = new Message();
message.setObject(response);
send(message);
}
代码示例来源:origin: net.segoia/distributed-processor
public void advertise() {
if (channel == null || !channel.isConnected()) {
return;
}
Message msg = new Message();
msg.setObject(localServices.keySet().toArray(new DistributedServiceDescription[0]));
try {
sendMessage(msg);
} catch (Exception e) {
Log.error(this, "Error sending advertise message", e);
}
}
代码示例来源:origin: org.codehaus.hydra-cache/harmony
@Override
public Collection<ResponseMessage> broadcast(RequestMessage request)
throws IOException {
if (log.isDebugEnabled())
log.debug("Sending operation request: " + request);
Message message = new Message();
message.setObject(request);
Future<Collection<ResponseMessage>> responseFuture = multiplexRecevier
.receiveFor(request);
send(message);
log.debug("Operation request sent");
try {
Collection<ResponseMessage> responseMessages = responseFuture.get(
multicastTimeOut, TimeUnit.MILLISECONDS);
if (log.isDebugEnabled())
log.debug("Response messages received: " + responseMessages);
List<ResponseMessage> results = new ArrayList<ResponseMessage>();
for (ResponseMessage responseMessage : responseMessages) {
results.add(responseMessage);
}
return results;
} catch (Exception ex) {
throw new IOException("Failed to request help for operation: "
+ request, ex);
}
}
代码示例来源:origin: net.segoia/distributed-processor
public boolean postEvent(Event event) {
Message msg = new Message();
msg.setObject(event);
try {
sendMessage(msg);
return true;
} catch (Exception e) {
logger.error("Failed to send event " + event, e);
return false;
}
}
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
rsp.setObject((Serializable)retval);
else
rsp.setObject(retval.toString());
代码示例来源:origin: org.jboss.eap/wildfly-client-all
private void sendMessages() throws Exception {
System.out.println("Start sending messages...");
String address = jChannel.getAddressAsString();
List<Address> mbrs = jChannel.getView().getMembers();
start = System.nanoTime();
for (int i = 0; i < numberOfMessages; ++i) {
AnycastAddress dst = getDestinations(mbrs);
Message message = new Message().dest(dst);
DataMessage dataMessage = new DataMessage();
dataMessage.type = DataMessage.DATA;
dataMessage.data = address + ":" + i;
message.setObject(dataMessage);
jChannel.send(message);
sentBytes += (dataMessage.data.getBytes().length + 1);
sentMessages++;
}
stop = System.nanoTime();
System.out.println("Finish sending messages...");
}
代码示例来源:origin: net.segoia/distributed-processor
private SubmitTaskResponse submitBroadcastTask(Task task, ProcessingResponseReceiver receiver) {
DistributedServiceDescription sd = task.getTargetService();
SubmitTaskResponse resp = new SubmitTaskResponse();
resp.setSuccessfull(true);
List<Address> servAddresses = globalServices.get(sd);
if (servAddresses != null) {
long taskId = task.getTaskId();
BroadcastTaskProcessingResponse btpr = new BroadcastTaskProcessingResponse(taskId, servAddresses.size());
pendingRequests.put(taskId, receiver);
pendigBroadcastRequests.put(taskId, btpr);
/* submit the task to every node that has the service active */
for (Address adr : servAddresses) {
Message msg = new Message();
msg.setDest(adr);
msg.setObject(task);
try {
sendMessage(msg);
} catch (Exception e) {
resp.setError(e);
resp.setSuccessfull(false);
}
}
} else {
resp.setSuccessfull(false);
resp.setError(new Exception("No address registered for service " + sd));
}
return resp;
}
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
update.putHeader(CausalNewViewHeader.NAME
, new CausalNewViewHeader(newView.getViewId(), newView.getLocalTime(), complete));
update.setObject(new MissingIndexesMessage(newView.getMissingTimes(), newView.getMissingCompletions()));
代码示例来源:origin: org.apache.geode/gemfire-core
private Message createJGMessage(byte[] msgBytes, Address src, Address dest, short version) {
Message msg = new Message();
msg.setDest(dest);
msg.setSrc(src);
msg.setObject(msgBytes);
msg.setFlag(Message.Flag.NO_RELIABILITY);
msg.setFlag(Message.Flag.NO_FC);
msg.setFlag(Message.Flag.DONT_BUNDLE);
msg.setFlag(Message.Flag.OOB);
return msg;
}
代码示例来源:origin: net.segoia/distributed-processor
/**
* Sends the response back to the client after the task was processed on the local node
*
* @param input
* @param output
*/
private void sendResponse(Task input, TaskProcessingResponse output) {
Message respMessage = new Message();
/* get the client address */
Address clientAddress = pendingResponses.remove(input);
respMessage.setDest(clientAddress);
respMessage.setObject(new TaskProcessingResponse(output.getTaskId(), output.getResult(), output.getException(),
this.getLocalNodeAddress()));
try {
sendMessage(respMessage);
} catch (Exception e) {
Log.error(this, "Error sending response for task " + input.getTaskId(), e);
}
}
代码示例来源:origin: net.segoia/distributed-processor
private SubmitTaskResponse submitSimpleTask(Task task, ProcessingResponseReceiver receiver) {
DistributedServiceDescription sd = task.getTargetService();
SubmitTaskResponse resp = new SubmitTaskResponse();
Address adr = getProcessingAddressForService(sd);
if (adr != null) {
Message msg = new Message();
msg.setDest(adr);
long taskId = task.getTaskId();
msg.setObject(task);
try {
pendingRequests.put(taskId, receiver);
sendMessage(msg);
resp.setSuccessfull(true);
} catch (Exception e) {
resp.setError(e);
resp.setSuccessfull(false);
}
} else {
resp.setSuccessfull(false);
resp.setError(new Exception("No address registered for service " + sd));
}
return resp;
}
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
update.putHeader(CausalNewViewHeader.NAME
, new CausalNewViewHeader(currentView.getView().getViewId(), 0, true)); // It has the time already
update.setObject(new MissingIndexesMessage(Collections.EMPTY_LIST, Collections.EMPTY_LIST));
内容来源于网络,如有侵权,请联系作者删除!