All Downloads are FREE. Search and download functionalities are using the official Maven repository.

test.FileSyncTest Maven / Gradle / Ivy

Go to download

Java UUID Generator (JUG) is a Java library for generating Universally Unique IDentifiers, UUIDs (see http://en.wikipedia.org/wiki/UUID). It can be used either as a component in a bigger application, or as a standalone command line tool. JUG generates UUIDs according to the IETF UUID draft specification. JUG supports 3 original official UUID generation methods as well as later additions (v6, v7)

There is a newer version: 5.1.0
Show newest version
package test;

import java.util.UUID;

import com.fasterxml.uuid.*;
import com.fasterxml.uuid.ext.*;
import com.fasterxml.uuid.impl.TimeBasedGenerator;

/**
 * Simple manual utility test class for manually checking whether file-based
 * synchronization seems to be working or not.
 */
public class FileSyncTest
{
    public static void main(String[] args)
        throws Exception
    {
        FileBasedTimestampSynchronizer sync = new FileBasedTimestampSynchronizer();
        // Let's stress-test it...
        sync.setUpdateInterval(2000L);

        // must have a NIC for this to work, should be ok:
        EthernetAddress eth = EthernetAddress.fromInterface();
        TimeBasedGenerator gen = Generators.timeBasedGenerator(eth, sync);

        int counter = 1;
        while (true) {
            UUID uuid = gen.generate();
	    // Default one is for convenient output
            System.out.println("#"+counter+" -> "+uuid);

	    /* This allows lexical sorting by uuid... (not very useful,
	     * since 'real' UUID ordering is not lexical)
	     */
            System.out.println(""+uuid+" (#"+counter+")");

	    // And this can be used to ensure there are no dups:
            System.out.println(""+uuid);
            ++counter;

            try {
                Thread.sleep(120L);
            } catch (InterruptedException ie) { }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy