本文整理汇总了Java中org.apache.catalina.tribes.util.UUIDGenerator.randomUUID方法的典型用法代码示例。如果您正苦于以下问题:Java UUIDGenerator.randomUUID方法的具体用法?Java UUIDGenerator.randomUUID怎么用?Java UUIDGenerator.randomUUID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.tribes.util.UUIDGenerator
的用法示例。
在下文中一共展示了UUIDGenerator.randomUUID方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendMessage
import org.apache.catalina.tribes.util.UUIDGenerator; //导入方法依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws
ChannelException {
//todo, optimize, if destination.length==1, then we can do
//msg.setOptions(msg.getOptions() & (~getOptionFlag())
//and just send one message
if (okToProcess(msg.getOptions()) ) {
super.sendMessage(destination, msg, null);
ChannelMessage confirmation = null;
if ( deepclone ) confirmation = (ChannelMessage)msg.deepclone();
else confirmation = (ChannelMessage)msg.clone();
confirmation.getMessage().reset();
UUIDGenerator.randomUUID(false,confirmation.getUniqueId(),0);
confirmation.getMessage().append(START_DATA,0,START_DATA.length);
confirmation.getMessage().append(msg.getUniqueId(),0,msg.getUniqueId().length);
confirmation.getMessage().append(END_DATA,0,END_DATA.length);
super.sendMessage(destination,confirmation,payload);
} else {
//turn off two phase commit
//this wont work if the interceptor has 0 as a flag
//since there is no flag to turn off
//msg.setOptions(msg.getOptions() & (~getOptionFlag()));
super.sendMessage(destination, msg, payload);
}
}
示例2: send
import org.apache.catalina.tribes.util.UUIDGenerator; //导入方法依赖的package包/类
/**
* Send a message and wait for the response.
* @param destination Member[] - the destination for the message, and the members you request a reply from
* @param message Serializable - the message you are sending out
* @param rpcOptions int - FIRST_REPLY, MAJORITY_REPLY or ALL_REPLY
* @param channelOptions channel sender options
* @param timeout long - timeout in milliseconds, if no reply is received within this time null is returned
* @return Response[] - an array of response objects.
* @throws ChannelException
*/
public Response[] send(Member[] destination,
Serializable message,
int rpcOptions,
int channelOptions,
long timeout) throws ChannelException {
if ( destination==null || destination.length == 0 ) return new Response[0];
//avoid dead lock
int sendOptions =
channelOptions & ~Channel.SEND_OPTIONS_SYNCHRONIZED_ACK;
RpcCollectorKey key = new RpcCollectorKey(UUIDGenerator.randomUUID(false));
RpcCollector collector = new RpcCollector(key,rpcOptions,destination.length);
try {
synchronized (collector) {
if ( rpcOptions != NO_REPLY ) responseMap.put(key, collector);
RpcMessage rmsg = new RpcMessage(rpcId, key.id, message);
channel.send(destination, rmsg, sendOptions);
if ( rpcOptions != NO_REPLY ) collector.wait(timeout);
}
} catch ( InterruptedException ix ) {
Thread.currentThread().interrupt();
} finally {
responseMap.remove(key);
}
return collector.getResponses();
}
示例3: createElectionMsg
import org.apache.catalina.tribes.util.UUIDGenerator; //导入方法依赖的package包/类
private CoordinationMessage createElectionMsg(MemberImpl local, MemberImpl[] others, MemberImpl leader) {
Membership m = new Membership(local,AbsoluteOrder.comp,true);
Arrays.fill(m,others);
MemberImpl[] mbrs = m.getMembers();
m.reset();
CoordinationMessage msg = new CoordinationMessage(leader, local, mbrs,new UniqueId(UUIDGenerator.randomUUID(true)), COORD_REQUEST);
return msg;
}
示例4: addRandomDomain
import org.apache.catalina.tribes.util.UUIDGenerator; //导入方法依赖的package包/类
/**
* Configures a set of channels to use a random domain. Use to ensure that
* multiple instance of the test suite do not interfere when running on the
* same machine. This may happen in a CI system or when a developer is
* running tests for multiple branches in parallel.
*/
public static void addRandomDomain(ManagedChannel[] channels) {
if (channels == null) {
return;
}
byte[] domain = UUIDGenerator.randomUUID(false);
for (ManagedChannel channel : channels) {
channel.getMembershipService().setDomain(domain);
DomainFilterInterceptor filter = new DomainFilterInterceptor();
filter.setDomain(domain);
channel.addInterceptor(filter);
}
}
示例5: send
import org.apache.catalina.tribes.util.UUIDGenerator; //导入方法依赖的package包/类
/**
* Send a message and wait for the response.
*
* @param destination
* Member[] - the destination for the message, and the members
* you request a reply from
* @param message
* Serializable - the message you are sending out
* @param rpcOptions
* int - FIRST_REPLY, MAJORITY_REPLY or ALL_REPLY
* @param channelOptions
* channel sender options
* @param timeout
* long - timeout in milliseconds, if no reply is received within
* this time null is returned
* @return Response[] - an array of response objects.
* @throws ChannelException
*/
public Response[] send(Member[] destination, Serializable message, int rpcOptions, int channelOptions, long timeout)
throws ChannelException {
if (destination == null || destination.length == 0)
return new Response[0];
// avoid dead lock
int sendOptions = channelOptions & ~Channel.SEND_OPTIONS_SYNCHRONIZED_ACK;
RpcCollectorKey key = new RpcCollectorKey(UUIDGenerator.randomUUID(false));
RpcCollector collector = new RpcCollector(key, rpcOptions, destination.length);
try {
synchronized (collector) {
if (rpcOptions != NO_REPLY)
responseMap.put(key, collector);
RpcMessage rmsg = new RpcMessage(rpcId, key.id, message);
channel.send(destination, rmsg, sendOptions);
if (rpcOptions != NO_REPLY)
collector.wait(timeout);
}
} catch (InterruptedException ix) {
Thread.currentThread().interrupt();
} finally {
responseMap.remove(key);
}
return collector.getResponses();
}
示例6: createElectionMsg
import org.apache.catalina.tribes.util.UUIDGenerator; //导入方法依赖的package包/类
private CoordinationMessage createElectionMsg(MemberImpl local, MemberImpl[] others, MemberImpl leader) {
Membership m = new Membership(local, AbsoluteOrder.comp, true);
Arrays.fill(m, others);
MemberImpl[] mbrs = m.getMembers();
m.reset();
CoordinationMessage msg = new CoordinationMessage(leader, local, mbrs,
new UniqueId(UUIDGenerator.randomUUID(true)), COORD_REQUEST);
return msg;
}
示例7: send
import org.apache.catalina.tribes.util.UUIDGenerator; //导入方法依赖的package包/类
/**
* Send a message and wait for the response.
* @param destination Member[] - the destination for the message, and the members you request a reply from
* @param message Serializable - the message you are sending out
* @param rpcOptions int - FIRST_REPLY, MAJORITY_REPLY or ALL_REPLY
* @param channelOptions channel sender options
* @param timeout long - timeout in milliseconds, if no reply is received within this time null is returned
* @return Response[] - an array of response objects.
* @throws ChannelException
*/
public Response[] send(Member[] destination,
Serializable message,
int rpcOptions,
int channelOptions,
long timeout) throws ChannelException {
if ( destination==null || destination.length == 0 ) return new Response[0];
//avoid dead lock
int sendOptions =
channelOptions & ~Channel.SEND_OPTIONS_SYNCHRONIZED_ACK;
RpcCollectorKey key = new RpcCollectorKey(UUIDGenerator.randomUUID(false));
RpcCollector collector = new RpcCollector(key,rpcOptions,destination.length);
try {
synchronized (collector) {
if ( rpcOptions != NO_REPLY ) responseMap.put(key, collector);
RpcMessage rmsg = new RpcMessage(rpcId, key.id, message);
channel.send(destination, rmsg, sendOptions);
if ( rpcOptions != NO_REPLY ) collector.wait(timeout);
}
} catch ( InterruptedException ix ) {
Thread.currentThread().interrupt();
}finally {
responseMap.remove(key);
}
return collector.getResponses();
}
示例8: send
import org.apache.catalina.tribes.util.UUIDGenerator; //导入方法依赖的package包/类
/**
* Send a message and wait for the response.
* @param destination Member[] - the destination for the message, and the members you request a reply from
* @param message Serializable - the message you are sending out
* @param rpcOptions int - FIRST_REPLY, MAJORITY_REPLY or ALL_REPLY
* @param channelOptions channel sender options
* @param timeout long - timeout in milliseconds, if no reply is received within this time null is returned
* @return Response[] - an array of response objects.
* @throws ChannelException
*/
public Response[] send(Member[] destination,
Serializable message,
int rpcOptions,
int channelOptions,
long timeout) throws ChannelException {
if ( destination==null || destination.length == 0 ) return new Response[0];
//avoid dead lock
int sendOptions =
channelOptions & ~Channel.SEND_OPTIONS_SYNCHRONIZED_ACK;
RpcCollectorKey key = new RpcCollectorKey(UUIDGenerator.randomUUID(false));
RpcCollector collector = new RpcCollector(key,rpcOptions,destination.length,timeout);
try {
synchronized (collector) {
if ( rpcOptions != NO_REPLY ) responseMap.put(key, collector);
RpcMessage rmsg = new RpcMessage(rpcId, key.id, message);
channel.send(destination, rmsg, sendOptions);
if ( rpcOptions != NO_REPLY ) collector.wait(timeout);
}
} catch ( InterruptedException ix ) {
Thread.currentThread().interrupt();
}finally {
responseMap.remove(key);
}
return collector.getResponses();
}
示例9: generateUUID
import org.apache.catalina.tribes.util.UUIDGenerator; //导入方法依赖的package包/类
/**
* Generates a UUID and invokes setUniqueId
*/
public void generateUUID() {
byte[] data = new byte[16];
UUIDGenerator.randomUUID(USE_SECURE_RANDOM_FOR_UUID,data,0);
setUniqueId(data);
}
示例10: generateUUID
import org.apache.catalina.tribes.util.UUIDGenerator; //导入方法依赖的package包/类
/**
* Generates a UUID and invokes setUniqueId
*/
public void generateUUID() {
byte[] data = new byte[16];
UUIDGenerator.randomUUID(USE_SECURE_RANDOM_FOR_UUID, data, 0);
setUniqueId(data);
}