本文整理汇总了Java中org.apache.commons.lang3.RandomStringUtils.randomAscii方法的典型用法代码示例。如果您正苦于以下问题:Java RandomStringUtils.randomAscii方法的具体用法?Java RandomStringUtils.randomAscii怎么用?Java RandomStringUtils.randomAscii使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.RandomStringUtils
的用法示例。
在下文中一共展示了RandomStringUtils.randomAscii方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: producerSendsToNonExistingTopic
import org.apache.commons.lang3.RandomStringUtils; //导入方法依赖的package包/类
@Ignore
@Test
public void producerSendsToNonExistingTopic() {
ServiceProperties serviceProperties = fillServiceProperties();
Topic cruft = new Topic("cruft");
Topic lard = new Topic("lard");
Producer producer = new ProducerFactory(serviceProperties).createProducer();
String key = RandomStringUtils.randomAscii(5);
SayHelloToCmd payload = SayHelloToCmd.newBuilder().setName(key).build();
Message request = Messages.requestFor(cruft, lard, key, payload, new OrangeContext());
producer.send(request);
// Results:
// 1.) NO topic auto creation i.e. KAFKA_AUTO_CREATE_TOPICS_ENABLE = false
// 2017-04-12 18:14:41,239 [Time-limited test] DEBUG c.s.s.f.kafka.messaging.Producer - Sending message com.sixt.service.framework.kafka.messaging.SayHelloToCmd with key O+oRQ to topic cruft
// loads of: 2017-04-12 18:14:41,340 [kafka-producer-network-thread | producer-2] WARN o.apache.kafka.clients.NetworkClient - Error while fetching metadata with correlation id 0 : {cruft=UNKNOWN_TOPIC_OR_PARTITION}
// and finally: org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
// 2.) WITH topic auto creation i.e. KAFKA_AUTO_CREATE_TOPICS_ENABLE = true
// 2017-04-12 18:18:24,488 [Time-limited test] DEBUG c.s.s.f.kafka.messaging.Producer - Sending message com.sixt.service.framework.kafka.messaging.SayHelloToCmd with key uXdJ~ to topic cruft
// one: 2017-04-12 18:18:24,638 [kafka-producer-network-thread | producer-2] WARN o.apache.kafka.clients.NetworkClient - Error while fetching metadata with correlation id 0 : {cruft=LEADER_NOT_AVAILABLE
// and finally: success
}
示例2: onLivingUpdate
import org.apache.commons.lang3.RandomStringUtils; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event)
{
if(Clef.config.zombiesCanUseInstruments == 1 && !event.getEntityLiving().world.isRemote && event.getEntityLiving() instanceof EntityZombie)
{
EntityZombie zombie = (EntityZombie)event.getEntityLiving();
if(zombie.getRNG().nextFloat() < 0.004F &&ItemInstrument.getUsableInstrument(zombie) != null && getTrackPlayedByPlayer(zombie) == null)
{
Track track = Clef.eventHandlerServer.findTrackByBand("zombies");
if(track != null)
{
if(track.zombies.add(zombie.getEntityId()))
{
Clef.channel.sendToAll(new PacketPlayingTracks(track));
}
}
else
{
TrackFile randTrack = AbcLibrary.tracks.get(zombie.getRNG().nextInt(AbcLibrary.tracks.size()));
track = new Track(RandomStringUtils.randomAscii(IOUtil.IDENTIFIER_LENGTH), "zombies", randTrack.md5, randTrack.track, false);
if(track.getTrack().trackLength > 0)
{
track.playAtProgress(zombie.getRNG().nextInt(track.getTrack().trackLength));
}
Clef.eventHandlerServer.tracksPlaying.add(track);
track.zombies.add(zombie.getEntityId());
Clef.channel.sendToAll(new PacketPlayingTracks(track));
}
}
}
}
示例3: consumerSubscribesToNonExistingTopic
import org.apache.commons.lang3.RandomStringUtils; //导入方法依赖的package包/类
@Ignore
@Test
public void consumerSubscribesToNonExistingTopic() throws InterruptedException {
ServiceProperties serviceProperties = fillServiceProperties();
Topic cruft = new Topic("krufty");
CountDownLatch latch = new CountDownLatch(1);
Consumer consumer = consumerFactoryWithHandler(serviceProperties, SayHelloToCmd.class, new MessageHandler<SayHelloToCmd>() {
@Override
public void onMessage(Message<SayHelloToCmd> message, OrangeContext context) {
latch.countDown();
}
}
).consumerForTopic(cruft, new DiscardFailedMessages());
Producer producer = new ProducerFactory(serviceProperties).createProducer();
String key = RandomStringUtils.randomAscii(5);
SayHelloToCmd payload = SayHelloToCmd.newBuilder().setName(key).build();
Message request = Messages.requestFor(cruft, cruft, key, payload, new OrangeContext());
producer.send(request);
assertTrue(latch.await(1, TimeUnit.MINUTES));
producer.shutdown();
consumer.shutdown();
// Results:
// 1.) WITH topic auto creation i.e. KAFKA_AUTO_CREATE_TOPICS_ENABLE = true
// All ok, needs to discover coordinator etc.
// 2.) NO topic auto creation i.e. KAFKA_AUTO_CREATE_TOPICS_ENABLE = false
//2017-04-12 18:27:16,701 [pool-9-thread-1] INFO c.s.s.f.kafka.messaging.Consumer - Consumer in group kruftmeister-com.sixt.service.unknown subscribed to topic kruftmeister
//2017-04-12 18:27:16,852 [pool-9-thread-1] WARN o.apache.kafka.clients.NetworkClient - Error while fetching metadata with correlation id 1 : {kruftmeister=UNKNOWN_TOPIC_OR_PARTITION}
//2017-04-12 18:27:18,876 [pool-9-thread-1] WARN o.apache.kafka.clients.NetworkClient - Error while fetching metadata with correlation id 40 : {kruftmeister=UNKNOWN_TOPIC_OR_PARTITION}
//2017-04-12 18:27:18,889 [pool-9-thread-1] INFO o.a.k.c.c.i.AbstractCoordinator - Discovered coordinator 172.19.0.3:9092 (id: 2147482646 rack: null) for group kruftmeister-com.sixt.service.unknown.
//2017-04-12 18:27:18,892 [pool-9-thread-1] INFO o.a.k.c.c.i.ConsumerCoordinator - Revoking previously assigned partitions [] for group kruftmeister-com.sixt.service.unknown
//2017-04-12 18:27:18,894 [pool-9-thread-1] DEBUG c.s.s.f.kafka.messaging.Consumer - ConsumerRebalanceListener.onPartitionsRevoked on []
//2017-04-12 18:27:18,917 [pool-9-thread-1] INFO o.a.k.c.c.i.AbstractCoordinator - (Re-)joining group kruftmeister-com.sixt.service.unknown
//2017-04-12 18:27:18,937 [pool-9-thread-1] INFO o.a.k.c.c.i.AbstractCoordinator - Marking the coordinator 172.19.0.3:9092 (id: 2147482646 rack: null) dead for group kruftmeister-com.sixt.service.unknown
//2017-04-12 18:27:19,041 [pool-9-thread-1] INFO o.a.k.c.c.i.AbstractCoordinator - Discovered coordinator 172.19.0.3:9092 (id: 2147482646 rack: null) for group kruftmeister-com.sixt.service.unknown.
//2017-04-12 18:27:19,041 [pool-9-thread-1] INFO o.a.k.c.c.i.AbstractCoordinator - (Re-)joining group kruftmeister-com.sixt.service.unknown
//2017-04-12 18:27:19,135 [pool-9-thread-1] INFO o.a.k.c.c.i.AbstractCoordinator - Successfully joined group kruftmeister-com.sixt.service.unknown with generation 1
//2017-04-12 18:27:19,135 [pool-9-thread-1] INFO o.a.k.c.c.i.ConsumerCoordinator - Setting newly assigned partitions [] for group kruftmeister-com.sixt.service.unknown
//2017-04-12 18:27:19,135 [pool-9-thread-1] DEBUG c.s.s.f.kafka.messaging.Consumer - ConsumerRebalanceListener.onPartitionsAssigned on []
// -> assigned to a topic with no partitions?
}
示例4: playAbc
import org.apache.commons.lang3.RandomStringUtils; //导入方法依赖的package包/类
public static void playAbc(String md5, String bandName, boolean syncPlay, boolean syncTrack, EntityPlayer player) //CLIENT NEVER CALLS THIS.
{
TrackFile file = getTrack(md5);
Track track;
if(!bandName.isEmpty())
{
//Find the band
track = Clef.eventHandlerServer.findTrackByBand(bandName);
if(track == null && md5.isEmpty())
{
return;
}
Track track1 = track;
if(track == null || !syncTrack) //No band
{
track = new Track(RandomStringUtils.randomAscii(IOUtil.IDENTIFIER_LENGTH), bandName, md5, (file != null ? file.track : null), false);
}
if(syncPlay && track1 != null)
{
track.playAtProgress(track1.playProg);
}
}
else if(md5.isEmpty())
{
return;
}
else
{
track = new Track(RandomStringUtils.randomAscii(IOUtil.IDENTIFIER_LENGTH), bandName, md5, (file != null ? file.track : null), false);
}
if(file == null) //We don't have the ABC. Ask from the client.
{
if(requestedABCFromPlayers.add(md5))
{
if(track.getTrack() == null)
{
tracksWaitingForTrackInfo.put(md5, track);
}
Clef.channel.sendTo(new PacketRequestFile(md5, false), player);
}
}
Track playerTrack = Clef.eventHandlerServer.getTrackPlayedByPlayer(player);
if(playerTrack != null)
{
playerTrack.players.remove(player);
if(!playerTrack.hasObjectsPlaying())
{
playerTrack.stop();
}
Clef.channel.sendToAll(new PacketPlayingTracks(playerTrack));
}
//queue the track. track plays when the trackfile is set.
Clef.eventHandlerServer.tracksPlaying.add(track);
track.players.put(player, 0);
if(track.getTrack() != null)
{
Clef.channel.sendToAll(new PacketPlayingTracks(track));
}
}