本文整理汇总了Java中com.eaio.uuid.UUID类的典型用法代码示例。如果您正苦于以下问题:Java UUID类的具体用法?Java UUID怎么用?Java UUID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UUID类属于com.eaio.uuid包,在下文中一共展示了UUID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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");
}
示例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");
}
示例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();
}
示例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());
}
}
示例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);
}
}
示例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;
}
}
示例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("-", "");
}
示例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();
}
示例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;
}
示例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;
}