org.jgroups.util.UUID.randomUUID()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.jgroups.util.UUID.randomUUID()方法的一些代码示例,展示了UUID.randomUUID()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UUID.randomUUID()方法的具体详情如下:
包路径:org.jgroups.util.UUID
类名称:UUID
方法名:randomUUID

UUID.randomUUID介绍

[英]Static factory to retrieve a type 4 (pseudo randomly generated) UUID. The UUID is generated using a cryptographically strong pseudo random number generator.
[中]

代码示例

代码示例来源:origin: wildfly/wildfly

public static Address createRandomAddress(String name) {
  UUID retval=UUID.randomUUID();
  NameCache.add(retval,name);
  return retval;
}

代码示例来源:origin: wildfly/wildfly

public static String getUniqueClusterName(String base_name) {
  return base_name != null ? base_name + "-" + UUID.randomUUID().toString()
   : UUID.randomUUID().toString();
}

代码示例来源:origin: wildfly/wildfly

protected Address generateAddress() {
  if(address_generators == null || address_generators.isEmpty())
    return UUID.randomUUID();
  if(address_generators.size() == 1)
    return address_generators.get(0).generateAddress();
  // at this point we have multiple AddressGenerators installed
  Address[] addrs=new Address[address_generators.size()];
  for(int i=0; i < addrs.length; i++)
    addrs[i]=address_generators.get(i).generateAddress();
  for(int i=0; i < addrs.length; i++) {
    if(!(addrs[i] instanceof ExtendedUUID)) {
      log.error("address generator %s does not subclass %s which is required if multiple address generators " +
            "are installed, removing it", addrs[i].getClass().getSimpleName(), ExtendedUUID.class.getSimpleName());
      addrs[i]=null;
    }
  }
  ExtendedUUID uuid=null;
  for(int i=0; i < addrs.length; i++) { // we only have ExtendedUUIDs in addrs
    if(addrs[i] != null) {
      if(uuid == null)
        uuid=(ExtendedUUID)addrs[i];
      else
        uuid.addContents((ExtendedUUID)addrs[i]);
    }
  }
  return uuid != null? uuid : UUID.randomUUID();
}

代码示例来源:origin: wildfly/wildfly

for(RelayConfig.BridgeConfig bridge_config: bridge_configs) {
  Bridge bridge=new Bridge(bridge_config.createChannel(), bridge_config.getClusterName(), bridge_name,
               () -> new SiteUUID(UUID.randomUUID(), null, my_site_id));
  bridges.add(bridge);

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public static Address createRandomAddress(String name) {
  UUID retval=UUID.randomUUID();
  NameCache.add(retval,name);
  return retval;
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public static String getUniqueClusterName(String base_name) {
  return base_name != null ? base_name + "-" + UUID.randomUUID().toString()
   : UUID.randomUUID().toString();
}

代码示例来源:origin: org.integratedmodelling/klab-common

private void createSignature() {
  File sigFile = new File(KLAB.CONFIG.getDataPath("engine") + File.separator + ".clientsig");
  if (!sigFile.exists()) {
    this.signature = UUID.randomUUID().toString();
    try {
      FileUtils.writeStringToFile(sigFile, this.signature);
    } catch (IOException e) {
      // ignore; engine will work in remote mode.grazie
    }
  } else {
    try {
      this.signature = FileUtils.readFileToString(sigFile);
    } catch (IOException e) {
      /*
       * ok, have it the hard way.
       */
      this.signature = UUID.randomUUID().toString();
    }
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

protected Address generateAddress() {
  if(address_generators == null || address_generators.isEmpty())
    return UUID.randomUUID();
  if(address_generators.size() == 1)
    return address_generators.get(0).generateAddress();
  // at this point we have multiple AddressGenerators installed
  Address[] addrs=new Address[address_generators.size()];
  for(int i=0; i < addrs.length; i++)
    addrs[i]=address_generators.get(i).generateAddress();
  for(int i=0; i < addrs.length; i++) {
    if(!(addrs[i] instanceof ExtendedUUID)) {
      log.error("address generator %s does not subclass %s which is required if multiple address generators " +
            "are installed, removing it", addrs[i].getClass().getSimpleName(), ExtendedUUID.class.getSimpleName());
      addrs[i]=null;
    }
  }
  ExtendedUUID uuid=null;
  for(int i=0; i < addrs.length; i++) { // we only have ExtendedUUIDs in addrs
    if(addrs[i] != null) {
      if(uuid == null)
        uuid=(ExtendedUUID)addrs[i];
      else
        uuid.addContents((ExtendedUUID)addrs[i]);
    }
  }
  return uuid != null? uuid : UUID.randomUUID();
}

代码示例来源:origin: org.infinispan/infinispan-core

public static Address generateAddress() {
   return new JGroupsAddress(UUID.randomUUID());
  }
}

代码示例来源:origin: org.infinispan/infinispan-core

protected List<Address> createAddresses(int numNodes) {
 ArrayList<Address> addresses = new ArrayList<Address>(numNodes);
 for (int i = 0; i < numNodes; i++) {
   addresses.add(new IndexedJGroupsAddress(UUID.randomUUID(), i));
 }
 return addresses;
}

代码示例来源:origin: org.jbpm/jbpm-wb-integration-backend

private static ObjectModel getObjectModelParameter(String resolver) {
  return new ObjectModel(resolver,
              UUID.randomUUID().toString(),
              Integer.toString(random.nextInt(100000)));
}

代码示例来源:origin: org.jbpm/jbpm-console-ng-workbench-integration-backend

private static ObjectModel getObjectModelParameter( String resolver ) {
    return new ObjectModel(resolver, UUID.randomUUID().toString(), Integer.toString(random.nextInt(100000)));
  }
}

代码示例来源:origin: kiegroup/jbpm-wb

private static ObjectModel getObjectModelParameter(String resolver) {
  return new ObjectModel(resolver,
              UUID.randomUUID().toString(),
              Integer.toString(random.nextInt(100000)));
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testJGroupsAddressMarshalling() throws Exception {
 JGroupsAddress address = new JGroupsAddress(UUID.randomUUID());
 marshallAndAssertEquality(address);
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testSingletonListMarshalling() throws Exception {
 GlobalTransaction gtx = gtf.newGlobalTransaction(new JGroupsAddress(UUID.randomUUID()), false);
 List<GlobalTransaction> l = Collections.singletonList(gtx);
 marshallAndAssertEquality(l);
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testGlobalTransactionMarshalling() throws Exception {
 JGroupsAddress jGroupsAddress = new JGroupsAddress(UUID.randomUUID());
 GlobalTransaction gtx = gtf.newGlobalTransaction(jGroupsAddress, false);
 marshallAndAssertEquality(gtx);
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testMapMarshalling() throws Exception {
 Map<Integer, GlobalTransaction> m1 = new HashMap<>();
 Map<Integer, GlobalTransaction> m2 = new TreeMap<>();
 Map<Integer, GlobalTransaction> m3 = new HashMap<>();
 Map<Integer, GlobalTransaction> m4 = new FastCopyHashMap<>();
 for (int i = 0; i < 10; i++) {
   JGroupsAddress jGroupsAddress = new JGroupsAddress(UUID.randomUUID());
   GlobalTransaction gtx = gtf.newGlobalTransaction(jGroupsAddress, false);
   m1.put(1000 * i, gtx);
   m2.put(1000 * i, gtx);
   m4.put(1000 * i, gtx);
 }
 Map m5 = Immutables.immutableMapWrap(m3);
 marshallAndAssertEquality(m1);
 marshallAndAssertEquality(m2);
 byte[] bytes = marshaller.objectToByteBuffer(m4);
 Map<Integer, GlobalTransaction> m4Read = (Map<Integer, GlobalTransaction>) marshaller.objectFromByteBuffer(bytes);
 for (Map.Entry<Integer, GlobalTransaction> entry : m4.entrySet()) {
   assert m4Read.get(entry.getKey()).equals(entry.getValue()) : "Writen[" + entry.getValue() + "] and read[" + m4Read.get(entry.getKey()) + "] objects should be the same";
 }
 marshallAndAssertEquality(m5);
}

代码示例来源:origin: apache/activemq-artemis

@Test(timeout = 60000)
public void testMessageWithToFieldSetToRandomAddress() throws Exception {
 doTestMessageWithToFieldSet(false, UUID.randomUUID().toString());
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testStateTransferControlCommand() throws Exception {
 Cache<Object,Object> cache = cm.getCache();
 ByteString cacheName = ByteString.fromString(EmbeddedCacheManager.DEFAULT_CACHE_NAME);
 ImmortalCacheEntry entry1 = (ImmortalCacheEntry) TestInternalCacheEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, -1, System.currentTimeMillis(), -1);
 Collection<InternalCacheEntry> state = new ArrayList<>();
 state.add(entry1);
 Address a1 = new JGroupsAddress(UUID.randomUUID());
 Address a2 = new JGroupsAddress(UUID.randomUUID());
 Address a3 = new JGroupsAddress(UUID.randomUUID());
 List<Address> oldAddresses = new ArrayList<>();
 oldAddresses.add(a1);
 oldAddresses.add(a2);
 DefaultConsistentHashFactory chf = new DefaultConsistentHashFactory();
 DefaultConsistentHash oldCh = chf.create(MurmurHash3.getInstance(), 2, 3, oldAddresses, null);
 List<Address> newAddresses = new ArrayList<>();
 newAddresses.add(a1);
 newAddresses.add(a2);
 newAddresses.add(a3);
 DefaultConsistentHash newCh = chf.create(MurmurHash3.getInstance(), 2, 3, newAddresses, null);
 StateRequestCommand c14 = new StateRequestCommand(cacheName, StateRequestCommand.Type.START_STATE_TRANSFER, a1, 99, new SmallIntSet());
 byte[] bytes = marshaller.objectToByteBuffer(c14);
 marshaller.objectFromByteBuffer(bytes);
 bytes = marshaller.objectToByteBuffer(c14);
 marshaller.objectFromByteBuffer(bytes);
 bytes = marshaller.objectToByteBuffer(c14);
 marshaller.objectFromByteBuffer(bytes);
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testSynchronousIgnoreLeaversInvocationToNonMembers() throws Exception {
 UUID randomUuid = UUID.randomUUID();
 Address randomAddress = JGroupsAddressCache.fromJGroupsAddress(randomUuid);
 JGroupsTransport transport = (JGroupsTransport) manager(0).getTransport();
 long initialMessages = transport.getChannel().getSentMessages();
 ReplicableCommand command = new ClusteredGetCommand("key", CACHE_NAME, 0, 0);
 CompletableFuture<Map<Address, Response>> future = transport
    .invokeRemotelyAsync(Collections.singletonList(randomAddress), command,
               ResponseMode.SYNCHRONOUS_IGNORE_LEAVERS, 1, null, DeliverOrder.NONE, true);
 assertEquals(CacheNotFoundResponse.INSTANCE, future.get().get(randomAddress));
 assertEquals(initialMessages, transport.getChannel().getSentMessages());
}

相关文章