Example usage for java.util.concurrent ConcurrentLinkedDeque ConcurrentLinkedDeque

List of usage examples for java.util.concurrent ConcurrentLinkedDeque ConcurrentLinkedDeque

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentLinkedDeque ConcurrentLinkedDeque.

Prototype

public ConcurrentLinkedDeque() 

Source Link

Document

Constructs an empty deque.

Usage

From source file:org.eclipse.flux.core.internal.messaging.AbstractMessagingConnector.java

public AbstractMessagingConnector() {
    this.connectionListeners = new ConcurrentLinkedDeque<>();
    this.messageHandlers = new ConcurrentHashMap<>();
}

From source file:com.sishuok.chapter3.web.controller.chat.MsgPublisher.java

public DeferredResult<String> startAsync(final String username) {
    final DeferredResult<String> result = new DeferredResult<String>(30L * 1000, null);

    final Runnable removeDeferredResultRunnable = new Runnable() {
        @Override/*w w w. j  a va2  s .  c  om*/
        public void run() {
            Queue<DeferredResult<String>> queue = usernameToDeferredResultMap.get(username);
            if (queue != null) {
                queue.remove(result);
            }
        }
    };
    result.onCompletion(removeDeferredResultRunnable);
    result.onTimeout(removeDeferredResultRunnable);

    //????
    Queue<DeferredResult<String>> queue = usernameToDeferredResultMap.get(username);
    if (queue == null) {
        queue = new ConcurrentLinkedDeque();
        usernameToDeferredResultMap.put(username, queue);
    }
    queue.add(result);

    return result;
}

From source file:com.ebay.pulsar.metric.processor.MetricProcessor.java

@Override
public void sendEvent(JetstreamEvent event) throws EventException {
    incrementEventRecievedCounter();//from  w  ww  .  j  a  v  a  2s  . co m
    String eventType = event.getEventType();

    Deque<DataPoint> dataByType = dataBuffer.get(eventType);
    if (dataByType == null) {
        dataByType = new ConcurrentLinkedDeque<DataPoint>();
        dataBuffer.put(eventType, dataByType);
    }

    Long currentTimestamp = System.currentTimeMillis();
    boolean isNewBatchOfEvents = false;

    if (dataByType.size() > 0
            && event.get("context_id") != dataByType.getLast().getEvents().peek().get("context_id"))
        isNewBatchOfEvents = true;

    //Flush old batchs
    if (isNewBatchOfEvents) {
        broadcastEventsByType(eventType, dataByType);
        incrementEventSentCounter();
    }

    if (dataByType.size() == 0 || isNewBatchOfEvents) {
        DataPoint dataPoint = new DataPoint(currentTimestamp);
        dataByType.add(dataPoint);
    }

    dataByType.getLast().addEvent(event);
    int maxLength = GENERIC_MAX_POINT;
    if (eventType.equalsIgnoreCase("MC_Metric") || eventType.equalsIgnoreCase("TwitterEventCount")) {
        maxLength = PAGE_VIEWS_POINT;
    }
    if (dataByType.size() > maxLength) {
        dataByType.removeFirst();
    }
}

From source file:org.eclipse.flux.core.internal.messaging.AbstractMessagingConnector.java

@Override
public void addMessageHandler(IMessageHandler messageHandler) {
    this.messageHandlers.putIfAbsent(messageHandler.getMessageType(),
            new ConcurrentLinkedDeque<IMessageHandler>());
    this.messageHandlers.get(messageHandler.getMessageType()).add(messageHandler);
}

From source file:io.cloudslang.lang.tools.build.tester.parallel.report.ThreadSafeRunTestResults.java

public ThreadSafeRunTestResults() {
    this.passedTests = new ConcurrentHashMap<>();
    this.failedTests = new ConcurrentHashMap<>();
    this.skippedTests = new ConcurrentHashMap<>();
    this.coveredExecutables = new TreeSet<>();
    this.uncoveredExecutables = new TreeSet<>();
    this.exceptions = new ConcurrentLinkedDeque<>();

    this.lockCoveredExecutables = new Object();
    this.lockUncoveredExecutables = new Object();
}

From source file:ch.algotrader.ordermgmt.DefaultOrderBook.java

public DefaultOrderBook() {
    this.orderMap = new ConcurrentHashMap<>();
    this.extIdToIntIdMap = new ConcurrentHashMap<>();
    this.orderExecMap = new ConcurrentHashMap<>();
    this.revisionMap = new ConcurrentHashMap<>();
    this.completedOrders = new ConcurrentLinkedDeque<>();
}

From source file:org.eclipse.flux.core.Repository.java

public Repository(IMessagingConnector messagingConnector, String user) {
    this.username = user;
    this.messagingConnector = messagingConnector;

    this.syncedProjects = new ConcurrentHashMap<String, ConnectedProject>();
    this.repositoryListeners = new ConcurrentLinkedDeque<>();

    this.messagingConnector.addConnectionListener(new IConnectionListener() {
        @Override/*ww w .ja v  a 2 s  . c  o m*/
        public void connected() {
            connect();
        }

        @Override
        public void disconnected() {
        }
    });

    IMessageHandler resourceChangedHandler = new AbstractMessageHandler("resourceChanged") {
        @Override
        public void handleMessage(String messageType, JSONObject message) {
            updateResource(message);
        }
    };
    this.messagingConnector.addMessageHandler(resourceChangedHandler);

    IMessageHandler resourceCreatedHandler = new AbstractMessageHandler("resourceCreated") {
        @Override
        public void handleMessage(String messageType, JSONObject message) {
            createResource(message);
        }
    };
    this.messagingConnector.addMessageHandler(resourceCreatedHandler);

    IMessageHandler resourceDeletedHandler = new AbstractMessageHandler("resourceDeleted") {
        @Override
        public void handleMessage(String messageType, JSONObject message) {
            deleteResource(message);
        }
    };
    this.messagingConnector.addMessageHandler(resourceDeletedHandler);

    IMessageHandler getProjectsRequestHandler = new AbstractMessageHandler("getProjectsRequest") {
        @Override
        public void handleMessage(String messageType, JSONObject message) {
            getProjects(message);
        }
    };
    this.messagingConnector.addMessageHandler(getProjectsRequestHandler);

    IMessageHandler getProjectRequestHandler = new AbstractMessageHandler("getProjectRequest") {
        @Override
        public void handleMessage(String messageType, JSONObject message) {
            getProject(message);
        }
    };
    this.messagingConnector.addMessageHandler(getProjectRequestHandler);

    IMessageHandler getProjectResponseHandler = new CallbackIDAwareMessageHandler("getProjectResponse",
            Repository.GET_PROJECT_CALLBACK) {
        @Override
        public void handleMessage(String messageType, JSONObject message) {
            getProjectResponse(message);
        }
    };
    this.messagingConnector.addMessageHandler(getProjectResponseHandler);

    IMessageHandler getResourceRequestHandler = new AbstractMessageHandler("getResourceRequest") {
        @Override
        public void handleMessage(String messageType, JSONObject message) {
            try {
                final String resourcePath = message.getString("resource");

                if (resourcePath.startsWith("classpath:")) {
                    getClasspathResource(message);
                } else {
                    getResource(message);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };
    this.messagingConnector.addMessageHandler(getResourceRequestHandler);

    IMessageHandler getResourceResponseHandler = new CallbackIDAwareMessageHandler("getResourceResponse",
            Repository.GET_RESOURCE_CALLBACK) {
        @Override
        public void handleMessage(String messageType, JSONObject message) {
            getResourceResponse(message);
        }
    };
    this.messagingConnector.addMessageHandler(getResourceResponseHandler);

    IMessageHandler getMetadataRequestHandler = new AbstractMessageHandler("getMetadataRequest") {
        @Override
        public void handleMessage(String messageType, JSONObject message) {
            getMetadata(message);
        }
    };
    this.messagingConnector.addMessageHandler(getMetadataRequestHandler);
}

From source file:org.eclipse.flux.client.impl.AbstractMessageConnector.java

public void addMessageHandler(IMessageHandler messageHandler) {
    this.messageHandlers.putIfAbsent(messageHandler.getMessageType(),
            new ConcurrentLinkedDeque<IMessageHandler>());
    this.messageHandlers.get(messageHandler.getMessageType()).add(messageHandler);
}

From source file:org.apache.spark.sql.hive.thriftserver.rsc.RSCDriver.java

public RSCDriver(SparkConf conf, RSCConf livyConf) throws Exception {
    Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwx------");
    this.localTmpDir = Files.createTempDirectory("rsc-tmp", PosixFilePermissions.asFileAttribute(perms))
            .toFile();/*w  ww . j  a v a  2s  .  co m*/
    this.executor = Executors.newCachedThreadPool();
    this.clients = new ConcurrentLinkedDeque<>();

    this.conf = conf;
    this.livyConf = livyConf;
    this.jcLock = new Object();
    this.shutdownLock = new Object();

    this.idleTimeout = new AtomicReference<>();
}

From source file:com.yahoo.elide.core.EntityBinding.java

public EntityBinding(Class<?> cls, String type) {
    // Map id's, attributes, and relationships
    Collection<AccessibleObject> fieldOrMethodList = CollectionUtils.union(Arrays.asList(cls.getFields()),
            Arrays.asList(cls.getMethods()));

    jsonApi = type;//  w w w.ja  va 2  s.c o m
    // Initialize our maps for this entity. Duplicates are checked above.
    attrsDeque = new ConcurrentLinkedDeque<>();
    relationshipsDeque = new ConcurrentLinkedDeque<>();
    relationshipTypes = new ConcurrentHashMap<>();
    relationshipToInverse = new ConcurrentHashMap<>();
    fieldsToValues = new ConcurrentHashMap<>();
    fieldsToTypes = new ConcurrentHashMap<>();
    fieldsToTriggers = new MultiValueMap<>();
    aliasesToFields = new ConcurrentHashMap<>();
    accessibleObject = new ConcurrentHashMap<>();
    bindEntityFields(cls, type, fieldOrMethodList);
    bindAccessibleObjects(cls, fieldOrMethodList);

    attrs = dequeToList(attrsDeque);
    relationships = dequeToList(relationshipsDeque);
}