List of usage examples for java.util UUID randomUUID
public static UUID randomUUID()
From source file:Main.java
public static void main(String[] args) { // creating UUID UUID uid = UUID.randomUUID(); // checking node value System.out.println("Node value is: " + uid.node()); }
From source file:Main.java
public static void main(String[] args) { // creating UUIDs UUID u1 = UUID.randomUUID(); UUID u2 = UUID.randomUUID(); // comparing uuids System.out.println("Comparing two UUIDs: " + u1.compareTo(u2)); }
From source file:Main.java
public static void main(String[] args) { // creating two UUIDs UUID u1 = UUID.randomUUID(); UUID u2 = UUID.randomUUID(); // checking equality System.out.println("Is two UUIDs equal: " + u1.equals(u2)); }
From source file:Main.java
public static void main(final String[] args) { ConcurrentHashMap<Integer, UUID> concurrentHashMap = new ConcurrentHashMap<>(); for (int i = 0; i < 100; i++) { concurrentHashMap.put(i, UUID.randomUUID()); }/* w w w. j a v a 2 s . co m*/ int threshold = 1; concurrentHashMap.forEachValue(threshold, System.out::println); concurrentHashMap.forEach((id, uuid) -> { if (id % 10 == 0) { System.out.println(String.format("%s: %s", id, uuid)); } }); String searchResult = concurrentHashMap.search(threshold, (id, uuid) -> { if (String.valueOf(uuid).contains(String.valueOf(id))) { return new String(id + ":" + uuid); } return null; }); System.out.println(searchResult); }
From source file:Main.java
public static void main(String[] args) { Map<String, String> map = new ConcurrentHashMap<String, String>(); for (int i = 0; i < MAP_SIZE; i++) { map.put("key:" + i, UUID.randomUUID().toString()); }//from ww w. j a v a2s .c om ExecutorService executor = Executors.newCachedThreadPool(); Accessor a1 = new Accessor(map); Accessor a2 = new Accessor(map); Mutator m = new Mutator(map); executor.execute(a1); executor.execute(m); executor.execute(a2); }
From source file:com.mycompany.integration.NewMain.java
/** * @param args the command line arguments *///from w ww. j a v a 2 s . com public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("spring-integration.xml"); MessageChannel channel = context.getBean("toRabbit", MessageChannel.class); for (int i = 0; i < 10; i++) { channel.send(build(UUID.randomUUID().toString())); } }
From source file:com.doctor.ignite.example.spring.CrossCacheQueries.java
public static void main(String[] args) throws InterruptedException { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext( SpringIgniteConfig.class); Ignite ignite = applicationContext.getBean(Ignite.class); CacheConfiguration<UUID, Person> cacheConfiguration = applicationContext .getBean("CacheConfigurationForDays", CacheConfiguration.class); IgniteCache<UUID, Person> igniteCache1 = getCache("person1", ignite, cacheConfiguration); Person person = new Person(UUID.randomUUID(), "doctor -1 ", BigDecimal.valueOf(88888888.888), "man", "..."); igniteCache1.put(person.getId(), person); Person person1 = new Person(UUID.randomUUID(), "doctor 118", BigDecimal.valueOf(88888888.888), "man", "..."); igniteCache1.put(person1.getId(), person1); Person person2 = new Person(UUID.randomUUID(), "doctor who 88 ", BigDecimal.valueOf(188888888.888), "man", "..."); igniteCache1.put(person2.getId(), person2); IgniteCache<UUID, Person> igniteCache2 = getCache("person2", ignite, cacheConfiguration); Person person3 = new Person(UUID.randomUUID(), "doctor who ---88 ", BigDecimal.valueOf(1188888888.888), "man", "..."); igniteCache2.put(person3.getId(), person3); // try (QueryCursor<List<?>> queryCursor = igniteCache1.query(new SqlFieldsQuery("select name from Person"))) { // for (List<?> entry : queryCursor) { // System.out.println("--}}}}}" + entry); // }//from w w w. j ava 2 s. com // } SqlQuery sqlQuery = new SqlQuery<>(Person.class, "from Person , \"person2\".Person "); try (QueryCursor queryCursor = igniteCache1.query(sqlQuery)) { for (Object object : queryCursor) { System.out.println(object); } } applicationContext.close(); }
From source file:com.doctor.ignite.example.spring.SqlUnion.java
public static void main(String[] args) throws InterruptedException { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext( SpringIgniteConfig.class); Ignite ignite = applicationContext.getBean(Ignite.class); CacheConfiguration<UUID, Person> cacheConfiguration = applicationContext .getBean("CacheConfigurationForDays", CacheConfiguration.class); IgniteCache<UUID, Person> igniteCache1 = getCache("person1", ignite, cacheConfiguration); Person person = new Person(UUID.randomUUID(), "doctor -1 ", BigDecimal.valueOf(88888888.888), "man", "..."); igniteCache1.put(person.getId(), person); Person person1 = new Person(UUID.randomUUID(), "doctor 118", BigDecimal.valueOf(88888888.888), "man", "..."); igniteCache1.put(person1.getId(), person1); Person person2 = new Person(UUID.randomUUID(), "doctor who 88 ", BigDecimal.valueOf(188888888.888), "man", "..."); igniteCache1.put(person2.getId(), person2); IgniteCache<UUID, Person> igniteCache2 = getCache("person2", ignite, cacheConfiguration); Person person3 = new Person(UUID.randomUUID(), "doctor who ---88 ", BigDecimal.valueOf(1188888888.888), "man", "..."); igniteCache2.put(person3.getId(), person3); SqlFieldsQuery sqlFieldsQuery = new SqlFieldsQuery( "select _val from Person union all select _val from \"person2\".Person"); try (QueryCursor queryCursor = igniteCache1.query(sqlFieldsQuery)) { for (Object object : queryCursor) { System.out.println(object); }//from w w w. j a v a 2 s . c o m } applicationContext.close(); }
From source file:ch.rasc.wampspring.demo.client.CallClient.java
public static void main(String[] args) throws InterruptedException { WebSocketClient webSocketClient = new StandardWebSocketClient(); JsonFactory jsonFactory = new MappingJsonFactory(new ObjectMapper()); CountDownLatch latch = new CountDownLatch(1_000_000); TestTextWebSocketHandler handler = new TestTextWebSocketHandler(jsonFactory, latch); Long[] start = new Long[1]; ListenableFuture<WebSocketSession> future = webSocketClient.doHandshake(handler, "ws://localhost:8080/wamp"); future.addCallback(wss -> {//w ww . ja va 2s . co m start[0] = System.currentTimeMillis(); for (int i = 0; i < 1_000_000; i++) { CallMessage callMessage = new CallMessage(UUID.randomUUID().toString(), "testService.sum", i, i + 1); try { wss.sendMessage(new TextMessage(callMessage.toJson(jsonFactory))); } catch (Exception e) { System.out.println("ERROR SENDING CALLMESSAGE" + e); latch.countDown(); } } }, t -> { System.out.println("DO HANDSHAKE ERROR: " + t); System.exit(1); }); if (!latch.await(3, TimeUnit.MINUTES)) { System.out.println("SOMETHING WENT WRONG"); } System.out.println((System.currentTimeMillis() - start[0]) / 1000 + " seconds"); System.out.println("SUCCESS: " + handler.getSuccess()); System.out.println("ERROR : " + handler.getError()); }
From source file:backup.store.ExternalExtendedBlockSort.java
public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); Path dir = new Path("file:///home/apm/Development/git-projects/hdfs-backup/hdfs-backup-core/tmp"); dir.getFileSystem(conf).delete(dir, true); long start = System.nanoTime(); try (ExternalExtendedBlockSort<LongWritable> sort = new ExternalExtendedBlockSort<>(conf, dir, LongWritable.class)) { Random random = new Random(); for (int bp = 0; bp < 1; bp++) { String bpid = UUID.randomUUID().toString(); for (int i = 0; i < 10000000; i++) { // for (int i = 0; i < 10; i++) { long genstamp = random.nextInt(20000); long blockId = random.nextLong(); ExtendedBlock extendedBlock = new ExtendedBlock(bpid, blockId, random.nextInt(Integer.MAX_VALUE), genstamp); sort.add(extendedBlock, new LongWritable(blockId)); }/*from ww w. jav a 2s . c o m*/ } System.out.println("finished"); sort.finished(); System.out.println("interate"); for (String blockPoolId : sort.getBlockPoolIds()) { ExtendedBlockEnum<LongWritable> blockEnum = sort.getBlockEnum(blockPoolId); ExtendedBlock block; long l = 0; while ((block = blockEnum.next()) != null) { // System.out.println(block); long blockId = block.getBlockId(); l += blockId; LongWritable currentValue = blockEnum.currentValue(); if (currentValue.get() != blockId) { System.err.println("Error " + blockId); } } System.out.println(l); } } long end = System.nanoTime(); System.out.println("Time [" + (end - start) / 1000000.0 + " ms]"); }