List of usage examples for java.util.concurrent LinkedBlockingDeque LinkedBlockingDeque
public LinkedBlockingDeque()
From source file:com.brsanthu.googleanalytics.GoogleAnalytics.java
protected synchronized ThreadPoolExecutor createExecutor(GoogleAnalyticsConfig config) { return new ThreadPoolExecutor(0, config.getMaxThreads(), 5, TimeUnit.MINUTES, new LinkedBlockingDeque<Runnable>(), createThreadFactory()); }
From source file:com.utdallas.s3lab.smvhunter.monkey.MonkeyMe.java
/** * UI Automation// www. ja va2s .com * @param device * @param apkName */ private void enumerateCurrentWindow(final IDevice device, String apkName, List<SmartInputBean> smartInput) { HierarchyViewer hv = new HierarchyViewer(device); BlockingQueue<String> eventQueue = new LinkedBlockingDeque<String>(); MonkeyWindowChangeListener windowListener = new MonkeyWindowChangeListener(eventQueue); WindowUpdater.startListenForWindowChanges(windowListener, device); try { UIEnumerator.ListWindows(hv, device, eventQueue, apkName, smartInput); } catch (Exception e) { e.printStackTrace(); } //stop the window updater WindowUpdater.stopListenForWindowChanges(windowListener, device); }
From source file:com.taobao.android.builder.tools.sign.LocalSignHelper.java
private static ApkCreatorFactory createFactory() { ZFileOptions options = new ZFileOptions(); options.setNoTimestamps(true);/*from w ww . jav a2s. co m*/ options.setCoverEmptySpaceUsingExtraField(true); ThreadPoolExecutor compressionExecutor = new ThreadPoolExecutor(0, /* Number of always alive threads */ 2, 100, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>()); options.setCompressor( new BestAndDefaultDeflateExecutorCompressor(compressionExecutor, options.getTracker(), 1.0)); options.setAutoSortFiles(true); return new ApkZFileCreatorFactory(options); }
From source file:specminers.smartic.MergingBlock.java
public List<State<String>> getNodesByBreadthFirstSearch(Automaton<String> automaton) { LinkedList<State<String>> V = new LinkedList<>(); Queue<State<String>> Q = new LinkedBlockingDeque<>(); V.add(automaton.getInitialState());/*from ww w .j a v a2 s . c o m*/ Q.add(automaton.getInitialState()); while (!Q.isEmpty()) { State<String> t = Q.poll(); for (Step<String> delta : automaton.getDelta().get(t)) { State<String> u = delta.getDestination(); if (!V.contains(u)) { V.add(u); Q.add(u); } } } return V; }
From source file:com.vmware.photon.controller.core.Main.java
/** * Creates a new Deployer Service Group. * * @param deployerConfig/*from w ww . j av a 2 s . co m*/ * @param apiFeServerSet * @param cloudStoreServerSet * @param httpClient * @return */ private static DeployerServiceGroup createDeployerServiceGroup(PhotonControllerConfig photonControllerConfig, DeployerConfig deployerConfig, ServerSet apiFeServerSet, ServerSet cloudStoreServerSet, CloseableHttpAsyncClient httpClient) { logger.info("Creating Deployer Service Group"); // Set containers config to deployer config try { deployerConfig.setContainersConfig(new ServiceConfigurator() .generateContainersConfig(deployerConfig.getDeployerContext().getConfigDirectory())); } catch (Exception e) { throw new RuntimeException(e); } final ApiClientFactory apiClientFactory = new ApiClientFactory(apiFeServerSet, httpClient, deployerConfig.getDeployerContext().getSharedSecret(), deployerConfig.getDeployerContext().isAuthEnabled()); /** * The blocking queue associated with the thread pool executor service * controls the rejection policy for new work items: a bounded queue, such as * an ArrayBlockingQueue, will cause new work items to be rejected (and thus * failed) when the queue length is reached. A LinkedBlockingQueue, which is * unbounded, is used here in order to enable the submission of an arbitrary * number of work items since this is the pattern expected for the deployer * (a large number of work items arrive all at once, and then no more). */ final BlockingQueue<Runnable> blockingQueue = new LinkedBlockingDeque<>(); final ListeningExecutorService listeningExecutorService = MoreExecutors .listeningDecorator(new ThreadPoolExecutor(deployerConfig.getDeployerContext().getCorePoolSize(), deployerConfig.getDeployerContext().getMaximumPoolSize(), deployerConfig.getDeployerContext().getKeepAliveTime(), TimeUnit.SECONDS, blockingQueue)); final HttpFileServiceClientFactory httpFileServiceClientFactory = new com.vmware.photon.controller.core.Main.HttpFileServiceClientFactoryImpl(); final AuthHelperFactory authHelperFactory = new com.vmware.photon.controller.core.Main.AuthHelperFactoryImpl(); final HealthCheckHelperFactory healthCheckHelperFactory = new com.vmware.photon.controller.core.Main.HealthCheckHelperFactoryImpl(); final ServiceConfiguratorFactory serviceConfiguratorFactory = new com.vmware.photon.controller.core.Main.ServiceConfiguratorFactoryImpl(); final ZookeeperClientFactory zookeeperServerSetBuilderFactory = new com.vmware.photon.controller.core.Main.ZookeeperClientFactoryImpl(); final HostManagementVmAddressValidatorFactory hostManagementVmAddressValidatorFactory = new com.vmware.photon.controller.core.Main.HostManagementVmAddressValidatorFactoryImpl(); final ClusterManagerFactory clusterManagerFactory = new ClusterManagerFactory(listeningExecutorService, httpClient, cloudStoreServerSet, Paths.get(deployerConfig.getDeployerContext().getScriptDirectory(), CLUSTER_SCRIPTS_DIRECTORY) .toString()); return new DeployerServiceGroup(deployerConfig.getDeployerContext(), apiClientFactory, deployerConfig.getContainersConfig(), listeningExecutorService, httpFileServiceClientFactory, authHelperFactory, healthCheckHelperFactory, serviceConfiguratorFactory, zookeeperServerSetBuilderFactory, hostManagementVmAddressValidatorFactory, clusterManagerFactory); }
From source file:co.beem.project.beem.FbTextService.java
/** * {@inheritDoc}/*from w ww . j ava2 s . com*/ */ @Override public void onCreate() { super.onCreate(); Utils.setContext(getApplicationContext()); smackAndroid = SmackAndroid.init(FbTextService.this); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); savingMessageQueue = new LinkedBlockingQueue<co.beem.project.beem.service.BeemMessage>(); stateChangeQueue = new LinkedBlockingQueue<User>(); sendImageQueue = new LinkedBlockingDeque<ImageMessageInQueue>(); isRunning = true; sessionManager = new SessionManager(FbTextService.this); savingMessageOnBackgroundThread(new SavingNewMessageTask()); savingMessageOnBackgroundThread(new UpdateUserStateTask()); savingMessageOnBackgroundThread(new SendImageTask()); handler = new Handler(); registerReceiver(mReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED)); this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CONNECTED)); this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CONNECTING)); this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_DISCONNECT)); this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CONNECTING_In)); registerReceiver(mOnOffReceiver, new IntentFilter(FbTextApplication.SEND_IMAGE_MESSAGE)); registerReceiver(mOnOffReceiver, new IntentFilter(FbTextApplication.SEND_INVITATION)); registerReceiver(mOnOffReceiver, new IntentFilter(FbTextApplication.UPDATE_USER_STATE)); registerReceiver(mOnOffReceiver, new IntentFilter(FbTextApplication.PUSH_NOTIFICATION_FAVORITE_ONLINE)); registerReceiver(mOnOffReceiver, new IntentFilter(FbTextApplication.CHANGE_STATUS)); mSettings = PreferenceManager.getDefaultSharedPreferences(this); mSettings.registerOnSharedPreferenceChangeListener(mPreferenceListener); if (mSettings.getBoolean(FbTextApplication.USE_AUTO_AWAY_KEY, false)) { mOnOffReceiverIsRegistered = true; registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON)); // registerReceiver(sma, filter) } String tmpJid = mSettings.getString(FbTextApplication.ACCOUNT_USERNAME_KEY, "").trim(); mLogin = StringUtils.parseName(tmpJid); boolean useSystemAccount = mSettings.getBoolean(FbTextApplication.USE_SYSTEM_ACCOUNT_KEY, false); mPort = DEFAULT_XMPP_PORT; mService = StringUtils.parseServer(tmpJid); mHost = mService; initMemorizingTrustManager(); if (mSettings.getBoolean(FbTextApplication.ACCOUNT_SPECIFIC_SERVER_KEY, false)) { mHost = mSettings.getString(FbTextApplication.ACCOUNT_SPECIFIC_SERVER_HOST_KEY, "").trim(); if ("".equals(mHost)) mHost = mService; String tmpPort = mSettings.getString(FbTextApplication.ACCOUNT_SPECIFIC_SERVER_PORT_KEY, "5222"); if (!"".equals(tmpPort)) mPort = Integer.parseInt(tmpPort); } if (mSettings.getBoolean(FbTextApplication.FULL_JID_LOGIN_KEY, false) || "gmail.com".equals(mService) || "googlemail.com".equals(mService) || useSystemAccount) { mLogin = tmpJid; } configure(ProviderManager.getInstance()); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Roster.setDefaultSubscriptionMode(SubscriptionMode.manual); mBind = new XmppFacade(this); if (FbTextApplication.isDebug) Log.d(TAG, "Create FacebookTextService \t id: " + mLogin + " \t host: " + mHost + "\tmPort" + mPort + "\t service" + mService); }