本文整理汇总了Java中com.fasterxml.uuid.EthernetAddress类的典型用法代码示例。如果您正苦于以下问题:Java EthernetAddress类的具体用法?Java EthernetAddress怎么用?Java EthernetAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EthernetAddress类属于com.fasterxml.uuid包,在下文中一共展示了EthernetAddress类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureGeneratorInitialized
import com.fasterxml.uuid.EthernetAddress; //导入依赖的package包/类
private static void ensureGeneratorInitialized() {
if (timeGenerator == null) {
synchronized (UUIDUtils.class) {
if (timeGenerator == null) {
timeGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
}
}
}
if (randomGenerator == null) {
synchronized (com.fasterxml.uuid.UUIDGenerator.class) {
if (randomGenerator == null) {
randomGenerator = Generators.randomBasedGenerator();
}
}
}
}
示例2: preStart
import com.fasterxml.uuid.EthernetAddress; //导入依赖的package包/类
/**
* Establishes a connection with the webtrends stream api
* @see akka.actor.UntypedActor#preStart()
*/
public void preStart() throws Exception {
// initialize the uuid generator which is based on time and ethernet address
this.uuidGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
// authenticate with the webtrends service
WebtrendsTokenRequest tokenRequest = new WebtrendsTokenRequest(this.authUrl, this.authAudience, this.authScope, this.clientId, this.clientSecret);
this.oAuthToken = tokenRequest.execute();
// initialize the webtrends stream socket client and connect the listener
this.webtrendsStreamSocketClient = new WebSocketClient();
try {
this.webtrendsStreamSocketClient.start();
ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest();
this.webtrendsStreamSocketClient.connect(this, new URI(this.eventStreamUrl), upgradeRequest);
await(5, TimeUnit.SECONDS);
} catch(Exception e) {
throw new RuntimeException("Unable to connect to web socket: " + e.getMessage(), e);
}
this.componentRegistryRef.tell(new ComponentRegistrationMessage(EVENT_SOURCE_ID, ComponentType.STREAM_LISTENER, getSelf()), getSelf());
}
示例3: ensureGeneratorInitialized
import com.fasterxml.uuid.EthernetAddress; //导入依赖的package包/类
protected void ensureGeneratorInitialized() {
if (timeBasedGenerator == null) {
synchronized (UuidIdGenerator.class) {
if (timeBasedGenerator == null) {
timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
}
}
}
}
示例4: ensureGeneratorInitialized
import com.fasterxml.uuid.EthernetAddress; //导入依赖的package包/类
protected void ensureGeneratorInitialized() {
if (timeBasedGenerator == null) {
synchronized (StrongUuidGenerator.class) {
if (timeBasedGenerator == null) {
timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
}
}
}
}
示例5: ensureGeneratorInitialized
import com.fasterxml.uuid.EthernetAddress; //导入依赖的package包/类
protected void ensureGeneratorInitialized() {
if (timeBasedGenerator == null) {
synchronized (StrongUuidGenerator.class) {
if (timeBasedGenerator == null) {
timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
}
}
}
}
示例6: getUuidGenerator
import com.fasterxml.uuid.EthernetAddress; //导入依赖的package包/类
@Override
public TimeBasedGenerator getUuidGenerator() {
if (uuidGenerator == null) {
EthernetAddress nic = EthernetAddress.fromInterface();
if (nic == null) {
// construct address with a random number
nic = EthernetAddress.constructMulticastAddress();
}
uuidGenerator = Generators.timeBasedGenerator(nic);
}
return uuidGenerator;
}
示例7: UUIDTimeIDGenerator
import com.fasterxml.uuid.EthernetAddress; //导入依赖的package包/类
public UUIDTimeIDGenerator() {
try {
uuid1 = new File(System.getProperty("java.io.tmpdir") + File.separator + "uuid1.lck");
uuid2 = new File(System.getProperty("java.io.tmpdir") + File.separator + "uuid2.lck");
synchronizer = new FileBasedTimestampSynchronizer(uuid1, uuid2);
generator = Generators.timeBasedGenerator(EthernetAddress.fromInterface(), synchronizer);
} catch (IOException e) {
log.error("error initialising time-based UUID generator",e);
}
}
示例8: generateV1Uuid
import com.fasterxml.uuid.EthernetAddress; //导入依赖的package包/类
public static String generateV1Uuid(){
EthernetAddress addr = EthernetAddress.fromInterface();
TimeBasedGenerator uuidGenerator = Generators.timeBasedGenerator(addr);
UUID uuid = uuidGenerator.generate();
return uuid.toString();
}
示例9: generateTimeBasedUUID
import com.fasterxml.uuid.EthernetAddress; //导入依赖的package包/类
public static UUID generateTimeBasedUUID()
{
return Generators.timeBasedGenerator( EthernetAddress.fromInterface() ).generate();
}
示例10: newTimeUUID
import com.fasterxml.uuid.EthernetAddress; //导入依赖的package包/类
/**
* Generate a timeuuid with the given timestamp in milliseconds and the time offset. Useful when you need to
* generate sequential UUIDs for the same period in time. I.E
* <p/>
* newTimeUUID(1000, 0) <br/> newTimeUUID(1000, 1) <br /> newTimeUUID(1000, 2) <br />
* <p/>
* etc.
* <p/>
* Only use this method if you are absolutely sure you need it. When it doubt use the method without the timestamp
* offset
*
* @param ts The timestamp in milliseconds
* @param timeoffset The offset, which should always be <= 10000. If you go beyond this range, the millisecond will
* be incremented since this is beyond the possible values when coverrting from millis to 1/10 microseconds stored
* in the time uuid.
*/
public static UUID newTimeUUID( long ts, int timeoffset ) {
if ( ts == 0 ) {
return newTimeUUID();
}
byte[] uuidBytes = new byte[16];
// 47 bits of randomness
EthernetAddress eth = EthernetAddress.constructMulticastAddress();
eth.toByteArray( uuidBytes, 10 );
setTimestamp( ts, uuidBytes, getRandomClockSequence(), timeoffset );
return uuid( uuidBytes );
}