本文整理汇总了Java中org.jgroups.util.UUID类的典型用法代码示例。如果您正苦于以下问题:Java UUID类的具体用法?Java UUID怎么用?Java UUID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UUID类属于org.jgroups.util包,在下文中一共展示了UUID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: remoteCacheWithoutProperties
import org.jgroups.util.UUID; //导入依赖的package包/类
@Test
public void remoteCacheWithoutProperties() throws Exception {
InfinispanConfiguration configuration = new InfinispanConfiguration();
configuration.setHost("localhost");
configuration.setCacheName("misc_cache");
InfinispanManager manager = new InfinispanManager(configuration);
manager.start();
BasicCache<Object, Object> cache = manager.getCache();
assertNotNull(cache);
assertTrue(cache instanceof RemoteCache);
RemoteCache<Object, Object> remoteCache = InfinispanUtil.asRemote(cache);
String key = UUID.randomUUID().toString();
assertNull(remoteCache.put(key, "val1"));
assertNull(remoteCache.put(key, "val2"));
manager.stop();
}
示例2: remoteCacheWithPropertiesTest
import org.jgroups.util.UUID; //导入依赖的package包/类
@Test
public void remoteCacheWithPropertiesTest() throws Exception {
InfinispanConfiguration configuration = new InfinispanConfiguration();
configuration.setHost("localhost");
configuration.setCacheName("misc_cache");
configuration.setConfigurationUri("infinispan/client.properties");
InfinispanManager manager = new InfinispanManager(configuration);
manager.start();
BasicCache<Object, Object> cache = manager.getCache();
assertNotNull(cache);
assertTrue(cache instanceof RemoteCache);
String key = UUID.randomUUID().toString();
assertNull(cache.put(key, "val1"));
assertNotNull(cache.put(key, "val2"));
manager.stop();
}
示例3: 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;
}
示例4: up
import org.jgroups.util.UUID; //导入依赖的package包/类
public void up(MessageBatch batch) {
for(Message msg: batch) {
Relay2Header hdr=(Relay2Header)msg.getHeader(id);
Address dest=msg.getDest();
if(hdr == null) {
// forward a multicast message to all bridges except myself, then pass up
if(dest == null && is_site_master && relay_multicasts && !msg.isFlagSet(Message.Flag.NO_RELAY)) {
Address src=msg.getSrc();
Address sender=new SiteUUID((UUID)msg.getSrc(), UUID.get(msg.getSrc()), site);
if(src instanceof ExtendedUUID)
((SiteUUID)sender).addContents((ExtendedUUID)src);
sendToBridges(sender, msg, site);
}
}
else { // header is not null
batch.remove(msg); // message is consumed
if(dest != null)
handleMessage(hdr, msg);
else
deliver(null, hdr.original_sender, msg);
}
}
if(!batch.isEmpty())
up_prot.up(batch);
}
示例5: sendDiscoveryRequest
import org.jgroups.util.UUID; //导入依赖的package包/类
protected void sendDiscoveryRequest(String cluster_name, List<Address> members_to_find) throws Exception {
PhysicalAddress physical_addr=(PhysicalAddress)down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr));
// https://issues.jboss.org/browse/JGRP-1670
PingData data=new PingData(local_addr, false, UUID.get(local_addr), physical_addr);
PingHeader hdr=new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name);
if(members_to_find != null && members_to_find.size() <= max_members_in_discovery_request)
data.mbrs(members_to_find);
// message needs to have DONT_BUNDLE flag: if A sends message M to B, and we need to fetch B's physical
// address, then the bundler thread blocks until the discovery request has returned. However, we cannot send
// the discovery *request* until the bundler thread has returned from sending M
Message msg=new Message(null).putHeader(getId(),hdr).setBuffer(marshal(data))
.setFlag(Message.Flag.INTERNAL,Message.Flag.DONT_BUNDLE,Message.Flag.OOB)
.setTransientFlag(Message.TransientFlag.DONT_LOOPBACK);
sendMcastDiscoveryRequest(msg);
}
示例6: handleConnect
import org.jgroups.util.UUID; //导入依赖的package包/类
private void handleConnect(GossipData request, Address addr, String group) throws Exception {
try {
checkExistingConnection(addr, group);
String logical_name = request.getLogicalName();
if (logical_name != null && addr instanceof org.jgroups.util.UUID)
org.jgroups.util.UUID.add(addr, logical_name);
// group name, logical address, logical name, physical addresses (could be null)
logical_addrs.add(addr); // allows us to remove the entries for this connection on socket close
addGroup(group, addr, this);
if(request.getPhysicalAddress() != null)
address_mappings.put(addr, request.getPhysicalAddress());
sendStatus(CONNECT_OK);
log.debug("connection handshake completed, added %s to group %s", addr, group);
} catch (Exception e) {
removeEntry(group, addr);
sendStatus(OP_FAIL);
throw new Exception("Unsuccessful connection setup handshake for " + this);
}
}
示例7: 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);
}
示例8: testResponsesComplete3
import org.jgroups.util.UUID; //导入依赖的package包/类
public void testResponsesComplete3() {
Address one=new SiteUUID((UUID)Util.createRandomAddress("lon1"), "lon1", "LON");
Address two=new SiteUUID((UUID)Util.createRandomAddress("sfo1"), "sfo1", "SFO");
Address three=new SiteUUID((UUID)Util.createRandomAddress("nyc1"), "nyc1", "NYC");
GroupRequest<Integer> req=new GroupRequest<>(null, null, Arrays.asList(one, two, three), RequestOptions.SYNC());
req.suspect(one);
req.receiveResponse(1, one, false);
req.siteUnreachable("LON");
checkComplete(req, false);
req.siteUnreachable("SFO");
req.receiveResponse(2, two, false);
req.suspect(two);
checkComplete(req, false);
req.siteUnreachable("NYC");
checkComplete(req, true);
req.suspect(three);
checkComplete(req, true);
req.receiveResponse(3, three, false);
checkComplete(req, true);
}
示例9: testMergeId
import org.jgroups.util.UUID; //导入依赖的package包/类
public static void testMergeId() throws Exception {
MergeId id=MergeId.create(UUID.randomUUID());
System.out.println("id = " + id);
_testSize(id);
id=MergeId.create(UUID.randomUUID());
System.out.println("id = " + id);
_testSize(id);
Address addr=UUID.randomUUID();
id=MergeId.create(addr);
System.out.println("id = " + id);
_testSize(id);
id=MergeId.create(addr);
System.out.println("id = " + id);
_testSize(id);
id=MergeId.create(addr);
System.out.println("id = " + id);
_testSize(id);
}
示例10: testArraySameSize
import org.jgroups.util.UUID; //导入依赖的package包/类
@Test
public void testArraySameSize() {
UUID node1 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node2 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node3 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node4 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node5 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node6 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID[] left = new UUID[]{node1, node3, node4, node5};
UUID[] right = new UUID[]{node1, node2, node4, node6};
Arrays.sort(left);
Arrays.sort(right);
List<ComparedValue<UUID>> comparedValues = ArrayUtils.compareSorted(left, right);
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node1, ComparedType.EQUAL)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node2, ComparedType.RIGHT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node3, ComparedType.LEFT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node4, ComparedType.EQUAL)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node5, ComparedType.LEFT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node6, ComparedType.RIGHT)));
}
示例11: testArrayLeftSideEmpty
import org.jgroups.util.UUID; //导入依赖的package包/类
@Test
public void testArrayLeftSideEmpty() {
UUID node1 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node2 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node4 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node6 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID[] left = new UUID[]{};
UUID[] right = new UUID[]{node1, node2, node4, node6};
Arrays.sort(left);
Arrays.sort(right);
List<ComparedValue<UUID>> comparedValues = ArrayUtils.compareSorted(left, right);
System.out.println(comparedValues);
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node1, ComparedType.RIGHT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node2, ComparedType.RIGHT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node4, ComparedType.RIGHT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node6, ComparedType.RIGHT)));
}
示例12: testArrayRightSideEmpty
import org.jgroups.util.UUID; //导入依赖的package包/类
@Test
public void testArrayRightSideEmpty() {
UUID node1 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node2 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node3 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node4 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node5 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node6 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID[] left = new UUID[]{node1, node2, node4, node6};
UUID[] right = new UUID[]{};
Arrays.sort(left);
Arrays.sort(right);
List<ComparedValue<UUID>> comparedValues = ArrayUtils.compareSorted(left, right);
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node1, ComparedType.LEFT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node2, ComparedType.LEFT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node4, ComparedType.LEFT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node6, ComparedType.LEFT)));
}
示例13: testArrayTotallyDifferent
import org.jgroups.util.UUID; //导入依赖的package包/类
@Test
public void testArrayTotallyDifferent() {
UUID node1 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node2 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node3 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node4 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node5 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID node6 = new UUID((long) (Math.random() * Long.MAX_VALUE), (long) (Math.random() * Long.MAX_VALUE));
UUID[] left = new UUID[]{node1, node2, node4};
UUID[] right = new UUID[]{node3, node5, node6};
Arrays.sort(left);
Arrays.sort(right);
List<ComparedValue<UUID>> comparedValues = ArrayUtils.compareSorted(left, right);
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node1, ComparedType.LEFT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node2, ComparedType.LEFT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node3, ComparedType.RIGHT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node4, ComparedType.LEFT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node5, ComparedType.RIGHT)));
Assert.assertTrue(comparedValues.contains(new ComparedValue<>(node6, ComparedType.RIGHT)));
}
示例14: testDeployAndRetrievePlan
import org.jgroups.util.UUID; //导入依赖的package包/类
@Test
public void testDeployAndRetrievePlan() throws Exception {
final String planId = UUID.randomUUID().toString();
final String planUri = SCAPE_URL + "/plan/" + planId;
final File f =
new File(this.getClass().getClassLoader().getResource(
"plato-plan.xml").getFile());
putPlanAndAssertCreated(planId, new FileInputStream(f), f.length());
/* check that the plan can be retrieved */
HttpGet get = new HttpGet(planUri);
HttpResponse resp = this.client.execute(get);
assertEquals(200, resp.getStatusLine().getStatusCode());
/* check that the xml is the same as deployed */
final String planXml = EntityUtils.toString(resp.getEntity());
assertEquals(IOUtils.toString(new FileInputStream(f)), planXml);
get.releaseConnection();
}
示例15: testDeployAndRetrieveLifecycleState
import org.jgroups.util.UUID; //导入依赖的package包/类
@Test
public void testDeployAndRetrieveLifecycleState() throws Exception {
final String planId = UUID.randomUUID().toString();
final String planUri = SCAPE_URL + "/plan/" + planId;
final File f =
new File(this.getClass().getClassLoader().getResource(
"plato-plan.xml").getFile());
putPlanAndAssertCreated(planId, new FileInputStream(f), f.length());
final HttpGet get = new HttpGet(SCAPE_URL + "/plan-state/" + planId);
HttpResponse resp = this.client.execute(get);
String state = EntityUtils.toString(resp.getEntity());
assertEquals(200, resp.getStatusLine().getStatusCode());
assertEquals("ENABLED:Initial deployment", state);
get.releaseConnection();
}