• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UUID类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.eaio.uuid.UUID的典型用法代码示例。如果您正苦于以下问题:Java UUID类的具体用法?Java UUID怎么用?Java UUID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UUID类属于com.eaio.uuid包,在下文中一共展示了UUID类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: readPartition

import com.eaio.uuid.UUID; //导入依赖的package包/类
final private Partition readPartition(final int id) throws Exception {
    _selectPartition.setInt(1, id);
    ResultSet rs = _selectPartition.executeQuery();
    try {
        if (rs.next()) {
            final Partition partition = Partition.create(new UUID(rs.getString(PARTITIONS_STOREID_FIELD_NAME)));
            partition.setPartitionId(rs.getInt(PARTITIONS_ID_FIELD_NAME));
            partition.setNextCartId(rs.getLong(PARTITIONS_NEXTCARTID_FIELD_NAME));
            return partition;
        }
    }
    finally {
        rs.close();
    }

    return null;
}
 
开发者ID:neeveresearch,项目名称:nvx-apps,代码行数:18,代码来源:PartitionPersister.java


示例2: processLine

import com.eaio.uuid.UUID; //导入依赖的package包/类
@Override
public boolean processLine(@Nonnull String line) throws IOException {
    final String[] strings = csvParser.parseLine(line);
    if (strings == null) {
        return false;
    }
    if (firstLine) {
        fieldNames = strings;
        firstLine = false;
        return true;
    }

    final Map<String, Object> fields = Seq.of(fieldNames)
            .zipWithIndex()
            .map(nameAndIndex -> nameAndIndex.map2(index -> strings[Math.toIntExact(index)]))
            .collect(Collectors.toMap(Tuple2::v1, Tuple2::v2));
    fields.put(Message.FIELD_ID, new UUID().toString());
    messages.add(new Message(fields));
    return true;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:21,代码来源:PipelinePerformanceBenchmarks.java


示例3: standardFields

import com.eaio.uuid.UUID; //导入依赖的package包/类
private static Map<String, Object> standardFields(final String testName) {

        Map<String, Object> fields = new HashMap();

        // Default/mandatory fields
        fields.put(EVENT_FIELD_ID, new UUID().toString());
        fields.put(EVENT_FIELD_SOURCE, testName);
        fields.put(EVENT_FIELD_HOST, HostOs.hostName());
        fields.put(EVENT_FIELD_TIMESTAMP, System.currentTimeMillis());
        try {
            // Cause slight pause to get unique ms timestamps
            Thread.sleep(2L);
        } catch (InterruptedException e) {
            // Ignore
        }
        fields.put(EVENT_FIELD_TIMEZONE, TIMEZONE_UTC.getId());
        fields.put(EVENT_FIELD_TYPE, "Event");
        fields.put(EVENT_FIELD_TAGS, Arrays.asList(new String[]{"spikex", testName}));
        fields.put(EVENT_FIELD_PRIORITY, EVENT_PRIORITY_NORMAL); // Default
        fields.put(EVENT_FIELD_MESSAGE,
                "08.11.2010 1:06:46 org.apache.coyote.http11.Http11AprProtocol start\n"
                + "INFO: Starting Coyote HTTP/1.1 on http-8080");

        return fields;
    }
 
开发者ID:clidev,项目名称:spike.x,代码行数:26,代码来源:EventCreator.java


示例4: FilterDef

import com.eaio.uuid.UUID; //导入依赖的package包/类
private FilterDef(
        final String module,
        final String chain,
        final String alias,
        final String verticle) {

    m_id = new UUID().toString();
    m_module = module;
    m_chain = chain;
    m_alias = alias;
    m_verticle = verticle;

    StringBuilder addr = new StringBuilder(chain.toLowerCase());
    addr.append(".");
    addr.append(alias.toLowerCase());

    m_inputAddress = addr.toString();
    m_outputAddress = ""; // No output messages by default
    m_deploymentId = "";
    m_instances = 1;
    m_worker = false;
    m_multiThreaded = false;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:24,代码来源:FiltersConfig.java


示例5: emitEvent

import com.eaio.uuid.UUID; //导入依赖的package包/类
/**
 * Emit event to given address
 *
 * @param event the event to send to the next filter
 * @param destAddr the destination address of the event
 */
protected void emitEvent(
        final JsonObject event,
        final String destAddr) {

    if (destAddr != null && destAddr.length() > 0) {

        // Always add UUID if missing
        if (!event.containsField(EVENT_FIELD_ID)) {
            event.putString(EVENT_FIELD_ID, new UUID().toString());
        }

        // Always add "chain" to event
        String chainName = (m_chainName != null ? m_chainName : "");
        event.putString(EVENT_FIELD_CHAIN, chainName);

        // Emit event to any listeners near or far...
        eventBus().publish(destAddr, event);
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:26,代码来源:AbstractFilter.java


示例6: disabledFilterTest

import com.eaio.uuid.UUID; //导入依赖的package包/类
@Test
public void disabledFilterTest() throws Exception {
    final GeoIpResolverEngine resolver = new GeoIpResolverEngine(config.toBuilder().enabled(false).build(), metricRegistry);

    final Map<String, Object> messageFields = Maps.newHashMap();
    messageFields.put("_id", (new UUID()).toString());
    messageFields.put("source", "192.168.0.1");
    messageFields.put("message", "Hello from 1.2.3.4");
    messageFields.put("extracted_ip", "1.2.3.4");
    messageFields.put("ipv6", "2001:4860:4860::8888");

    final Message message = new Message(messageFields);
    final boolean filtered = resolver.filter(message);

    assertFalse(filtered, "Message should not be filtered out");
    assertEquals(message.getFields().size(), messageFields.size(), "Filter should not add new message fields");
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-map-widget,代码行数:18,代码来源:GeoIpResolverEngineTest.java


示例7: filterResolvesIpGeoLocation

import com.eaio.uuid.UUID; //导入依赖的package包/类
@Test
public void filterResolvesIpGeoLocation() throws Exception {
    final GeoIpResolverEngine resolver = new GeoIpResolverEngine(config, metricRegistry);

    final Map<String, Object> messageFields = Maps.newHashMap();
    messageFields.put("_id", (new UUID()).toString());
    messageFields.put("source", "192.168.0.1");
    messageFields.put("message", "Hello from 1.2.3.4");
    messageFields.put("extracted_ip", "1.2.3.4");
    messageFields.put("gl2_remote_ip", "1.2.3.4");
    messageFields.put("ipv6", "2001:4860:4860::8888");

    final Message message = new Message(messageFields);
    final boolean filtered = resolver.filter(message);

    assertFalse(filtered, "Message should not be filtered out");
    assertEquals(metricRegistry.timer(name(GeoIpResolverEngine.class, "resolveTime")).getCount(), 3, "Should have looked up three IPs");
    assertFieldNotResolved(message, "source", "Should not have resolved private IP");
    assertFieldNotResolved(message, "message", "Should have resolved public IP");
    assertFieldNotResolved(message, "gl2_remote_ip", "Should not have resolved text with an IP");
    assertFieldResolved(message, "extracted_ip", "Should have resolved public IP");
    assertFieldResolved(message, "ipv6", "Should have resolved public IPv6");
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-map-widget,代码行数:24,代码来源:GeoIpResolverEngineTest.java


示例8: setupRecords

import com.eaio.uuid.UUID; //导入依赖的package包/类
private void setupRecords() {
	Activity act = new Activity("act1");
	act.setName("hello");
	act.setMyFloat(5.65f);
	act.setUniqueColumn("notunique");
	act.setNumTimes(5);
	act.setIsCool(true);
	BigInteger bigInt = BigInteger.valueOf(Long.MAX_VALUE+87);
	act.setBigInt(bigInt);
	time = LocalDateTime.now();
	act.setDate(time);
	uid = new UUID();
	act.setUniqueId(uid);
	mgr.put(act);
	
	//Everything is null for this activity so queries above should not find him...
	Activity act2 = new Activity("act2");
	act2.setNumTimes(58);
	mgr.put(act2);
	
	mgr.flush();
}
 
开发者ID:guci314,项目名称:playorm,代码行数:23,代码来源:TestIndexTypes.java


示例9: updateThing

import com.eaio.uuid.UUID; //导入依赖的package包/类
@Override
	public void updateThing(Thing thing) {
		if (thing == null || StringUtils.isBlank(thing.getId()) || StringUtils.isBlank(thing.getAppid()) ||
				StringUtils.isBlank(SERVICE_ACCESS_KEY)) {
			return;
		}
		try {
			Date now = new Date();
			com.microsoft.azure.iot.service.sdk.Message messageToSend;
			messageToSend = new com.microsoft.azure.iot.service.sdk.Message(ParaObjectUtils.getJsonWriterNoIdent().
					writeValueAsBytes(thing.getDeviceState()));

			messageToSend.setDeliveryAcknowledgement(DeliveryAcknowledgement.None);
			messageToSend.setMessageId(new UUID().toString());
			messageToSend.setExpiryTimeUtc(new Date(now.getTime() + 24 * 60 * 60 * 1000));
			messageToSend.setCorrelationId(new UUID().toString());
//			messageToSend.setUserId(thing.getCreatorid());
			messageToSend.clearCustomProperties();

			getClient().send(cloudIDForThing(thing), messageToSend);
		} catch (Exception e) {
			logger.warn("Couldn't create thing: {}", e.getMessage());
		}
	}
 
开发者ID:Erudika,项目名称:para,代码行数:25,代码来源:AzureIoTService.java


示例10: run

import com.eaio.uuid.UUID; //导入依赖的package包/类
/**
 * Implementation of {@link Runnable#run}
 */
final public void run() {
    if (_engine != null && _engine.getState() == AepEngine.State.Started) {
        final DoDataMaintenanceRequest request = DoDataMaintenanceRequest.create();
        request.setHeader(MessageHeader.create());
        request.getHeader().setOrigin(APP_NAME);
        request.getHeader().setSourceId(String.valueOf(APP_PART));
        request.getHeader().setTransactionId(new UUID().toString());
        _messageScheduler.send(request);
    }
}
 
开发者ID:neeveresearch,项目名称:nvx-apps,代码行数:14,代码来源:App.java


示例11: doDelete

import com.eaio.uuid.UUID; //导入依赖的package包/类
@Override
final protected void doDelete(final UUID id) throws Exception {
    if (_partitionPersister.delete(id.toString()) > 0) {
        return;
    }
    if (_cartPersister.delete(id.toString()) > 0) {
        return;
    }
    if (_itemPersister.delete(id.toString()) > 0) {
        return;
    }
}
 
开发者ID:neeveresearch,项目名称:nvx-apps,代码行数:13,代码来源:Persister.java


示例12: generateUuid

import com.eaio.uuid.UUID; //导入依赖的package包/类
/**
 * Generate UUID
 * @param dash If needs to keep dash
 * @return UUID
 */
public static String generateUuid(boolean dash) {
    String uuid = new UUID().toString();
    
    if (dash) {
        return uuid;
    }
    
    return uuid.replaceAll("-", "");
}
 
开发者ID:brunocvcunha,项目名称:instagram4j,代码行数:15,代码来源:InstagramGenericUtil.java


示例13: AbstractVerticle

import com.eaio.uuid.UUID; //导入依赖的package包/类
public AbstractVerticle() {
    m_interval = 0L;
    m_timerId = 0L;
    m_config = new JsonObject(); // Empty until verticle start method called
    m_localAddress = "";

    // Create unique address
    m_address = getClass().getName() + "." + new UUID().toString();
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:10,代码来源:AbstractVerticle.java


示例14: createNotificationEvent

import com.eaio.uuid.UUID; //导入依赖的package包/类
/**
 * Creates a new notification event based on the given filter.
 *
 * @param filter the filter that created the event
 * @param timestamp the event timestamp
 * @param timezone the timezone to use for the timestamp
 * @param host the event host
 * @param priority the event priority
 * @param title the title of the notification
 * @param message the message of the notification
 * <p>
 * @return the new event
 */
public static JsonObject createNotificationEvent(
        final AbstractFilter filter,
        final long timestamp,
        final ZoneId timezone,
        final String host,
        final String priority,
        final String title,
        final String message) {

    Preconditions.checkNotNull(filter);
    Preconditions.checkNotNull(timezone);
    Preconditions.checkNotNull(host);
    Preconditions.checkNotNull(priority);
    Preconditions.checkNotNull(title);
    Preconditions.checkNotNull(message);

    JsonObject event = new JsonObject();
    event.putString(EVENT_FIELD_ID, new UUID().toString());
    event.putString(EVENT_FIELD_SOURCE, filter.getName());
    event.putNumber(EVENT_FIELD_TIMESTAMP, timestamp);
    event.putString(EVENT_FIELD_TIMEZONE, timezone.getId());
    event.putString(EVENT_FIELD_TYPE, EVENT_TYPE_NOTIFICATION);
    event.putString(EVENT_FIELD_CHAIN, filter.getChainName());
    event.putString(EVENT_FIELD_HOST, host);
    event.putString(EVENT_FIELD_PRIORITY, priority);
    event.putString(EVENT_FIELD_TITLE, title);
    event.putString(EVENT_FIELD_MESSAGE, message);
    event.putArray(EVENT_FIELD_DESTINATIONS, new JsonArray());
    event.putArray(EVENT_FIELD_TAGS, new JsonArray());
    return event;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:45,代码来源:Events.java


示例15: createBatchEvent

import com.eaio.uuid.UUID; //导入依赖的package包/类
/**
 * Creates a new batch event based on the given filter.
 *
 * @param filter the filter that created the event
 * @param events the list of events to add to the batch
 * <p>
 * @return the new batch event
 */
public static JsonObject createBatchEvent(
        final AbstractFilter filter,
        final List<String> events) {

    Preconditions.checkNotNull(filter);
    Preconditions.checkNotNull(events);

    JsonObject batch = new JsonObject();
    batch.putString(EVENT_FIELD_ID, new UUID().toString());
    batch.putString(EVENT_FIELD_SOURCE, filter.getName());
    batch.putNumber(EVENT_FIELD_TIMESTAMP, System.currentTimeMillis());
    batch.putString(EVENT_FIELD_TIMEZONE, ZoneId.of("UTC").getId());
    batch.putString(EVENT_FIELD_TYPE, EVENT_TYPE_BATCH);
    batch.putString(EVENT_FIELD_CHAIN, filter.getChainName());
    batch.putString(EVENT_FIELD_PRIORITY, EVENT_PRIORITY_NORMAL); // Default

    JsonArray jsonEvents = new JsonArray();
    for (String event : events) {
        jsonEvents.addObject(new JsonObject(event));
    }

    batch.putString(EVENT_FIELD_TYPE, EVENT_TYPE_BATCH);
    batch.putArray(EVENT_FIELD_BATCH_EVENTS, jsonEvents);
    batch.putNumber(EVENT_FIELD_BATCH_SIZE, events.size());
    return batch;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:35,代码来源:Events.java


示例16: testUuid

import com.eaio.uuid.UUID; //导入依赖的package包/类
@Test
public void testUuid()
{
    UUID uuid = new UUID();
    System.out.println(uuid.toString());
    assertTrue("larger than 0", uuid.toString().length() > 0);
}
 
开发者ID:cnmydida,项目名称:pandapay,代码行数:8,代码来源:UuidTest.java


示例17: testJavaUuid

import com.eaio.uuid.UUID; //导入依赖的package包/类
@Test
public void testJavaUuid()
{
    java.util.UUID uuid = UuidUtils.getTimeUUID();
    System.out.println(uuid.toString());
    assertTrue("larger than 0", uuid.toString().length() > 0);
}
 
开发者ID:cnmydida,项目名称:pandapay,代码行数:8,代码来源:UuidTest.java


示例18: testManyJavaUuid

import com.eaio.uuid.UUID; //导入依赖的package包/类
@Test
public void testManyJavaUuid()
{
    for (int i = 0; i < 100; i++)
    {
        java.util.UUID uuid = UuidUtils.getTimeUUID();
        System.out.println(uuid.toString());
    }
}
 
开发者ID:cnmydida,项目名称:pandapay,代码行数:10,代码来源:UuidTest.java


示例19: convertToNoSqlImpl

import com.eaio.uuid.UUID; //导入依赖的package包/类
@Override
public byte[] convertToNoSqlImpl(Object value) {
	UUID uid = (UUID) value;
    long time = uid.getTime();
    long clockSeqAndNode = uid.getClockSeqAndNode();
    byte[] timeArray = LONG_CONVERTER.convertToNoSql(time);
    byte[] nodeArray = LONG_CONVERTER.convertToNoSql(clockSeqAndNode);
    byte[] combinedUUID = new byte[timeArray.length + nodeArray.length];
    System.arraycopy(timeArray,0,combinedUUID,0         ,timeArray.length);
    System.arraycopy(nodeArray,0,combinedUUID,timeArray.length,nodeArray.length);
    return combinedUUID;			
}
 
开发者ID:guci314,项目名称:playorm,代码行数:13,代码来源:Converters.java


示例20: convertFromNoSqlImpl

import com.eaio.uuid.UUID; //导入依赖的package包/类
@Override
public Object convertFromNoSqlImpl(byte[] value) {
	try {
		byte[] timeArray = new byte[8];
		byte[] clockSeqAndNodeArray=new byte[8];
		System.arraycopy(value,0,timeArray,0,8);
		System.arraycopy(value,8,clockSeqAndNodeArray,0,8);
		long time = StandardConverters.convertFromBytes(Long.class, timeArray);
		long clockSeqAndNode = StandardConverters.convertFromBytes(Long.class, clockSeqAndNodeArray);
		UUID ud = new UUID(time,clockSeqAndNode);
		return ud;
	} catch(Exception e) {
		throw new RuntimeException("value in len="+value.length, e);
	}
}
 
开发者ID:guci314,项目名称:playorm,代码行数:16,代码来源:Converters.java



注:本文中的com.eaio.uuid.UUID类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NamePattern类代码示例发布时间:2022-05-21
下一篇:
Java NLinearInterpolatorFactory类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap