当前位置: 首页>>代码示例>>Java>>正文


Java ConcurrentSet类代码示例

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


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

示例1: testSenderManager

import io.netty.util.internal.ConcurrentSet; //导入依赖的package包/类
@Test
public void testSenderManager() {
    HostPort hostPort = new HostPort("192.168.1.10", 6379);
    Map<ALERT_TYPE, Set<AlertEntity>> alerts = new ConcurrentHashMap<>();
    AlertEntity alert = new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.XREDIS_VERSION_NOT_VALID);
    Set<AlertEntity> set = new ConcurrentSet<>();
    set.add(alert);
    alerts.put(ALERT_TYPE.XREDIS_VERSION_NOT_VALID, set);

    new Thread(new Runnable() {
        @Override
        public void run() {
            alerts.get(ALERT_TYPE.XREDIS_VERSION_NOT_VALID).remove(alert);
        }
    }).start();
    List<Map<ALERT_TYPE, Set<AlertEntity>>> result = senderManager.getGroupedAlerts(alerts);
    logger.info("result: {}", result.get(0));
    if(!result.isEmpty()) {
        Set<AlertEntity> alertEntities = result.get(0).getOrDefault(alert.getAlertType(), null);
        if(alertEntities != null) {
            Assert.assertFalse(alertEntities.isEmpty());
        }
    }
}
 
开发者ID:ctripcorp,项目名称:x-pipe,代码行数:25,代码来源:SenderManagerTest.java

示例2: listfield

import io.netty.util.internal.ConcurrentSet; //导入依赖的package包/类
@Test
public void listfield() throws CEUException, ParseException {

	ListHandler<String> handler = ListHandlerBuilder.build().byAllRows()
			.collect().byField("email", String.class);
	Command command = new Command("SELECT email FROM \"" + TABLE_NAME
			+ "\" allow filtering ");

	List<String> emails = existOptional(runner.query(command, handler));
	final Set<String> setEmails = new ConcurrentSet<String>();

	emails.stream().forEach(email -> {
		Assert.assertTrue(emails.get(0).startsWith("userTest"));
		Assert.assertTrue(emails.get(0).endsWith("@gmail.com"));
		setEmails.add(email);
	});

	Assert.assertEquals(emails.size() - 1, setEmails.size());

}
 
开发者ID:Taulukko,项目名称:taulukko-commons-ceu,代码行数:21,代码来源:ListHandlerTest.java

示例3: StreamCutService

import io.netty.util.internal.ConcurrentSet; //导入依赖的package包/类
public StreamCutService(final int bucketCount, String processId, final StreamMetadataStore streamMetadataStore,
                        final StreamMetadataTasks streamMetadataTasks, final ScheduledExecutorService executor) {
    this.bucketCount = bucketCount;
    this.processId = processId;
    this.streamMetadataStore = streamMetadataStore;
    this.streamMetadataTasks = streamMetadataTasks;
    this.executor = executor;
    this.buckets = new ConcurrentSet<>();
}
 
开发者ID:pravega,项目名称:pravega,代码行数:10,代码来源:StreamCutService.java

示例4: add

import io.netty.util.internal.ConcurrentSet; //导入依赖的package包/类
@Override
public boolean add(Channel channel) {
    ConcurrentSet<Channel> set =
        channel instanceof ServerChannel? serverChannels : nonServerChannels;

    boolean added = set.add(channel);
    if (added) {
        channel.closeFuture().addListener(remover);
    }
    return added;
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:12,代码来源:DefaultChannelGroup.java

示例5: StatefulRedisPubSubConnectionImpl

import io.netty.util.internal.ConcurrentSet; //导入依赖的package包/类
/**
 * Initialize a new connection.
 *
 * @param writer the channel writer
 * @param codec Codec used to encode/decode keys and values.
 * @param timeout Maximum time to wait for a response.
 * @param unit Unit of time for the timeout.
 */
public StatefulRedisPubSubConnectionImpl(RedisChannelWriter<K, V> writer, RedisCodec<K, V> codec, long timeout,
        TimeUnit unit) {
    super(writer, codec, timeout, unit);

    listeners = new CopyOnWriteArrayList<>();
    channels = new ConcurrentSet<>();
    patterns = new ConcurrentSet<>();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:17,代码来源:StatefulRedisPubSubConnectionImpl.java

示例6: handleUpdateRecommendationsForUser

import io.netty.util.internal.ConcurrentSet; //导入依赖的package包/类
private Observable<Void> handleUpdateRecommendationsForUser(HttpServerRequest<ByteBuf> request, final HttpServerResponse<ByteBuf> response) {
    System.out.println("HTTP request -> update recommendations for user: " + request.getPath());
    final String userId = userIdFromPath(request.getPath());
    if (userId == null) {
        response.setStatus(HttpResponseStatus.BAD_REQUEST);
        return response.close();
    }
    return request.getContent().flatMap(new Func1<ByteBuf, Observable<Void>>() {
        @Override
        public Observable<Void> call(ByteBuf byteBuf) {
            String movieId = byteBuf.toString(Charset.defaultCharset());
            System.out.println(format("    updating: {user=%s, movie=%s}", userId, movieId));
            synchronized (this) {
                Set<String> recommendations;
                if (userRecommendations.containsKey(userId)) {
                    recommendations = userRecommendations.get(userId);
                } else {
                    recommendations = new ConcurrentSet<String>();
                    userRecommendations.put(userId, recommendations);
                }
                recommendations.add(movieId);
            }
            response.setStatus(HttpResponseStatus.OK);
            return response.close();
        }
    });
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:28,代码来源:RxMovieServer.java

示例7: onContextRefreshed

import io.netty.util.internal.ConcurrentSet; //导入依赖的package包/类
@Override
public void onContextRefreshed() {
    runningJobs = new ConcurrentSet<>();
    executorService = Executors.newCachedThreadPool();
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:6,代码来源:SchedulerSupport.java

示例8: deliver_updates_through_several_threads

import io.netty.util.internal.ConcurrentSet; //导入依赖的package包/类
@SuppressWarnings("MethodWithMultipleLoops")
@Test
public void deliver_updates_through_several_threads() throws InterruptedException {
    final int threadsCount = Given.THREADS_COUNT_IN_POOL_EXECUTOR;
    @SuppressWarnings("LocalVariableNamingConvention") // Too long variable name
    final int threadExecutionMaxAwaitSeconds = Given.AWAIT_SECONDS;

    final Set<String> threadInvocationRegistry = new ConcurrentSet<>();

    final Stand stand = Stand.newBuilder()
                             .build();

    final ExecutorService executor = Executors.newFixedThreadPool(threadsCount);

    final Runnable task = new Runnable() {
        @Override
        public void run() {
            final String threadName = Thread.currentThread()
                                            .getName();
            Assert.assertFalse(threadInvocationRegistry.contains(threadName));
            final ProjectId enitityId = ProjectId.newBuilder()
                                                 .setId(Identifier.newUuid())
                                                 .build();
            final Given.StandTestAggregate entity = Given.aggregateRepo()
                                                         .create(enitityId);
            stand.post(requestFactory.createCommandContext()
                                     .getActorContext()
                                     .getTenantId(), entity);

            threadInvocationRegistry.add(threadName);
        }
    };

    for (int i = 0; i < threadsCount; i++) {
        executor.execute(task);
    }

    executor.awaitTermination(threadExecutionMaxAwaitSeconds, TimeUnit.SECONDS);

    Assert.assertEquals(threadInvocationRegistry.size(), threadsCount);

}
 
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:43,代码来源:StandPostShould.java

示例9: HttpServerHandler

import io.netty.util.internal.ConcurrentSet; //导入依赖的package包/类
public HttpServerHandler(ConcurrentSet activeChannels, HttpServer server)
{
    this.server = server;
    this.activeChannels = activeChannels;
}
 
开发者ID:buremba,项目名称:netty-rest,代码行数:6,代码来源:HttpServerHandler.java

示例10: HaProxyBackendServerHandler

import io.netty.util.internal.ConcurrentSet; //导入依赖的package包/类
public HaProxyBackendServerHandler(ConcurrentSet activeChannels, HttpServer httpServer) {
    super(activeChannels, httpServer);
}
 
开发者ID:buremba,项目名称:netty-rest,代码行数:4,代码来源:HaProxyBackendServerHandler.java


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