本文整理汇总了Java中org.jgroups.util.UUID.add方法的典型用法代码示例。如果您正苦于以下问题:Java UUID.add方法的具体用法?Java UUID.add怎么用?Java UUID.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgroups.util.UUID
的用法示例。
在下文中一共展示了UUID.add方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installView
import org.jgroups.util.UUID; //导入方法依赖的package包/类
protected Object installView(byte[] buf, int offset, int length) {
try {
ViewData data=(ViewData)Util.streamableFromByteBuffer(ViewData.class, buf, offset, length);
if(data.uuids != null)
UUID.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("failed installing view", e);
}
return null;
}
示例2: setAddress
import org.jgroups.util.UUID; //导入方法依赖的package包/类
/**
* Generates new UUID and sets local address. Sends down a REMOVE_ADDRESS (if existing address was present) and
* a SET_LOCAL_ADDRESS
*/
protected void setAddress() {
Address old_addr=local_addr;
local_addr=generateAddress();
if(old_addr != null)
down(new Event(Event.REMOVE_ADDRESS, old_addr));
if(name == null || name.isEmpty()) // generate a logical name if not set
name=Util.generateLocalName();
if(name != null && !name.isEmpty())
UUID.add(local_addr, name);
Event evt=new Event(Event.SET_LOCAL_ADDRESS, local_addr);
down(evt);
if(up_handler != null)
up_handler.up(evt);
}
示例3: addInfo
import org.jgroups.util.UUID; //导入方法依赖的package包/类
/** Adds received INFO to views hashmap */
protected void addInfo(Address sender, ViewId view_id, String logical_name, PhysicalAddress physical_addr) {
if(logical_name != null && sender instanceof UUID)
UUID.add(sender, logical_name);
if(physical_addr != null)
down(new Event(Event.SET_PHYSICAL_ADDRESS, new Tuple<>(sender, physical_addr)));
synchronized(views) {
ViewId existing=views.get(sender);
if(existing == null || existing.compareTo(view_id) < 0)
views.put(sender, view_id);
}
}
示例4: setPingData
import org.jgroups.util.UUID; //导入方法依赖的package包/类
protected void setPingData(PingData data) {
if(data.getAddress() != null) {
if(data.getPhysicalAddr() != null)
addPhysicalAddressToCache(data.getAddress(),data.getPhysicalAddr());
if(data.getLogicalName() != null)
UUID.add(data.getAddress(), data.getLogicalName());
}
}
示例5: readCacheFromDisk
import org.jgroups.util.UUID; //导入方法依赖的package包/类
/** Reads all mappings from disk */
protected synchronized void readCacheFromDisk() {
if(log.isDebugEnabled())
log.debug("reading all mappings from disk cache " + root_dir);
File[] files=root_dir.listFiles(filter);
if(files == null)
return;
for(File file: files) {
// implementing a simple spin lock doing a few attempts to read the file
// this is done since the file may be written in concurrency and may therefore not be readable
Mapping data=null;
for(int i=0; i < 3; i++) {
data=null;
if(file.exists())
data=readAddressMapping(file);
if(data != null)
break;
else
Util.sleep(100);
}
if(data == null) {
log.warn("failed parsing content in " + file.getAbsolutePath() + ": removing it ");
deleteFile(file);
}
else {
if(data != null && data.getLogicalAddr() != null && data.getPhysicalAddr() != null) {
cache.put(data.getLogicalAddr(), (PhysicalAddress)data.getPhysicalAddr());
if(data.getLogicalName() != null && UUID.get(data.getLogicalAddr()) == null)
UUID.add(data.getLogicalAddr(), data.getLogicalName());
}
}
}
}
示例6: addDiscoveryResponseToCaches
import org.jgroups.util.UUID; //导入方法依赖的package包/类
protected boolean addDiscoveryResponseToCaches(Address mbr, String logical_name, PhysicalAddress physical_addr) {
if(mbr == null)
return false;
if(logical_name != null)
UUID.add(mbr, logical_name);
if(physical_addr != null)
return (Boolean)down(new Event(Event.SET_PHYSICAL_ADDRESS, new Tuple<>(mbr, physical_addr)));
return false;
}
示例7: setName
import org.jgroups.util.UUID; //导入方法依赖的package包/类
@ManagedAttribute(writable=true, description="The logical name of this channel. Stays with the channel until " +
"the channel is closed")
public void setName(String name) {
if(name != null) {
if(isConnected())
throw new IllegalStateException("name cannot be set if channel is connected (should be done before)");
this.name=name;
if(local_addr != null)
UUID.add(local_addr, this.name);
}
}
示例8: testGossipData
import org.jgroups.util.UUID; //导入方法依赖的package包/类
public static void testGossipData() throws Exception {
GossipData data;
final Address own=org.jgroups.util.UUID.randomUUID();
final Address coord=org.jgroups.util.UUID.randomUUID();
UUID.add(own, "own");
UUID.add(coord, "coord");
final PhysicalAddress physical_addr_1=new IpAddress("127.0.0.1", 7500);
_testSize(new GossipData());
data=new GossipData((byte)1);
_testSize(data);
data=new GossipData((byte)1, "DemoCluster", own, (List<Address>)null, (PhysicalAddress)null);
_testSize(data);
data=new GossipData((byte)1, "DemoCluster", own, Arrays.asList(own, coord), (PhysicalAddress)null);
_testSize(data);
data=new GossipData((byte)1, "DemoCluster", own, Arrays.asList(own, coord), physical_addr_1);
_testSize(data);
data=new GossipData((byte)1, "demo", own, "logical_name", (PhysicalAddress)null);
_testSize(data);
data=new GossipData((byte)1, "demo", own, new byte[]{'b', 'e', 'l', 'a'});
_testSize(data);
byte[] buffer=new byte[10];
buffer[2]='B';
buffer[3]='e';
buffer[4]='l';
buffer[5]='a';
data=new GossipData((byte)1, "demo", own, buffer, 2, 4);
_testSize(data);
}
示例9: randomUUID
import org.jgroups.util.UUID; //导入方法依赖的package包/类
public static CanBeSiteMaster randomUUID(String logical_name, boolean can_become_site_master) {
CanBeSiteMaster retval=new CanBeSiteMaster(generateRandomBytes(), can_become_site_master);
UUID.add(retval, logical_name);
return retval;
}