List of usage examples for java.util UUID randomUUID
public static UUID randomUUID()
From source file:io.mapzone.arena.csw.InsertRecordRequest.java
/** * Test./* www .j a v a2 s . c om*/ */ public static final void main(String[] args) throws Exception { RecordXML record = new RecordXML(); CswMetadataDCMI md = new CswMetadataDCMI(null, record); md.setIdentifier(UUID.randomUUID().toString()); md.setTitle("Test"); md.setDescription("HashCode: " + md.hashCode()); InsertRecordRequest request = new InsertRecordRequest(record).baseUrl.put("http://localhost:8090/csw"); request.execute(new NullProgressMonitor()); }
From source file:com.doctor.ignite.example.spring.SpringIgniteExample.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> igniteCache2 = ignite.cache("cacheForDays"); if (igniteCache2 == null) { CacheConfiguration<UUID, Person> cacheConfiguration2 = new CacheConfiguration<>(cacheConfiguration); cacheConfiguration2.setName("cacheForDays"); igniteCache2 = ignite.createCache(cacheConfiguration2); System.out.println("--------createCache:" + "cacheForDays"); }/* ww w .j a va2s . c o m*/ Person person = new Person(UUID.randomUUID(), "doctor", BigDecimal.valueOf(88888888.888), "man", "..."); System.out.println(igniteCache2.get(person.getId())); igniteCache2.put(person.getId(), person); System.out.println(igniteCache2.get(person.getId())); TimeUnit.SECONDS.sleep(6); System.out.println(igniteCache2.get(person.getId())); System.out.println(""); Person person1 = new Person(UUID.randomUUID(), "doctor 118", BigDecimal.valueOf(88888888.888), "man", "..."); igniteCache2.put(person1.getId(), person1); Person person2 = new Person(UUID.randomUUID(), "doctor who 88 ", BigDecimal.valueOf(188888888.888), "man", "..."); igniteCache2.put(person2.getId(), person2); try (QueryCursor<List<?>> queryCursor = igniteCache2.query(new SqlFieldsQuery("select name from Person"))) { for (List<?> entry : queryCursor) { System.out.println(entry); } } applicationContext.close(); }
From source file:com.manisha.allmybooksarepacked.utility.JSONUtils.java
public static void main(String[] args) throws IOException { Book one = new Book(); one.setIsbn10(UUID.randomUUID().toString()); Book two = new Book(); one.setIsbn10(UUID.randomUUID().toString()); List<Book> bookList = new ArrayList<>(); bookList.add(one);//from ww w. j av a 2s .c o m bookList.add(two); System.out.println(objectToJSON(bookList)); }
From source file:com.btoddb.fastpersitentqueue.speedtest.SpeedTest.java
public static void main(String[] args) throws Exception { if (0 == args.length) { System.out.println();//from w w w. j av a2 s . co m System.out.println("ERROR: must specify the config file path/name"); System.out.println(); System.exit(1); } SpeedTestConfig config = SpeedTestConfig.create(args[0]); System.out.println(config.toString()); File theDir = new File(config.getDirectory(), "speed-" + UUID.randomUUID().toString()); FileUtils.forceMkdir(theDir); Fpq queue = config.getFpq(); queue.setJournalDirectory(new File(theDir, "journals")); queue.setPagingDirectory(new File(theDir, "pages")); try { queue.init(); // // start workers // AtomicLong counter = new AtomicLong(); AtomicLong pushSum = new AtomicLong(); AtomicLong popSum = new AtomicLong(); long startTime = System.currentTimeMillis(); Set<SpeedPushWorker> pushWorkers = new HashSet<SpeedPushWorker>(); for (int i = 0; i < config.getNumberOfPushers(); i++) { pushWorkers.add(new SpeedPushWorker(queue, config, counter, pushSum)); } Set<SpeedPopWorker> popWorkers = new HashSet<SpeedPopWorker>(); for (int i = 0; i < config.getNumberOfPoppers(); i++) { popWorkers.add(new SpeedPopWorker(queue, config, popSum)); } ExecutorService pusherExecSrvc = Executors.newFixedThreadPool( config.getNumberOfPushers() + config.getNumberOfPoppers(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { Thread t = new Thread(runnable); t.setName("SpeedTest-Pusher"); return t; } }); ExecutorService popperExecSrvc = Executors.newFixedThreadPool( config.getNumberOfPushers() + config.getNumberOfPoppers(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { Thread t = new Thread(runnable); t.setName("SpeedTest-Popper"); return t; } }); long startPushing = System.currentTimeMillis(); for (SpeedPushWorker sw : pushWorkers) { pusherExecSrvc.submit(sw); } long startPopping = System.currentTimeMillis(); for (SpeedPopWorker sw : popWorkers) { popperExecSrvc.submit(sw); } // // wait to finish // long endTime = startTime + config.getDurationOfTest() * 1000; long endPushing = 0; long displayTimer = 0; while (0 == endPushing || !queue.isEmpty()) { // display status every second if (1000 < (System.currentTimeMillis() - displayTimer)) { System.out.println(String.format("status (%ds) : journals = %d : memory segments = %d", (endTime - System.currentTimeMillis()) / 1000, queue.getJournalMgr().getJournalIdMap().size(), queue.getMemoryMgr().getSegments().size())); displayTimer = System.currentTimeMillis(); } pusherExecSrvc.shutdown(); if (pusherExecSrvc.awaitTermination(100, TimeUnit.MILLISECONDS)) { endPushing = System.currentTimeMillis(); // tell poppers, all pushers are finished for (SpeedPopWorker sw : popWorkers) { sw.stopWhenQueueEmpty(); } } } long endPopping = System.currentTimeMillis(); popperExecSrvc.shutdown(); popperExecSrvc.awaitTermination(10, TimeUnit.SECONDS); long numberOfPushes = 0; for (SpeedPushWorker sw : pushWorkers) { numberOfPushes += sw.getNumberOfEntries(); } long numberOfPops = 0; for (SpeedPopWorker sw : popWorkers) { numberOfPops += sw.getNumberOfEntries(); } long pushDuration = endPushing - startPushing; long popDuration = endPopping - startPopping; System.out.println("push - pop checksum = " + pushSum.get() + " - " + popSum.get() + " = " + (pushSum.get() - popSum.get())); System.out.println("push duration = " + pushDuration); System.out.println("pop duration = " + popDuration); System.out.println(); System.out.println("pushed = " + numberOfPushes); System.out.println("popped = " + numberOfPops); System.out.println(); System.out.println("push entries/sec = " + numberOfPushes / (pushDuration / 1000f)); System.out.println("pop entries/sec = " + numberOfPops / (popDuration / 1000f)); System.out.println(); System.out.println("journals created = " + queue.getJournalsCreated()); System.out.println("journals removed = " + queue.getJournalsRemoved()); } finally { if (null != queue) { queue.shutdown(); } // FileUtils.deleteDirectory(theDir); } }
From source file:instamo.AccumuloApp.java
public static void main(String[] args) throws Exception { File tmpDir = new File(FileUtils.getTempDirectory(), "macc-" + UUID.randomUUID().toString()); try {//from w ww . j a va 2 s . c o m MiniAccumuloCluster la = new MiniAccumuloCluster(tmpDir, "pass1234", new HashMap<String, String>()); la.start(); System.out.println("\n ---- Running Accumulo App against accumulo-" + la.getAccumuloVersion() + "\n"); run(la.getInstanceName(), la.getZookeepers(), "pass1234", args); System.out.println("\n ---- Ran Accumulo App\n"); la.stop(); } finally { FileUtils.deleteQuietly(tmpDir); } }
From source file:instamo.MapReduceExample.java
public static void main(String[] args) throws Exception { File tmpDir = new File(FileUtils.getTempDirectory(), "macc-" + UUID.randomUUID().toString()); MiniAccumuloClusterWrapper la = new MiniAccumuloClusterWrapperImpl(tmpDir, "pass1234"); la.start();/*from w ww . j av a 2 s . c o m*/ System.out.println("\n ---- Running Mapred Against Accumulo\n"); run(la.getInstanceName(), la.getZooKeepers(), "pass1234", args); System.out.println("\n ---- Ran Mapred Against Accumulo\n"); la.stop(); }
From source file:ch.rasc.wampspring.demo.client.CallClientSockJs.java
public static void main(String[] args) throws InterruptedException { List<Transport> transports = new ArrayList<>(2); transports.add(new WebSocketTransport(new StandardWebSocketClient())); transports.add(new RestTemplateXhrTransport()); WebSocketClient webSocketClient = new SockJsClient(transports); JsonFactory jsonFactory = new MappingJsonFactory(new ObjectMapper()); CountDownLatch latch = new CountDownLatch(10_000); TestTextWebSocketHandler handler = new TestTextWebSocketHandler(jsonFactory, latch); Long[] start = new Long[1]; ListenableFuture<WebSocketSession> future = webSocketClient.doHandshake(handler, "ws://localhost:8080/wampOverSockJS"); future.addCallback(wss -> {// w ww . jav a 2 s. com start[0] = System.currentTimeMillis(); for (int i = 0; i < 10_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:Student.java
public static void main(String[] a) throws Exception { em.getTransaction().begin();/*w w w. j a v a 2 s.co m*/ Student student = new Student(); student.setId(UUID.randomUUID().toString()); student.setName("Joe"); student.setDob(Calendar.getInstance().getTime()); em.persist(student); em.flush(); em.getTransaction().commit(); Query query = em.createQuery("SELECT e FROM Student e"); List<Student> list = (List<Student>) query.getResultList(); System.out.println(list); em.close(); emf.close(); Helper.checkData(); }
From source file:ke.co.tawi.babblesms.server.utils.randomgenerate.IncomingLogGenerator.java
/** * @param args/*from w ww. j a v a 2 s . co m*/ */ public static void main(String[] args) { System.out.println("Have started IncomingSMSGenerator."); File outFile = new File("/tmp/logs/incomingSMS.csv"); RandomDataGenerator randomDataImpl = new RandomDataGenerator(); String randomStrFile = "/tmp/random.txt"; List<String> randomStrings = new ArrayList<>(); int randStrLength = 0; long startDate = 1412380800; // Unix time in seconds for Oct 4 2014 long stopDate = 1420070340; // Unix time for in seconds Dec 31 2014 SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 2011-06-01 00:16:45" List<String> shortcodeUuids = new ArrayList<>(); shortcodeUuids.add("094def52-bc18-4a9e-9b84-c34cc6476c75"); shortcodeUuids.add("e9570c5d-0cc4-41e5-81df-b0674e9dda1e"); shortcodeUuids.add("a118c8ea-f831-4288-986d-35e22c91fc4d"); shortcodeUuids.add("a2688d72-291b-470c-8926-31a903f5ed0c"); shortcodeUuids.add("9bef62f6-e682-4efd-98e9-ca41fa4ef993"); int shortcodeCount = shortcodeUuids.size() - 1; try { randomStrings = FileUtils.readLines(new File(randomStrFile)); randStrLength = randomStrings.size(); for (int j = 0; j < 30000; j++) { FileUtils.write(outFile, // shortcodeUuids.get(randomDataImpl.nextInt(0, shortcodeCount)) + "|" // Destination UUID.randomUUID().toString() + "|" // Unique Code + randomDataImpl.nextLong(new Long("254700000000").longValue(), new Long("254734999999").longValue()) + "|" // Origin + shortcodeUuids.get(randomDataImpl.nextInt(0, shortcodeCount)) + "|" + randomStrings.get(randomDataImpl.nextInt(0, randStrLength - 1)) + "|" // Message + "N|" // deleted + dateFormatter.format( new Date(randomDataImpl.nextLong(startDate, stopDate) * 1000)) + "\n", // smsTime true); // Append to file } } catch (IOException e) { System.err.println("IOException in main."); e.printStackTrace(); } System.out.println("Have finished IncomingSMSGenerator."); }
From source file:org.jasig.portlet.data.Exporter.java
public static void main(String[] args) throws Exception { String dir = args[0];/*from w w w . ja v a2 s. c o m*/ String importExportContext = args[1]; String sessionFactoryBeanName = args[2]; String modelClassName = args[3]; String serviceBeanName = args[4]; String serviceBeanMethodName = args[5]; ApplicationContext context = PortletApplicationContextLocator.getApplicationContext(importExportContext); SessionFactory sessionFactory = context.getBean(sessionFactoryBeanName, SessionFactory.class); Class<?> modelClass = Class.forName(modelClassName); Object service = context.getBean(serviceBeanName); Session session = sessionFactory.getCurrentSession(); Transaction transaction = session.beginTransaction(); JAXBContext jc = JAXBContext.newInstance(modelClass); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); Method method = service.getClass().getMethod(serviceBeanMethodName); List<?> objects = (List<?>) method.invoke(service, null); for (Object o : objects) { session.lock(o, LockMode.NONE); JAXBElement je2 = new JAXBElement(new QName(modelClass.getSimpleName().toLowerCase()), modelClass, o); String output = dir + File.separator + UUID.randomUUID().toString() + ".xml"; try { marshaller.marshal(je2, new FileOutputStream(output)); } catch (Exception exception) { exception.printStackTrace(); } } transaction.commit(); }