当前位置: 首页>>代码示例>>Java>>正文


Java UUID类代码示例

本文整理汇总了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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:InfinispanConfigurationTestIT.java

示例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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:InfinispanConfigurationTestIT.java

示例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;
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:23,代码来源:RELAY.java

示例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);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:27,代码来源:RELAY2.java

示例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);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:19,代码来源:PING.java

示例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);
    }
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:24,代码来源:GossipRouter.java

示例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);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:20,代码来源:JChannel.java

示例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);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:24,代码来源:GroupRequestTest.java

示例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);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:23,代码来源:SizeTest.java

示例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)));
}
 
开发者ID:vert-x3,项目名称:vertx-jgroups,代码行数:24,代码来源:TestArrayUtils.java

示例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)));
}
 
开发者ID:vert-x3,项目名称:vertx-jgroups,代码行数:22,代码来源:TestArrayUtils.java

示例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)));
}
 
开发者ID:vert-x3,项目名称:vertx-jgroups,代码行数:22,代码来源:TestArrayUtils.java

示例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)));
}
 
开发者ID:vert-x3,项目名称:vertx-jgroups,代码行数:24,代码来源:TestArrayUtils.java

示例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();
}
 
开发者ID:fasseg,项目名称:fcrepo4-scape,代码行数:21,代码来源:PlanIT.java

示例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();
}
 
开发者ID:fasseg,项目名称:fcrepo4-scape,代码行数:18,代码来源:PlanIT.java


注:本文中的org.jgroups.util.UUID类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。