本文整理汇总了Java中org.eclipse.jetty.util.ConcurrentHashSet类的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentHashSet类的具体用法?Java ConcurrentHashSet怎么用?Java ConcurrentHashSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConcurrentHashSet类属于org.eclipse.jetty.util包,在下文中一共展示了ConcurrentHashSet类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
public void start() {
// TODO: remove redundant fields from config and move this check to XRE Redirector
if (! config.getEnableCommunicationEndpoint()) {
log.warn("skipping Jetty endpoint due to configuration");
return;
}
if (started) {
log.warn("Jetty is already started");
}
started = true;
Integer port = config.getCommunicationEndpointPort();
log.info("Starting embedded jetty server (XRERedirector Gateway) on port: {}", port);
WebAppContext webAppContext = new WebAppContext();
webAppContext.setConfigurations(new Configuration[]{new AnnotationConfiguration() {
@Override
public void preConfigure(WebAppContext context) {
ClassInheritanceMap map = new ClassInheritanceMap();
map.put(WebApplicationInitializer.class.getName(), new ConcurrentHashSet<String>() {{
add(WebAppInitializer.class.getName());
}});
context.setAttribute(CLASS_INHERITANCE_MAP, map);
_classInheritanceHandler = new ClassInheritanceHandler(map);
}
}});
server = new Server(port);
server.setHandler(webAppContext);
try {
server.start();
} catch (Exception e) {
log.error("Failed to start embedded jetty server (XRERedirector communication endpoint) on port: " + port, e);
}
log.info("Started embedded jetty server (Redirector Gateway) on port: {}", port);
}
示例2: shouldNotifyOneListenerForEachMessage
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
@Test
public void shouldNotifyOneListenerForEachMessage() throws InterruptedException {
GoMessageQueue<GoMessage> queue = new GoMessageQueue<>(messageService, "TestQueue");
int numberOfListeners = 2;
int numberOfMessages = numberOfListeners + 2;
for (int i = 0; i < numberOfListeners; i++) {
queue.addListener(new StubGoMessageListener(i));
}
Set<String> expectMessages = new ConcurrentHashSet<>();
for (int i = 0; i < numberOfMessages; i++) {
String text = "Message-" + i;
queue.post(new GoTextMessage(text));
expectMessages.add(text);
}
assertWillHappen(receivedMessage, is(expectMessages), Timeout.FIVE_SECONDS);
}
示例3: receiveRefreshDBList
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
@NetEventListener(netEvent = SysConstantDefine.GETASYNCDATABELONGLISTKEY)
public NetEventData receiveRefreshDBList(NetEventData eventData){
String listKey = (String)eventData.getParam();
// 查看并插入listKeys插入
String classKey = KeyParser.getClassNameFromListKey(listKey);
Set<String> listKeys = listKeysMap.get(classKey);
if(listKeys == null){
listKeys = new ConcurrentHashSet<>();
listKeysMap.putIfAbsent(classKey,listKeys);
listKeys = listKeysMap.get(classKey);
}
listKeys.add(listKey);// 注意这里一定要先插入,再获取再插入,而不能创建-插入-放入listKeysMap,多线程下回出错
// 从异步列表中获取相应的对象
List<AsyncData> result = null;
List<AsyncData> asyncDataList = asyncDataMap.get(classKey);
if(asyncDataList != null){
for(AsyncData asyncData : asyncDataList){
if(KeyParser.isObjectBelongToList(asyncData.getObject(),listKey)){
if(result == null){
result = new ArrayList<>();
}
result.add(asyncData);
}
}
}
return new NetEventData(eventData.getNetEvent(),result);
}
示例4: IdSegment
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
public IdSegment(Class cls){
this.cls = cls;
this.usingIds = new ConcurrentHashSet<>();
this.canUseIds = new ConcurrentLinkedDeque<>();
this.idMark = new AtomicInteger();
}
示例5: PrimeCounterAdapter
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
public PrimeCounterAdapter(final ICoordinator extension, final int lBoundPassed, final int uBoundPassed,
final ConcurrentHashSet<BigInteger> primeSetPassed, final BigIntegerCounter prime, final BigIntegerCounter notprime)
{
assert null != extension : "Parameter 'extension' of 'PrimeCounterAdapter''s ctor must not be null";
assert null != primeSetPassed : "Parameter 'primeSetPassed' of 'PrimeCounterAdapter''s ctor must not be null";
this.coordinator = extension;
this.adapterLBound = lBoundPassed;
this.adapterUBound = uBoundPassed;
this.primeSetRef = primeSetPassed;
this.primes = prime;
this.notPrimes = notprime;
}
示例6: main
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
System.out.println(IOUtils.toString(new FileInputStream("../metl-server/src/main/resources/Metl.asciiart")));
new File(System.getProperty("java.io.tmpdir")).mkdirs();
new File("working").mkdirs();
System.setProperty("org.jumpmind.metl.ui.init.config.dir","working");
Server server = new Server(42000);
ClassList classlist = Configuration.ClassList.setServerDefault(server);
classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");
WebAppContext webapp = new WebAppContext();
webapp.setParentLoaderPriority(true);
webapp.setConfigurationDiscovered(true);
webapp.setContextPath("/metl");
webapp.setWar("../metl-war/src/main/webapp");
webapp.setResourceBase("../metl-war/src/main/webapp");
ConcurrentHashMap<String, ConcurrentHashSet<String>> map = new ClassInheritanceMap();
ConcurrentHashSet<String> set = new ConcurrentHashSet<>();
set.add("org.jumpmind.metl.ui.init.AppInitializer");
map.put("org.springframework.web.WebApplicationInitializer", set);
webapp.setAttribute(AnnotationConfiguration.CLASS_INHERITANCE_MAP, map);
server.setHandler(webapp);
ServerContainer webSocketServer = WebSocketServerContainerInitializer.configureContext(webapp);
webSocketServer.setDefaultMaxSessionIdleTimeout(10000000);
server.start();
server.join();
}
示例7: FileEventManager
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
/**
*
* @param fileTree The file tree representation of PeerWasp
* @param messageBus To publish events system-wide
*/
@Inject
public FileEventManager(final FileTree fileTree, MessageBus messageBus) {
this.fileComponentQueue = new FileComponentQueue();
this.fileTree = fileTree;
this.messageBus = messageBus;
this.failedOperations = new ConcurrentHashSet<Path>();
}
示例8: SubtransExecutor
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
public SubtransExecutor( Trans parentTrans, TransMeta subtransMeta, boolean shareVariables,
TransExecutorData transExecutorData, TransExecutorParameters parameters ) {
this.parentTrans = parentTrans;
this.subtransMeta = subtransMeta;
this.shareVariables = shareVariables;
this.parameters = parameters;
this.statuses = new LinkedHashMap<>();
this.running = new ConcurrentHashSet<>();
}
示例9: JobThread
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
public JobThread(int jobId, IJobHandler handler) {
this.jobId = jobId;
this.handler = handler;
this.triggerQueue = new LinkedBlockingQueue<TriggerParam>();
this.triggerLogIdSet = new ConcurrentHashSet<Integer>();
}
示例10: startServer
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
public static void startServer(JettyConfig jettyConfig) throws Exception {
if(!jettyConfig.isQuietMode())
{
System.out.println();
System.out.println("Starting embedded jetty...");
}
//create the server
Server server = new Server();
ServerConnector c = new ServerConnector(server);
//set the context path
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setWelcomeFiles(new String[] {"/static/test.html"});
//tell the webApp about our Spring MVC web initializer. The hoops I jump through here are because
//Jetty 9 AnnotationConfiguration doesn't scan non-jar classpath locations for a class that implements WebApplicationInitializer.
//The code below explicitly tells Jetty about our implementation of WebApplicationInitializer.
//this Jetty bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=404176 and the discussion around it defines the issue best. I decided
//I would not rely on the potentially buggy solution put into Jetty 9 (discussed in the bug thread) and just go for a fix I know would work.
webAppContext.setConfigurations(new Configuration[] {
new AnnotationConfiguration() {
@Override
public void preConfigure(WebAppContext context) throws Exception {
ClassInheritanceMap map = new ClassInheritanceMap();
ConcurrentHashSet<String> hashSet = new ConcurrentHashSet<String>();
hashSet.add(SpringMvcInitializer.class.getName());
map.put(WebApplicationInitializer.class.getName(), hashSet);
context.setAttribute(CLASS_INHERITANCE_MAP, map);
_classInheritanceHandler = new ClassInheritanceHandler(map);
}
}
});
server.setHandler(webAppContext);
//core server configuration
c.setIdleTimeout(jettyConfig.getIdleTimeout());
c.setAcceptQueueSize(jettyConfig.getAcceptQueueSize());
c.setPort(jettyConfig.getPort());
c.setHost(jettyConfig.getHost());
server.addConnector(c);
//start the server and make it available when initialization is complete
server.start();
server.join();
}
示例11: testMergeStartStopRandomClientsServers
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testMergeStartStopRandomClientsServers() throws Exception {
for (int iter = 0; iter < 3; iter++) {
log.info("Iteration: " + iter);
final int srvs = 5;
final int clients = 5;
Ignite srv0 = startGrids(srvs);
for (int i = 0; i < clients; i++) {
client.set(true);
startGrid(srvs + i);
}
final int threads = 8;
final int initNodes = srvs + clients;
mergeExchangeWaitVersion(srv0, initNodes + threads);
final AtomicInteger idx = new AtomicInteger(initNodes);
final ConcurrentHashSet<Integer> stopNodes = new ConcurrentHashSet<>();
IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
@Override public Void call() throws Exception {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
if (rnd.nextBoolean()) {
Integer stopIdx;
for (;;) {
stopIdx = rnd.nextInt(initNodes - 1) + 1;
if (stopNodes.add(stopIdx))
break;
}
log.info("Stop node: " + stopIdx);
stopGrid(getTestIgniteInstanceName(stopIdx), true, false);
}
else {
int nodeIdx = idx.incrementAndGet();
if (rnd.nextInt(5) == 0) {
log.info("Start client: " + nodeIdx);
client.set(true);
}
else
log.info("Start server: " + nodeIdx);
startGrid(nodeIdx);
}
return null;
}
}, threads, "test-thread");
fut.get();
checkCaches();
stopAllGrids();
}
}
示例12: getSynchronizedPathsAsSet
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
@Override
public Set<Path> getSynchronizedPathsAsSet() {
Set<Path> synchronizedFiles = new ConcurrentHashSet<Path>();
rootOfFileTree.getSynchronizedChildrenPaths(synchronizedFiles);
return synchronizedFiles;
}
示例13: testFlowNoConflictsWithClients
import org.eclipse.jetty.util.ConcurrentHashSet; //导入依赖的package包/类
/**
*
*/
public void testFlowNoConflictsWithClients() throws Exception {
startComputation(0, stopFlag0);
startComputation(1, stopFlag1);
startComputation(2, stopFlag2);
startComputation(3, stopFlag3);
startComputation(4, stopFlag4);
final Set<Integer> deafClientObservedIds = new ConcurrentHashSet<>();
startListening(5, true, deafClientObservedIds);
final Set<Integer> regClientObservedIds = new ConcurrentHashSet<>();
startListening(6, false, regClientObservedIds);
START_LATCH.countDown();
Thread killer = new Thread(new ServerNodeKiller());
Thread resurrection = new Thread(new ServerNodeResurrection());
killer.setName("node-killer-thread");
killer.start();
resurrection.setName("node-resurrection-thread");
resurrection.start();
while (!updatesQueue.isEmpty())
Thread.sleep(1000);
killer.interrupt();
resurrection.interrupt();
}