org.mule.runtime.core.api.util.UUID类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.mule.runtime.core.api.util.UUID类的一些代码示例,展示了UUID类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UUID类的具体详情如下:
包路径:org.mule.runtime.core.api.util.UUID
类名称:UUID

UUID介绍

[英]UUID Generates a UUID using the Johann Burkard UUID Library. In our performance tests we found this to be the implementation of type 1 UUID that was most performant in high concurrency scenarios.
[中]UUID使用Johann Burkard UUID Library生成UUID。在我们的性能测试中,我们发现这是类型1 UUID的实现,在高并发性场景中性能最好。

代码示例

代码示例来源:origin: mulesoft/mule

/**
 * Generates a unique id for an artifact (domain or application).
 *
 * @return {@link String} a uniqueId
 */
public String getUniqueIdString(String type) {
 return TOOLING_PREFIX + "-" + type + "-" + UUID.getUUID();
}

代码示例来源:origin: mulesoft/mule

@Benchmark
public String clusterUUIDPrefix() throws MuleException {
 return getClusterUUID(getClusterIdPrefix());
}

代码示例来源:origin: mulesoft/mule

@Override
public String getUniqueIdString() {
 return getUUID();
}

代码示例来源:origin: mulesoft/mule

@Benchmark
public String clusterUUID() throws MuleException {
 return getClusterUUID(getClusterId());
}

代码示例来源:origin: mulesoft/mule

protected String generateTaskToken() {
 return currentThread().getName() + " - " + getUUID();
}

代码示例来源:origin: org.mule.runtime/mule-core

@Override
public String getUniqueIdString() {
 return getClusterUUID(clusterConfiguration.getClusterNodeId());
}

代码示例来源:origin: mulesoft/mule

public MuleContextProcessBuilder(File testDirectory) {
 this.testDirectory = testDirectory;
 systemProperties.put(MULE_CONTEXT_CONFIGURATION_ID_KEY, UUID.getUUID());
 systemProperties.put(TIMEOUT_IN_SECONDS, "120");
 systemProperties.put(FakeMuleServer.FAKE_SERVER_DISABLE_LOG_REPOSITORY_SELECTOR, "true");
}

代码示例来源:origin: org.mule.tests/mule-tests-performance

@Benchmark
public String clusterUUID() throws MuleException {
 return getClusterUUID(getClusterId());
}

代码示例来源:origin: mulesoft/mule

@Benchmark
public String UUID() throws MuleException {
 return getUUID();
}

代码示例来源:origin: mulesoft/mule

@Override
protected String getArtifactId(ArtifactDescriptor artifactDescriptor) {
 return TOOLING_EXTENSION_MODEL + getUUID() + "/" + artifactDescriptor.getName();
}

代码示例来源:origin: mulesoft/mule

public static MuleContextWithRegistry mockMuleContext() {
 final MuleContextWithRegistry muleContext =
   mock(DefaultMuleContext.class,
      withSettings().defaultAnswer(RETURNS_DEEP_STUBS).extraInterfaces(PrivilegedMuleContext.class).lenient());
 when(muleContext.getUniqueIdString()).thenReturn(UUID.getUUID());
 when(muleContext.getDefaultErrorHandler(empty())).thenReturn(new OnErrorPropagateHandler());
 StreamingManager streamingManager = mock(StreamingManager.class, RETURNS_DEEP_STUBS);
 try {
  MuleRegistry registry = mock(MuleRegistry.class, withSettings().lenient());
  when(muleContext.getRegistry()).thenReturn(registry);
  ComponentInitialStateManager componentInitialStateManager =
    mock(ComponentInitialStateManager.class, withSettings().lenient());
  when(componentInitialStateManager.mustStartMessageSource(any())).thenReturn(true);
  when(registry.lookupObject(ComponentInitialStateManager.SERVICE_ID)).thenReturn(componentInitialStateManager);
  doReturn(streamingManager).when(registry).lookupObject(StreamingManager.class);
  doReturn(mock(NotificationDispatcher.class)).when(registry).lookupObject(NotificationDispatcher.class);
  doReturn(mock(ObjectStoreManager.class, RETURNS_DEEP_STUBS)).when(registry).lookupObject(OBJECT_STORE_MANAGER);
 } catch (RegistrationException e) {
  throw new RuntimeException(e);
 }
 return muleContext;
}

代码示例来源:origin: mulesoft/mule

@Test
public void testGenerateUniqueAndIncrementalIds() throws Exception {
 final Set<String> ids = new HashSet<String>();
 final List<Object[]> idsWithIndexes = new ArrayList<Object[]>(1000);
 final int numberOfIdsToGenerate = 10000;
 for (int index = 0; index < numberOfIdsToGenerate; index++) {
  String generatedId = UUID.getUUID();
  idsWithIndexes.add(new Object[] {generatedId, Integer.valueOf(index)});
  if (ids.contains(generatedId)) {
   fail("REPEATED ID :" + index + ": " + generatedId);
  } else {
   ids.add(generatedId);
  }
 }
 final Comparator<Object[]> comparatorById = new Comparator<Object[]>() {
  public int compare(Object[] o1, Object[] o2) {
   return ((String) o1[0]).compareTo((String) o2[0]);
  }
 };
 Collections.sort(idsWithIndexes, comparatorById);
 for (int index = 0; index < numberOfIdsToGenerate; index++) {
  assertEquals(Integer.valueOf(index), idsWithIndexes.get(index)[1]);
 }
}

代码示例来源:origin: mulesoft/mule

private MuleContext buildStartedMuleContext() throws Exception {
 ctx.initialise();
 // DefaultMuleContext refuses to start without these objects in place
 SecurityManager securityManager = mock(SecurityManager.class);
 ((MuleContextWithRegistry) ctx).getRegistry().registerObject(UUID.getUUID(), securityManager);
 QueueManager queueManager = mock(QueueManager.class);
 ((MuleContextWithRegistry) ctx).getRegistry().registerObject(UUID.getUUID(), queueManager);
 ctx.start();
 return ctx;
}

代码示例来源:origin: mulesoft/mule

@Test
public void isDisposedEventGroupPartition() throws Exception {
 EventGroup eventGroup = new EventGroup(UUID.getUUID(), muleContext);
 PartitionableObjectStore objectStore = mock(PartitionableObjectStore.class);
 eventGroup.initEventsStore(objectStore);
 eventGroup.clear();
 verify(objectStore).disposePartition(anyString());
}

代码示例来源:origin: mulesoft/mule

/**
 * {@inheritDoc}
 */
@Override
public ConnectivityTestingService build() {
 checkState(artifactDeclaration != null, "artifact configuration cannot be null");
 return new TemporaryArtifactConnectivityTestingService(() -> {
  String applicationName = UUID.getUUID() + "-connectivity-testing-temp-app";
  File applicationFolder = new File(getExecutionFolder(), applicationName);
  ApplicationDescriptor applicationDescriptor = new ApplicationDescriptor(applicationName);
  applicationDescriptor.setArtifactDeclaration(artifactDeclaration);
  applicationDescriptor.setConfigResources(emptySet());
  applicationDescriptor.setArtifactLocation(applicationFolder);
  createDeployablePomFile(applicationFolder, model);
  updateArtifactPom(applicationFolder, model);
  MavenClientProvider mavenClientProvider =
    MavenClientProvider.discoverProvider(DefaultConnectivityTestingServiceBuilder.class.getClassLoader());
  applicationDescriptor
    .setClassLoaderModel(new DeployableMavenClassLoaderModelLoader(mavenClientProvider
      .createMavenClient(GlobalConfigLoader.getMavenConfig()))
        .load(applicationFolder, emptyMap(), ArtifactType.APP));
  return defaultApplicationFactory.createArtifact(applicationDescriptor);
 });
}

代码示例来源:origin: org.mule.runtime/mule-module-tooling-support

/**
 * Generates a unique id for an artifact (domain or application).
 *
 * @return {@link String} a uniqueId
 */
public String getUniqueIdString(String type) {
 return TOOLING_PREFIX + "-" + type + "-" + UUID.getUUID();
}

代码示例来源:origin: org.mule.runtime/mule-module-extensions-support

@Override
public String getUniqueIdString() {
 return getUUID();
}

代码示例来源:origin: mulesoft/mule

.then(invocation -> Optional.of(new MetadataCacheId(UUID.getUUID(), null)));
when(cacheIdGenerator.getIdForGlobalMetadata(any()))
  .then(invocation -> Optional.of(new MetadataCacheId(UUID.getUUID(), null)));
when(cacheIdGenerator.getIdForMetadataKeys(any()))
  .then(invocation -> Optional.of(new MetadataCacheId(UUID.getUUID(), null)));

代码示例来源:origin: mulesoft/mule

when(cacheIdGeneratorFactory.create(any(), any())).thenReturn(cacheIdGenerator);
when(cacheIdGenerator.getIdForComponentMetadata(any()))
  .then(invocation -> Optional.of(new MetadataCacheId(UUID.getUUID(), null)));
when(cacheIdGenerator.getIdForGlobalMetadata(any()))
  .then(invocation -> Optional.of(new MetadataCacheId(UUID.getUUID(), null)));
when(cacheIdGenerator.getIdForMetadataKeys(any()))
  .then(invocation -> Optional.of(new MetadataCacheId(UUID.getUUID(), null)));

代码示例来源:origin: mulesoft/mule

@Test
public void arrivalOrderEvents() throws Exception {
 EventGroup eventGroup = new EventGroup(UUID.getUUID(), muleContext);
 eventGroup.initEventsStore(objectStore);
 for (int i = 0; i < 3; i++) {
  eventGroup.addEvent(eventBuilder(muleContext).message(Message.of("foo" + i)).build());
 }
 CoreEvent result = eventGroup.getMessageCollectionEvent();
 Message message = result.getMessage();
 List<Message> messages = (List<Message>) message.getPayload().getValue();
 assertThat(messages.size(), is(3));
 assertThat(messages.get(0).getPayload().getValue(), is("foo0"));
 assertThat(messages.get(1).getPayload().getValue(), is("foo1"));
 assertThat(messages.get(2).getPayload().getValue(), is("foo2"));
}

相关文章